|
@@ -8,6 +8,7 @@ let BillsTemplates = mongoose.model('temp_bills');
|
|
|
let BillsTemplateDAO = function(){};
|
|
let BillsTemplateDAO = function(){};
|
|
|
import BillsTemplateModel from "../../pm/models/templates/bills_template_model";
|
|
import BillsTemplateModel from "../../pm/models/templates/bills_template_model";
|
|
|
const uuidV1 = require('uuid/v1');
|
|
const uuidV1 = require('uuid/v1');
|
|
|
|
|
+const billsUtil = require('../../../public/billsUtil');
|
|
|
|
|
|
|
|
BillsTemplateDAO.prototype.getTemplate = function (type, callback) {
|
|
BillsTemplateDAO.prototype.getTemplate = function (type, callback) {
|
|
|
if (callback) {
|
|
if (callback) {
|
|
@@ -82,7 +83,9 @@ BillsTemplateDAO.prototype.getNeedfulTemplate = async function (templateLibID) {
|
|
|
}
|
|
}
|
|
|
//过滤掉不含清单固定类别的模板数据 (导入接口只包含必要的清单模板数据)
|
|
//过滤掉不含清单固定类别的模板数据 (导入接口只包含必要的清单模板数据)
|
|
|
let needfulDatas = billsDatas.filter(data => getFlag(data));
|
|
let needfulDatas = billsDatas.filter(data => getFlag(data));
|
|
|
- sortToTreeData(needfulDatas);
|
|
|
|
|
|
|
+ sortSeqToNextSibling(needfulDatas);
|
|
|
|
|
+ //sortToTreeData(needfulDatas);
|
|
|
|
|
+ billsUtil.resetTreeData(needfulDatas, uuidV1);
|
|
|
return needfulDatas;
|
|
return needfulDatas;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -152,10 +155,15 @@ function sortToTreeData(needfulData) {
|
|
|
for(let bill of needfulData){
|
|
for(let bill of needfulData){
|
|
|
uuidMaping[bill.ID] = uuidV1();
|
|
uuidMaping[bill.ID] = uuidV1();
|
|
|
}
|
|
}
|
|
|
|
|
+ const reg = /@\d+/;
|
|
|
needfulData.forEach(function (template) {
|
|
needfulData.forEach(function (template) {
|
|
|
template.ID = uuidMaping[template.ID] ? uuidMaping[template.ID] : -1;
|
|
template.ID = uuidMaping[template.ID] ? uuidMaping[template.ID] : -1;
|
|
|
template.ParentID = uuidMaping[template.ParentID] ? uuidMaping[template.ParentID] : -1;
|
|
template.ParentID = uuidMaping[template.ParentID] ? uuidMaping[template.ParentID] : -1;
|
|
|
template.NextSiblingID = uuidMaping[template.NextSiblingID] ? uuidMaping[template.NextSiblingID] : -1;
|
|
template.NextSiblingID = uuidMaping[template.NextSiblingID] ? uuidMaping[template.NextSiblingID] : -1;
|
|
|
|
|
+ const needToParseCalcBase = template.calcBase && reg.test(template.calcBase);
|
|
|
|
|
+ if (needToParseCalcBase) {
|
|
|
|
|
+ template.calcBase = billsUtil.parseCalcBase(template.calcBase, uuidMaping);
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|