@@ -75,15 +75,16 @@ import { defaultProps, handleTree } from '@/utils/tree'
75
75
import ContractCountPerformance from ' ./components/ContractCountPerformance.vue'
76
76
import ContractPricePerformance from ' ./components/ContractPricePerformance.vue'
77
77
import ReceivablePricePerformance from ' ./components/ReceivablePricePerformance.vue'
78
+ import dayjs from " dayjs"
78
79
79
80
defineOptions ({ name: ' CrmStatisticsCustomer' })
80
81
81
82
const queryParams = reactive ({
82
83
deptId: useUserStore ().getUser .deptId ,
83
84
userId: undefined ,
84
85
times: [
85
- // 默认显示当年的数据
86
- formatDate (beginOfDay (new Date (new Date ().getTime () - 3600 * 1000 * 24 * 7 )))
86
+ formatDate ( beginOfDay ( new Date ( new Date (). getFullYear (), 0 , 1 , 0 , 0 , 0 ))), // 默认查询当年的数据,比如2024年,起始时间2024-01-01 00:00:00
87
+ formatDate (beginOfDay (new Date (new Date ().getFullYear () + 1 , 0 , 1 , 0 , 0 , 0 ))) // 查询时间范围结束时间,2025-01-01 00:00:00
87
88
]
88
89
})
89
90
@@ -111,13 +112,13 @@ const handleQuery = () => {
111
112
// 从 queryParams.times[0] 中获取到了年份
112
113
const selectYear = parseInt (queryParams .times [0 ])
113
114
114
- // 创建一个新的 Date 对象,设置为指定的年份的第一天
115
- const fullDate = new Date (selectYear , 0 , 1 , 0 , 0 , 0 )
115
+ // 创建一个新的 Date 对象,设置为指定的年份的第一天,以及第二年的第一天,以时间段的方式,将查询时间传递给后端
116
+ const fullDate = new Date (selectYear , 0 , 1 , 0 , 0 , 0 ) // 比如2024年,起始时间2024-01-01 00:00:00
117
+ const nextFullDate = new Date (selectYear + 1 , 0 , 1 , 0 , 0 , 0 ) // 查询时间范围结束时间,2025-01-01 00:00:00
116
118
117
119
// 将完整的日期时间格式化为需要的字符串形式,比如 2004-01-01 00:00:00
118
- queryParams .times [0 ] = ` ${fullDate .getFullYear ()}-${
119
- String (fullDate .getMonth () + 1 ).padStart (2 , ' 0' )
120
- }-${String (fullDate .getDate ()).padStart (2 , ' 0' )} ${String (fullDate .getHours ()).padStart (2 , ' 0' )}:${String (fullDate .getMinutes ()).padStart (2 , ' 0' )}:${String (fullDate .getSeconds ()).padStart (2 , ' 0' )} `
120
+ queryParams .times [0 ] = dayjs (fullDate ).format (' YYYY-MM-DD HH:mm:ss' )
121
+ queryParams .times [1 ] = dayjs (nextFullDate ).format (' YYYY-MM-DD HH:mm:ss' )
121
122
122
123
switch (activeTab .value ) {
123
124
case ' ContractCountPerformance' :
0 commit comments