|
@@ -50,7 +50,7 @@ module.exports = app => {
|
|
|
* @returns {boolean}
|
|
|
* @private
|
|
|
*/
|
|
|
- _matchCode(code, rule) {
|
|
|
+ _matchCodeByRule(code, rule) {
|
|
|
const codeParts = code.split('-');
|
|
|
const ruleParts = rule.split('-');
|
|
|
const numReg = /(^[0-9]+$)/, charReg = /(^[a-z]+$)/i;
|
|
@@ -67,6 +67,16 @@ module.exports = app => {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ _matchCodeByRules(code, rules) {
|
|
|
+ const ruleArr = rules.split(';');
|
|
|
+ for (const r of ruleArr) {
|
|
|
+ if (this._matchCodeByRule(code, r)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 过滤符合指标节点node匹配规则的清单
|
|
|
* 已经匹配过的清单不再匹配
|
|
@@ -79,7 +89,7 @@ module.exports = app => {
|
|
|
return this.bills.filter(function (b) {
|
|
|
if (!b.match_node) {
|
|
|
if (node.match_type === nodeConst.matchType.code) {
|
|
|
- return self._matchCode(b.code, node.match_key);
|
|
|
+ return self._matchCodeByRules(b.code, node.match_key);
|
|
|
} else {
|
|
|
return node.match_key === b.name;
|
|
|
}
|
|
@@ -111,6 +121,20 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ _getChildrenBillsValue(param, bills) {
|
|
|
+ if (bills) {
|
|
|
+ const children = this.ctx.helper.filterObj(this.bills, 'n_pid', bills.n_id);
|
|
|
+ switch(param.match_num) {
|
|
|
+ case paramConst.matchNum.quantity: return this.ctx.helper.sumField(children, 'quantity');
|
|
|
+ case paramConst.matchNum.total_price: return this.ctx.helper.sumField(children, 'total_price');
|
|
|
+ case paramConst.matchNum.dgn_quantity1: return this.ctx.helper.sumField(children, 'dgn_quantity1');
|
|
|
+ case paramConst.matchNum.dgn_quantity2: return this.ctx.helper.sumField(children, 'dgn_quantity2');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return undefined;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取指标参数取值(固定Id匹配)
|
|
|
* @param {Object} param - 指标参数
|
|
@@ -135,7 +159,7 @@ module.exports = app => {
|
|
|
*/
|
|
|
_getCodeParamValue(param) {
|
|
|
for (const b of this.bills) {
|
|
|
- if (this._matchCode(b.code, param.match_key)) {
|
|
|
+ if (this._matchCodeByRules(b.code, param.match_key)) {
|
|
|
return this._getNodeBillsValue(param, b);
|
|
|
}
|
|
|
}
|
|
@@ -166,6 +190,7 @@ module.exports = app => {
|
|
|
case paramConst.matchType.fixed_id: return this._getFixedIdParamValue(param);
|
|
|
case paramConst.matchType.node_default: return this._getNodeBillsValue(param, nodeBills);
|
|
|
case paramConst.matchType.parent_default: return this._getNodeBillsValue(param, this._getParentBills(nodeBills));
|
|
|
+ case paramConst.matchType.child_gather: return this._getChildrenBillsValue(param, nodeBills);
|
|
|
case paramConst.matchType.code: return this._getCodeParamValue(param);
|
|
|
// to do 匹配属性
|
|
|
default: return undefined;
|