diff --git a/apps/web-antd/src/api/erp/product/category/index.ts b/apps/web-antd/src/api/erp/product/category/index.ts index b16a91e3a..74e5465c1 100644 --- a/apps/web-antd/src/api/erp/product/category/index.ts +++ b/apps/web-antd/src/api/erp/product/category/index.ts @@ -4,11 +4,12 @@ export namespace ErpProductCategoryApi { /** ERP 产品分类信息 */ export interface ProductCategory { id?: number; // 分类编号 - parentId: number; // 父分类编号 + parentId?: number; // 父分类编号 name: string; // 分类名称 - code: string; // 分类编码 - sort: number; // 分类排序 - status: number; // 开启状态 + code?: string; // 分类编码 + sort?: number; // 分类排序 + status?: number; // 开启状态 + children?: ProductCategory[]; // 子分类 } } diff --git a/apps/web-antd/src/views/erp/product/category/data.ts b/apps/web-antd/src/views/erp/product/category/data.ts new file mode 100644 index 000000000..9d95075cb --- /dev/null +++ b/apps/web-antd/src/views/erp/product/category/data.ts @@ -0,0 +1,125 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { ErpProductCategoryApi } from '#/api/erp/product/category'; + +import { handleTree } from '@vben/utils'; + +import { z } from '#/adapter/form'; +import { getProductCategoryList } from '#/api/erp/product/category'; +import { CommonStatusEnum, DICT_TYPE, getDictOptions } from '#/utils'; + +/** 新增/修改的表单 */ +export function useFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'id', + component: 'Input', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'parentId', + label: '上级分类', + component: 'ApiTreeSelect', + componentProps: { + allowClear: true, + api: async () => { + const data = await getProductCategoryList(); + data.unshift({ + id: 0, + name: '顶级分类', + }); + return handleTree(data); + }, + labelField: 'name', + valueField: 'id', + childrenField: 'children', + placeholder: '请选择上级分类', + treeDefaultExpandAll: true, + }, + rules: 'selectRequired', + }, + { + fieldName: 'name', + label: '分类名称', + component: 'Input', + componentProps: { + placeholder: '请输入分类名称', + }, + rules: 'required', + }, + { + fieldName: 'code', + label: '分类编码', + component: 'Input', + componentProps: { + placeholder: '请输入分类编码', + }, + rules: z.string().regex(/^[A-Z]+$/, '分类编码必须为大写字母'), + }, + { + fieldName: 'sort', + label: '显示顺序', + component: 'InputNumber', + componentProps: { + min: 0, + controlsPosition: 'right', + placeholder: '请输入显示顺序', + }, + rules: 'required', + }, + + { + 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 useGridColumns(): VxeTableGridOptions['columns'] { + return [ + { + field: 'name', + title: '分类名称', + align: 'left', + treeNode: true, + }, + { + field: 'code', + title: '分类编码', + }, + { + field: 'sort', + title: '显示顺序', + }, + { + field: 'status', + title: '分类状态', + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.COMMON_STATUS }, + }, + }, + { + field: 'createTime', + title: '创建时间', + formatter: 'formatDateTime', + }, + { + title: '操作', + width: 220, + fixed: 'right', + slots: { default: 'actions' }, + }, + ]; +} diff --git a/apps/web-antd/src/views/erp/product/category/index.vue b/apps/web-antd/src/views/erp/product/category/index.vue index 47c5b65b9..01fdede9e 100644 --- a/apps/web-antd/src/views/erp/product/category/index.vue +++ b/apps/web-antd/src/views/erp/product/category/index.vue @@ -1,34 +1,166 @@ diff --git a/apps/web-antd/src/views/erp/product/category/modules/form.vue b/apps/web-antd/src/views/erp/product/category/modules/form.vue new file mode 100644 index 000000000..ad6ffa89b --- /dev/null +++ b/apps/web-antd/src/views/erp/product/category/modules/form.vue @@ -0,0 +1,92 @@ + + + diff --git a/apps/web-antd/src/views/erp/product/product/data.ts b/apps/web-antd/src/views/erp/product/product/data.ts new file mode 100644 index 000000000..8b44beef8 --- /dev/null +++ b/apps/web-antd/src/views/erp/product/product/data.ts @@ -0,0 +1,220 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; + +import { handleTree } from '@vben/utils'; + +import { z } from '#/adapter/form'; +import { getProductCategorySimpleList } from '#/api/erp/product/category'; +import { getProductUnitSimpleList } from '#/api/erp/product/unit'; +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', + componentProps: { + placeholder: '请输入名称', + }, + }, + { + fieldName: 'barCode', + label: '条码', + component: 'Input', + rules: 'required', + componentProps: { + placeholder: '请输入条码', + }, + }, + { + fieldName: 'categoryId', + label: '分类', + component: 'ApiTreeSelect', + componentProps: { + api: async () => { + const data = await getProductCategorySimpleList(); + return handleTree(data); + }, + + labelField: 'name', + valueField: 'id', + childrenField: 'children', + placeholder: '请选择分类', + treeDefaultExpandAll: true, + }, + rules: 'required', + }, + { + fieldName: 'unitId', + label: '单位', + component: 'ApiSelect', + componentProps: { + api: getProductUnitSimpleList, + labelField: 'name', + valueField: 'id', + placeholder: '请选择单位', + }, + rules: 'required', + }, + { + fieldName: 'status', + label: '状态', + component: 'RadioGroup', + componentProps: { + options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + buttonStyle: 'solid', + optionType: 'button', + }, + rules: z.number().default(CommonStatusEnum.ENABLE), + }, + { + fieldName: 'standard', + label: '规格', + component: 'Input', + componentProps: { + placeholder: '请输入规格', + }, + }, + { + fieldName: 'expiryDay', + label: '保质期天数', + component: 'InputNumber', + componentProps: { + placeholder: '请输入保质期天数', + }, + }, + { + fieldName: 'weight', + label: '重量(kg)', + component: 'InputNumber', + componentProps: { + placeholder: '请输入重量(kg)', + }, + }, + { + fieldName: 'purchasePrice', + label: '采购价格', + component: 'InputNumber', + componentProps: { + placeholder: '请输入采购价格,单位:元', + }, + }, + { + fieldName: 'salePrice', + label: '销售价格', + component: 'InputNumber', + componentProps: { + placeholder: '请输入销售价格,单位:元', + }, + }, + { + fieldName: 'minPrice', + label: '最低价格', + component: 'InputNumber', + componentProps: { + placeholder: '请输入最低价格,单位:元', + }, + }, + { + fieldName: 'remark', + label: '备注', + component: 'Textarea', + }, + ]; +} + +/** 列表的搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'name', + label: '名称', + component: 'Input', + }, + { + fieldName: 'categoryId', + label: '分类', + component: 'ApiTreeSelect', + componentProps: { + api: async () => { + const data = await getProductCategorySimpleList(); + return handleTree(data); + }, + + labelField: 'name', + valueField: 'id', + childrenField: 'children', + placeholder: '请选择分类', + treeDefaultExpandAll: true, + }, + }, + ]; +} + +/** 列表的字段 */ +export function useGridColumns(): VxeTableGridOptions['columns'] { + return [ + { + field: 'barCode', + title: '条码', + }, + { + field: 'name', + title: '名称', + }, + { + field: 'standard', + title: '规格', + }, + { + field: 'categoryName', + title: '分类', + }, + { + field: 'unitName', + title: '单位', + }, + { + field: 'purchasePrice', + title: '采购价格', + }, + { + field: 'salePrice', + title: '销售价格', + }, + { + field: 'minPrice', + title: '最低价格', + }, + { + field: 'status', + title: '状态', + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.COMMON_STATUS }, + }, + }, + { + field: 'createTime', + title: '创建时间', + formatter: 'formatDateTime', + }, + { + title: '操作', + width: 130, + fixed: 'right', + slots: { default: 'actions' }, + }, + ]; +} diff --git a/apps/web-antd/src/views/erp/product/product/index.vue b/apps/web-antd/src/views/erp/product/product/index.vue index d52ab9c92..1748c0d09 100644 --- a/apps/web-antd/src/views/erp/product/product/index.vue +++ b/apps/web-antd/src/views/erp/product/product/index.vue @@ -1,34 +1,152 @@ diff --git a/apps/web-antd/src/views/erp/product/product/modules/form.vue b/apps/web-antd/src/views/erp/product/product/modules/form.vue new file mode 100644 index 000000000..cbaf8072c --- /dev/null +++ b/apps/web-antd/src/views/erp/product/product/modules/form.vue @@ -0,0 +1,86 @@ + + + diff --git a/apps/web-antd/src/views/erp/product/unit/data.ts b/apps/web-antd/src/views/erp/product/unit/data.ts new file mode 100644 index 000000000..7de094158 --- /dev/null +++ b/apps/web-antd/src/views/erp/product/unit/data.ts @@ -0,0 +1,89 @@ +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', + }, + { + 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: 'status', + label: '单位状态', + component: 'Select', + componentProps: { + allowClear: true, + options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + }, + }, + ]; +} + +/** 列表的字段 */ +export function useGridColumns(): VxeTableGridOptions['columns'] { + return [ + { + field: 'id', + title: '单位编号', + }, + { + field: 'name', + title: '单位名称', + }, + { + field: 'status', + title: '单位状态', + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.COMMON_STATUS }, + }, + }, + { + field: 'createTime', + title: '创建时间', + formatter: 'formatDateTime', + }, + { + title: '操作', + width: 130, + fixed: 'right', + slots: { default: 'actions' }, + }, + ]; +} diff --git a/apps/web-antd/src/views/erp/product/unit/index.vue b/apps/web-antd/src/views/erp/product/unit/index.vue index 70e5ebd61..1386c131f 100644 --- a/apps/web-antd/src/views/erp/product/unit/index.vue +++ b/apps/web-antd/src/views/erp/product/unit/index.vue @@ -1,34 +1,152 @@ diff --git a/apps/web-antd/src/views/erp/product/unit/modules/form.vue b/apps/web-antd/src/views/erp/product/unit/modules/form.vue new file mode 100644 index 000000000..4871e227c --- /dev/null +++ b/apps/web-antd/src/views/erp/product/unit/modules/form.vue @@ -0,0 +1,88 @@ + + + diff --git a/apps/web-antd/src/views/erp/purchase/order/modules/form.vue b/apps/web-antd/src/views/erp/purchase/order/modules/form.vue index d1399bfa2..8b93ae7e2 100644 --- a/apps/web-antd/src/views/erp/purchase/order/modules/form.vue +++ b/apps/web-antd/src/views/erp/purchase/order/modules/form.vue @@ -111,7 +111,11 @@ const [Modal, modalApi] = useVbenModal({ // 提交表单 const data = (await formApi.getValues()) as ErpPurchaseOrderApi.PurchaseOrder; - data.items = formData.value?.items; + data.items = formData.value?.items?.map((item) => ({ + ...item, + // 解决新增采购订单报错 + id: undefined, + })); // 将文件数组转换为字符串 if (data.fileUrl && Array.isArray(data.fileUrl)) { data.fileUrl = data.fileUrl.length > 0 ? data.fileUrl[0] : '';