|
@@ -54,6 +54,11 @@ const XML_EXPORT_BASE = (() => {
|
|
|
Bid: 2, //招标
|
|
|
Control: 3 //控制价
|
|
|
};
|
|
|
+ const EXPORT_KIND_NAME = {
|
|
|
+ 1: '投标',
|
|
|
+ 2: '招标',
|
|
|
+ 3: '控制价'
|
|
|
+ };
|
|
|
// 配置项
|
|
|
const CONFIG = Object.freeze({
|
|
|
HINT_START,
|
|
@@ -63,7 +68,8 @@ const XML_EXPORT_BASE = (() => {
|
|
|
ADJUST_TYPE,
|
|
|
TIMEOUT_TIME,
|
|
|
GRANULARITY,
|
|
|
- EXPORT_KIND
|
|
|
+ EXPORT_KIND,
|
|
|
+ EXPORT_KIND_NAME
|
|
|
});
|
|
|
|
|
|
// 缓存项 不需要的时候需要清空
|
|
@@ -108,12 +114,13 @@ const XML_EXPORT_BASE = (() => {
|
|
|
* 一个节点对应一个构造方法,方便调整配置、方便其他版本开发、接手的人看起来更直观
|
|
|
* @param {String}name 节点名
|
|
|
* {Array}attrs 节点属性数据
|
|
|
- * {Array}failList 失败列表
|
|
|
+ * {String}alias 别名,有些节点名称是英文,但是提示的时候需要显示中文的时候用
|
|
|
* @return {void}
|
|
|
* */
|
|
|
- function Element(name, attrs) {
|
|
|
+ function Element(name, attrs, alias) {
|
|
|
this.name = name;
|
|
|
- let checkData = check(name, attrs);
|
|
|
+ const hintName = alias || name;
|
|
|
+ const checkData = check(hintName, attrs);
|
|
|
this.fail = checkData.failHints;
|
|
|
this.attrs = checkData.filterAttrs;
|
|
|
handleXMLEntity(this.attrs);
|
|
@@ -167,7 +174,7 @@ const XML_EXPORT_BASE = (() => {
|
|
|
for (let data of datas) {
|
|
|
const isHasValue = hasValue(data.value);
|
|
|
// 某属性是非必须的,并且设置了mustHasValue,意味着必须要有值才输出该属性
|
|
|
- if (!data.required && data.mustHasValue && !hasValue) {
|
|
|
+ if (!data.required && data.mustHasValue && !isHasValue) {
|
|
|
continue;
|
|
|
}
|
|
|
// 值统一转换成String,并且处理各类型属性空值时的默认取值
|
|
@@ -525,7 +532,7 @@ const XML_EXPORT_BASE = (() => {
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
- * 通过getData接口获取单位工程详细数据
|
|
|
+ * 通过getData接口获取单位工程详细数据(带缓存功能)
|
|
|
* @param {Number}tenderID 单位工程ID
|
|
|
* {String}userID 用户ID
|
|
|
* @return {Object} 跟projectObj.project的数据结构一致
|
|
@@ -723,6 +730,17 @@ const XML_EXPORT_BASE = (() => {
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
+ // 获取节点的某属性
|
|
|
+ function getAttr(ele, name) {
|
|
|
+ return (ele.attrs.find(attr => attr.name === name) || {}).value;
|
|
|
+ }
|
|
|
+ // 设置节点的某属性
|
|
|
+ function setAttr(ele, name, value) {
|
|
|
+ const attr = ele.attrs.find(attr => attr.name === name);
|
|
|
+ if (attr) {
|
|
|
+ attr.value = value;
|
|
|
+ }
|
|
|
+ }
|
|
|
// 从srcEle节点中获取元素名为eleName的元素
|
|
|
function getElementFromSrc(srcEle, eleName) {
|
|
|
if (!srcEle || !srcEle.children || !srcEle.children.length) {
|
|
@@ -814,6 +832,8 @@ const XML_EXPORT_BASE = (() => {
|
|
|
transformCalcBaseState,
|
|
|
getCodeSheetData,
|
|
|
getElementFromSrc,
|
|
|
+ getAttr,
|
|
|
+ setAttr,
|
|
|
getParsedData,
|
|
|
setupCode,
|
|
|
softCheck
|
|
@@ -838,6 +858,9 @@ const XML_EXPORT_BASE = (() => {
|
|
|
for (let ele of eles) {
|
|
|
rst += _startTag(ele);
|
|
|
if (ele.children.length > 0) {
|
|
|
+ if (ele.children.some(c => !c)) {
|
|
|
+ debugger;
|
|
|
+ }
|
|
|
rst += _toXMLStr(ele.children);
|
|
|
rst += _endTag(ele);
|
|
|
}
|