Pārlūkot izejas kodu

清单精灵插入定额,跳过清单下已有定额

zhongzewei 6 gadi atpakaļ
vecāks
revīzija
1045a28143

+ 1 - 0
modules/all_models/ration.js

@@ -52,6 +52,7 @@ let rationSchema = new Schema({
     isSubcontract: Boolean,                     // 是否分包
     installationKey:String,                   //用来记录安装增加费的关联字段
     // 定额特有属性:
+    stdID: Number,                            //来自的标准定额ID
     libID: Number,
     maskName: String,
     caption: String,

+ 2 - 0
modules/main/facade/ration_facade.js

@@ -120,6 +120,7 @@ async function insertNewRation(newData,defaultLibID,std,calQuantity) {//插入
         newData.caption = std.caption;
         newData.unit = std.unit;
         newData.libID = std.rationRepId;
+        newData.stdID = std.ID;
         newData.content = std.jobContent;
         newData.annotation = std.annotation;
         if (std.chapter) {
@@ -438,6 +439,7 @@ async function  updateRation(std,defaultLibID,rationID,billsItemID,projectID,cal
     ration.unit = std.unit;
     if (std.type === 'std') {
         ration.libID = std.rationRepId;
+        ration.stdID = std.ID;
     }
     ration.content = std.jobContent;
     ration.adjustState = '';

+ 28 - 6
web/building_saas/main/js/views/billsElf.js

@@ -252,7 +252,6 @@ const BillsElf = (function() {
     //清单焦点变换-清单精灵操作,获取清单前九位编码的标准清单清单精灵选项
     //@param {String}code @return {void}
     function billsSelElf(code) {
-        console.log('enterS');
         let elfSheet = elfItem.workBook.getActiveSheet();
         cleanData(elfSheet, elfItem.headers, -1);
         if (!code || code === '') {
@@ -634,7 +633,7 @@ const BillsElf = (function() {
         };
         return new OptionsCellType();
     }
-    //获取清单精灵生成的定额数据
+    //获取清单精灵生成的定额数据(跳过重复,不允许重复插入)
     //@return {Array}
     function getInsertElfRationData(){
         let rst = [];
@@ -645,17 +644,29 @@ const BillsElf = (function() {
         if(!tree){
             return rst;
         }
+        let mainSelected = projectObj.project.mainTree.selected;
+        let mainSelRationNodes = _.filter(mainSelected.children, function (c) {
+            return c.data && c.data.type === rationType.ration;
+        });
+        //原本清单存在此定额
+        function existTheRation(rationID) {
+            let r = _.find(mainSelRationNodes, function (node) {
+                return node.data && node.data.stdID && node.data.stdID == rationID;
+            });
+            return r;
+        }
+        //造价书当前选中清单下的定额
         for(let node of tree.items){
             for(let perChecked of node.data.optionChecked){
                 //选项直接是定额
-                if(perChecked.type === itemType.ration){
+                if(perChecked.type === itemType.ration && !existTheRation(perChecked.rationID)){
                     rst.push({itemQuery: {userID: userID, ID: perChecked.rationID}, rationType: rationType.ration});
                 }
                 //选项下子选项是定额
                 else {
                     let rationOpts = getOptions(perChecked, bills.selected.elf.datas);
                     for(let ration of rationOpts){
-                        if(ration.type === itemType.ration){
+                        if(ration.type === itemType.ration && !existTheRation(ration.rationID)){
                             rst.push({itemQuery: {userID: userID, ID: ration.rationID}, rationType: rationType.ration});
                         }
                     }
@@ -679,14 +690,25 @@ const BillsElf = (function() {
         if (!elfSelected || !elfSelected.data.optionChecked || !elfSelected.data.optionChecked[0]) {
             return rst;
         }
+        let mainSelected = projectObj.project.mainTree.selected;
+        let mainSelRationNodes = _.filter(mainSelected.children, function (c) {
+            return c.data && c.data.type === rationType.ration;
+        });
+        //原本清单存在此定额
+        function existTheRation(rationID) {
+            let r = _.find(mainSelRationNodes, function (node) {
+                return node.data && node.data.stdID && node.data.stdID == rationID;
+            });
+            return r;
+        }
         //选中的节点第一个选项时定额选项或第一个选项下的子选项时定额选项
         let firstOptionChecked = elfSelected.data.optionChecked[0];
-        if (firstOptionChecked.type === itemType.ration) {
+        if (firstOptionChecked.type === itemType.ration && !existTheRation(firstOptionChecked.rationID)) {
             rst.push({itemQuery: {userID: userID, ID: firstOptionChecked.rationID}, rationType: rationType.ration});
         } else {
             let rationOpts = getOptions(firstOptionChecked, bills.selected.elf.datas);
             for(let ration of rationOpts){
-                if(ration.type === itemType.ration){
+                if(ration.type === itemType.ration && !existTheRation(ration.rationID)){
                     rst.push({itemQuery: {userID: userID, ID: ration.rationID}, rationType: rationType.ration});
                     break;
                 }