|
|
@@ -240,9 +240,26 @@
|
|
|
<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="自定义"></el-radio-button>
|
|
|
</el-radio-group>
|
|
|
</div>
|
|
|
|
|
|
+
|
|
|
+ <el-date-picker
|
|
|
+ v-if="queryTime === '自定义'"
|
|
|
+ v-model="customRange"
|
|
|
+ type="daterange"
|
|
|
+ range-separator="至"
|
|
|
+ start-placeholder="开始日期"
|
|
|
+ end-placeholder="结束日期"
|
|
|
+ value-format="yyyy-MM-dd"
|
|
|
+ size="medium"
|
|
|
+ style="margin-left: 10px"
|
|
|
+ @change="handleCustomTimeChange"
|
|
|
+ />
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
<div class="action-group">
|
|
|
<el-radio-group v-model="userTypeText" @change="handleUserType">
|
|
|
<el-radio-button label="会员"></el-radio-button>
|
|
|
@@ -942,6 +959,7 @@ export default {
|
|
|
components: {CountTo},
|
|
|
data() {
|
|
|
return {
|
|
|
+ customRange: [], // [startDate, endDate]
|
|
|
percentage: 0,
|
|
|
// 预测message
|
|
|
remainMessage: '',
|
|
|
@@ -1021,6 +1039,19 @@ export default {
|
|
|
todayGoodsNum: 0
|
|
|
}
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ queryTime(newVal, oldVal) {
|
|
|
+ if (newVal === '自定义' && oldVal !== '自定义') {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ const end = dayjs().format('YYYY-MM-DD');
|
|
|
+ const start = dayjs().subtract(6, 'day').format('YYYY-MM-DD');
|
|
|
+ this.customRange = [start, end];
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ this.handleAnalysis();
|
|
|
+ }
|
|
|
+ },
|
|
|
mounted() {
|
|
|
this.$nextTick(() => {
|
|
|
this.initViewerChart()
|
|
|
@@ -1051,6 +1082,11 @@ export default {
|
|
|
this.refresh();
|
|
|
},
|
|
|
methods: {
|
|
|
+ handleCustomTimeChange(val) {
|
|
|
+ // val = ['2026-01-01', '2026-01-07']
|
|
|
+ if (!val || val.length !== 2) return;
|
|
|
+ this.handleAnalysis();
|
|
|
+ },
|
|
|
handleUserType(){
|
|
|
if(this.userTypeText === '会员'){
|
|
|
this.userType = 1
|
|
|
@@ -1349,6 +1385,12 @@ export default {
|
|
|
param.startTime = this.formatDate(lastMonth.startOf('month'));
|
|
|
param.endTime = this.formatDate(lastMonth.endOf('month'));
|
|
|
type = 4;
|
|
|
+ } else if (this.queryTime === '自定义') {
|
|
|
+ if (this.customRange && this.customRange.length === 2) {
|
|
|
+ param.startTime = this.customRange[0];
|
|
|
+ param.endTime = this.customRange[1];
|
|
|
+ }
|
|
|
+ type = 5; // 自定义时间
|
|
|
} else {
|
|
|
console.warn(`未知的 queryTime: ${this.queryTime}, 默认使用今日`);
|
|
|
param.startTime = this.formatDate(today);
|