From 2271982de09628a04da06630c4ab690ef64fbfab Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期三, 19 八月 2026 10:55:06 +0800
Subject: [PATCH] refactor(mdm): 将物料相关字段统一改为品种并优化下拉菜单确认逻辑

---
 src/views/basicData/mdm/components/select-dialog.vue |   41 +++++++++++++++++++++++++++++++++++++----
 1 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/src/views/basicData/mdm/components/select-dialog.vue b/src/views/basicData/mdm/components/select-dialog.vue
index 9c7a48a..2c37055 100644
--- a/src/views/basicData/mdm/components/select-dialog.vue
+++ b/src/views/basicData/mdm/components/select-dialog.vue
@@ -1,13 +1,15 @@
 <script lang="ts" setup>
 import type { VxeTableGridOptions } from '#/adapter/vxe-table';
 import type { MdmItemApi } from '#/api/mdm/item';
+import type { MesMdItemTypeApi } from '#/api/mes/md/item/type';
 
 import { nextTick, ref } from 'vue';
 
-import { message, Modal } from 'ant-design-vue';
+import { message, Modal, Tag } from 'ant-design-vue';
 
 import { useVbenVxeGrid } from '#/adapter/vxe-table';
 import { getItemPage } from '#/api/mdm/item';
+import { getItemTypeSimpleList } from '#/api/mes/md/item/type';
 
 import {
   useMdmItemSelectGridColumns,
@@ -24,6 +26,21 @@
 const multiple = ref(true); // 鏄惁澶氶��
 const selectedRows = ref<MdmItemApi.Item[]>([]); // 宸查�夌墿鏂欏垪琛�
 const preSelectedIds = ref<number[]>([]); // 棰勯�夌墿鏂欑紪鍙峰垪琛�
+const categoryList = ref<MesMdItemTypeApi.ItemType[]>([]); // 鍒嗙被鍒楄〃缂撳瓨
+
+const TAG_COLORS = ['green', 'orange', 'blue', 'purple', 'cyan', 'magenta', 'geekblue', 'volcano', 'gold', 'lime'] as const;
+
+function getCategoryName(categoryId?: number) {
+  if (!categoryId || !categoryList.value.length) return '';
+  const category = categoryList.value.find((item) => item.id === categoryId);
+  return category?.name || '';
+}
+
+function getCategoryColor(categoryId?: number): string {
+  if (!categoryId) return '';
+  const index = categoryList.value.findIndex((item) => item.id === categoryId);
+  return index >= 0 ? TAG_COLORS[index % TAG_COLORS.length]! : '';
+}
 
 /** 鑾峰彇褰撳墠琛ㄦ牸鏁版嵁 */
 function getTableRows() {
@@ -121,6 +138,13 @@
     proxyConfig: {
       ajax: {
         query: async ({ page }, formValues) => {
+          if (!categoryList.value.length) {
+            try {
+              categoryList.value = await getItemTypeSimpleList();
+            } catch {
+              categoryList.value = [];
+            }
+          }
           return await getItemPage({
             pageNo: page.currentPage,
             pageSize: page.pageSize,
@@ -185,7 +209,7 @@
 function handleConfirm() {
   const rows = multiple.value ? getMultipleSelectedRows() : selectedRows.value;
   if (rows.length === 0) {
-    message.warning(multiple.value ? '璇疯嚦灏戦�夋嫨涓�鏉℃暟鎹�' : '璇烽�夋嫨涓�鏉℃暟鎹�');
+    message.warning(multiple.value ? '璇疯嚦灏戦�夋嫨涓�涓搧绉�' : '璇烽�夋嫨涓�涓搧绉�');
     return;
   }
   emit('selected', multiple.value ? rows : [rows[0]!]);
@@ -198,12 +222,21 @@
 <template>
   <Modal
     v-model:open="open"
-    title="鐗╂枡閫夋嫨"
+    title="鍝佺閫夋嫨"
     width="80%"
     :destroy-on-close="true"
     @ok="handleConfirm"
     @cancel="closeModal"
   >
-    <Grid table-title="鐗╂枡鍒楄〃" />
+    <Grid table-title="鍝佺鍒楄〃">
+      <template #categoryId="{ row }">
+        <Tag v-if="getCategoryColor(row.categoryId)" :color="getCategoryColor(row.categoryId)">{{ getCategoryName(row.categoryId) }}</Tag>
+        <span v-else>{{ getCategoryName(row.categoryId) || '-' }}</span>
+      </template>
+      <template #isBatchManaged="{ row }">
+        <Tag v-if="row.isBatchManaged" color="success">鏄�</Tag>
+        <Tag v-else>鍚�</Tag>
+      </template>
+    </Grid>
   </Modal>
 </template>

--
Gitblit v1.9.3