From b64a0deae5b5d33f9e20671a68936b27f0b9b00b Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 21 七月 2026 18:03:03 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_pro2.0' into dev_pro2.0

---
 src/views/basicData/mdm/index.vue |   84 ++++++++++++++++++++++++++++++++---------
 1 files changed, 65 insertions(+), 19 deletions(-)

diff --git a/src/views/basicData/mdm/index.vue b/src/views/basicData/mdm/index.vue
index c10a75f..4cc1c42 100644
--- a/src/views/basicData/mdm/index.vue
+++ b/src/views/basicData/mdm/index.vue
@@ -1,8 +1,9 @@
 <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 { ref } from 'vue';
+import { computed, ref } from 'vue';
 
 import { confirm, Page, useVbenModal } from '#/packages/effects/common-ui/src';
 import { downloadFileFromBlobPart, isEmpty } from '#/packages/utils/src';
@@ -13,13 +14,14 @@
 import {
   deleteItem,
   deleteItemList,
-  exportItem,
+  // exportItem,
   getItemPage,
   updateItemStatus,
 } from '#/api/mdm/item';
+import { getItemTypeSimpleList } from '#/api/mes/md/item/type';
 import { $t } from '#/locales';
 
-import { useGridColumns, useGridFormSchema, ITEM_TYPE_MAP, ITEM_TYPE_COLOR_MAP } from './data';
+import { useGridColumns, useGridFormSchema } from './data';
 import Form from './modules/form.vue';
 
 defineOptions({ name: 'MdmItem' });
@@ -29,16 +31,54 @@
   destroyOnClose: true,
 });
 
+// 鍒嗙被鍒楄〃缂撳瓨
+const categoryList = ref<MesMdItemTypeApi.ItemType[]>([]);
+
+const TAG_COLORS = [
+  'green',
+  'orange',
+  'blue',
+  'purple',
+  'cyan',
+  'magenta',
+  'geekblue',
+  'volcano',
+  'gold',
+  'lime',
+] as const;
+
+/** 鍒嗙被ID 鈫� 棰滆壊鏄犲皠锛堝熀浜庡垎绫诲湪鍒楄〃涓殑绱㈠紩寰幆鍒嗛厤锛� */
+const categoryColorMap = computed(() => {
+  const map = new Map<number, string>();
+  categoryList.value.forEach((item, index) => {
+    map.set(item.id!, TAG_COLORS[index % TAG_COLORS.length]!);
+  });
+  return map;
+});
+
+/** 鑾峰彇鍒嗙被Tag棰滆壊 */
+function getCategoryColor(categoryId?: number): string {
+  if (!categoryId) return '';
+  return categoryColorMap.value.get(categoryId) || '';
+}
+
+/** 鑾峰彇鍒嗙被鍚嶇О */
+function getCategoryName(categoryId?: number) {
+  if (!categoryId || !categoryList.value.length) return '';
+  const category = categoryList.value.find((item) => item.id === categoryId);
+  return category?.name || '';
+}
+
 /** 鍒锋柊琛ㄦ牸 */
 function handleRefresh() {
   gridApi.query();
 }
 
 /** 瀵煎嚭琛ㄦ牸 */
-async function handleExport() {
-  const data = await exportItem(await gridApi.formApi.getValues());
-  downloadFileFromBlobPart({ fileName: '鐗╂枡.xls', source: data });
-}
+// async function handleExport() {
+//   const data = await exportItem(await gridApi.formApi.getValues());
+//   downloadFileFromBlobPart({ fileName: '鐗╂枡.xls', source: data });
+// }
 
 /** 鍒涘缓鐗╂枡 */
 function handleCreate() {
@@ -118,6 +158,14 @@
     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,
@@ -156,13 +204,13 @@
               auth: ['mdm:item:create'],
               onClick: handleCreate,
             },
-            {
-              label: $t('ui.actionTitle.export'),
-              type: 'primary',
-              icon: ACTION_ICON.DOWNLOAD,
-              auth: ['mdm:item:export'],
-              onClick: handleExport,
-            },
+            // {
+            //   label: $t('ui.actionTitle.export'),
+            //   type: 'primary',
+            //   icon: ACTION_ICON.DOWNLOAD,
+            //   auth: ['mdm:item:export'],
+            //   onClick: handleExport,
+            // },
             {
               label: $t('ui.actionTitle.deleteBatch'),
               type: 'primary',
@@ -175,11 +223,9 @@
           ]"
         />
       </template>
-      <template #itemType="{ row }">
-        <Tag v-if="row.itemType === 1" color="green">鍘熸枡</Tag>
-        <Tag v-else-if="row.itemType === 2" color="orange">鍗婃垚鍝�</Tag>
-        <Tag v-else-if="row.itemType === 3" color="blue">鎴愬搧</Tag>
-        <Tag v-else-if="row.itemType === 4" color="purple">杈呮枡</Tag>
+      <template #categoryName="{ 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>

--
Gitblit v1.9.3