YangYuGang
2025-03-08 8cae1dcd8d2bde01880ac4b70bdda4e61df3c7ef
src/views/components/ImportExcelModal.vue
@@ -40,6 +40,7 @@
  // import { useLocale } from '/@/locales/useLocale';
  import { BasicTable } from '/@/components/Table';
  import { ImportExcel, ValidateTableImport } from '/@/api/tigerapi/system';
  import { useUserStore } from '/@/store/modules/user';
  const emit = defineEmits(['success', 'register', 'toExcel']);
  const props = defineProps({
@@ -58,7 +59,7 @@
  });
  // const { getLocale } = useLocale();
  const { t } = useI18n('');
  const { createMessage, createConfirm } = useMessage();
  const { createMessage, createConfirm, createErrorModal } = useMessage();
  const tmpHeader = ref([]);
  const filename = ref('');
  const entityName = ref('');
@@ -118,7 +119,7 @@
      let dataSource = [] as any[];
      results.map((item) => {
        let entity = {} as any;
        let entity = { AUTH_ORG: useUserStore().userInfo?.orgCode.toString() } as any;
        baseColumns.value.map((c) => {
          entity[c['dataIndex']] = item[c['title']]; //c['dataIndex']=='BATCH_NO'?`${item[c['ORDER_NO']]}-01`: item[c['title']];
        });
@@ -136,13 +137,34 @@
      EntityJson: JSON.stringify(tableListRef.value[0].dataSource),
      CheckJson: checkJson.value,
      where: where.value,
      typeFullName: typeFullName.value
      typeFullName: typeFullName.value,
    });
    if (res.IsSuccessed) {
      tableListRef.value[0].dataSource = res.Data;
      err.value = '';
    } else {
      tableListRef.value = [];
      tableListRef.value = [
        {
          title: '列表信息',
          columns: [
            {
              title: '字段1',
              dataIndex: 'field1',
              width: 200,
              sorter: true,
              resizable: true,
            },
            {
              title: '字段2',
              dataIndex: 'field2',
              width: 200,
              sorter: true,
              resizable: true,
            },
          ],
          dataSource: [],
        },
      ];
      createMessage.error('导入失败' + res.Message);
      err.value = res.Message;
    }
@@ -171,7 +193,10 @@
        title: () => h('span', t('导入信息')),
        content: () => h('span', t('确认有修改的数据是否正确,有异常的数据无法导入')),
        onOk: async () => {
          const apiAction = await ImportExcel(entityName.value, tableListRef.value[0]['dataSource'] as any[]);
          const apiAction = await ImportExcel(entityName.value, {
            EntityJson: JSON.stringify(tableListRef.value[0].dataSource),
            typeFullName: typeFullName.value,
          });
          if (apiAction.IsSuccessed) {
            closeModal();
            createMessage.success(t('导入成功'));
@@ -179,6 +204,11 @@
              isUpdate: unref(false),
              values: { ...values, id: 0 },
            });
          } else {
            createErrorModal({
              title: t('sys.api.errorTip'),
              content: apiAction.Message,
            });
          }
        },
      });