Skip to content

Commit f01dc0a

Browse files
committed
优化代码实现。
1 parent 449d119 commit f01dc0a

File tree

1 file changed

+8
-7
lines changed
  • src/views/crm/statistics/performance

1 file changed

+8
-7
lines changed

src/views/crm/statistics/performance/index.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,16 @@ import { defaultProps, handleTree } from '@/utils/tree'
7575
import ContractCountPerformance from './components/ContractCountPerformance.vue'
7676
import ContractPricePerformance from './components/ContractPricePerformance.vue'
7777
import ReceivablePricePerformance from './components/ReceivablePricePerformance.vue'
78+
import dayjs from "dayjs"
7879
7980
defineOptions({ name: 'CrmStatisticsCustomer' })
8081
8182
const queryParams = reactive({
8283
deptId: useUserStore().getUser.deptId,
8384
userId: undefined,
8485
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
8788
]
8889
})
8990
@@ -111,13 +112,13 @@ const handleQuery = () => {
111112
// 从 queryParams.times[0] 中获取到了年份
112113
const selectYear = parseInt(queryParams.times[0])
113114
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
116118
117119
// 将完整的日期时间格式化为需要的字符串形式,比如 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')
121122
122123
switch (activeTab.value) {
123124
case 'ContractCountPerformance':

0 commit comments

Comments
 (0)