|
|
@@ -9,27 +9,13 @@ let async = require('async');
|
|
|
const uuidV1 = require('uuid/v1');
|
|
|
const mongoose = require('mongoose');
|
|
|
let mainColLibModel = mongoose.model('std_main_col_lib');
|
|
|
+const billsUtil = require('../../../public/billsUtil');
|
|
|
|
|
|
import BillsTemplateModel from "../models/templates/bills_template_model";
|
|
|
import EngineeringLibModel from "../../users/models/engineering_lib_model";
|
|
|
|
|
|
module.exports = {
|
|
|
copyTemplateData: async function (property, newProjID, callback) {
|
|
|
- // 原ID引用更新成新ID引用
|
|
|
- function parseCalcBase(calcBase, uuidMapping) {
|
|
|
- const orgIDRefs = [...new Set(calcBase.match(/@\d+/g))];
|
|
|
- orgIDRefs.forEach(orgRef => {
|
|
|
- const orgID = orgRef.match(/\d+/)[0];
|
|
|
- const newID = uuidMapping[orgID] || null;
|
|
|
- // ID匹配不上则不转换这个引用
|
|
|
- if (!newID) {
|
|
|
- return;
|
|
|
- }
|
|
|
- const replaceStr = `@${newID}`;
|
|
|
- calcBase = calcBase.replace(new RegExp(`${orgRef}\\b`, 'g'), replaceStr);
|
|
|
- });
|
|
|
- return calcBase;
|
|
|
- }
|
|
|
async.parallel([
|
|
|
async function (cb) {
|
|
|
// 获取清单模板数据
|
|
|
@@ -50,7 +36,7 @@ module.exports = {
|
|
|
template.NextSiblingID = uuidMaping[template.NextSiblingID] ? uuidMaping[template.NextSiblingID] : -1;
|
|
|
const needToParseCalcBase = template.calcBase && reg.test(template.calcBase);
|
|
|
if (needToParseCalcBase) {
|
|
|
- template.calcBase = parseCalcBase(template.calcBase, uuidMaping);
|
|
|
+ template.calcBase = billsUtil.parseCalcBase(template.calcBase, uuidMaping);
|
|
|
}
|
|
|
});
|
|
|
billsData.insertData(billsDatas, callback);
|