Quellcode durchsuchen

定额库编辑器-导出内部数据时,多加一列“工作内容”、一列“附注”,同样导入内部数据时更新这两列文本。

zhongzewei vor 6 Jahren
Ursprung
Commit
dd904168a8
1 geänderte Dateien mit 39 neuen und 10 gelöschten Zeilen
  1. 39 10
      modules/ration_repository/models/ration_item.js

+ 39 - 10
modules/ration_repository/models/ration_item.js

@@ -10,6 +10,7 @@ let rationRepositoryDao = require('./repository_map');
 const scMathUtil = require('../../../public/scMathUtil').getUtil();
 const rationItemModel = mongoose.model('std_ration_lib_ration_items');
 const stdRationLibModel = mongoose.model('std_ration_lib_map');
+const stdRationSectionModel = mongoose.model('std_ration_lib_ration_chapter_trees');
 const compleRationModel = mongoose.model('complementary_ration_items');
 import STDGLJListModel from '../../std_glj_lib/models/gljModel';
 
@@ -939,17 +940,20 @@ rationItemDAO.prototype.exportExcelData = async function(rationRepId) {
     const condition = {
         rationRepId: rationRepId
     };
-    // @todo 限制导出的数量以防内存溢出
-    const rationDataList = await this.getRationItemByCondition(condition, ['name', 'code', 'ID', 'sectionId', 'feeType', 'caption', 'basePrice']);
+    const rationDataList = await this.getRationItemByCondition(condition, ['name', 'code', 'ID', 'sectionId', 'feeType', 'caption', 'basePrice', 'jobContent', 'annotation']);
 
     // 整理数据
     let rationData = [];
     for (const tmp of rationDataList) {
         const sectionId = tmp.sectionId <= 0 || tmp.sectionId === undefined ? null : tmp.sectionId;
         const feeType = tmp.feeType === '' || tmp.feeType === undefined ? null : tmp.feeType;
-        const ration = [sectionId, feeType, tmp.ID, tmp.code, tmp.name, tmp.caption, tmp.basePrice];
+        const ration = [sectionId, feeType, tmp.ID, tmp.code, tmp.name, tmp.caption, tmp.basePrice, tmp.jobContent, tmp.annotation];
         rationData.push(ration);
     }
+    const excelData = [['树ID', '取费专业', '定额ID', '定额编码', '定额名', '定额显示名称', '基价', '工作内容', '附注']];
+    excelData.push.apply(excelData, rationData);
+
+    return excelData;
     //根据编号排序,优先级:number-number-..., number, Anumber....
     /*let regConnector = /-/g,
         regLetter = /[a-z,A-Z]/g,
@@ -1013,10 +1017,10 @@ rationItemDAO.prototype.exportExcelData = async function(rationRepId) {
         }
         return rst;
     });*/
-    const excelData = [['树ID', '取费专业', '定额ID', '定额编码', '定额名', '定额显示名称', '基价']];
+    /*const excelData = [['树ID', '取费专业', '定额ID', '定额编码', '定额名', '定额显示名称', '基价']];
     excelData.push.apply(excelData, rationData);
 
-    return excelData;
+    return excelData;*/
 };
 
 /**
@@ -1030,12 +1034,17 @@ rationItemDAO.prototype.batchUpdateSectionIdFromExcel = async function(data) {
         return false;
     }
     // 批量执行update
-    let bulkOprs = [];
+    let bulkOprs = [],
+        sectionIDs = [];
     for (const tmp of data) {
         let rationId = parseInt(tmp[2]);
         rationId = isNaN(rationId) || rationId <= 0 ? 0 : rationId;
         let sectionId = parseInt(tmp[0]);
         sectionId = isNaN(sectionId) || sectionId <= 0 ? 0 : sectionId;
+        if (sectionId <= 0 || rationId <= 0) {
+            continue;
+        }
+        sectionIDs.push(sectionId);
         // 取费专业
         let feeType = tmp[1] ? parseInt(tmp[1]) : null;
         feeType = isNaN(feeType) || feeType <= 0 ? null : feeType;
@@ -1043,15 +1052,35 @@ rationItemDAO.prototype.batchUpdateSectionIdFromExcel = async function(data) {
         name = name ? name : '';
         let caption = tmp[5];
         caption = caption ? caption : '';
-        if (sectionId <= 0 || rationId <= 0) {
-            continue;
-        }
-        bulkOprs.push({updateOne: {filter: {ID: rationId}, update: {$set: {sectionId: sectionId, feeType: feeType, name: name, caption: caption}}}});
+        let jobContent = tmp[7] ? tmp[7] : '';
+        let annotation = tmp[8] ? tmp[8] : '';
+        bulkOprs.push({updateOne: {
+            filter: {ID: rationId},
+            update: {$set: {
+                sectionId,
+                feeType,
+                name,
+                caption,
+                jobContent,
+                annotation
+            }}}
+        });
     }
     if(bulkOprs.length <= 0){
         throw '无有效数据(树ID、定额ID不为空、且为数值)';
     }
     await rationItemModel.bulkWrite(bulkOprs);
+    // 更新章节树工作内容、附注节点选项(全设置为ALL)
+    sectionIDs = Array.from(new Set(sectionIDs));
+    if (sectionIDs.length) {
+        await stdRationSectionModel.updateMany(
+            {ID: {$in: sectionIDs}},
+            {$set: {
+                jobContentSituation: 'ALL',
+                annotationSituation: 'ALL'
+            }}
+        )
+    }
 };
 
 module.exports = new rationItemDAO();