From 2860faf987e3468b1d100aad23dcb5753570aea4 Mon Sep 17 00:00:00 2001 From: xingyu4j Date: Wed, 30 Apr 2025 15:29:05 +0800 Subject: [PATCH] feat: crm business status --- .../src/views/crm/business/status/data.ts | 131 +++++++++++++++ .../src/views/crm/business/status/index.vue | 157 ++++++++++++++---- .../crm/business/status/modules/form.vue | 94 +++++++++++ 3 files changed, 353 insertions(+), 29 deletions(-) create mode 100644 apps/web-antd/src/views/crm/business/status/data.ts create mode 100644 apps/web-antd/src/views/crm/business/status/modules/form.vue diff --git a/apps/web-antd/src/views/crm/business/status/data.ts b/apps/web-antd/src/views/crm/business/status/data.ts new file mode 100644 index 000000000..2cdfce008 --- /dev/null +++ b/apps/web-antd/src/views/crm/business/status/data.ts @@ -0,0 +1,131 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { CrmBusinessStatusApi } from '#/api/crm/business/status'; + +import { useAccess } from '@vben/access'; +import { getRangePickerDefaultProps } from '@vben/utils'; + +import { z } from '#/adapter/form'; +import { CommonStatusEnum } from '#/utils/constants'; +import { DICT_TYPE, getDictOptions } from '#/utils/dict'; + +const { hasAccessByCodes } = useAccess(); + +/** 新增/修改的表单 */ +export function useFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'id', + component: 'Input', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'name', + label: '状态组名', + component: 'Input', + rules: 'required', + }, + { + fieldName: 'deptIds', + label: '应用部门', + component: 'TreeSelect', + componentProps: { + multiple: true, + treeCheckable: true, + showCheckedStrategy: 'SHOW_PARENT', + placeholder: '请选择应用部门', + }, + }, + { + fieldName: 'status', + label: '状态', + component: 'RadioGroup', + componentProps: { + options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + buttonStyle: 'solid', + optionType: 'button', + }, + rules: z.number().default(CommonStatusEnum.ENABLE), + }, + ]; +} + +/** 列表的搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'name', + label: '状态组名', + component: 'Input', + }, + { + fieldName: 'createTime', + label: '创建时间', + component: 'RangePicker', + componentProps: { + ...getRangePickerDefaultProps(), + allowClear: true, + }, + }, + ]; +} + +/** 列表的字段 */ +export function useGridColumns( + onActionClick: OnActionClickFn, +): VxeTableGridOptions['columns'] { + return [ + { + field: 'name', + title: '状态组名', + minWidth: 200, + }, + { + field: 'deptNames', + title: '应用部门', + minWidth: 200, + formatter: ({ cellValue }) => { + return cellValue?.length > 0 ? cellValue.join(' ') : '全公司'; + }, + }, + { + field: 'creator', + title: '创建人', + minWidth: 100, + }, + { + field: 'createTime', + title: '创建时间', + minWidth: 180, + formatter: 'formatDateTime', + }, + { + field: 'operation', + title: '操作', + width: 160, + fixed: 'right', + align: 'center', + cellRender: { + name: 'TableAction', + props: { + actions: [ + { + label: '编辑', + code: 'edit', + show: hasAccessByCodes(['crm:business-status:update']), + }, + { + label: '删除', + code: 'delete', + show: hasAccessByCodes(['crm:business-status:delete']), + }, + ], + onActionClick, + }, + }, + }, + ]; +} diff --git a/apps/web-antd/src/views/crm/business/status/index.vue b/apps/web-antd/src/views/crm/business/status/index.vue index adb8b3bb0..8dc07be69 100644 --- a/apps/web-antd/src/views/crm/business/status/index.vue +++ b/apps/web-antd/src/views/crm/business/status/index.vue @@ -1,38 +1,137 @@ diff --git a/apps/web-antd/src/views/crm/business/status/modules/form.vue b/apps/web-antd/src/views/crm/business/status/modules/form.vue new file mode 100644 index 000000000..a9f18663a --- /dev/null +++ b/apps/web-antd/src/views/crm/business/status/modules/form.vue @@ -0,0 +1,94 @@ + + +