From 7f6726f456c910199df7735357a8dfe8cb669d57 Mon Sep 17 00:00:00 2001 From: xingyu4j Date: Fri, 30 May 2025 00:40:14 +0800 Subject: [PATCH] feat: add customer-limit-config --- .../src/api/crm/customer/limitConfig/index.ts | 16 +- .../views/crm/customer/limitConfig/data.ts | 140 +++++++++++++ .../views/crm/customer/limitConfig/index.vue | 190 +++++++++++++++--- .../crm/customer/limitConfig/modules/form.vue | 100 +++++++++ 4 files changed, 408 insertions(+), 38 deletions(-) create mode 100644 apps/web-antd/src/views/crm/customer/limitConfig/data.ts create mode 100644 apps/web-antd/src/views/crm/customer/limitConfig/modules/form.vue diff --git a/apps/web-antd/src/api/crm/customer/limitConfig/index.ts b/apps/web-antd/src/api/crm/customer/limitConfig/index.ts index 773255762..f99a35f31 100644 --- a/apps/web-antd/src/api/crm/customer/limitConfig/index.ts +++ b/apps/web-antd/src/api/crm/customer/limitConfig/index.ts @@ -12,16 +12,14 @@ export namespace CrmCustomerLimitConfigApi { maxCount?: number; dealCountEnabled?: boolean; } +} - /** - * 客户限制配置类型 - */ - export enum LimitConfType { - /** 锁定客户数限制 */ - CUSTOMER_LOCK_LIMIT = 2, - /** 拥有客户数限制 */ - CUSTOMER_QUANTITY_LIMIT = 1, - } +/** 客户限制配置类型 */ +export enum LimitConfType { + /** 锁定客户数限制 */ + CUSTOMER_LOCK_LIMIT = 2, + /** 拥有客户数限制 */ + CUSTOMER_QUANTITY_LIMIT = 1, } /** 查询客户限制配置列表 */ diff --git a/apps/web-antd/src/views/crm/customer/limitConfig/data.ts b/apps/web-antd/src/views/crm/customer/limitConfig/data.ts new file mode 100644 index 000000000..0895e1d21 --- /dev/null +++ b/apps/web-antd/src/views/crm/customer/limitConfig/data.ts @@ -0,0 +1,140 @@ +import type { VbenFormSchema } from '@vben/common-ui'; + +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; + +import { handleTree } from '@vben/utils'; + +import { LimitConfType } from '#/api/crm/customer/limitConfig'; +import { getSimpleDeptList } from '#/api/system/dept'; +import { getSimpleUserList } from '#/api/system/user'; +import { DICT_TYPE } from '#/utils'; + +/** 新增/修改的表单 */ +export function useFormSchema(confType: LimitConfType): VbenFormSchema[] { + return [ + { + fieldName: 'id', + component: 'Input', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'userIds', + label: '规则适用人群', + component: 'ApiSelect', + componentProps: { + api: getSimpleUserList, + fieldNames: { + label: 'nickname', + value: 'id', + }, + multiple: true, + allowClear: true, + }, + rules: 'required', + }, + { + fieldName: 'deptIds', + label: '规则适用部门', + component: 'ApiTreeSelect', + componentProps: { + api: async () => { + const data = await getSimpleDeptList(); + return handleTree(data); + }, + multiple: true, + fieldNames: { label: 'name', value: 'id', children: 'children' }, + placeholder: '请选择规则适用部门', + treeDefaultExpandAll: true, + }, + rules: 'required', + }, + { + fieldName: 'maxCount', + label: + confType === LimitConfType.CUSTOMER_QUANTITY_LIMIT + ? '拥有客户数上限' + : '锁定客户数上限', + component: 'InputNumber', + }, + { + fieldName: 'dealCountEnabled', + label: '成交客户是否占用拥有客户数', + component: 'RadioGroup', + componentProps: { + options: [ + { label: '是', value: true }, + { label: '否', value: false }, + ], + }, + dependencies: { + triggerFields: [''], + show: () => confType === LimitConfType.CUSTOMER_QUANTITY_LIMIT, + }, + }, + ]; +} + +/** 列表的字段 */ +export function useGridColumns( + confType: LimitConfType, +): VxeTableGridOptions['columns'] { + return [ + { + field: 'id', + title: '编号', + fixed: 'left', + }, + { + field: 'users', + title: '规则适用人群', + formatter: ({ cellValue }) => { + return cellValue + .map((user: any) => { + return user.nickname; + }) + .join(','); + }, + }, + { + field: 'depts', + title: '规则适用部门', + formatter: ({ cellValue }) => { + return cellValue + .map((dept: any) => { + return dept.name; + }) + .join(','); + }, + }, + { + field: 'maxCount', + title: + confType === LimitConfType.CUSTOMER_QUANTITY_LIMIT + ? '拥有客户数上限' + : '锁定客户数上限', + }, + { + field: 'dealCountEnabled', + title: '成交客户是否占用拥有客户数', + visible: confType === LimitConfType.CUSTOMER_QUANTITY_LIMIT, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING }, + }, + }, + { + field: 'createTime', + title: '创建时间', + formatter: 'formatDateTime', + }, + { + title: '操作', + width: 180, + fixed: 'right', + slots: { default: 'actions' }, + }, + ]; +} diff --git a/apps/web-antd/src/views/crm/customer/limitConfig/index.vue b/apps/web-antd/src/views/crm/customer/limitConfig/index.vue index 3820d40e6..465afd49c 100644 --- a/apps/web-antd/src/views/crm/customer/limitConfig/index.vue +++ b/apps/web-antd/src/views/crm/customer/limitConfig/index.vue @@ -1,38 +1,170 @@ diff --git a/apps/web-antd/src/views/crm/customer/limitConfig/modules/form.vue b/apps/web-antd/src/views/crm/customer/limitConfig/modules/form.vue new file mode 100644 index 000000000..39fa36d27 --- /dev/null +++ b/apps/web-antd/src/views/crm/customer/limitConfig/modules/form.vue @@ -0,0 +1,100 @@ + + +