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 @@
-
-
+
+
+
+ {{ scope.row.code }}
+
+
+
@@ -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 @@
+
+
+
+
+
+