|
|
@@ -32,9 +32,15 @@ const IMPORT_VIEW = (() => {
|
|
|
}
|
|
|
|
|
|
// 导入相关事件监听器
|
|
|
+ let importData = null;
|
|
|
+ let areaKey = '';
|
|
|
function importListener() {
|
|
|
// 文件选择变更
|
|
|
$('#interface-import-file').change(function () {
|
|
|
+ importData = null;
|
|
|
+ areaKey = '';
|
|
|
+ $('#import-rename-input').val('');
|
|
|
+ $('#import-rename').hide();
|
|
|
const file = $(this)[0].files[0];
|
|
|
$('#interface-import-label').text(file && file.name || '请选择导入文件');
|
|
|
});
|
|
|
@@ -55,10 +61,24 @@ const IMPORT_VIEW = (() => {
|
|
|
if (!parentArea || !subArea) {
|
|
|
throw '请选择有效地区。';
|
|
|
}
|
|
|
- const areaKey = `${parentArea}@${subArea}`;
|
|
|
- await STD_INTERFACE.loadScriptByArea(areaKey, STD_INTERFACE.ScriptType.IMPORT);
|
|
|
- const onlyImportMatchBills = areaKey === '广东@中山';
|
|
|
- const importData = await INTERFACE_EXPORT_BASE.extractImportData(INTERFACE_IMPORT.entry, file, areaKey, false, onlyImportMatchBills);
|
|
|
+ const curAreaKey = `${parentArea}@${subArea}`;
|
|
|
+ if (!(importData && areaKey && areaKey === curAreaKey)) {
|
|
|
+ areaKey = curAreaKey;
|
|
|
+ await STD_INTERFACE.loadScriptByArea(areaKey, STD_INTERFACE.ScriptType.IMPORT);
|
|
|
+ const onlyImportMatchBills = areaKey === '广东@中山';
|
|
|
+ importData = await INTERFACE_EXPORT_BASE.extractImportData(INTERFACE_IMPORT.entry, file, areaKey, false, onlyImportMatchBills);
|
|
|
+ }
|
|
|
+ const constructionName = $('#import-rename').is(':visible') ? $('#import-rename-input').val() : importData.name;
|
|
|
+ // 确定建设项目的名称(不允许重复)
|
|
|
+ const sameDepthProjs = getProjs(projTreeObj.tree.selected);
|
|
|
+ const matchedProject = sameDepthProjs.find(node => node.data.name === constructionName);
|
|
|
+ if (matchedProject || !constructionName) {
|
|
|
+ $('#import-rename-input').val(constructionName);
|
|
|
+ $('#import-rename').show();
|
|
|
+ $('#import-rename-input').focus();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ importData.name = constructionName;
|
|
|
$('#interface-import-modal').modal('hide');
|
|
|
$.bootstrapLoading.progressStart('导入文件', true);
|
|
|
$("#progress_modal_body").text('正在导入接口文件,请稍候……');
|
|
|
@@ -93,6 +113,8 @@ const IMPORT_VIEW = (() => {
|
|
|
|
|
|
$(document).ready(() => {
|
|
|
$('#interface-import-modal').on('show.bs.modal', () => {
|
|
|
+ $('#import-rename-input').val('');
|
|
|
+ $('#import-rename').hide();
|
|
|
$('#interface-import-file').val('');
|
|
|
$('#interface-import-label').text('请选择导入文件');
|
|
|
IMPORT_VIEW.initFileAccept($('#interface-import-file'));
|