diff --git a/apps/web-antd/src/views/wms/md/item/data.ts b/apps/web-antd/src/views/wms/md/item/data.ts new file mode 100644 index 000000000..40a7e72dd --- /dev/null +++ b/apps/web-antd/src/views/wms/md/item/data.ts @@ -0,0 +1,267 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; + +import { h, markRaw } from 'vue'; + +import { Button } from 'ant-design-vue'; + +import { z } from '#/adapter/form'; +import { getItemBrandSimpleList } from '#/api/wms/md/item/brand'; +import { generateWmsCode } from '#/views/wms/utils/constants'; + +import { WmsItemBrandSelect } from './brand/components'; +import { WmsItemCategorySelect } from './category/components'; + +/** 新增/修改商品的表单 */ +export function useFormSchema(formApi?: any): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'id', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'name', + label: '商品名称', + component: 'Input', + componentProps: { + maxLength: 60, + placeholder: '请输入商品名称', + }, + rules: z.string().min(1, '商品名称不能为空').max(60), + }, + { + fieldName: 'categoryId', + label: '商品分类', + component: markRaw(WmsItemCategorySelect), + rules: 'required', + }, + { + fieldName: 'code', + label: '商品编号', + component: 'Input', + componentProps: { + maxLength: 20, + placeholder: '请输入商品编号', + }, + rules: z.string().min(1, '商品编号不能为空').max(20), + suffix: () => { + return h( + Button, + { + type: 'default', + onClick: () => { + formApi?.setFieldValue('code', generateWmsCode('I')); + }, + }, + { default: () => '生成' }, + ); + }, + }, + { + fieldName: 'unit', + label: '商品单位', + component: 'Input', + componentProps: { + maxLength: 20, + placeholder: '请输入单位', + }, + }, + { + fieldName: 'brandId', + label: '商品品牌', + component: markRaw(WmsItemBrandSelect), + }, + // TODO @AI:textarea 组件。vue3 + ep 也要调整下; + { + fieldName: 'remark', + label: '备注', + component: 'Input', + componentProps: { + maxLength: 255, + placeholder: '请输入备注', + }, + }, + ]; +} + +/** 列表的搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'categoryId', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'code', + label: '商品编号', + component: 'Input', + componentProps: { + allowClear: true, + placeholder: '请输入商品编号', + }, + }, + { + fieldName: 'name', + label: '商品名称', + component: 'Input', + componentProps: { + allowClear: true, + placeholder: '请输入商品名称', + }, + }, + { + fieldName: 'brandId', + label: '商品品牌', + component: 'ApiSelect', + componentProps: { + allowClear: true, + api: getItemBrandSimpleList, + labelField: 'name', + placeholder: '请选择商品品牌', + showSearch: true, + valueField: 'id', + }, + }, + ]; +} + +/** 列表的字段 */ +export function useGridColumns(): VxeTableGridOptions['columns'] { + return [ + { + field: 'itemInfo', + title: '商品信息', + minWidth: 220, + slots: { default: 'itemInfo' }, + }, + { + field: 'skuInfo', + title: '规格信息', + minWidth: 180, + slots: { default: 'skuInfo' }, + }, + { + field: 'priceInfo', + title: '金额(元)', + minWidth: 140, + slots: { default: 'priceInfo' }, + }, + { + field: 'weightInfo', + title: '重量(kg)', + minWidth: 140, + slots: { default: 'weightInfo' }, + }, + { + field: 'dimensionInfo', + title: '长宽高(cm)', + minWidth: 180, + align: 'right', + slots: { default: 'dimensionInfo' }, + }, + { + field: 'actions', + title: '操作', + width: 120, + fixed: 'right', + slots: { default: 'actions' }, + }, + ]; +} + +/** SKU 选择弹窗搜索表单 */ +export function useSkuSelectGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'itemName', + label: '商品名称', + component: 'Input', + componentProps: { + allowClear: true, + placeholder: '请输入商品名称', + }, + }, + { + fieldName: 'itemCode', + label: '商品编号', + component: 'Input', + componentProps: { + allowClear: true, + placeholder: '请输入商品编号', + }, + }, + { + fieldName: 'name', + label: '规格名称', + component: 'Input', + componentProps: { + allowClear: true, + placeholder: '请输入规格名称', + }, + }, + { + fieldName: 'code', + label: '规格编号', + component: 'Input', + componentProps: { + allowClear: true, + placeholder: '请输入规格编号', + }, + }, + { + fieldName: 'barCode', + label: '条码', + component: 'Input', + componentProps: { + allowClear: true, + placeholder: '请输入条码', + }, + }, + ]; +} + +/** SKU 选择弹窗列表字段 */ +export function useSkuSelectGridColumns(): VxeTableGridOptions['columns'] { + return [ + { type: 'checkbox', width: 50 }, + { + field: 'itemInfo', + title: '商品信息', + minWidth: 220, + slots: { default: 'itemInfo' }, + }, + { + field: 'skuInfo', + title: '规格信息', + minWidth: 220, + slots: { default: 'skuInfo' }, + }, + { + field: 'priceInfo', + title: '金额(元)', + minWidth: 160, + slots: { default: 'priceInfo' }, + }, + { + field: 'weightInfo', + title: '重量(kg)', + minWidth: 160, + slots: { default: 'weightInfo' }, + }, + { + field: 'dimensionInfo', + title: '长宽高(cm)', + minWidth: 180, + align: 'right', + slots: { default: 'dimensionInfo' }, + }, + ]; +} diff --git a/apps/web-antd/src/views/wms/md/item/index.vue b/apps/web-antd/src/views/wms/md/item/index.vue new file mode 100644 index 000000000..f2a90eac3 --- /dev/null +++ b/apps/web-antd/src/views/wms/md/item/index.vue @@ -0,0 +1,274 @@ + + + diff --git a/apps/web-antd/src/views/wms/md/item/modules/form.vue b/apps/web-antd/src/views/wms/md/item/modules/form.vue new file mode 100644 index 000000000..2cd1e6e51 --- /dev/null +++ b/apps/web-antd/src/views/wms/md/item/modules/form.vue @@ -0,0 +1,103 @@ + + + diff --git a/apps/web-antd/src/views/wms/md/item/modules/sku-form.vue b/apps/web-antd/src/views/wms/md/item/modules/sku-form.vue new file mode 100644 index 000000000..1b8f0ca8c --- /dev/null +++ b/apps/web-antd/src/views/wms/md/item/modules/sku-form.vue @@ -0,0 +1,291 @@ + + +