From 04ebad9ff9a5bd1f4f3ad8d819ada1c6ac20fefc Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期一, 12 十月 2026 11:53:46 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_海西州_北京同仁堂' into dev_海西州_北京同仁堂

---
 src/views/basicData/mdm/modules/import-form.vue |  113 ++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 96 insertions(+), 17 deletions(-)

diff --git a/src/views/basicData/mdm/modules/import-form.vue b/src/views/basicData/mdm/modules/import-form.vue
index 5cc47a2..c868b40 100644
--- a/src/views/basicData/mdm/modules/import-form.vue
+++ b/src/views/basicData/mdm/modules/import-form.vue
@@ -1,18 +1,28 @@
 <script lang="ts" setup>
 import type { FileType } from 'ant-design-vue/es/upload/interface';
 
-import { h } from 'vue';
+import { computed, ref } from 'vue';
 
 import { useVbenModal } from '@vben/common-ui';
 import { downloadFileFromBlobPart } from '@vben/utils';
 
-import { Button, message, notification, Upload } from 'ant-design-vue';
+import { Button, message, Upload } from 'ant-design-vue';
 
 import { useVbenForm } from '#/adapter/form';
 import { importItem, importItemTemplate } from '#/api/mdm/item';
 import { $t } from '#/locales';
 
 import { useImportFormSchema } from '../data';
+
+/** 瀵煎叆缁撴灉锛屽搴斿悗绔� MdmItemImportRespVO */
+interface ImportResult {
+  /** 鏂板鎴愬姛鐨勭墿鏂� */
+  createList?: string[];
+  /** 鏇存柊鎴愬姛鐨勭墿鏂� */
+  updateList?: string[];
+  /** 澶辫触鏄庣粏锛歬ey 涓恒�岀墿鏂欑紪鐮� 鍚嶇О銆嶏紝value 涓哄け璐ュ師鍥� */
+  failureList?: Record<string, string>;
+}
 
 const emit = defineEmits(['success']);
 
@@ -26,6 +36,17 @@
   showDefaultActions: false,
 });
 
+const importResult = ref<ImportResult>({});
+const createCount = computed(() => importResult.value.createList?.length ?? 0);
+const updateCount = computed(() => importResult.value.updateList?.length ?? 0);
+const failureEntries = computed(() =>
+  Object.entries(importResult.value.failureList ?? {}),
+);
+const failureCount = computed(() => failureEntries.value.length);
+
+// 娉ㄦ剰锛氭湰缁勪欢閲岀殑澶氫釜 useVbenModal 鏈夊厛鍚庨『搴忚姹傗�斺��
+// 鐖堕〉闈㈢敤 useVbenModal({ connectedComponent: ImportForm }) 閫氳繃 provide/inject 缁戝畾锛�
+// 鍙湁绗竴涓皟鐢ㄤ細鎺ョ杩欎釜缁戝畾銆傛墍浠ュ鍏ョ獥鍙e繀椤诲0鏄庡湪鏈�鍓嶏紝鍏朵綑寮规锛堝缁撴灉寮规锛夋帓鍦ㄥ悗闈€��
 const [Modal, modalApi] = useVbenModal({
   async onConfirm() {
     const { valid } = await formApi.validate();
@@ -37,29 +58,45 @@
     const data = await formApi.getValues();
     try {
       const response = (await importItem(data.file, data.updateSupport)) as any;
-      // 鍏抽棴骞舵彁绀�
-      await modalApi.close();
+      const resultData = (response?.data || response || {}) as ImportResult;
+      const hasFailure = Object.keys(resultData.failureList ?? {}).length > 0;
+
       emit('success');
 
-      const resultData = response?.data || response || {};
-      const failureList = resultData.failureList || {};
-
-      if (Object.keys(failureList).length > 0) {
-        const errorNodes = Object.entries(failureList).map(([name, reason]) => {
-          return h('div', `${name}: ${reason}`);
-        });
-
-        notification.warning({
-          message: '瀵煎叆瀹屾垚锛岄儴鍒嗙墿鏂欏鍏ュけ璐�',
-          description: () => h('div', errorNodes),
-          duration: null,
-        });
+      if (hasFailure) {
+        // 涓嶈兘鍦ㄨ繖閲屽厛鍏冲鍏ョ獥鍙o細鐖堕〉闈㈤厤缃簡 destroyOnClose锛�
+        // 鍏崇獥浼氭妸鏈粍浠舵暣涓噸寤猴紝鍒氭墦寮�鐨勭粨鏋滃脊妗嗕細琚繛甯﹀嵏杞斤紙闂竴涓嬪氨娑堝け锛夈��
+        // 鏀逛负鎶婄粨鏋滃脊妗嗗彔鍦ㄤ笂闈紝绛夊畠鍏抽棴鍚庡啀鍏冲鍏ョ獥鍙o紙瑙佷笅闈� onClosed锛夈��
+        importResult.value = resultData;
+        resultModalApi.open();
       } else {
+        importResult.value = {};
         message.success($t('ui.actionMessage.operationSuccess'));
+        await modalApi.close();
       }
     } finally {
       modalApi.unlock();
     }
+  },
+});
+
+/** 瀵煎叆缁撴灉寮规锛氬け璐ユ槑缁嗗彲鑳藉緢闀匡紝寮规鍐呭浐瀹氶珮搴︽粴鍔紝閬垮厤鍍忛�氱煡鏉¢偅鏍锋拺鍑哄睆骞� */
+const [ResultModal, resultModalApi] = useVbenModal({
+  onOpenChange(isOpen: boolean) {
+    if (isOpen) {
+      resultModalApi.setState({
+        confirmText: '鐭ラ亾浜�',
+        showCancelButton: false,
+      });
+    }
+  },
+  // 蹇呴』鏄惧紡鎻愪緵锛歁odalApi.onConfirm 鏄� this.api.onConfirm?.() 鐨勫彲閫夎皟鐢紝涓嶄紶鍒欑偣鎸夐挳姣棤鍙嶅簲
+  onConfirm() {
+    resultModalApi.close();
+  },
+  // 缁撴灉寮规鍏抽棴鍚庡啀鍏冲鍏ョ獥鍙o紙姝ゆ椂鏈粍浠惰閿�姣佹槸瀹夊叏鐨勶級
+  onClosed() {
+    modalApi.close();
   },
 });
 
@@ -102,4 +139,46 @@
       </div>
     </template>
   </Modal>
+
+  <ResultModal title="瀵煎叆缁撴灉" class="w-[760px]">
+    <div class="mx-4">
+      <div class="mb-3 flex flex-wrap gap-x-6 gap-y-1 text-sm">
+        <span>
+          鏂板锛�<span class="font-medium text-green-600">{{ createCount }}</span>
+          鏉�
+        </span>
+        <span>
+          鏇存柊锛�<span class="font-medium text-blue-600">{{ updateCount }}</span>
+          鏉�
+        </span>
+        <span>
+          澶辫触锛�<span class="font-medium text-red-600">{{ failureCount }}</span>
+          鏉�
+        </span>
+      </div>
+
+      <div
+        v-if="failureCount > 0"
+        class="overflow-hidden rounded-md border border-red-100"
+      >
+        <div
+          class="border-b border-red-100 bg-red-50 px-3 py-2 text-sm font-medium text-red-600"
+        >
+          澶辫触鏄庣粏锛堝叡 {{ failureCount }} 鏉★紝涓嬫柟鍖哄煙鍙粴鍔ㄦ煡鐪嬶級
+        </div>
+        <div class="max-h-[60vh] overflow-y-auto">
+          <div
+            v-for="[itemKey, itemReason] in failureEntries"
+            :key="itemKey"
+            class="flex gap-2 border-b border-gray-100 px-3 py-2 text-sm last:border-b-0"
+          >
+            <span class="w-56 shrink-0 break-all text-gray-700">
+              {{ itemKey }}
+            </span>
+            <span class="break-all text-red-500">{{ itemReason }}</span>
+          </div>
+        </div>
+      </div>
+    </div>
+  </ResultModal>
 </template>

--
Gitblit v1.9.3