pxb 2 недель назад
Родитель
Сommit
a53f6c4777

+ 98 - 5
src/views/Digital/order/index.vue

@@ -1,6 +1,15 @@
 <template>
   <div class="new-app-container layout-vertical">
-    <YMTableSearch :loading="loading" :search-form="searchForm" @onValueChange="onValueChange" @submit="onSubmit" />
+    <YMTableSearch :loading="loading" :search-form="searchForm" @onValueChange="onValueChange" @submit="onSubmit">
+      <template #created_range="{ form }">
+        <div style="margin-right: 20px">
+          <el-date-picker v-model="form.created_range" type="daterange" align="right" unlink-panels range-separator="至"
+            start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd HH:mm:ss" format="yyyy年MM月dd日"
+            :default-time="['00:00:00', '23:59:59']" :picker-options="pickerOptions" style="width: 260px">
+          </el-date-picker>
+        </div>
+      </template>
+    </YMTableSearch>
 
     <div class="tab-container">
       <el-tabs v-model="activeType" @tab-click="handleTabClick">
@@ -67,8 +76,51 @@ export default {
       activeType: '',
       detailId: null, // 详情弹窗使用的订单ID
       lotteryTypeTabs: [{ label: '全部', value: '' }, ...lotteryTypeOptions],
+      pickerOptions: {
+        shortcuts: [
+          {
+            text: '今天',
+            onClick(picker) {
+              const start = new Date()
+              start.setHours(0, 0, 0, 0)
+              const end = new Date()
+              end.setHours(23, 59, 59, 999)
+              picker.$emit('pick', [start, end])
+            }
+          },
+          {
+            text: '昨天',
+            onClick(picker) {
+              const start = new Date()
+              start.setTime(start.getTime() - 3600 * 1000 * 24 * 1)
+              start.setHours(0, 0, 0, 0)
+              const end = new Date()
+              end.setTime(end.getTime() - 3600 * 1000 * 24 * 1)
+              end.setHours(23, 59, 59, 999)
+              picker.$emit('pick', [start, end])
+            }
+          },
+          {
+            text: '7天内',
+            onClick(picker) {
+              const start = new Date()
+              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
+              start.setHours(0, 0, 0, 0)
+              const end = new Date()
+              end.setHours(23, 59, 59, 999)
+              picker.$emit('pick', [start, end])
+            }
+          }
+        ]
+      },
 
       searchForm: [
+        { label: '注册来源', type: 'select', prop: 'from', default: '1', clearable: true, options: [
+          { label: 'tg用户', value: '-1' },
+          { label: '后台客服账号', value: '0' },
+          { label: '真实用户', value: '1' },
+          { label: '虚拟用户', value: '2' },
+        ] },
         { label: 'ID', type: 'input', prop: 'id', clearable: true },
         { label: '期号', type: 'input', prop: 'issue', clearable: true },
         { label: '订单号', type: 'input', prop: 'ordernum', clearable: true },
@@ -76,7 +128,9 @@ export default {
         { label: '会员账号', type: 'input', prop: 'first_name', clearable: true },
         { label: '游戏玩法', type: 'input', prop: 'gameplay', clearable: true },
         { label: '下注号码', type: 'input', prop: 'number', clearable: true },
-        { label: '注单状态', type: 'select', prop: 'lottery_status', clearable: true, options: lotteryStatusOptions }
+        { label: '注单状态', type: 'select', prop: 'lottery_status', clearable: true, options: lotteryStatusOptions },
+        { label: '下单时间', type: 'slot', prop: 'created_range', slotName: 'created_range',
+          default: this.getTodayRange() }
       ],
 
       columns: [
@@ -99,6 +153,23 @@ export default {
         },
         { label: '会员ID', prop: 'member_id', width: '100' },
         { label: '会员账号', prop: 'first_name', width: 140 },
+        {
+          label: '注册来源',
+          prop: 'user_from',
+          html: true,
+          method: (row) => {
+            const map = {
+              '-1': 'tg用户',
+              0: '后台客服账号',
+              1: '真实用户',
+              2: '虚拟用户'
+            }
+            const from = row.user_from
+            const text = map[from] || '--'
+            const color = Number(from) === 1 ? '#05A58F' : Number(from) === 2 ? '#F3061F' : '#606266'
+            return `<span style="color: ${color}">${text}</span>`
+          }
+        },
         {
           label: '投注内容',
           prop: 'number',
@@ -201,21 +272,43 @@ export default {
     }
   },
   mounted() {
-    this.onSubmit(this.queryData)
+    // 进页面默认当天:用默认当天范围发起首次请求,保留路由参数(如 issue)
+    this.onSubmit({ ...this.queryData, created_range: this.getTodayRange() })
   },
   methods: {
+    getTodayRange() {
+      const today = this.formatDate(new Date())
+      return [today + ' 00:00:00', today + ' 23:59:59']
+    },
+    formatDate(date) {
+      const pad = n => String(n).padStart(2, '0')
+      return date.getFullYear() + '-' + pad(date.getMonth() + 1) + '-' + pad(date.getDate())
+    },
     handleTabClick() {
       this.onSubmit(this.queryData)
     },
     onValueChange(val) { },
     onSubmit(params = {}) {
       const validParams = Object.keys(params).reduce((acc, key) => {
-        if (params[key] !== '' && params[key] !== null && params[key] !== undefined) {
-          acc[key] = params[key]
+        const v = params[key]
+        if (v !== '' && v !== null && v !== undefined && !(Array.isArray(v) && v.length === 0)) {
+          acc[key] = v
         }
         return acc
       }, {})
 
+      // 时间筛选:有值时转 start_time / end_time;为空时不带时间参数
+      if (validParams.created_range && validParams.created_range.length === 2) {
+        validParams.start_time = validParams.created_range[0].split(' ')[0]
+        validParams.end_time = validParams.created_range[1].split(' ')[0]
+      }
+      delete validParams.created_range
+
+      // 注册来源默认真实用户
+      if (validParams.from === undefined) {
+        validParams.from = '1'
+      }
+
       if (this.activeType !== '') {
         validParams.type = this.activeType
       }

+ 102 - 5
src/views/orderManage/List/index.vue

@@ -1,6 +1,15 @@
 <template>
   <div class="new-app-container layout-vertical">
-    <YMTableSearch :loading="loading" :search-form="searchForm" @onValueChange="onValueChange" @submit="onSubmit" />
+    <YMTableSearch :loading="loading" :search-form="searchForm" @onValueChange="onValueChange" @submit="onSubmit">
+      <template #created_range="{ form }">
+        <div style="margin-right: 20px">
+          <el-date-picker v-model="form.created_range" type="daterange" align="right" unlink-panels range-separator="至"
+            start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd HH:mm:ss" format="yyyy年MM月dd日"
+            :default-time="['00:00:00', '23:59:59']" :picker-options="pickerOptions" style="width: 260px">
+          </el-date-picker>
+        </div>
+      </template>
+    </YMTableSearch>
     <YMTable ref="table" :apis="apis" :columns="columns" :custom-style="{ height: 'calc(100vh - 200px)' }" :index="true"
       :rows-actions="rowsActions" :selection="false" :show-summary="false" :table-key="1" :table-options="tableOptions"
       :actions-width="140">
@@ -156,9 +165,52 @@ export default {
       loading: false,
       queryData: {},
       viewRow: null,
+      pickerOptions: {
+        shortcuts: [
+          {
+            text: '今天',
+            onClick(picker) {
+              const start = new Date()
+              start.setHours(0, 0, 0, 0)
+              const end = new Date()
+              end.setHours(23, 59, 59, 999)
+              picker.$emit('pick', [start, end])
+            }
+          },
+          {
+            text: '昨天',
+            onClick(picker) {
+              const start = new Date()
+              start.setTime(start.getTime() - 3600 * 1000 * 24 * 1)
+              start.setHours(0, 0, 0, 0)
+              const end = new Date()
+              end.setTime(end.getTime() - 3600 * 1000 * 24 * 1)
+              end.setHours(23, 59, 59, 999)
+              picker.$emit('pick', [start, end])
+            }
+          },
+          {
+            text: '7天内',
+            onClick(picker) {
+              const start = new Date()
+              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
+              start.setHours(0, 0, 0, 0)
+              const end = new Date()
+              end.setHours(23, 59, 59, 999)
+              picker.$emit('pick', [start, end])
+            }
+          }
+        ]
+      },
 
       // 搜索表单配置
       searchForm: [
+        { label: '注册来源', prop: 'from', type: 'select', default: '1', clearable: true, options: [
+          { label: 'tg用户', value: '-1' },
+          { label: '后台客服账号', value: '0' },
+          { label: '真实用户', value: '1' },
+          { label: '虚拟用户', value: '2' },
+        ] },
         { label: 'ID', type: 'input', prop: 'id', clearable: true },
         { label: '订单号', prop: 'order_id', type: 'input' },
         { label: '会员昵称', type: 'input', prop: 'first_name', clearable: true },
@@ -213,7 +265,9 @@ export default {
             { label: '已同意', value: 2 },
             { label: '已驳回', value: 3 }
           ]
-        }
+        },
+        { label: '下单时间', prop: 'created_range', type: 'slot', slotName: 'created_range',
+          default: this.getTodayRange() }
       ],
 
       apis: {
@@ -245,6 +299,24 @@ export default {
         },
         { label: '会员ID', prop: 'member_id', width: 120 },
         { label: '会员昵称', prop: 'first_name', width: 150 },
+        {
+          label: '注册来源',
+          prop: 'user_from',
+          width: 100,
+          html: true,
+          method: (row) => {
+            const map = {
+              '-1': 'tg用户',
+              0: '后台客服账号',
+              1: '真实用户',
+              2: '虚拟用户'
+            }
+            const from = row.user_from
+            const text = map[from] || '--'
+            const color = Number(from) === 1 ? '#05A58F' : Number(from) === 2 ? '#F3061F' : '#606266'
+            return `<span style="color: ${color}">${text}</span>`
+          }
+        },
         { label: '赛事ID', prop: 'issue', width: 120 },
         {
           label: '赛事信息',
@@ -514,13 +586,38 @@ export default {
     }
   },
   mounted() {
-    this.onSubmit()
+    // 进页面默认当天:用默认当天范围发起首次请求
+    this.onSubmit({ created_range: this.getTodayRange() })
   },
   methods: {
     onValueChange(val) { },
     onSubmit(params = {}) {
-      this.queryData = params
-      this.$refs.table.getList(params)
+      const query = { ...params }
+
+      // 时间筛选:有值时转 start_time / end_time;为空时不带时间参数
+      if (query.created_range && query.created_range.length === 2) {
+        query.start_time = query.created_range[0].split(' ')[0]
+        query.end_time = query.created_range[1].split(' ')[0]
+      }
+      delete query.created_range
+
+      // 注册来源默认真实用户
+      if (query.from === undefined) {
+        query.from = '1'
+      }
+
+      this.queryData = query
+      this.$refs.table.getList(query)
+    },
+
+    formatDate(date) {
+      const pad = n => String(n).padStart(2, '0')
+      return date.getFullYear() + '-' + pad(date.getMonth() + 1) + '-' + pad(date.getDate())
+    },
+
+    getTodayRange() {
+      const today = this.formatDate(new Date())
+      return [today + ' 00:00:00', today + ' 23:59:59']
     },
 
     // ---------- 退款(返回 Promise,便于弹窗关闭) ----------

+ 1 - 1
src/views/user/userStatistics/index.vue

@@ -213,7 +213,7 @@ export default {
         this.chart = echarts.init(this.$refs.trendChart)
       }
 
-      const hasData = this.trendRows.length > 0 && this.trendRows.some(r => r.user > 0 || r.virtual > 0)
+      const hasData = this.trendRows.length > 0
       const isToday = this.query.type === 'today'
       const userName = isToday ? '今日会员新增' : '会员总数'
       const virtualName = isToday ? '今日虚拟会员新增' : '虚拟会员总数'