diff --git a/apps/web-antd/src/api/crm/statistics/rank.ts b/apps/web-antd/src/api/crm/statistics/rank.ts index f5fcfb167..216696c87 100644 --- a/apps/web-antd/src/api/crm/statistics/rank.ts +++ b/apps/web-antd/src/api/crm/statistics/rank.ts @@ -11,6 +11,38 @@ export namespace CrmStatisticsRankApi { } } +export function getDatas(activeTabName: any, params: any) { + switch (activeTabName) { + case 'contactCountRank': { + return getContactsCountRank(params); + } + case 'contractCountRank': { + return getContractCountRank(params); + } + case 'contractPriceRank': { + return getContractPriceRank(params); + } + case 'customerCountRank': { + return getCustomerCountRank(params); + } + case 'followCountRank': { + return getFollowCountRank(params); + } + case 'followCustomerCountRank': { + return getFollowCustomerCountRank(params); + } + case 'productSalesRank': { + return getProductSalesRank(params); + } + case 'receivablePriceRank': { + return getReceivablePriceRank(params); + } + default: { + return []; + } + } +} + /** 获得合同排行榜 */ export function getContractPriceRank(params: PageParam) { return requestClient.get( diff --git a/apps/web-antd/src/views/crm/statistics/rank/chartOptions.ts b/apps/web-antd/src/views/crm/statistics/rank/chartOptions.ts new file mode 100644 index 000000000..7234687c5 --- /dev/null +++ b/apps/web-antd/src/views/crm/statistics/rank/chartOptions.ts @@ -0,0 +1,394 @@ +import { cloneDeep } from '@vben/utils'; + +export function getChartOptions(activeTabName: any, res: any): any { + switch (activeTabName) { + case 'contactCountRank': { + return { + dataset: { + dimensions: ['nickname', 'count'], + source: cloneDeep(res).reverse(), + }, + grid: { + left: 20, + right: 20, + bottom: 20, + containLabel: true, + }, + legend: { + top: 50, + }, + series: [ + { + name: '新增联系人数排行', + type: 'bar', + }, + ], + toolbox: { + feature: { + dataZoom: { + yAxisIndex: false, // 数据区域缩放:Y 轴不缩放 + }, + brush: { + type: ['lineX', 'clear'], // 区域缩放按钮、还原按钮 + }, + saveAsImage: { show: true, name: '新增联系人数排行' }, // 保存为图片 + }, + }, + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'shadow', + }, + }, + xAxis: { + type: 'value', + name: '新增联系人数(个)', + }, + yAxis: { + type: 'category', + name: '创建人', + }, + }; + } + case 'contractCountRank': { + return { + dataset: { + dimensions: ['nickname', 'count'], + source: cloneDeep(res).reverse(), + }, + grid: { + left: 20, + right: 20, + bottom: 20, + containLabel: true, + }, + legend: { + top: 50, + }, + series: [ + { + name: '签约合同排行', + type: 'bar', + }, + ], + toolbox: { + feature: { + dataZoom: { + yAxisIndex: false, // 数据区域缩放:Y 轴不缩放 + }, + brush: { + type: ['lineX', 'clear'], // 区域缩放按钮、还原按钮 + }, + saveAsImage: { show: true, name: '签约合同排行' }, // 保存为图片 + }, + }, + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'shadow', + }, + }, + xAxis: { + type: 'value', + name: '签约合同数(个)', + }, + yAxis: { + type: 'category', + name: '签订人', + }, + }; + } + case 'contractPriceRank': { + return { + dataset: { + dimensions: ['nickname', 'count'], + source: cloneDeep(res).reverse(), + }, + grid: { + left: 20, + right: 20, + bottom: 20, + containLabel: true, + }, + legend: { + top: 50, + }, + series: [ + { + name: '合同金额排行', + type: 'bar', + }, + ], + toolbox: { + feature: { + dataZoom: { + yAxisIndex: false, // 数据区域缩放:Y 轴不缩放 + }, + brush: { + type: ['lineX', 'clear'], // 区域缩放按钮、还原按钮 + }, + saveAsImage: { show: true, name: '合同金额排行' }, // 保存为图片 + }, + }, + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'shadow', + }, + }, + xAxis: { + type: 'value', + name: '合同金额(元)', + }, + yAxis: { + type: 'category', + name: '签订人', + }, + }; + } + case 'customerCountRank': { + return { + dataset: { + dimensions: ['nickname', 'count'], + source: cloneDeep(res).reverse(), + }, + grid: { + left: 20, + right: 20, + bottom: 20, + containLabel: true, + }, + legend: { + top: 50, + }, + series: [ + { + name: '新增客户数排行', + type: 'bar', + }, + ], + toolbox: { + feature: { + dataZoom: { + yAxisIndex: false, // 数据区域缩放:Y 轴不缩放 + }, + brush: { + type: ['lineX', 'clear'], // 区域缩放按钮、还原按钮 + }, + saveAsImage: { show: true, name: '新增客户数排行' }, // 保存为图片 + }, + }, + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'shadow', + }, + }, + xAxis: { + type: 'value', + name: '新增客户数(个)', + }, + yAxis: { + type: 'category', + name: '创建人', + }, + }; + } + case 'followCountRank': { + return { + dataset: { + dimensions: ['nickname', 'count'], + source: cloneDeep(res).reverse(), + }, + grid: { + left: 20, + right: 20, + bottom: 20, + containLabel: true, + }, + legend: { + top: 50, + }, + series: [ + { + name: '跟进次数排行', + type: 'bar', + }, + ], + toolbox: { + feature: { + dataZoom: { + yAxisIndex: false, // 数据区域缩放:Y 轴不缩放 + }, + brush: { + type: ['lineX', 'clear'], // 区域缩放按钮、还原按钮 + }, + saveAsImage: { show: true, name: '跟进次数排行' }, // 保存为图片 + }, + }, + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'shadow', + }, + }, + xAxis: { + type: 'value', + name: '跟进次数(次)', + }, + yAxis: { + type: 'category', + name: '员工', + }, + }; + } + case 'followCustomerCountRank': { + return { + dataset: { + dimensions: ['nickname', 'count'], + source: cloneDeep(res).reverse(), + }, + grid: { + left: 20, + right: 20, + bottom: 20, + containLabel: true, + }, + legend: { + top: 50, + }, + series: [ + { + name: '跟进客户数排行', + type: 'bar', + }, + ], + toolbox: { + feature: { + dataZoom: { + yAxisIndex: false, // 数据区域缩放:Y 轴不缩放 + }, + brush: { + type: ['lineX', 'clear'], // 区域缩放按钮、还原按钮 + }, + saveAsImage: { show: true, name: '跟进客户数排行' }, // 保存为图片 + }, + }, + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'shadow', + }, + }, + xAxis: { + type: 'value', + name: '跟进客户数(个)', + }, + yAxis: { + type: 'category', + name: '员工', + }, + }; + } + case 'productSalesRank': { + return { + dataset: { + dimensions: ['nickname', 'count'], + source: cloneDeep(res).reverse(), + }, + grid: { + left: 20, + right: 20, + bottom: 20, + containLabel: true, + }, + legend: { + top: 50, + }, + series: [ + { + name: '产品销量排行', + type: 'bar', + }, + ], + toolbox: { + feature: { + dataZoom: { + yAxisIndex: false, // 数据区域缩放:Y 轴不缩放 + }, + brush: { + type: ['lineX', 'clear'], // 区域缩放按钮、还原按钮 + }, + saveAsImage: { show: true, name: '产品销量排行' }, // 保存为图片 + }, + }, + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'shadow', + }, + }, + xAxis: { + type: 'value', + name: '产品销量', + }, + yAxis: { + type: 'category', + name: '员工', + }, + }; + } + case 'receivablePriceRank': { + return { + dataset: { + dimensions: ['nickname', 'count'], + source: cloneDeep(res).reverse(), + }, + grid: { + left: 20, + right: 20, + bottom: 20, + containLabel: true, + }, + legend: { + top: 50, + }, + series: [ + { + name: '回款金额排行', + type: 'bar', + }, + ], + toolbox: { + feature: { + dataZoom: { + yAxisIndex: false, // 数据区域缩放:Y 轴不缩放 + }, + brush: { + type: ['lineX', 'clear'], // 区域缩放按钮、还原按钮 + }, + saveAsImage: { show: true, name: '回款金额排行' }, // 保存为图片 + }, + }, + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'shadow', + }, + }, + xAxis: { + type: 'value', + name: '回款金额(元)', + }, + yAxis: { + type: 'category', + name: '签订人', + nameGap: 30, + }, + }; + } + default: { + return {}; + } + } +} diff --git a/apps/web-antd/src/views/crm/statistics/rank/data.ts b/apps/web-antd/src/views/crm/statistics/rank/data.ts new file mode 100644 index 000000000..84c78a712 --- /dev/null +++ b/apps/web-antd/src/views/crm/statistics/rank/data.ts @@ -0,0 +1,276 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; + +import { useUserStore } from '@vben/stores'; +import { beginOfDay, endOfDay, formatDateTime, handleTree } from '@vben/utils'; + +import { getSimpleDeptList } from '#/api/system/dept'; +import { getRangePickerDefaultProps } from '#/utils'; + +const userStore = useUserStore(); + +export const customerSummaryTabs = [ + { + tab: '合同金额排行', + key: 'contractPriceRank', + }, + { + tab: '回款金额排行', + key: 'receivablePriceRank', + }, + { + tab: '签约合同排行', + key: 'contractCountRank', + }, + { + tab: '产品销量排行', + key: 'productSalesRank', + }, + { + tab: '新增客户数排行', + key: 'customerCountRank', + }, + { + tab: '新增联系人数排行', + key: 'contactCountRank', + }, + { + tab: '跟进次数排行', + key: 'followCountRank', + }, + { + tab: '跟进客户数排行', + key: 'followCustomerCountRank', + }, +]; + +/** 列表的搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'times', + label: '时间范围', + component: 'RangePicker', + componentProps: { + ...getRangePickerDefaultProps(), + }, + defaultValue: [ + formatDateTime(beginOfDay(new Date(Date.now() - 3600 * 1000 * 24 * 7))), + formatDateTime(endOfDay(new Date(Date.now() - 3600 * 1000 * 24))), + ] as [Date, Date], + }, + { + fieldName: 'deptId', + label: '归属部门', + component: 'ApiTreeSelect', + componentProps: { + api: async () => { + const data = await getSimpleDeptList(); + return handleTree(data); + }, + labelField: 'name', + valueField: 'id', + childrenField: 'children', + treeDefaultExpandAll: true, + }, + defaultValue: userStore.userInfo?.deptId, + }, + ]; +} + +/** 列表的字段 */ +export function useGridColumns( + activeTabName: any, +): VxeTableGridOptions['columns'] { + switch (activeTabName) { + case 'contactCountRank': { + return [ + { + type: 'seq', + title: '公司排名', + }, + { + field: 'nickname', + title: '创建人', + minWidth: 200, + }, + { + field: 'deptName', + title: '部门', + minWidth: 200, + }, + { + field: 'count', + title: '新增联系人数(个)', + minWidth: 200, + }, + ]; + } + case 'contractCountRank': { + return [ + { + type: 'seq', + title: '公司排名', + }, + { + field: 'nickname', + title: '签订人', + minWidth: 200, + }, + { + field: 'deptName', + title: '部门', + minWidth: 200, + }, + { + field: 'count', + title: '签约合同数(个)', + minWidth: 200, + }, + ]; + } + case 'contractPriceRank': { + return [ + { + type: 'seq', + title: '公司排名', + }, + { + field: 'nickname', + title: '签订人', + minWidth: 200, + }, + { + field: 'deptName', + title: '部门', + minWidth: 200, + }, + { + field: 'count', + title: '合同金额(元)', + minWidth: 200, + formatter: 'formatAmount2', + }, + ]; + } + case 'customerCountRank': { + return [ + { + type: 'seq', + title: '公司排名', + }, + { + field: 'nickname', + title: '签订人', + minWidth: 200, + }, + { + field: 'deptName', + title: '部门', + minWidth: 200, + }, + { + field: 'count', + title: '新增客户数(个)', + minWidth: 200, + }, + ]; + } + case 'followCountRank': { + return [ + { + type: 'seq', + title: '公司排名', + }, + { + field: 'nickname', + title: '签订人', + minWidth: 200, + }, + { + field: 'deptName', + title: '部门', + minWidth: 200, + }, + { + field: 'count', + title: '跟进次数(次)', + minWidth: 200, + }, + ]; + } + case 'followCustomerCountRank': { + return [ + { + type: 'seq', + title: '公司排名', + }, + { + field: 'nickname', + title: '签订人', + minWidth: 200, + }, + { + field: 'deptName', + title: '部门', + minWidth: 200, + }, + { + field: 'count', + title: '跟进客户数(个)', + minWidth: 200, + }, + ]; + } + case 'productSalesRank': { + return [ + { + type: 'seq', + title: '公司排名', + }, + { + field: 'nickname', + title: '签订人', + minWidth: 200, + }, + { + field: 'deptName', + title: '部门', + minWidth: 200, + }, + { + field: 'count', + title: '产品销量', + minWidth: 200, + }, + ]; + } + case 'receivablePriceRank': { + return [ + { + type: 'seq', + title: '公司排名', + }, + { + field: 'nickname', + title: '签订人', + minWidth: 200, + }, + { + field: 'deptName', + title: '部门', + minWidth: 200, + }, + { + field: 'count', + title: '回款金额(元)', + minWidth: 200, + formatter: 'formatAmount2', + }, + ]; + } + default: { + return []; + } + } +} diff --git a/apps/web-antd/src/views/crm/statistics/rank/index.vue b/apps/web-antd/src/views/crm/statistics/rank/index.vue index 52c96d9f1..5fa21e517 100644 --- a/apps/web-antd/src/views/crm/statistics/rank/index.vue +++ b/apps/web-antd/src/views/crm/statistics/rank/index.vue @@ -1,28 +1,79 @@