From db6a9aeabe4cabd4dd9a99c2d1aac53f5f49a982 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 28 Mar 2026 09:47:38 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(mes):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=89=A9=E6=96=99=E4=BA=A7=E5=93=81=E7=8A=B6=E6=80=81=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=BC=98=E5=8C=96=E7=89=A9?= =?UTF-8?q?=E6=96=99=E5=88=86=E7=B1=BB=E9=80=89=E6=8B=A9=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/mes/md/item/index.ts | 5 ++ src/views/mes/md/item/MdItemForm.vue | 47 +++++---------- src/views/mes/md/item/index.vue | 39 +++++++++++-- .../item/type/components/MdItemTypeSelect.vue | 57 +++++++++++++++++++ 4 files changed, 109 insertions(+), 39 deletions(-) create mode 100644 src/views/mes/md/item/type/components/MdItemTypeSelect.vue diff --git a/src/api/mes/md/item/index.ts b/src/api/mes/md/item/index.ts index a0be1ac2e..d80323100 100644 --- a/src/api/mes/md/item/index.ts +++ b/src/api/mes/md/item/index.ts @@ -47,6 +47,11 @@ export const MdItemApi = { return await request.put({ url: `/mes/md/item/update`, data }) }, + // 修改物料产品状态 + updateItemStatus: async (id: number, status: number) => { + return await request.put({ url: `/mes/md/item/update-status`, params: { id, status } }) + }, + // 删除物料产品 deleteItem: async (id: number) => { return await request.delete({ url: `/mes/md/item/delete?id=` + id }) diff --git a/src/views/mes/md/item/MdItemForm.vue b/src/views/mes/md/item/MdItemForm.vue index 6128ea367..a9520d83e 100644 --- a/src/views/mes/md/item/MdItemForm.vue +++ b/src/views/mes/md/item/MdItemForm.vue @@ -37,22 +37,12 @@ - - + - - + import { getIntDictOptions, DICT_TYPE } from '@/utils/dict' import { MdItemApi, MdItemVO } from '@/api/mes/md/item' -import { MdItemTypeApi, MdItemTypeVO } from '@/api/mes/md/item/type' import { AutoCodeRecordApi } from '@/api/mes/md/autocode/record' import MdItemBatchConfigForm from './MdItemBatchConfigForm.vue' import MdProductBomForm from './MdProductBomForm.vue' import MdProductSopForm from './MdProductSopForm.vue' import MdProductSipForm from './MdProductSipForm.vue' import MdUnitMeasureSelect from '@/views/mes/md/unitmeasure/components/MdUnitMeasureSelect.vue' +import MdItemTypeSelect from '@/views/mes/md/item/type/components/MdItemTypeSelect.vue' import { CommonStatusEnum } from '@/utils/constants' -import { defaultProps, handleTree } from '@/utils/tree' import { MesAutoCodeRuleCode } from '@/views/mes/utils/constants' /** MES 物料产品 表单 */ @@ -153,8 +142,11 @@ const { t } = useI18n() // 国际化 const message = useMessage() // 消息弹窗 const dialogVisible = ref(false) // 弹窗的是否展示 -// TODO @AI:标题对齐下,使用 compute ,然后有新增物料/产品;修改物料/产品;查看物料/产品; -const dialogTitle = ref('') // 弹窗的标题 +const dialogTitle = computed(() => { + if (formType.value === 'create') return '新增物料/产品' + if (formType.value === 'update') return '修改物料/产品' + return '查看物料/产品' +}) // 弹窗标题 const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 const formType = ref('') // 表单的类型:create - 新增;update - 修改 const activeTab = ref('bom') // 当前激活的 Tab @@ -171,7 +163,8 @@ const formData = ref({ maxStock: 0, highValue: false, batchFlag: true, - remark: undefined + remark: undefined, + itemOrProduct: undefined }) const formRules = reactive({ code: [{ required: true, message: '物料编码不能为空', trigger: 'blur' }], @@ -181,17 +174,7 @@ const formRules = reactive({ status: [{ required: true, message: '状态不能为空', trigger: 'blur' }] }) const formRef = ref() // 表单 Ref -const itemTypeTree = ref([]) // 物料分类树 -const itemTypeList = ref([]) // 物料分类列表(扁平) - -/** 当前物料的「物料/产品」标识 */ -const currentItemOrProduct = computed(() => { - if (!formData.value.itemTypeId) { - return '' - } - const itemType = itemTypeList.value.find((t) => t.id === formData.value.itemTypeId) - return itemType?.itemOrProduct || '' -}) +const currentItemOrProduct = computed(() => formData.value.itemOrProduct || '') // 物料/产品的标签 /** 生成物料编码 */ const generateCode = async () => { @@ -201,7 +184,6 @@ const generateCode = async () => { /** 打开弹窗 */ const open = async (type: string, id?: number) => { dialogVisible.value = true - dialogTitle.value = t('action.' + type) formType.value = type activeTab.value = 'bom' resetForm() @@ -214,9 +196,6 @@ const open = async (type: string, id?: number) => { formLoading.value = false } } - // 物料分类 - itemTypeList.value = await MdItemTypeApi.getItemTypeSimpleList() - itemTypeTree.value = handleTree(itemTypeList.value) } defineExpose({ open }) // 提供 open 方法,用于打开弹窗 @@ -236,7 +215,6 @@ const submitForm = async () => { await MdItemApi.updateItem(data) message.success(t('common.updateSuccess')) } - // TODO @AI:【对齐】应该都不需要自动关闭;用户按需添加; dialogVisible.value = false // 发送操作成功的事件 emit('success') @@ -260,7 +238,8 @@ const resetForm = () => { maxStock: 0, highValue: false, batchFlag: true, - remark: undefined + remark: undefined, + itemOrProduct: undefined } formRef.value?.resetFields() } diff --git a/src/views/mes/md/item/index.vue b/src/views/mes/md/item/index.vue index 5dedcc66c..0783e14f0 100644 --- a/src/views/mes/md/item/index.vue +++ b/src/views/mes/md/item/index.vue @@ -89,8 +89,13 @@ - - + + + @@ -105,10 +110,15 @@ - - + import { getIntDictOptions, DICT_TYPE } from '@/utils/dict' +import { checkPermi } from '@/utils/permission' import { dateFormatter } from '@/utils/formatTime' import download from '@/utils/download' +import { CommonStatusEnum } from '@/utils/constants' import { MdItemApi, MdItemVO } from '@/api/mes/md/item' import MdItemForm from './MdItemForm.vue' import MdItemImportForm from './MdItemImportForm.vue' @@ -234,6 +246,23 @@ const openForm = (type: string, id?: number) => { formRef.value.open(type, id) } +/** 切换物料状态 */ +const handleStatusChange = async (row: MdItemVO) => { + try { + // 修改状态的二次确认 + const text = row.status === CommonStatusEnum.ENABLE ? '启用' : '停用' + await message.confirm('确认要"' + text + '""' + row.name + '"物料吗?') + // 发起修改状态 + await MdItemApi.updateItemStatus(row.id, row.status) + // 刷新列表 + await getList() + } catch { + // 取消后,恢复按钮 + row.status = + row.status === CommonStatusEnum.ENABLE ? CommonStatusEnum.DISABLE : CommonStatusEnum.ENABLE + } +} + /** 删除按钮操作 */ const handleDelete = async (id: number) => { try { diff --git a/src/views/mes/md/item/type/components/MdItemTypeSelect.vue b/src/views/mes/md/item/type/components/MdItemTypeSelect.vue new file mode 100644 index 000000000..10803eed7 --- /dev/null +++ b/src/views/mes/md/item/type/components/MdItemTypeSelect.vue @@ -0,0 +1,57 @@ + + + +