From f6a5ca97a442b0547262cd1b3bc49f5456b1464d Mon Sep 17 00:00:00 2001 From: xingyu4j Date: Thu, 29 May 2025 01:51:29 +0800 Subject: [PATCH] feat: add crm product --- apps/web-antd/src/views/crm/product/data.ts | 166 +++++++++++++++++ apps/web-antd/src/views/crm/product/index.vue | 175 +++++++++++++++--- .../src/views/crm/product/modules/form.vue | 82 ++++++++ 3 files changed, 397 insertions(+), 26 deletions(-) create mode 100644 apps/web-antd/src/views/crm/product/data.ts create mode 100644 apps/web-antd/src/views/crm/product/modules/form.vue diff --git a/apps/web-antd/src/views/crm/product/data.ts b/apps/web-antd/src/views/crm/product/data.ts new file mode 100644 index 000000000..592460a61 --- /dev/null +++ b/apps/web-antd/src/views/crm/product/data.ts @@ -0,0 +1,166 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; + +import { z } from '#/adapter/form'; +import { CommonStatusEnum, DICT_TYPE, getDictOptions } from '#/utils'; + +/** 新增/修改的表单 */ +export function useFormSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'id', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + component: 'Input', + fieldName: 'name', + label: '产品名称', + rules: 'required', + }, + { + component: 'Input', + fieldName: 'no', + label: '产品编码', + rules: 'required', + }, + { + component: 'Input', + fieldName: 'categoryName', + label: '产品类型', + rules: 'required', + }, + { + fieldName: 'unit', + label: '产品单位', + component: 'Select', + componentProps: { + options: getDictOptions(DICT_TYPE.CRM_PRODUCT_UNIT), + }, + rules: 'required', + }, + { + component: 'InputNumber', + fieldName: 'price', + label: '价格(元)', + rules: 'required', + componentProps: { + min: 0, + precision: 2, + step: 0.1, + }, + }, + { + component: 'Textarea', + fieldName: 'description', + label: '产品描述', + }, + { + fieldName: 'status', + label: '上架状态', + component: 'RadioGroup', + componentProps: { + options: getDictOptions(DICT_TYPE.CRM_PRODUCT_STATUS, 'number'), + buttonStyle: 'solid', + optionType: 'button', + }, + rules: z.number().default(CommonStatusEnum.ENABLE), + }, + ]; +} + +/** 列表的搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'name', + label: '产品名称', + component: 'Input', + }, + { + fieldName: 'status', + label: '上架状态', + component: 'Select', + componentProps: { + allowClear: true, + options: getDictOptions(DICT_TYPE.CRM_PRODUCT_STATUS, 'number'), + }, + }, + ]; +} + +/** 列表的字段 */ +export function useGridColumns(): VxeTableGridOptions['columns'] { + return [ + { + field: 'id', + title: '产品编号', + visible: false, + }, + { + field: 'name', + title: '产品名称', + slots: { default: 'name' }, + }, + { + field: 'categoryName', + title: '产品类型', + }, + { + field: 'unit', + title: '产品单位', + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.CRM_PRODUCT_UNIT }, + }, + }, + { + field: 'no', + title: '产品编码', + }, + { + field: 'price', + title: '价格(元)', + formatter: 'formatNumber', + }, + { + field: 'description', + title: '产品描述', + }, + { + field: 'status', + title: '上架状态', + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.CRM_PRODUCT_STATUS }, + }, + }, + { + field: 'ownerUserName', + title: '负责人', + }, + { + field: 'updateTime', + title: '更新时间', + formatter: 'formatDateTime', + }, + { + field: 'creatorName', + title: '创建人', + }, + { + field: 'createTime', + title: '创建时间', + formatter: 'formatDateTime', + }, + { + title: '操作', + width: 160, + fixed: 'right', + slots: { default: 'actions' }, + }, + ]; +} diff --git a/apps/web-antd/src/views/crm/product/index.vue b/apps/web-antd/src/views/crm/product/index.vue index 805a634a5..93bcbd458 100644 --- a/apps/web-antd/src/views/crm/product/index.vue +++ b/apps/web-antd/src/views/crm/product/index.vue @@ -1,34 +1,157 @@ diff --git a/apps/web-antd/src/views/crm/product/modules/form.vue b/apps/web-antd/src/views/crm/product/modules/form.vue new file mode 100644 index 000000000..ef24d9a94 --- /dev/null +++ b/apps/web-antd/src/views/crm/product/modules/form.vue @@ -0,0 +1,82 @@ + + +