gaoluyang
3 天以前 6164c340e703d4a52227a2b6df5b22bdad112245
src/views/mes/md/item/modules/import-form.vue
@@ -6,11 +6,12 @@
import { useVbenModal } from '@vben/common-ui';
import { downloadFileFromBlobPart } from '@vben/utils';
import { Button, message, Upload } from 'ant-design-vue';
import { Button, Upload } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form';
import { importItem, importItemTemplate } from '#/api/mes/md/item';
import { $t } from '#/locales';
import { notifyImportResult } from '#/utils';
import { useImportFormSchema } from '../data';
@@ -41,23 +42,21 @@
    try {
      const result = await importItem(data.file, data.updateSupport);
      const importData = result as MesMdItemApi.ItemImportRespVO;
      let text = `上传成功数量:${importData.createCodes?.length || 0};`;
      for (const code of importData.createCodes || []) {
        text += `< ${code} >`;
      }
      text += `更新成功数量:${importData.updateCodes?.length || 0};`;
      for (const code of importData.updateCodes || []) {
        text += `< ${code} >`;
      }
      text += `更新失败数量:${Object.keys(importData.failureCodes || {}).length};`;
      for (const code in importData.failureCodes || {}) {
        text += `< ${code}: ${importData.failureCodes?.[code]} >`;
      }
      message.info(text);
      // 关闭并提示
      const createCount = importData.createCodes?.length || 0;
      const updateCount = importData.updateCodes?.length || 0;
      // 关闭并按导入结果提示:仅在确有数据写入时通知列表刷新
      await modalApi.close();
      emit('success');
      message.success($t('ui.actionMessage.operationSuccess'));
      if (createCount + updateCount > 0) {
        emit('success');
      }
      notifyImportResult({
        subject: '物料',
        createCount,
        updateCount,
        failures: importData.failureCodes,
        masterDataHint: '【物料分类】中的对应编码',
      });
    } finally {
      modalApi.unlock();
    }