gaoluyang
2 天以前 6164c340e703d4a52227a2b6df5b22bdad112245
src/views/system/post/modules/import-form.vue
@@ -4,11 +4,11 @@
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 { importPost, importPostTemplate } from '#/api/system/post';
import { $t } from '#/locales';
import { notifyImportResult } from '#/utils';
import { useImportFormSchema } from '../data';
@@ -34,11 +34,21 @@
    // 提交表单
    const data = await formApi.getValues();
    try {
      await importPost(data.file, data.updateSupport);
      // 关闭并提示
      const importData = await importPost(data.file, data.updateSupport);
      const createCount = importData.createPostNames?.length || 0;
      const updateCount = importData.updatePostNames?.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.failurePostNames,
      });
    } finally {
      modalApi.unlock();
    }