ソースを参照

恒春来
-主页新增指定日期查询条件

lk 1 日 前
コミット
00fc083490
1 ファイル変更59 行追加5 行削除
  1. 59 5
      src/views/index.vue

+ 59 - 5
src/views/index.vue

@@ -240,9 +240,21 @@
             <el-radio-button label="本周"></el-radio-button>
             <el-radio-button label="本月"></el-radio-button>
             <el-radio-button label="上月"></el-radio-button>
+            <el-radio-button label="指定日期" v-if="!showCompanyField"></el-radio-button>
           </el-radio-group>
+          <el-date-picker
+      v-if="queryTime === '指定日期'"
+      v-model="specificDate"
+      type="date"
+      placeholder="请选择日期"
+      :picker-options="pickerOptions"
+      format="yyyy-MM-dd"
+      value-format="yyyy-MM-dd"
+      size="medium"
+      style=" width: 150px;"
+      @change="handleAnalysis"
+    ></el-date-picker>
         </div>
-
         <div class="action-group">
           <el-radio-group v-model="userTypeText" @change="handleUserType">
             <el-radio-button label="会员"></el-radio-button>
@@ -1018,9 +1030,44 @@ export default {
       // 商品总数
       goodsTotalNum: 0,
       // 今日商品总数
-      todayGoodsNum: 0
+      todayGoodsNum: 0,
+      // 指定选择的日期
+      specificDate:null,
+      pickerOptions: {
+        disabledDate(time) {
+          // 可选:限制只能选择今天及以前的日期
+          return time.getTime() > Date.now();
+        },
+        // // 快捷选择
+        // shortcuts: [{
+        //   text: '今天',
+        //   onClick(picker) {
+        //     picker.$emit('pick', new Date());
+        //   }
+        // }, {
+        //   text: '昨天',
+        //   onClick(picker) {
+        //     const date = new Date();
+        //     date.setTime(date.getTime() - 3600 * 1000 * 24);
+        //     picker.$emit('pick', date);
+        //   }
+        // }, {
+        //   text: '一周前',
+        //   onClick(picker) {
+        //     const date = new Date();
+        //     date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
+        //     picker.$emit('pick', date);
+        //   }
+        // }]
+      }
     }
   },
+  computed: {
+    // 计算属性判断是否显示
+    showCompanyField() {
+      return process.env.VUE_APP_TITLE_INDEX === '恒春来';
+    },
+  },
   mounted() {
     this.$nextTick(() => {
       this.initViewerChart()
@@ -1349,7 +1396,11 @@ export default {
         param.startTime = this.formatDate(lastMonth.startOf('month'));
         param.endTime = this.formatDate(lastMonth.endOf('month'));
         type = 4;
-      } else {
+      }else if(this.queryTime === '指定日期'){
+        param.startTime = this.formatDate(this.specificDate);
+        param.endTime = this.formatDate(this.specificDate);
+        type = 5;
+      }else {
         console.warn(`未知的 queryTime: ${this.queryTime}, 默认使用今日`);
         param.startTime = this.formatDate(today);
         param.endTime = this.formatDate(today);
@@ -1360,7 +1411,10 @@ export default {
     },
     // 分析概览
     handleAnalysis(e) {
-
+      if(this.queryTime === '指定日期' && this.specificDate === null ){
+        return;
+      }
+      if(this.queryTime != '指定日期')this.specificDate = null;
       let param = this.getParam();
       analysisPreview(param).then(res => {
         if (res.code === 200) {
@@ -1387,7 +1441,7 @@ export default {
       } else if (this.selectedDiv === 2) {
         this.handleAnswerRedPackViewerChart()
         this.handleAnswerRedPackMoneyViewerChart()
-      }
+      }     
     },
     handleAnswerRedPackViewerChart(){
       let param = this.getParam();