|
|
@@ -9,7 +9,7 @@
|
|
|
* 注意:导出脚本必须有一个“entry”方法挂载在“INTERFACE_EXPORT”对象上。 eg: INTERFACE_EXPORT = { entry: () => void }
|
|
|
* entry方法返回的结果必须为[{ data, exportKind,(导出类型,招、投标、控制价) fileName(文件名) }]
|
|
|
* 其中data为xml的object形式:
|
|
|
- * xml:
|
|
|
+ * xml:
|
|
|
* <JingJiBiao Xmbh="001">
|
|
|
* <ZhaoBiaoXx Zbr="vian">
|
|
|
* </ZhaoBiaoXx>
|
|
|
@@ -19,11 +19,11 @@
|
|
|
* name: 'JingJiBiao',
|
|
|
* attrs: [{ name: 'xmbh', value: '001' }],
|
|
|
* children: [
|
|
|
- * {
|
|
|
+ * {
|
|
|
* name: 'ZhaoBiaoXx',
|
|
|
* attrs: [{ name: 'Zbr', value: 'vian' }],
|
|
|
* children: []
|
|
|
- * }
|
|
|
+ * }
|
|
|
* ]
|
|
|
* }
|
|
|
*/
|
|
|
@@ -33,47 +33,56 @@ let INTERFACE_EXPORT = {};
|
|
|
let INTERFACE_IMPORT = {};
|
|
|
|
|
|
const STD_INTERFACE = (() => {
|
|
|
- 'use strict';
|
|
|
+ "use strict";
|
|
|
|
|
|
// 根据地区配置,初始化地区选项
|
|
|
function initInterfaceAreas($parentAreas, $subAreas) {
|
|
|
const connectedAreas = Object.keys(INTERFACE_CONFIG);
|
|
|
const parentMap = {};
|
|
|
- connectedAreas.forEach(connectedArea => {
|
|
|
- const areas = connectedArea.split('@');
|
|
|
- if ((COMPILATION_NAME === '安徽养护(2018)' && areas[0] !== '安徽') ||
|
|
|
- (COMPILATION_NAME === '广东公路造价(2018)' && areas[0] !== '广东') ||
|
|
|
- (COMPILATION_NAME === '浙江养护(2005)' && areas[0] !== '浙江') ||
|
|
|
- (COMPILATION_NAME === '广西养护(2020)' && areas[0] !== '广西')
|
|
|
- ) {
|
|
|
+ connectedAreas.forEach((connectedArea) => {
|
|
|
+ const areas = connectedArea.split("@");
|
|
|
+ if (
|
|
|
+ (COMPILATION_NAME === "安徽养护(2018)" && areas[0] !== "安徽") ||
|
|
|
+ (COMPILATION_NAME === "广东公路造价(2018)" && areas[0] !== "广东") ||
|
|
|
+ (COMPILATION_NAME === "浙江养护(2005)" && areas[0] !== "浙江") ||
|
|
|
+ (COMPILATION_NAME === "广西养护(2020)" && areas[0] !== "广西")
|
|
|
+ ) {
|
|
|
return;
|
|
|
}
|
|
|
- if (COMPILATION_NAME.includes('山东养护(2016)')) {
|
|
|
- if (areas[0].includes('山东')) (parentMap[areas[0]] || (parentMap[areas[0]] = [])).push(areas[1]);
|
|
|
+ if (COMPILATION_NAME.includes("山东养护(2016/2024)")) {
|
|
|
+ if (areas[0].includes("山东"))
|
|
|
+ (parentMap[areas[0]] || (parentMap[areas[0]] = [])).push(areas[1]);
|
|
|
} else {
|
|
|
(parentMap[areas[0]] || (parentMap[areas[0]] = [])).push(areas[1]);
|
|
|
}
|
|
|
});
|
|
|
- const parentAreasHtml = Object
|
|
|
- .keys(parentMap)
|
|
|
- .reduce((acc, area) => acc += `<option value="${area}">${area}</option>`, '');
|
|
|
+ const parentAreasHtml = Object.keys(parentMap).reduce(
|
|
|
+ (acc, area) => (acc += `<option value="${area}">${area}</option>`),
|
|
|
+ ""
|
|
|
+ );
|
|
|
$parentAreas.html(parentAreasHtml);
|
|
|
- const subAreasHtml = parentMap[Object.keys(parentMap)[0]].reduce((acc, area) => acc += `<option value="${area}">${area}</option>`, '');
|
|
|
+ const subAreasHtml = parentMap[Object.keys(parentMap)[0]].reduce(
|
|
|
+ (acc, area) => (acc += `<option value="${area}">${area}</option>`),
|
|
|
+ ""
|
|
|
+ );
|
|
|
$subAreas.html(subAreasHtml);
|
|
|
// 父级地区变更,子地区选项更新
|
|
|
$parentAreas.change(function () {
|
|
|
- if (typeof EXPORT_VIEW !== 'undefined') {
|
|
|
+ if (typeof EXPORT_VIEW !== "undefined") {
|
|
|
EXPORT_VIEW.resetState(); // 清空导出接口缓存
|
|
|
}
|
|
|
const curArea = $(this).val();
|
|
|
- const subAreasHtml = parentMap[curArea].reduce((acc, area) => acc += `<option value="${area}">${area}</option>`, '');
|
|
|
+ const subAreasHtml = parentMap[curArea].reduce(
|
|
|
+ (acc, area) => (acc += `<option value="${area}">${area}</option>`),
|
|
|
+ ""
|
|
|
+ );
|
|
|
$subAreas.html(subAreasHtml);
|
|
|
});
|
|
|
$subAreas.change(function () {
|
|
|
- if (typeof EXPORT_VIEW !== 'undefined') {
|
|
|
+ if (typeof EXPORT_VIEW !== "undefined") {
|
|
|
EXPORT_VIEW.resetState(); // 清空导出接口缓存
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -86,37 +95,42 @@ const STD_INTERFACE = (() => {
|
|
|
*/
|
|
|
function loadScript(path) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
- const scriptID = 'interface-script';
|
|
|
- const body = document.getElementsByTagName('body')[0];
|
|
|
+ const scriptID = "interface-script";
|
|
|
+ const body = document.getElementsByTagName("body")[0];
|
|
|
// 移除原来的
|
|
|
const orgScript = document.getElementById(scriptID);
|
|
|
if (orgScript) {
|
|
|
body.removeChild(orgScript);
|
|
|
}
|
|
|
// 增加新的
|
|
|
- const script = document.createElement('script');
|
|
|
+ const script = document.createElement("script");
|
|
|
script.src = path;
|
|
|
- script.type = 'text/javascript';
|
|
|
+ script.type = "text/javascript";
|
|
|
script.id = scriptID;
|
|
|
body.appendChild(script);
|
|
|
- script.onload = script.onreadystatechange = function () { // ie、ff触发事件不同,都写上
|
|
|
- if (!this.readyState || this.readyState === 'loaded' || this.readyState === 'complete') {
|
|
|
+ script.onload = script.onreadystatechange = function () {
|
|
|
+ // ie、ff触发事件不同,都写上
|
|
|
+ if (
|
|
|
+ !this.readyState ||
|
|
|
+ this.readyState === "loaded" ||
|
|
|
+ this.readyState === "complete"
|
|
|
+ ) {
|
|
|
script.onload = script.onreadystatechange = null;
|
|
|
resolve();
|
|
|
}
|
|
|
};
|
|
|
script.onerror = function () {
|
|
|
- reject('script加载失败。');
|
|
|
+ reject("script加载失败。");
|
|
|
};
|
|
|
});
|
|
|
}
|
|
|
|
|
|
const ScriptType = {
|
|
|
- EXPORT: 'export',
|
|
|
- IMPORT: 'import',
|
|
|
+ EXPORT: "export",
|
|
|
+ IMPORT: "import",
|
|
|
};
|
|
|
|
|
|
- let curArea = '';
|
|
|
+ let curArea = "";
|
|
|
/**
|
|
|
* 根据地区和脚本类型加载脚本
|
|
|
* @param {String} area - 地区选项 eg: '安徽省@马鞍山'
|
|
|
@@ -145,5 +159,4 @@ const STD_INTERFACE = (() => {
|
|
|
ScriptType,
|
|
|
loadScriptByArea,
|
|
|
};
|
|
|
-
|
|
|
-})();
|
|
|
+})();
|