|
|
@@ -371,7 +371,7 @@ const INTERFACE_EXPORT_BASE = (() => {
|
|
|
}
|
|
|
|
|
|
// 处理单位工程数据
|
|
|
- function handleTenderData(tenders, templateData) {
|
|
|
+ function handleTenderData(tenders, templateData, rationValuationData, engineeringLib) {
|
|
|
tenders.forEach((tender, index) => {
|
|
|
tender.compilation = compilationData._id;
|
|
|
tender.userID = userID;
|
|
|
@@ -380,9 +380,6 @@ const INTERFACE_EXPORT_BASE = (() => {
|
|
|
tender.NextSiblingID = index === tenders.length - 1 ? -1 : templateData.projectBeginID + index + 2;
|
|
|
tender.projType = projectType.tender;
|
|
|
const featureTarget = _.cloneDeep(templateData.feature); // 必须拷贝出一份新数据,否则会被下一个单位工程覆盖
|
|
|
- const rationValuationData = JSON.parse(rationValuation)[0];
|
|
|
- const engineeringList = rationValuationData.engineering_list;
|
|
|
- const engineeringLib = engineeringList.find(item => item.lib.visible);
|
|
|
if (!engineeringLib) {
|
|
|
throw '不存在可用工程专业。';
|
|
|
}
|
|
|
@@ -392,6 +389,10 @@ const INTERFACE_EXPORT_BASE = (() => {
|
|
|
{ key: 'valuationType', value: '工程量清单' }, // 导入的时候以下项不一定有数据,但是需要自动生成
|
|
|
{ key: 'feeStandard', value: engineeringLib.lib.feeName },
|
|
|
];
|
|
|
+ const needEngineering = featureTarget && featureTarget.find(item => item.key === 'engineering');
|
|
|
+ if (needEngineering) {
|
|
|
+ featureSource.push({ key: 'engineering', value: engineeringLib.lib.name });
|
|
|
+ }
|
|
|
tender.property = {
|
|
|
rootProjectID: tender.ParentID,
|
|
|
region: '全省',
|
|
|
@@ -445,7 +446,20 @@ const INTERFACE_EXPORT_BASE = (() => {
|
|
|
}
|
|
|
const projectCount = 1 + importData.tenders.length;
|
|
|
// const feeName = compilationData.name === '安徽养护(2018)' ? '安徽养护' : '公路工程';
|
|
|
- const templateData = await ajaxPost('/pm/api/getImportTemplateData', { user_id: userID, valuationID, projectCount });
|
|
|
+ // 一些接口需要根据导入文件,匹配工程专业库
|
|
|
+ const rationValuationData = rationValuation && JSON.parse(rationValuation)[0]; // 只有工程量清单才能导入接口
|
|
|
+ if (!rationValuationData) {
|
|
|
+ throw '无法获取工程量清单计价数据';
|
|
|
+ }
|
|
|
+ const engineeringList = (rationValuationData.engineering_list || []).filter(item => item.lib.visible);
|
|
|
+ let engineeringLib = engineeringList[0];
|
|
|
+ if (importData.engineeringName && importData.feeName) {
|
|
|
+ const matchLibs = engineeringList.filter(item => item.lib && item.lib.name === importData.engineeringName);
|
|
|
+ engineeringLib = matchLibs.find(item => item.lib.feeName === importData.feeName) || matchLibs[0] || engineeringList[0];
|
|
|
+ }
|
|
|
+ const engineeringID = engineeringLib.engineering_id || null;
|
|
|
+
|
|
|
+ const templateData = await ajaxPost('/pm/api/getImportTemplateData', { user_id: userID, valuationID, engineeringID, projectCount });
|
|
|
if (!templateData) {
|
|
|
throw '无法获取有效模板数据。';
|
|
|
}
|
|
|
@@ -472,7 +486,7 @@ const INTERFACE_EXPORT_BASE = (() => {
|
|
|
};
|
|
|
delete importData.info;
|
|
|
// 处理单位工程数据
|
|
|
- handleTenderData(importData.tenders, templateData);
|
|
|
+ handleTenderData(importData.tenders, templateData, rationValuationData, engineeringLib);
|
|
|
console.log(importData);
|
|
|
}
|
|
|
|