From b35ce18c6e6a6da67f2bd52fc421989386411b93 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 21 May 2026 09:11:58 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=88wms=EF=BC=89:=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=20md=20unit=20=E7=9A=84=E8=BF=81=E7=A7=BB=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/api/mes/md/unitmeasure/index.ts | 19 +- .../components/md-unit-measure-select.vue | 9 +- .../src/views/mes/md/unitmeasure/data.ts | 196 ++++++++++++++++++ .../src/views/mes/md/unitmeasure/index.vue | 152 ++++++++++++++ .../views/mes/md/unitmeasure/modules/form.vue | 95 +++++++++ .../src/api/mes/md/unitmeasure/index.ts | 19 +- .../components/md-unit-measure-select.vue | 11 +- .../src/views/mes/md/unitmeasure/data.ts | 193 +++++++++++++++++ .../src/views/mes/md/unitmeasure/index.vue | 152 ++++++++++++++ .../views/mes/md/unitmeasure/modules/form.vue | 95 +++++++++ 10 files changed, 914 insertions(+), 27 deletions(-) create mode 100644 apps/web-antd/src/views/mes/md/unitmeasure/data.ts create mode 100644 apps/web-antd/src/views/mes/md/unitmeasure/index.vue create mode 100644 apps/web-antd/src/views/mes/md/unitmeasure/modules/form.vue create mode 100644 apps/web-ele/src/views/mes/md/unitmeasure/data.ts create mode 100644 apps/web-ele/src/views/mes/md/unitmeasure/index.vue create mode 100644 apps/web-ele/src/views/mes/md/unitmeasure/modules/form.vue diff --git a/apps/web-antd/src/api/mes/md/unitmeasure/index.ts b/apps/web-antd/src/api/mes/md/unitmeasure/index.ts index aff7a47b5..5556a022a 100644 --- a/apps/web-antd/src/api/mes/md/unitmeasure/index.ts +++ b/apps/web-antd/src/api/mes/md/unitmeasure/index.ts @@ -5,14 +5,15 @@ import { requestClient } from '#/api/request'; export namespace MesMdUnitMeasureApi { /** MES 计量单位 */ export interface UnitMeasure { - id: number; - code?: string; - name?: string; - primaryFlag?: boolean; - primaryId?: number; - changeRate?: number; - status?: number; - remark?: string; + id?: number; // 单位编号 + code?: string; // 单位编码 + name?: string; // 单位名称 + primaryFlag?: boolean; // 是否主单位 + primaryId?: number; // 主单位编号 + changeRate?: number; // 与主单位换算比例 + status?: number; // 状态 + remark?: string; // 备注 + createTime?: Date; // 创建时间 } } @@ -54,6 +55,6 @@ export function deleteUnitMeasure(id: number) { } /** 导出计量单位 */ -export function exportUnitMeasure(params: any) { +export function exportUnitMeasure(params: PageParam) { return requestClient.download('/mes/md/unit-measure/export-excel', { params }); } diff --git a/apps/web-antd/src/views/mes/md/unitmeasure/components/md-unit-measure-select.vue b/apps/web-antd/src/views/mes/md/unitmeasure/components/md-unit-measure-select.vue index f88b4ed73..9238115b5 100644 --- a/apps/web-antd/src/views/mes/md/unitmeasure/components/md-unit-measure-select.vue +++ b/apps/web-antd/src/views/mes/md/unitmeasure/components/md-unit-measure-select.vue @@ -29,17 +29,18 @@ const emit = defineEmits<{ 'update:modelValue': [value: number | undefined]; }>(); -const allList = ref([]); -const filteredList = ref([]); -const selectedItem = ref(); +const allList = ref([]); // 计量单位列表 +const filteredList = ref([]); // 过滤后的计量单位列表 +const selectedItem = ref(); // 当前选中计量单位 -const selectValue = computed({ +const selectValue = computed({ // 选择器绑定值 get: () => props.modelValue, set: (value: number | undefined) => { emit('update:modelValue', value); }, }); +/** 前端按名称和编码过滤计量单位 */ function handleFilter(input: string, option: any) { const keyword = input.toLowerCase(); const item = option?.item as MesMdUnitMeasureApi.UnitMeasure | undefined; diff --git a/apps/web-antd/src/views/mes/md/unitmeasure/data.ts b/apps/web-antd/src/views/mes/md/unitmeasure/data.ts new file mode 100644 index 000000000..8352d9c10 --- /dev/null +++ b/apps/web-antd/src/views/mes/md/unitmeasure/data.ts @@ -0,0 +1,196 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { MesMdUnitMeasureApi } from '#/api/mes/md/unitmeasure'; + +import { CommonStatusEnum, DICT_TYPE } from '@vben/constants'; +import { getDictOptions } from '@vben/hooks'; + +import { z } from '#/adapter/form'; +import { getUnitMeasureSimpleList } from '#/api/mes/md/unitmeasure'; + +/** 新增/修改计量单位的表单 */ +export function useFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'id', + component: 'Input', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'code', + label: '单位编码', + component: 'Input', + componentProps: { + placeholder: '请输入单位编码', + }, + rules: 'required', + }, + { + fieldName: 'name', + label: '单位名称', + component: 'Input', + componentProps: { + placeholder: '请输入单位名称', + }, + rules: 'required', + }, + { + fieldName: 'primaryFlag', + label: '是否主单位', + component: 'RadioGroup', + componentProps: { + buttonStyle: 'solid', + optionType: 'button', + options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'), + }, + rules: z.boolean().default(true), + }, + { + fieldName: 'primaryId', + label: '主单位', + component: 'ApiSelect', + componentProps: { + allowClear: true, + api: async () => { + const list = await getUnitMeasureSimpleList(); + return list.filter((item) => item.primaryFlag === true); + }, + labelField: 'name', + placeholder: '请选择主单位', + valueField: 'id', + }, + dependencies: { + triggerFields: ['primaryFlag'], + show: (values) => values.primaryFlag === false, + }, + }, + { + fieldName: 'changeRate', + label: '与主单位换算比例', + component: 'InputNumber', + componentProps: { + class: '!w-full', + min: 0, + precision: 4, + step: 1, + }, + dependencies: { + triggerFields: ['primaryFlag'], + show: (values) => values.primaryFlag === false, + }, + }, + { + fieldName: 'status', + label: '状态', + component: 'RadioGroup', + componentProps: { + buttonStyle: 'solid', + optionType: 'button', + options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + }, + rules: z.number().default(CommonStatusEnum.ENABLE), + }, + { + fieldName: 'remark', + label: '备注', + component: 'Textarea', + 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: 'status', + label: '状态', + component: 'Select', + componentProps: { + allowClear: true, + options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + placeholder: '请选择状态', + }, + }, + ]; +} + +/** 列表的字段 */ +export function useGridColumns(): VxeTableGridOptions['columns'] { + return [ + { + field: 'code', + title: '单位编码', + minWidth: 160, + }, + { + field: 'name', + title: '单位名称', + minWidth: 160, + }, + { + field: 'primaryFlag', + title: '是否主单位', + width: 120, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING }, + }, + }, + { + field: 'changeRate', + title: '与主单位换算比例', + minWidth: 150, + }, + { + field: 'status', + title: '状态', + width: 120, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.COMMON_STATUS }, + }, + }, + { + field: 'remark', + title: '备注', + minWidth: 180, + }, + { + field: 'createTime', + title: '创建时间', + width: 180, + formatter: 'formatDateTime', + }, + { + title: '操作', + width: 160, + fixed: 'right', + slots: { default: 'actions' }, + }, + ]; +} diff --git a/apps/web-antd/src/views/mes/md/unitmeasure/index.vue b/apps/web-antd/src/views/mes/md/unitmeasure/index.vue new file mode 100644 index 000000000..c4697989c --- /dev/null +++ b/apps/web-antd/src/views/mes/md/unitmeasure/index.vue @@ -0,0 +1,152 @@ + + + diff --git a/apps/web-antd/src/views/mes/md/unitmeasure/modules/form.vue b/apps/web-antd/src/views/mes/md/unitmeasure/modules/form.vue new file mode 100644 index 000000000..46948bec9 --- /dev/null +++ b/apps/web-antd/src/views/mes/md/unitmeasure/modules/form.vue @@ -0,0 +1,95 @@ + + + diff --git a/apps/web-ele/src/api/mes/md/unitmeasure/index.ts b/apps/web-ele/src/api/mes/md/unitmeasure/index.ts index aff7a47b5..5556a022a 100644 --- a/apps/web-ele/src/api/mes/md/unitmeasure/index.ts +++ b/apps/web-ele/src/api/mes/md/unitmeasure/index.ts @@ -5,14 +5,15 @@ import { requestClient } from '#/api/request'; export namespace MesMdUnitMeasureApi { /** MES 计量单位 */ export interface UnitMeasure { - id: number; - code?: string; - name?: string; - primaryFlag?: boolean; - primaryId?: number; - changeRate?: number; - status?: number; - remark?: string; + id?: number; // 单位编号 + code?: string; // 单位编码 + name?: string; // 单位名称 + primaryFlag?: boolean; // 是否主单位 + primaryId?: number; // 主单位编号 + changeRate?: number; // 与主单位换算比例 + status?: number; // 状态 + remark?: string; // 备注 + createTime?: Date; // 创建时间 } } @@ -54,6 +55,6 @@ export function deleteUnitMeasure(id: number) { } /** 导出计量单位 */ -export function exportUnitMeasure(params: any) { +export function exportUnitMeasure(params: PageParam) { return requestClient.download('/mes/md/unit-measure/export-excel', { params }); } diff --git a/apps/web-ele/src/views/mes/md/unitmeasure/components/md-unit-measure-select.vue b/apps/web-ele/src/views/mes/md/unitmeasure/components/md-unit-measure-select.vue index 3d7282589..bf53e6d46 100644 --- a/apps/web-ele/src/views/mes/md/unitmeasure/components/md-unit-measure-select.vue +++ b/apps/web-ele/src/views/mes/md/unitmeasure/components/md-unit-measure-select.vue @@ -29,17 +29,18 @@ const emit = defineEmits<{ 'update:modelValue': [value: number | undefined]; }>(); -const allList = ref([]); -const filteredList = ref([]); -const selectedItem = ref(); +const allList = ref([]); // 计量单位列表 +const filteredList = ref([]); // 过滤后的计量单位列表 +const selectedItem = ref(); // 当前选中计量单位 -const selectValue = computed({ +const selectValue = computed({ // 选择器绑定值 get: () => props.modelValue, set: (value: number | undefined) => { emit('update:modelValue', value); }, }); +/** 前端按名称和编码过滤计量单位 */ function handleFilter(query: string) { if (!query) { filteredList.value = allList.value; @@ -107,7 +108,7 @@ onMounted(async () => { v-for="item in filteredList" :key="item.id" :label="item.name" - :value="item.id" + :value="item.id!" >
{{ item.name }} diff --git a/apps/web-ele/src/views/mes/md/unitmeasure/data.ts b/apps/web-ele/src/views/mes/md/unitmeasure/data.ts new file mode 100644 index 000000000..c6510c388 --- /dev/null +++ b/apps/web-ele/src/views/mes/md/unitmeasure/data.ts @@ -0,0 +1,193 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { MesMdUnitMeasureApi } from '#/api/mes/md/unitmeasure'; + +import { CommonStatusEnum, DICT_TYPE } from '@vben/constants'; +import { getDictOptions } from '@vben/hooks'; + +import { z } from '#/adapter/form'; +import { getUnitMeasureSimpleList } from '#/api/mes/md/unitmeasure'; + +/** 新增/修改计量单位的表单 */ +export function useFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'id', + component: 'Input', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'code', + label: '单位编码', + component: 'Input', + componentProps: { + placeholder: '请输入单位编码', + }, + rules: 'required', + }, + { + fieldName: 'name', + label: '单位名称', + component: 'Input', + componentProps: { + placeholder: '请输入单位名称', + }, + rules: 'required', + }, + { + fieldName: 'primaryFlag', + label: '是否主单位', + component: 'RadioGroup', + componentProps: { + options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'), + }, + rules: z.boolean().default(true), + }, + { + fieldName: 'primaryId', + label: '主单位', + component: 'ApiSelect', + componentProps: { + api: async () => { + const list = await getUnitMeasureSimpleList(); + return list.filter((item) => item.primaryFlag === true); + }, + clearable: true, + labelField: 'name', + placeholder: '请选择主单位', + valueField: 'id', + }, + dependencies: { + triggerFields: ['primaryFlag'], + show: (values) => values.primaryFlag === false, + }, + }, + { + fieldName: 'changeRate', + label: '与主单位换算比例', + component: 'InputNumber', + componentProps: { + class: '!w-full', + controlsPosition: 'right', + min: 0, + precision: 4, + step: 1, + }, + dependencies: { + triggerFields: ['primaryFlag'], + show: (values) => values.primaryFlag === false, + }, + }, + { + fieldName: 'status', + label: '状态', + component: 'RadioGroup', + componentProps: { + options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + }, + rules: z.number().default(CommonStatusEnum.ENABLE), + }, + { + fieldName: 'remark', + label: '备注', + component: 'Textarea', + 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: 'status', + label: '状态', + component: 'Select', + componentProps: { + clearable: true, + options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + placeholder: '请选择状态', + }, + }, + ]; +} + +/** 列表的字段 */ +export function useGridColumns(): VxeTableGridOptions['columns'] { + return [ + { + field: 'code', + title: '单位编码', + minWidth: 160, + }, + { + field: 'name', + title: '单位名称', + minWidth: 160, + }, + { + field: 'primaryFlag', + title: '是否主单位', + width: 120, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING }, + }, + }, + { + field: 'changeRate', + title: '与主单位换算比例', + minWidth: 150, + }, + { + field: 'status', + title: '状态', + width: 120, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.COMMON_STATUS }, + }, + }, + { + field: 'remark', + title: '备注', + minWidth: 180, + }, + { + field: 'createTime', + title: '创建时间', + width: 180, + formatter: 'formatDateTime', + }, + { + title: '操作', + width: 160, + fixed: 'right', + slots: { default: 'actions' }, + }, + ]; +} diff --git a/apps/web-ele/src/views/mes/md/unitmeasure/index.vue b/apps/web-ele/src/views/mes/md/unitmeasure/index.vue new file mode 100644 index 000000000..28508aba2 --- /dev/null +++ b/apps/web-ele/src/views/mes/md/unitmeasure/index.vue @@ -0,0 +1,152 @@ + + + diff --git a/apps/web-ele/src/views/mes/md/unitmeasure/modules/form.vue b/apps/web-ele/src/views/mes/md/unitmeasure/modules/form.vue new file mode 100644 index 000000000..28c2d1f0f --- /dev/null +++ b/apps/web-ele/src/views/mes/md/unitmeasure/modules/form.vue @@ -0,0 +1,95 @@ + + +