Skip to content

Commit f4dd1be

Browse files
committed
1, 修改数据列表无法刷新的问题;
2, 修改时间选择,后端按照年实现的,前端同样按照年份选择实现; 3,修改环比同比计算; 4,回款金额统计bug修复。
1 parent b57a2c5 commit f4dd1be

File tree

4 files changed

+40
-34
lines changed

4 files changed

+40
-34
lines changed

src/views/crm/statistics/performance/components/ContractCountPerformance.vue

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- 客户总量统计 -->
1+
<!-- 员工业绩统计 -->
22
<template>
33
<!-- Echarts图 -->
44
<el-card shadow="never">
@@ -180,6 +180,7 @@ const loadData = async () => {
180180
181181
// 2.2 更新列表数据
182182
list.value = performanceList
183+
convertListData()
183184
loading.value = false
184185
185186
}
@@ -189,9 +190,10 @@ const columnsData = reactive([]);
189190
const tableData = reactive([{title: '当月合同数量统计(个)'}, {title: '上月合同数量统计(个)'},
190191
{title: '去年当月合同数量统计(个)'}, {title: '同比增长率(%)'}, {title: '环比增长率(%)'}])
191192
192-
// 定义 init 方法
193-
const init = () => {
193+
// 定义 convertListData 方法,数据行列转置,展示每月数据
194+
const convertListData = () => {
194195
const columnObj = {label: '日期', prop: 'title'}
196+
columnsData.splice(0, columnsData.length);//清空数组
195197
columnsData.push(columnObj)
196198
197199
list.value.forEach((item, index) => {
@@ -200,8 +202,8 @@ const init = () => {
200202
tableData[0]['prop' + index] = item.currentMonthCount
201203
tableData[1]['prop' + index] = item.lastMonthCount
202204
tableData[2]['prop' + index] = item.lastYearCount
203-
tableData[3]['prop' + index] = item.lastYearCount !== 0 ? (item.currentMonthCount / item.lastYearCount).toFixed(2) : 'NULL'
204-
tableData[4]['prop' + index] = item.lastMonthCount !== 0 ? (item.currentMonthCount / item.lastMonthCount).toFixed(2) : 'NULL'
205+
tableData[3]['prop' + index] = item.lastMonthCount !== 0 ? (item.currentMonthCount / item.lastMonthCount).toFixed(2) : 'NULL'
206+
tableData[4]['prop' + index] = item.lastYearCount !== 0 ? (item.currentMonthCount / item.lastYearCount).toFixed(2) : 'NULL'
205207
})
206208
}
207209
@@ -210,6 +212,5 @@ defineExpose({ loadData })
210212
/** 初始化 */
211213
onMounted(async () => {
212214
await loadData()
213-
init()
214215
})
215216
</script>

src/views/crm/statistics/performance/components/ContractPricePerformance.vue

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- 客户总量统计 -->
1+
<!-- 员工业绩统计 -->
22
<template>
33
<!-- Echarts图 -->
44
<el-card shadow="never">
@@ -180,6 +180,7 @@ const loadData = async () => {
180180
181181
// 2.2 更新列表数据
182182
list.value = performanceList
183+
convertListData()
183184
loading.value = false
184185
185186
}
@@ -190,8 +191,9 @@ const tableData = reactive([{title: '当月合同金额统计(元)'}, {title
190191
{title: '同比增长率(%)'}, {title: '环比增长率(%)'}])
191192
192193
// 定义 init 方法
193-
const init = () => {
194+
const convertListData = () => {
194195
const columnObj = {label: '日期', prop: 'title'}
196+
columnsData.splice(0, columnsData.length)//清空数组
195197
columnsData.push(columnObj)
196198
197199
list.value.forEach((item, index) => {
@@ -200,8 +202,8 @@ const init = () => {
200202
tableData[0]['prop' + index] = item.currentMonthCount
201203
tableData[1]['prop' + index] = item.lastMonthCount
202204
tableData[2]['prop' + index] = item.lastYearCount
203-
tableData[3]['prop' + index] = item.lastYearCount !== 0 ? (item.currentMonthCount / item.lastYearCount).toFixed(2) : 'NULL'
204-
tableData[4]['prop' + index] = item.lastMonthCount !== 0 ? (item.currentMonthCount / item.lastMonthCount).toFixed(2) : 'NULL'
205+
tableData[3]['prop' + index] = item.lastMonthCount !== 0 ? (item.currentMonthCount / item.lastMonthCount).toFixed(2) : 'NULL'
206+
tableData[4]['prop' + index] = item.lastYearCount !== 0 ? (item.currentMonthCount / item.lastYearCount).toFixed(2) : 'NULL'
205207
})
206208
}
207209
@@ -210,6 +212,5 @@ defineExpose({ loadData })
210212
/** 初始化 */
211213
onMounted(async () => {
212214
await loadData()
213-
init()
214215
})
215216
</script>

src/views/crm/statistics/performance/components/ReceivablePricePerformance.vue

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- 客户总量统计 -->
1+
<!-- 员工业绩统计 -->
22
<template>
33
<!-- Echarts图 -->
44
<el-card shadow="never">
@@ -180,6 +180,7 @@ const loadData = async () => {
180180
181181
// 2.2 更新列表数据
182182
list.value = performanceList
183+
convertListData()
183184
loading.value = false
184185
185186
}
@@ -190,8 +191,9 @@ const tableData = reactive([{title: '当月回款金额统计(元)'}, {title
190191
{title: '去年当月回款金额统计(元)'}, {title: '同比增长率(%)'}, {title: '环比增长率(%)'}]);
191192
192193
// 定义 init 方法
193-
const init = () => {
194+
const convertListData = () => {
194195
const columnObj = {label: '日期', prop: 'title'}
196+
columnsData.splice(0, columnsData.length)//清空数组
195197
columnsData.push(columnObj)
196198
197199
list.value.forEach((item, index) => {
@@ -200,8 +202,8 @@ const init = () => {
200202
tableData[0]['prop' + index] = item.currentMonthCount
201203
tableData[1]['prop' + index] = item.lastMonthCount
202204
tableData[2]['prop' + index] = item.lastYearCount
203-
tableData[3]['prop' + index] = item.lastYearCount !== 0 ? (item.currentMonthCount / item.lastYearCount).toFixed(2) : 'NULL'
204-
tableData[4]['prop' + index] = item.lastMonthCount !== 0 ? (item.currentMonthCount / item.lastMonthCount).toFixed(2) : 'NULL'
205+
tableData[3]['prop' + index] = item.lastMonthCount !== 0 ? (item.currentMonthCount / item.lastMonthCount).toFixed(2) : 'NULL'
206+
tableData[4]['prop' + index] = item.lastYearCount !== 0 ? (item.currentMonthCount / item.lastYearCount).toFixed(2) : 'NULL'
205207
})
206208
}
207209
@@ -210,6 +212,5 @@ defineExpose({ loadData })
210212
/** 初始化 */
211213
onMounted(async () => {
212214
await loadData()
213-
init()
214215
})
215216
</script>

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

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- 数据统计 - 员工客户分析 -->
1+
<!-- 数据统计 - 员工业绩分析 -->
22
<template>
33
<ContentWrap>
44
<!-- 搜索工作栏 -->
@@ -9,16 +9,13 @@
99
:inline="true"
1010
label-width="68px"
1111
>
12-
<el-form-item label="时间范围" prop="orderDate">
12+
<el-form-item label="选择年份" prop="orderDate">
1313
<el-date-picker
14-
v-model="queryParams.times"
15-
:shortcuts="defaultShortcuts"
14+
v-model="queryParams.times[0]"
1615
class="!w-240px"
17-
end-placeholder="结束日期"
18-
start-placeholder="开始日期"
19-
type="daterange"
20-
value-format="YYYY-MM-DD HH:mm:ss"
21-
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
16+
type="year"
17+
value-format="YYYY"
18+
:default-time="[new Date().getFullYear()]"
2219
/>
2320
</el-form-item>
2421
<el-form-item label="归属部门" prop="deptId">
@@ -62,7 +59,7 @@
6259
<ContractPricePerformance :query-params="queryParams" ref="ContractPricePerformanceRef" />
6360
</el-tab-pane>
6461
<!-- 员工回款金额统计 -->
65-
<el-tab-pane label="员工回款金额统计" name="followupType" lazy>
62+
<el-tab-pane label="员工回款金额统计" name="ReceivablePricePerformance" lazy>
6663
<ReceivablePricePerformance :query-params="queryParams" ref="ReceivablePricePerformanceRef" />
6764
</el-tab-pane>
6865
</el-tabs>
@@ -78,19 +75,15 @@ import { defaultProps, handleTree } from '@/utils/tree'
7875
import ContractCountPerformance from './components/ContractCountPerformance.vue'
7976
import ContractPricePerformance from './components/ContractPricePerformance.vue'
8077
import ReceivablePricePerformance from './components/ReceivablePricePerformance.vue'
81-
import CustomerFollowupType from './components/CustomerFollowupType.vue'
82-
import CustomerConversionStat from './components/CustomerConversionStat.vue'
83-
import CustomerDealCycle from './components/CustomerDealCycle.vue'
8478
8579
defineOptions({ name: 'CrmStatisticsCustomer' })
8680
8781
const queryParams = reactive({
8882
deptId: useUserStore().getUser.deptId,
8983
userId: undefined,
9084
times: [
91-
// 默认显示最近一周的数据
92-
formatDate(beginOfDay(new Date(new Date().getTime() - 3600 * 1000 * 24 * 7))),
93-
formatDate(endOfDay(new Date(new Date().getTime() - 3600 * 1000 * 24)))
85+
// 默认显示当年的数据
86+
formatDate(beginOfDay(new Date(new Date().getTime() - 3600 * 1000 * 24 * 7)))
9487
]
9588
})
9689
@@ -113,9 +106,19 @@ const ContractPricePerformanceRef = ref()
113106
// 3.员工回款金额统计
114107
const ReceivablePricePerformanceRef = ref()
115108
116-
117109
/** 搜索按钮操作 */
118-
const handleQuery = () => {
110+
const handleQuery = () => {
111+
// 从 queryParams.times[0] 中获取到了年份
112+
const selectYear = parseInt(queryParams.times[0])
113+
114+
// 创建一个新的 Date 对象,设置为指定的年份的第一天
115+
const fullDate = new Date(selectYear, 0, 1, 0, 0, 0)
116+
117+
// 将完整的日期时间格式化为需要的字符串形式,比如 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')}`
121+
119122
switch (activeTab.value) {
120123
case 'ContractCountPerformance':
121124
ContractCountPerformanceRef.value?.loadData?.()

0 commit comments

Comments
 (0)