From eb0f2a5ff27fde3c27661de24afeab4b88e06261 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 24 May 2026 19:04:50 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=88mes=EF=BC=89=EF=BC=9Atm=20tool=20?= =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E8=BF=81=E7=A7=BB=E5=AE=8C=E6=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/views/mes/tm/tool/data.ts | 305 +++++++++++++++++ apps/web-antd/src/views/mes/tm/tool/index.vue | 174 ++++++++++ .../src/views/mes/tm/tool/modules/form.vue | 126 +++++++ .../mes/tm/tool/type/components/index.ts | 2 + .../type/components/tm-tool-type-select.vue | 55 ++++ .../type/components/tm-tool-type-tree.vue | 106 ++++++ .../src/views/mes/tm/tool/type/data.ts | 209 ++++++++++++ .../src/views/mes/tm/tool/type/index.vue | 153 +++++++++ .../views/mes/tm/tool/type/modules/form.vue | 102 ++++++ apps/web-ele/src/views/mes/tm/tool/data.ts | 309 ++++++++++++++++++ apps/web-ele/src/views/mes/tm/tool/index.vue | 172 ++++++++++ .../src/views/mes/tm/tool/modules/form.vue | 126 +++++++ .../mes/tm/tool/type/components/index.ts | 2 + .../type/components/tm-tool-type-select.vue | 52 +++ .../type/components/tm-tool-type-tree.vue | 106 ++++++ .../src/views/mes/tm/tool/type/data.ts | 208 ++++++++++++ .../src/views/mes/tm/tool/type/index.vue | 151 +++++++++ .../views/mes/tm/tool/type/modules/form.vue | 102 ++++++ 18 files changed, 2460 insertions(+) create mode 100644 apps/web-antd/src/views/mes/tm/tool/data.ts create mode 100644 apps/web-antd/src/views/mes/tm/tool/index.vue create mode 100644 apps/web-antd/src/views/mes/tm/tool/modules/form.vue create mode 100644 apps/web-antd/src/views/mes/tm/tool/type/components/index.ts create mode 100644 apps/web-antd/src/views/mes/tm/tool/type/components/tm-tool-type-select.vue create mode 100644 apps/web-antd/src/views/mes/tm/tool/type/components/tm-tool-type-tree.vue create mode 100644 apps/web-antd/src/views/mes/tm/tool/type/data.ts create mode 100644 apps/web-antd/src/views/mes/tm/tool/type/index.vue create mode 100644 apps/web-antd/src/views/mes/tm/tool/type/modules/form.vue create mode 100644 apps/web-ele/src/views/mes/tm/tool/data.ts create mode 100644 apps/web-ele/src/views/mes/tm/tool/index.vue create mode 100644 apps/web-ele/src/views/mes/tm/tool/modules/form.vue create mode 100644 apps/web-ele/src/views/mes/tm/tool/type/components/index.ts create mode 100644 apps/web-ele/src/views/mes/tm/tool/type/components/tm-tool-type-select.vue create mode 100644 apps/web-ele/src/views/mes/tm/tool/type/components/tm-tool-type-tree.vue create mode 100644 apps/web-ele/src/views/mes/tm/tool/type/data.ts create mode 100644 apps/web-ele/src/views/mes/tm/tool/type/index.vue create mode 100644 apps/web-ele/src/views/mes/tm/tool/type/modules/form.vue diff --git a/apps/web-antd/src/views/mes/tm/tool/data.ts b/apps/web-antd/src/views/mes/tm/tool/data.ts new file mode 100644 index 000000000..fbff2a1a3 --- /dev/null +++ b/apps/web-antd/src/views/mes/tm/tool/data.ts @@ -0,0 +1,305 @@ +import type { VbenFormApi, VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { MesTmToolApi } from '#/api/mes/tm/tool'; + +import { h, markRaw } from 'vue'; + +import { DICT_TYPE } from '@vben/constants'; +import { getDictOptions } from '@vben/hooks'; +import { formatDateTime } from '@vben/utils'; + +import { Button } from 'ant-design-vue'; + +import { z } from '#/adapter/form'; +import { generateAutoCode } from '#/api/mes/md/autocode/record'; +import { + MesAutoCodeRuleCode, + MesMaintenTypeEnum, + MesToolStatusEnum, +} from '#/views/mes/utils/constants'; + +import { TmToolTypeSelect } from './type/components'; + +/** 新增/修改工具的表单 */ +export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] { + return [ + { + fieldName: 'id', + component: 'Input', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'code', + label: '工具编码', + component: 'Input', + componentProps: { + placeholder: '请输入工具编码', + }, + dependencies: { + triggerFields: ['id'], + componentProps: (values) => ({ disabled: !!values.id }), + }, + rules: 'required', + suffix: () => + h( + Button, + { + type: 'default', + onClick: async () => { + const code = await generateAutoCode(MesAutoCodeRuleCode.TM_TOOL_CODE); + await formApi?.setFieldValue('code', code); + }, + }, + { default: () => '生成' }, + ), + }, + { + fieldName: 'name', + label: '工具名称', + component: 'Input', + componentProps: { + placeholder: '请输入工具名称', + }, + rules: 'required', + }, + { + fieldName: 'toolTypeId', + label: '工具类型', + component: markRaw(TmToolTypeSelect), + componentProps: { + placeholder: '请选择工具类型', + onChange: async (row: any) => { + if (row?.codeFlag) { + await formApi?.setFieldValue('quantity', 1); + await formApi?.setFieldValue('availableQuantity', 1); + } + }, + }, + rules: 'selectRequired', + }, + { + fieldName: 'brand', + label: '品牌', + component: 'Input', + componentProps: { + placeholder: '请输入品牌', + }, + }, + { + fieldName: 'specification', + label: '型号规格', + component: 'Input', + componentProps: { + placeholder: '请输入型号规格', + }, + }, + { + fieldName: 'quantity', + label: '库存数量', + component: 'InputNumber', + componentProps: { + class: '!w-full', + min: 1, + onChange: async (value?: number) => { + const values = (await formApi?.getValues()) as MesTmToolApi.Tool | undefined; + if (!values?.id) { + await formApi?.setFieldValue('availableQuantity', value); + } + }, + precision: 0, + }, + rules: 'required', + }, + { + fieldName: 'availableQuantity', + label: '可用数量', + component: 'InputNumber', + componentProps: { + class: '!w-full', + disabled: true, + min: 0, + precision: 0, + }, + rules: z.number().default(1), + }, + { + fieldName: 'status', + label: '状态', + component: 'Select', + componentProps: { + disabled: true, + options: getDictOptions(DICT_TYPE.MES_TM_TOOL_STATUS, 'number'), + }, + rules: z.number().default(MesToolStatusEnum.STORE), + }, + { + fieldName: 'maintenType', + label: '保养维护类型', + component: 'Select', + componentProps: { + allowClear: true, + options: getDictOptions(DICT_TYPE.MES_TM_MAINTEN_TYPE, 'number'), + placeholder: '请选择保养维护类型', + }, + }, + { + fieldName: 'nextMaintenDate', + label: '下次保养日期', + component: 'DatePicker', + componentProps: { + format: 'YYYY-MM-DD HH:mm:ss', + showTime: true, + valueFormat: 'x', + }, + dependencies: { + triggerFields: ['maintenType'], + show: (values) => values.maintenType === MesMaintenTypeEnum.REGULAR, + }, + }, + { + fieldName: 'nextMaintenPeriod', + label: '下次保养周期', + component: 'InputNumber', + componentProps: { + class: '!w-full', + min: 1, + precision: 0, + }, + dependencies: { + triggerFields: ['maintenType'], + show: (values) => values.maintenType === MesMaintenTypeEnum.USAGE, + }, + }, + { + fieldName: 'remark', + label: '备注', + component: 'Textarea', + formItemClass: 'col-span-3', + componentProps: { + placeholder: '请输入备注', + rows: 3, + }, + }, + ]; +} + +/** 列表的搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'code', + label: '工具编码', + component: 'Input', + componentProps: { + allowClear: true, + placeholder: '请输入工具编码', + }, + }, + { + fieldName: 'name', + label: '工具名称', + component: 'Input', + componentProps: { + allowClear: true, + placeholder: '请输入工具名称', + }, + }, + { + fieldName: 'brand', + label: '品牌', + component: 'Input', + componentProps: { + allowClear: true, + placeholder: '请输入品牌', + }, + }, + { + fieldName: 'specification', + label: '型号规格', + component: 'Input', + componentProps: { + allowClear: true, + placeholder: '请输入型号规格', + }, + }, + { + fieldName: 'status', + label: '状态', + component: 'Select', + componentProps: { + allowClear: true, + options: getDictOptions(DICT_TYPE.MES_TM_TOOL_STATUS, 'number'), + placeholder: '请选择状态', + }, + }, + ]; +} + +/** 列表的字段 */ +export function useGridColumns(): VxeTableGridOptions['columns'] { + return [ + { + field: 'code', + title: '工具编码', + minWidth: 140, + slots: { + default: 'code', + }, + }, + { field: 'name', title: '工具名称', minWidth: 150 }, + { field: 'toolTypeName', title: '工具类型', minWidth: 140 }, + { field: 'brand', title: '品牌', minWidth: 120 }, + { field: 'specification', title: '型号规格', minWidth: 140 }, + { field: 'quantity', title: '库存数量', width: 100 }, + { field: 'availableQuantity', title: '可用数量', width: 100 }, + { + field: 'maintenType', + title: '保养维护类型', + width: 140, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.MES_TM_MAINTEN_TYPE }, + }, + }, + { + field: 'nextMaintenDate', + title: '下次保养', + width: 180, + formatter: ({ row }) => { + if (row.maintenType === MesMaintenTypeEnum.REGULAR) { + return row.nextMaintenDate ? formatDateTime(row.nextMaintenDate) : '-'; + } + if (row.maintenType === MesMaintenTypeEnum.USAGE) { + return row.nextMaintenPeriod == null ? '-' : `${row.nextMaintenPeriod} 次`; + } + return '-'; + }, + }, + { + field: 'status', + title: '状态', + width: 120, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.MES_TM_TOOL_STATUS }, + }, + }, + { + field: 'createTime', + title: '创建时间', + width: 180, + formatter: 'formatDateTime', + }, + { + title: '操作', + width: 180, + fixed: 'right', + slots: { + default: 'actions', + }, + }, + ]; +} diff --git a/apps/web-antd/src/views/mes/tm/tool/index.vue b/apps/web-antd/src/views/mes/tm/tool/index.vue new file mode 100644 index 000000000..2998e3f75 --- /dev/null +++ b/apps/web-antd/src/views/mes/tm/tool/index.vue @@ -0,0 +1,174 @@ + + + diff --git a/apps/web-antd/src/views/mes/tm/tool/modules/form.vue b/apps/web-antd/src/views/mes/tm/tool/modules/form.vue new file mode 100644 index 000000000..0e0a26942 --- /dev/null +++ b/apps/web-antd/src/views/mes/tm/tool/modules/form.vue @@ -0,0 +1,126 @@ + + + diff --git a/apps/web-antd/src/views/mes/tm/tool/type/components/index.ts b/apps/web-antd/src/views/mes/tm/tool/type/components/index.ts new file mode 100644 index 000000000..8b3fe0741 --- /dev/null +++ b/apps/web-antd/src/views/mes/tm/tool/type/components/index.ts @@ -0,0 +1,2 @@ +export { default as TmToolTypeSelect } from './tm-tool-type-select.vue'; +export { default as TmToolTypeTree } from './tm-tool-type-tree.vue'; diff --git a/apps/web-antd/src/views/mes/tm/tool/type/components/tm-tool-type-select.vue b/apps/web-antd/src/views/mes/tm/tool/type/components/tm-tool-type-select.vue new file mode 100644 index 000000000..68425cf39 --- /dev/null +++ b/apps/web-antd/src/views/mes/tm/tool/type/components/tm-tool-type-select.vue @@ -0,0 +1,55 @@ + + + diff --git a/apps/web-antd/src/views/mes/tm/tool/type/components/tm-tool-type-tree.vue b/apps/web-antd/src/views/mes/tm/tool/type/components/tm-tool-type-tree.vue new file mode 100644 index 000000000..7fc64c91f --- /dev/null +++ b/apps/web-antd/src/views/mes/tm/tool/type/components/tm-tool-type-tree.vue @@ -0,0 +1,106 @@ + + + diff --git a/apps/web-antd/src/views/mes/tm/tool/type/data.ts b/apps/web-antd/src/views/mes/tm/tool/type/data.ts new file mode 100644 index 000000000..b3778f427 --- /dev/null +++ b/apps/web-antd/src/views/mes/tm/tool/type/data.ts @@ -0,0 +1,209 @@ +import type { VbenFormApi, VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { MesTmToolTypeApi } from '#/api/mes/tm/tool/type'; + +import { h } from 'vue'; + +import { DICT_TYPE } from '@vben/constants'; +import { getDictOptions } from '@vben/hooks'; + +import { Button } from 'ant-design-vue'; + +import { z } from '#/adapter/form'; +import { generateAutoCode } from '#/api/mes/md/autocode/record'; +import { MesAutoCodeRuleCode, MesMaintenTypeEnum } from '#/views/mes/utils/constants'; + +/** 新增/修改工具类型的表单 */ +export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] { + return [ + { + fieldName: 'id', + component: 'Input', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'code', + label: '类型编码', + component: 'Input', + componentProps: { + placeholder: '请输入类型编码', + }, + rules: 'required', + suffix: () => + h( + Button, + { + type: 'default', + onClick: async () => { + const code = await generateAutoCode(MesAutoCodeRuleCode.TM_TOOL_TYPE_CODE); + await formApi?.setFieldValue('code', code); + }, + }, + { default: () => '生成' }, + ), + }, + { + fieldName: 'name', + label: '类型名称', + component: 'Input', + componentProps: { + placeholder: '请输入类型名称', + }, + rules: 'required', + }, + { + fieldName: 'codeFlag', + label: '是否编码管理', + component: 'RadioGroup', + componentProps: { + buttonStyle: 'solid', + optionType: 'button', + options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'), + }, + rules: z.boolean().default(true), + }, + { + fieldName: 'maintenType', + label: '保养维护类型', + component: 'Select', + componentProps: { + allowClear: true, + options: getDictOptions(DICT_TYPE.MES_TM_MAINTEN_TYPE, 'number'), + placeholder: '请选择保养维护类型', + }, + dependencies: { + triggerFields: ['codeFlag'], + show: (values) => !!values.codeFlag, + }, + rules: 'selectRequired', + }, + { + fieldName: 'maintenPeriod', + label: '保养周期', + component: 'InputNumber', + componentProps: { + class: '!w-full', + min: 1, + precision: 0, + }, + dependencies: { + triggerFields: ['codeFlag', 'maintenType'], + show: (values) => + !!values.codeFlag && + [MesMaintenTypeEnum.REGULAR, MesMaintenTypeEnum.USAGE].includes(values.maintenType), + }, + rules: 'required', + }, + { + fieldName: 'remark', + label: '备注', + component: 'Textarea', + formItemClass: 'col-span-2', + componentProps: { + placeholder: '请输入备注', + rows: 3, + }, + }, + ]; +} + +/** 列表的搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'code', + label: '类型编码', + component: 'Input', + componentProps: { + allowClear: true, + placeholder: '请输入类型编码', + }, + }, + { + fieldName: 'name', + label: '类型名称', + component: 'Input', + componentProps: { + allowClear: true, + placeholder: '请输入类型名称', + }, + }, + { + fieldName: 'maintenType', + label: '保养维护类型', + component: 'Select', + componentProps: { + allowClear: true, + options: getDictOptions(DICT_TYPE.MES_TM_MAINTEN_TYPE, 'number'), + placeholder: '请选择保养维护类型', + }, + }, + ]; +} + +/** 列表的字段 */ +export function useGridColumns(): VxeTableGridOptions['columns'] { + return [ + { + field: 'code', + title: '类型编码', + minWidth: 140, + slots: { + default: 'code', + }, + }, + { field: 'name', title: '类型名称', minWidth: 150 }, + { + field: 'codeFlag', + title: '编码管理', + width: 120, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING }, + }, + }, + { + field: 'maintenType', + title: '保养维护类型', + width: 140, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.MES_TM_MAINTEN_TYPE }, + }, + }, + { + field: 'maintenPeriod', + title: '保养周期', + width: 100, + formatter: ({ row }) => { + if (row.maintenPeriod == null) { + return '-'; + } + if (row.maintenType === MesMaintenTypeEnum.REGULAR) { + return `${row.maintenPeriod} 天`; + } + if (row.maintenType === MesMaintenTypeEnum.USAGE) { + return `${row.maintenPeriod} 次`; + } + return '-'; + }, + }, + { + field: 'createTime', + title: '创建时间', + width: 180, + formatter: 'formatDateTime', + }, + { + title: '操作', + width: 180, + fixed: 'right', + slots: { + default: 'actions', + }, + }, + ]; +} diff --git a/apps/web-antd/src/views/mes/tm/tool/type/index.vue b/apps/web-antd/src/views/mes/tm/tool/type/index.vue new file mode 100644 index 000000000..4ce0188fc --- /dev/null +++ b/apps/web-antd/src/views/mes/tm/tool/type/index.vue @@ -0,0 +1,153 @@ + + + diff --git a/apps/web-antd/src/views/mes/tm/tool/type/modules/form.vue b/apps/web-antd/src/views/mes/tm/tool/type/modules/form.vue new file mode 100644 index 000000000..9a4897340 --- /dev/null +++ b/apps/web-antd/src/views/mes/tm/tool/type/modules/form.vue @@ -0,0 +1,102 @@ + + + diff --git a/apps/web-ele/src/views/mes/tm/tool/data.ts b/apps/web-ele/src/views/mes/tm/tool/data.ts new file mode 100644 index 000000000..0c0e00050 --- /dev/null +++ b/apps/web-ele/src/views/mes/tm/tool/data.ts @@ -0,0 +1,309 @@ +import type { VbenFormApi, VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { MesTmToolApi } from '#/api/mes/tm/tool'; + +import { h, markRaw } from 'vue'; + +import { DICT_TYPE } from '@vben/constants'; +import { getDictOptions } from '@vben/hooks'; +import { formatDateTime } from '@vben/utils'; + +import { ElButton } from 'element-plus'; + +import { z } from '#/adapter/form'; +import { generateAutoCode } from '#/api/mes/md/autocode/record'; +import { + MesAutoCodeRuleCode, + MesMaintenTypeEnum, + MesToolStatusEnum, +} from '#/views/mes/utils/constants'; + +import { TmToolTypeSelect } from './type/components'; + +/** 新增/修改工具的表单 */ +export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] { + return [ + { + fieldName: 'id', + component: 'Input', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'code', + label: '工具编码', + component: 'Input', + componentProps: { + placeholder: '请输入工具编码', + }, + dependencies: { + triggerFields: ['id'], + componentProps: (values) => ({ disabled: !!values.id }), + }, + rules: 'required', + suffix: () => + h( + ElButton, + { + type: 'default', + onClick: async () => { + const code = await generateAutoCode(MesAutoCodeRuleCode.TM_TOOL_CODE); + await formApi?.setFieldValue('code', code); + }, + }, + { default: () => '生成' }, + ), + }, + { + fieldName: 'name', + label: '工具名称', + component: 'Input', + componentProps: { + placeholder: '请输入工具名称', + }, + rules: 'required', + }, + { + fieldName: 'toolTypeId', + label: '工具类型', + component: markRaw(TmToolTypeSelect), + componentProps: { + placeholder: '请选择工具类型', + onChange: async (row: any) => { + if (row?.codeFlag) { + await formApi?.setFieldValue('quantity', 1); + await formApi?.setFieldValue('availableQuantity', 1); + } + }, + }, + rules: 'selectRequired', + }, + { + fieldName: 'brand', + label: '品牌', + component: 'Input', + componentProps: { + placeholder: '请输入品牌', + }, + }, + { + fieldName: 'specification', + label: '型号规格', + component: 'Input', + componentProps: { + placeholder: '请输入型号规格', + }, + }, + { + fieldName: 'quantity', + label: '库存数量', + component: 'InputNumber', + componentProps: { + class: '!w-full', + controlsPosition: 'right', + min: 1, + onChange: async (value?: number) => { + const values = (await formApi?.getValues()) as MesTmToolApi.Tool | undefined; + if (!values?.id) { + await formApi?.setFieldValue('availableQuantity', value); + } + }, + precision: 0, + }, + rules: 'required', + }, + { + fieldName: 'availableQuantity', + label: '可用数量', + component: 'InputNumber', + componentProps: { + class: '!w-full', + controlsPosition: 'right', + disabled: true, + min: 0, + precision: 0, + }, + rules: z.number().default(1), + }, + { + fieldName: 'status', + label: '状态', + component: 'Select', + componentProps: { + disabled: true, + options: getDictOptions(DICT_TYPE.MES_TM_TOOL_STATUS, 'number'), + }, + rules: z.number().default(MesToolStatusEnum.STORE), + }, + { + fieldName: 'maintenType', + label: '保养维护类型', + component: 'Select', + componentProps: { + clearable: true, + options: getDictOptions(DICT_TYPE.MES_TM_MAINTEN_TYPE, 'number'), + placeholder: '请选择保养维护类型', + }, + }, + { + fieldName: 'nextMaintenDate', + label: '下次保养日期', + component: 'DatePicker', + componentProps: { + class: '!w-full', + format: 'YYYY-MM-DD HH:mm:ss', + showTime: true, + valueFormat: 'x', + }, + dependencies: { + triggerFields: ['maintenType'], + show: (values) => values.maintenType === MesMaintenTypeEnum.REGULAR, + }, + }, + { + fieldName: 'nextMaintenPeriod', + label: '下次保养周期', + component: 'InputNumber', + componentProps: { + class: '!w-full', + controlsPosition: 'right', + min: 1, + precision: 0, + }, + dependencies: { + triggerFields: ['maintenType'], + show: (values) => values.maintenType === MesMaintenTypeEnum.USAGE, + }, + }, + { + fieldName: 'remark', + label: '备注', + component: 'Textarea', + formItemClass: 'col-span-3', + componentProps: { + placeholder: '请输入备注', + rows: 3, + }, + }, + ]; +} + +/** 列表的搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'code', + label: '工具编码', + component: 'Input', + componentProps: { + clearable: true, + placeholder: '请输入工具编码', + }, + }, + { + fieldName: 'name', + label: '工具名称', + component: 'Input', + componentProps: { + clearable: true, + placeholder: '请输入工具名称', + }, + }, + { + fieldName: 'brand', + label: '品牌', + component: 'Input', + componentProps: { + clearable: true, + placeholder: '请输入品牌', + }, + }, + { + fieldName: 'specification', + label: '型号规格', + component: 'Input', + componentProps: { + clearable: true, + placeholder: '请输入型号规格', + }, + }, + { + fieldName: 'status', + label: '状态', + component: 'Select', + componentProps: { + clearable: true, + options: getDictOptions(DICT_TYPE.MES_TM_TOOL_STATUS, 'number'), + placeholder: '请选择状态', + }, + }, + ]; +} + +/** 列表的字段 */ +export function useGridColumns(): VxeTableGridOptions['columns'] { + return [ + { + field: 'code', + title: '工具编码', + minWidth: 140, + slots: { + default: 'code', + }, + }, + { field: 'name', title: '工具名称', minWidth: 150 }, + { field: 'toolTypeName', title: '工具类型', minWidth: 140 }, + { field: 'brand', title: '品牌', minWidth: 120 }, + { field: 'specification', title: '型号规格', minWidth: 140 }, + { field: 'quantity', title: '库存数量', width: 100 }, + { field: 'availableQuantity', title: '可用数量', width: 100 }, + { + field: 'maintenType', + title: '保养维护类型', + width: 140, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.MES_TM_MAINTEN_TYPE }, + }, + }, + { + field: 'nextMaintenDate', + title: '下次保养', + width: 180, + formatter: ({ row }) => { + if (row.maintenType === MesMaintenTypeEnum.REGULAR) { + return row.nextMaintenDate ? formatDateTime(row.nextMaintenDate) : '-'; + } + if (row.maintenType === MesMaintenTypeEnum.USAGE) { + return row.nextMaintenPeriod == null ? '-' : `${row.nextMaintenPeriod} 次`; + } + return '-'; + }, + }, + { + field: 'status', + title: '状态', + width: 120, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.MES_TM_TOOL_STATUS }, + }, + }, + { + field: 'createTime', + title: '创建时间', + width: 180, + formatter: 'formatDateTime', + }, + { + title: '操作', + width: 180, + fixed: 'right', + slots: { + default: 'actions', + }, + }, + ]; +} diff --git a/apps/web-ele/src/views/mes/tm/tool/index.vue b/apps/web-ele/src/views/mes/tm/tool/index.vue new file mode 100644 index 000000000..005453dd8 --- /dev/null +++ b/apps/web-ele/src/views/mes/tm/tool/index.vue @@ -0,0 +1,172 @@ + + + diff --git a/apps/web-ele/src/views/mes/tm/tool/modules/form.vue b/apps/web-ele/src/views/mes/tm/tool/modules/form.vue new file mode 100644 index 000000000..bf46e425c --- /dev/null +++ b/apps/web-ele/src/views/mes/tm/tool/modules/form.vue @@ -0,0 +1,126 @@ + + + diff --git a/apps/web-ele/src/views/mes/tm/tool/type/components/index.ts b/apps/web-ele/src/views/mes/tm/tool/type/components/index.ts new file mode 100644 index 000000000..8b3fe0741 --- /dev/null +++ b/apps/web-ele/src/views/mes/tm/tool/type/components/index.ts @@ -0,0 +1,2 @@ +export { default as TmToolTypeSelect } from './tm-tool-type-select.vue'; +export { default as TmToolTypeTree } from './tm-tool-type-tree.vue'; diff --git a/apps/web-ele/src/views/mes/tm/tool/type/components/tm-tool-type-select.vue b/apps/web-ele/src/views/mes/tm/tool/type/components/tm-tool-type-select.vue new file mode 100644 index 000000000..270850bc3 --- /dev/null +++ b/apps/web-ele/src/views/mes/tm/tool/type/components/tm-tool-type-select.vue @@ -0,0 +1,52 @@ + + + diff --git a/apps/web-ele/src/views/mes/tm/tool/type/components/tm-tool-type-tree.vue b/apps/web-ele/src/views/mes/tm/tool/type/components/tm-tool-type-tree.vue new file mode 100644 index 000000000..19010b069 --- /dev/null +++ b/apps/web-ele/src/views/mes/tm/tool/type/components/tm-tool-type-tree.vue @@ -0,0 +1,106 @@ + + + diff --git a/apps/web-ele/src/views/mes/tm/tool/type/data.ts b/apps/web-ele/src/views/mes/tm/tool/type/data.ts new file mode 100644 index 000000000..527f4a844 --- /dev/null +++ b/apps/web-ele/src/views/mes/tm/tool/type/data.ts @@ -0,0 +1,208 @@ +import type { VbenFormApi, VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { MesTmToolTypeApi } from '#/api/mes/tm/tool/type'; + +import { h } from 'vue'; + +import { DICT_TYPE } from '@vben/constants'; +import { getDictOptions } from '@vben/hooks'; + +import { ElButton } from 'element-plus'; + +import { z } from '#/adapter/form'; +import { generateAutoCode } from '#/api/mes/md/autocode/record'; +import { MesAutoCodeRuleCode, MesMaintenTypeEnum } from '#/views/mes/utils/constants'; + +/** 新增/修改工具类型的表单 */ +export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] { + return [ + { + fieldName: 'id', + component: 'Input', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'code', + label: '类型编码', + component: 'Input', + componentProps: { + placeholder: '请输入类型编码', + }, + rules: 'required', + suffix: () => + h( + ElButton, + { + type: 'default', + onClick: async () => { + const code = await generateAutoCode(MesAutoCodeRuleCode.TM_TOOL_TYPE_CODE); + await formApi?.setFieldValue('code', code); + }, + }, + { default: () => '生成' }, + ), + }, + { + fieldName: 'name', + label: '类型名称', + component: 'Input', + componentProps: { + placeholder: '请输入类型名称', + }, + rules: 'required', + }, + { + fieldName: 'codeFlag', + label: '是否编码管理', + component: 'RadioGroup', + componentProps: { + options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'), + }, + rules: z.boolean().default(true), + }, + { + fieldName: 'maintenType', + label: '保养维护类型', + component: 'Select', + componentProps: { + clearable: true, + options: getDictOptions(DICT_TYPE.MES_TM_MAINTEN_TYPE, 'number'), + placeholder: '请选择保养维护类型', + }, + dependencies: { + triggerFields: ['codeFlag'], + show: (values) => !!values.codeFlag, + }, + rules: 'selectRequired', + }, + { + fieldName: 'maintenPeriod', + label: '保养周期', + component: 'InputNumber', + componentProps: { + class: '!w-full', + controlsPosition: 'right', + min: 1, + precision: 0, + }, + dependencies: { + triggerFields: ['codeFlag', 'maintenType'], + show: (values) => + !!values.codeFlag && + [MesMaintenTypeEnum.REGULAR, MesMaintenTypeEnum.USAGE].includes(values.maintenType), + }, + rules: 'required', + }, + { + fieldName: 'remark', + label: '备注', + component: 'Textarea', + formItemClass: 'col-span-2', + componentProps: { + placeholder: '请输入备注', + rows: 3, + }, + }, + ]; +} + +/** 列表的搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'code', + label: '类型编码', + component: 'Input', + componentProps: { + clearable: true, + placeholder: '请输入类型编码', + }, + }, + { + fieldName: 'name', + label: '类型名称', + component: 'Input', + componentProps: { + clearable: true, + placeholder: '请输入类型名称', + }, + }, + { + fieldName: 'maintenType', + label: '保养维护类型', + component: 'Select', + componentProps: { + clearable: true, + options: getDictOptions(DICT_TYPE.MES_TM_MAINTEN_TYPE, 'number'), + placeholder: '请选择保养维护类型', + }, + }, + ]; +} + +/** 列表的字段 */ +export function useGridColumns(): VxeTableGridOptions['columns'] { + return [ + { + field: 'code', + title: '类型编码', + minWidth: 140, + slots: { + default: 'code', + }, + }, + { field: 'name', title: '类型名称', minWidth: 150 }, + { + field: 'codeFlag', + title: '编码管理', + width: 120, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING }, + }, + }, + { + field: 'maintenType', + title: '保养维护类型', + width: 140, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.MES_TM_MAINTEN_TYPE }, + }, + }, + { + field: 'maintenPeriod', + title: '保养周期', + width: 100, + formatter: ({ row }) => { + if (row.maintenPeriod == null) { + return '-'; + } + if (row.maintenType === MesMaintenTypeEnum.REGULAR) { + return `${row.maintenPeriod} 天`; + } + if (row.maintenType === MesMaintenTypeEnum.USAGE) { + return `${row.maintenPeriod} 次`; + } + return '-'; + }, + }, + { + field: 'createTime', + title: '创建时间', + width: 180, + formatter: 'formatDateTime', + }, + { + title: '操作', + width: 180, + fixed: 'right', + slots: { + default: 'actions', + }, + }, + ]; +} diff --git a/apps/web-ele/src/views/mes/tm/tool/type/index.vue b/apps/web-ele/src/views/mes/tm/tool/type/index.vue new file mode 100644 index 000000000..3cc81e9c2 --- /dev/null +++ b/apps/web-ele/src/views/mes/tm/tool/type/index.vue @@ -0,0 +1,151 @@ + + + diff --git a/apps/web-ele/src/views/mes/tm/tool/type/modules/form.vue b/apps/web-ele/src/views/mes/tm/tool/type/modules/form.vue new file mode 100644 index 000000000..4588bf62b --- /dev/null +++ b/apps/web-ele/src/views/mes/tm/tool/type/modules/form.vue @@ -0,0 +1,102 @@ + + +