|
|
@@ -2,7 +2,7 @@
|
|
|
<div class="container-fluid">
|
|
|
<Navbar :title="$t('lang.DataImportPanel.DataImport')" :is-go-back="true" />
|
|
|
|
|
|
- <div style="margin-top: 2rem">
|
|
|
+ <div style="margin-top: 1.2rem">
|
|
|
<a-steps :current="current">
|
|
|
<a-step
|
|
|
v-for="item in steps"
|
|
|
@@ -111,6 +111,14 @@
|
|
|
>
|
|
|
{{ $t("lang.DataImportPanel.testImport") }}
|
|
|
</button>
|
|
|
+ <button
|
|
|
+ v-if="isError"
|
|
|
+ type="button"
|
|
|
+ class="btn btn-primary btn-primary-1 btn-primary-import"
|
|
|
+ @click="exportErrorExcel"
|
|
|
+ >
|
|
|
+ 导出Excel
|
|
|
+ </button>
|
|
|
<button
|
|
|
v-if="testSuccess"
|
|
|
type="button"
|
|
|
@@ -149,26 +157,25 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <a-table
|
|
|
+ <CommonTable
|
|
|
v-if="current === 2"
|
|
|
- bordered
|
|
|
- sticky
|
|
|
:columns="columns"
|
|
|
:data-source="dataSource"
|
|
|
- :scroll="{ x: 2200 }"
|
|
|
>
|
|
|
- <a-table-column type="index" />
|
|
|
<template #bodyCell="{ column, record }">
|
|
|
<template v-if="column.key === 'ImportResult'">
|
|
|
{{ record.ImportResult }}
|
|
|
</template>
|
|
|
</template>
|
|
|
- </a-table>
|
|
|
+ </CommonTable>
|
|
|
<Loading v-if="loading" />
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="steps-action">
|
|
|
- <a-button v-if="current > 0" class="prevBtn" @click="prev">
|
|
|
+ <a-button v-if="current === 1" class="prevBtn" @click="prev">
|
|
|
+ 上一步
|
|
|
+ </a-button>
|
|
|
+ <a-button v-if="current === 2" class="prevFixed" @click="prev">
|
|
|
上一步
|
|
|
</a-button>
|
|
|
<a-button
|
|
|
@@ -186,7 +193,7 @@
|
|
|
|
|
|
<script>
|
|
|
import Common from '../common/Common.js';
|
|
|
-
|
|
|
+import CommonTable from '../common/CommonTable.vue';
|
|
|
import DownloadService from '../resource/file/DownloadService.js';
|
|
|
import WorkflowResource from '../api/workflow/WorkflowResource.js';
|
|
|
import { Notify, Uuid, Navbar } from 'pc-component-v3';
|
|
|
@@ -206,6 +213,7 @@ export default {
|
|
|
LoadingOutlined,
|
|
|
SmileOutlined,
|
|
|
Navbar,
|
|
|
+ CommonTable,
|
|
|
},
|
|
|
|
|
|
data: function () {
|
|
|
@@ -232,7 +240,7 @@ export default {
|
|
|
sheetItems: [],
|
|
|
importFields: [],
|
|
|
importTable: {},
|
|
|
- selectedIndex: -1,
|
|
|
+ selectedIndex: 0,
|
|
|
dataTemplateNos: [],
|
|
|
loading: false,
|
|
|
selectedFile: null,
|
|
|
@@ -244,6 +252,7 @@ export default {
|
|
|
lineCount: null, // 导入行数
|
|
|
columnCount: null, // 导入列数
|
|
|
testSuccess: false, // 测试导入是否成功
|
|
|
+ isError: false,
|
|
|
};
|
|
|
},
|
|
|
|
|
|
@@ -280,6 +289,7 @@ export default {
|
|
|
},
|
|
|
prev() {
|
|
|
this.current--;
|
|
|
+ this.isError = false;
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
@@ -471,7 +481,7 @@ export default {
|
|
|
|
|
|
for (var i = 0, len = data.length; i < len; i++) {
|
|
|
_self.sheetItems.push(data[i]);
|
|
|
- _self.selectedIndex = i - 1;
|
|
|
+ // _self.selectedIndex = i - 1;
|
|
|
}
|
|
|
},
|
|
|
|
|
|
@@ -524,17 +534,35 @@ export default {
|
|
|
item.title = item.displayName;
|
|
|
item.dataIndex = item.fieldName;
|
|
|
item.key = item.fieldName;
|
|
|
- item.width = 100;
|
|
|
+ item.width = 120;
|
|
|
});
|
|
|
- _self.columns = columns;
|
|
|
- _self.columns.push({
|
|
|
+ columns.push({
|
|
|
title: _self.$t('lang.DataImportPanel.processingResults'),
|
|
|
dataIndex: 'ImportResult',
|
|
|
key: 'ImportResult',
|
|
|
- width: 100,
|
|
|
+ width: 150,
|
|
|
fixed: 'right',
|
|
|
+ filters: [
|
|
|
+ {
|
|
|
+ text: '成功',
|
|
|
+ value: '成功',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: '失败',
|
|
|
+ value: '失败',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ filterMultiple: false,
|
|
|
+ onFilter: (value, record) => record.ImportResult.indexOf(value) === 0,
|
|
|
// scopedSlots: { customRender: 'ImportResult' },
|
|
|
});
|
|
|
+ _self.columns = columns.map(item => ({
|
|
|
+ ...item,
|
|
|
+ resizable: true,
|
|
|
+ mainWidth: 75,
|
|
|
+ maxWidth: 400,
|
|
|
+ ellipsis: true,
|
|
|
+ }));
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
@@ -612,33 +640,17 @@ export default {
|
|
|
_self.showTestImportTable(data.dataList);
|
|
|
_self.uploadClassFile();
|
|
|
if (data.isSuccess) {
|
|
|
- if (isformalImport) {
|
|
|
- Notify.info(
|
|
|
- _self.$t('lang.Notify.success'),
|
|
|
- _self.$t('lang.DataImportPanel.describe5'),
|
|
|
- false,
|
|
|
- );
|
|
|
- } else {
|
|
|
- Notify.info(
|
|
|
- _self.$t('lang.Notify.success'),
|
|
|
- _self.$t('lang.DataImportPanel.describe6'),
|
|
|
- false,
|
|
|
- );
|
|
|
- }
|
|
|
+ Notify.info(
|
|
|
+ _self.$t('lang.Notify.success'),
|
|
|
+ _self.$t('lang.DataImportPanel.describe5'),
|
|
|
+ false,
|
|
|
+ );
|
|
|
} else {
|
|
|
- if (isformalImport) {
|
|
|
- Notify.error(
|
|
|
- _self.$t('lang.Notify.fail'),
|
|
|
- _self.$t('lang.DataImportPanel.describe7'),
|
|
|
- false,
|
|
|
- );
|
|
|
- } else {
|
|
|
- Notify.error(
|
|
|
- _self.$t('lang.Notify.fail'),
|
|
|
- _self.$t('lang.DataImportPanel.describe8'),
|
|
|
- false,
|
|
|
- );
|
|
|
- }
|
|
|
+ Notify.error(
|
|
|
+ _self.$t('lang.Notify.fail'),
|
|
|
+ _self.$t('lang.DataImportPanel.describe7') + `导入成功${data.successCount}条,导入失败${data.errorCount}条。`,
|
|
|
+ false,
|
|
|
+ );
|
|
|
}
|
|
|
},
|
|
|
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
|
|
@@ -648,6 +660,32 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
|
|
|
+ // 导出表格数据
|
|
|
+ exportErrorExcel: function () {
|
|
|
+ const url = Common.getApiURL('dataImportResource/downloadTemplateExcel');
|
|
|
+ const xhr = new XMLHttpRequest();
|
|
|
+ xhr.open('get', url, true);
|
|
|
+ xhr.setRequestHeader('token', localStorage.getItem('#token'));
|
|
|
+ xhr.setRequestHeader('Content-type', 'application/json');
|
|
|
+ xhr.responseType = 'blob';
|
|
|
+ xhr.onreadystatechange = function () {
|
|
|
+ if (xhr.readyState === 4 && xhr.status === 200) {
|
|
|
+ let res = xhr.response;
|
|
|
+ let blob = new Blob([res]);
|
|
|
+ const blobUrl = URL.createObjectURL(blob);
|
|
|
+ const link = document.createElement('a');
|
|
|
+ link.download = '数据.xlsx';
|
|
|
+ link.style.display = 'none';
|
|
|
+ link.href = blobUrl;
|
|
|
+ document.body.appendChild(link);
|
|
|
+ link.click();
|
|
|
+ URL.revokeObjectURL(blobUrl);
|
|
|
+ document.body.removeChild(link);
|
|
|
+ message.success('导出数据成功。');
|
|
|
+ }
|
|
|
+ };
|
|
|
+ xhr.send();
|
|
|
+ },
|
|
|
/**
|
|
|
* 测试导入之后将文件上传到服务端并保存
|
|
|
*/
|
|
|
@@ -688,17 +726,24 @@ export default {
|
|
|
}
|
|
|
|
|
|
_self.dataSource = [];
|
|
|
-
|
|
|
+ let successCount = 0;
|
|
|
data.forEach(function (item) {
|
|
|
+ if (item.ImportResult === '成功') {
|
|
|
+ successCount += 1;
|
|
|
+ }
|
|
|
_self.dataSource.push(item.data);
|
|
|
});
|
|
|
+ let errorCount = data.length - successCount;
|
|
|
+ // message
|
|
|
const flag = _self.dataSource.every(item => {
|
|
|
return item.ImportResult === '成功';
|
|
|
});
|
|
|
if (flag) {
|
|
|
this.testSuccess = true;
|
|
|
+ this.isError = false;
|
|
|
} else {
|
|
|
this.testSuccess = false;
|
|
|
+ this.isError = true;
|
|
|
}
|
|
|
},
|
|
|
|
|
|
@@ -854,7 +899,10 @@ export default {
|
|
|
position: absolute;
|
|
|
right: 0px;
|
|
|
}
|
|
|
-
|
|
|
+.prevFixed {
|
|
|
+ position: fixed;
|
|
|
+ top: 93%;
|
|
|
+}
|
|
|
.btn-primary-1 {
|
|
|
color: #fff;
|
|
|
background: #1890ff;
|
|
|
@@ -872,7 +920,7 @@ export default {
|
|
|
.btn-primary-import {
|
|
|
margin-left: 5px;
|
|
|
}
|
|
|
-:deep(.ant-table-sticky-scroll){
|
|
|
+:deep(.ant-table-sticky-scroll) {
|
|
|
display: none !important;
|
|
|
}
|
|
|
</style>
|