Przeglądaj źródła

右键插入功能

zhangweicheng 8 lat temu
rodzic
commit
50a87b9b65

+ 1 - 0
modules/main/models/bills.js

@@ -24,6 +24,7 @@ let billsSchema = new Schema({
     code: String,
     fullCode: String,
     type:Number,
+    isAdd:{type: Number,default:0},//1 true 0 false是否新增
     name: String,
     unit: String,
     quantity: String, // Decimal

+ 2 - 0
modules/ration_glj/models/ration_glj_temp.js

@@ -147,6 +147,8 @@ let billsSchema = new Schema({
     chapterID: Number,
     code: String,
     fullCode: String,
+    type:Number,
+    isAdd:{type: Number,default:0},//1 true 0 false是否新增
     name: String,
     unit: String,
     quantity: String, // Decimal

+ 2 - 3
web/building_saas/glj/js/project_glj_spread.js

@@ -48,9 +48,8 @@ ProjectGLJSpread.prototype.init = function () {
         {name: 'ID', field: 'id', visible: false},
         {name: '类型', field: 'unit_price.type', visible: false},
         {name: '总消耗量', field: 'quantity', visible: true,width:100,decimalField:'glj.quantity'},
-        {name: '总消耗量', field: 'quantity', visible: true,width:100,decimalField:'glj.quantity'},
-        {name: '分部分项总消耗量', field: 'subdivisionQuantity', visible: true,width:100,decimalField:'glj.quantity'},
-        {name: '技术措施项目总消耗量', field: 'techQuantity', visible: true,width:100,decimalField:'glj.quantity'},
+        {name: '分部分项总消耗量', field: 'subdivisionQuantity', visible: false,width:100,decimalField:'glj.quantity'},
+        {name: '技术措施项目总消耗量', field: 'techQuantity', visible: false,width:100,decimalField:'glj.quantity'},
         {name: '定额价', field: "base_price", visible: true,width:70,decimalField:"glj.unitPrice",validator: 'number'},//这里feiedID设置是为了在计不计取价差的时候做显示用
         {name: '调整价', field: 'adjust_price', visible: true,width:70,decimalField:"glj.unitPrice"},
         {name: '市场价', field: "unit_price.market_price", visible: true, validator: 'number',width:70,decimalField:"glj.unitPrice"},

+ 36 - 4
web/building_saas/main/js/controllers/project_controller.js

@@ -54,17 +54,49 @@ ProjectController = {
         }
     },
     addRootBill:function (project, sheetController) {//添加大项费用
-        let newSource = null, newNode = null
-        newSource = project.Bills.insertBills(-1, project.mainTree.selected.source.getNextSiblingID(),true);
-        newNode = project.mainTree.insert(-1, project.mainTree.selected.getNextSiblingID());
+        if (!project || !sheetController) { return null; }
+        this.addSpecialBill(project, sheetController,null, null,true,billType.DXFY);
+    },
+    addFB:function(project, sheetController) {//添加分部
+        if (!project || !sheetController) { return null; }
+        let selected = project.mainTree.selected;
+        if(selected.parent==null&&isFlag(selected.data)&&selected.data.flagsIndex.fixed.flag==fixedFlag.SUB_ENGINERRING){//选中的是分部分项,则插入做为最后一个子项
+            this.addSpecialBill(project, sheetController,selected, null,true,billType.FB);
+        }
+        if(selected.parent){
+            this.addSpecialBill(project, sheetController,selected.parent, selected.nextSibling,true,billType.FB);
+        }
+
+    },
+    addFX:function(project, sheetController) {//添加分项
+        if (!project || !sheetController) { return null; }
+        let selected = project.mainTree.selected;
+        if(selected.data.type==billType.FB||(selected.parent==null&&isFlag(selected.data)&&selected.data.flagsIndex.fixed.flag==fixedFlag.SUB_ENGINERRING)){//选中的是分部或者是分部分项工程,则插入做为最后一个子项
+            this.addSpecialBill(project, sheetController,selected, null,true,billType.FX);
+        }
+        if(selected.parent){
+            if(selected.data.type==billType.FX){
+                this.addSpecialBill(project, sheetController,selected.parent, selected.nextSibling,true,billType.FX);
+            }
+        }
+    },
+    addSpecialBill(project,sheetController,parent,nextSibling,isUserAdd,type){
+        let newSource = null, newNode = null;
+        let b_nexID = nextSibling==null?-1:nextSibling.source.getID();//主树和清单树,对应的树节点ID不一样
+        let m_nexID = nextSibling==null?-1:nextSibling.getID();
+        let b_parent = parent==null?-1:parent.source.getID();
+        let m_parent = parent==null?-1:parent.getID();
+
+        newSource = project.Bills.insertSpecialBill(b_parent, b_nexID,isUserAdd,type);
+        newNode = project.mainTree.insert(m_parent,m_nexID);
         if (newNode) {
             newNode.source = newSource;
             newNode.sourceType = project.Bills.getSourceType();
             newNode.data = newSource.data;
             this.syncDisplayNewNode(sheetController, newNode);
         }
-
     },
+
     addRation: function (project, sheetController, rationType, std) {
         if (!project || !sheetController) { return; }
 

+ 34 - 5
web/building_saas/main/js/models/bills.js

@@ -150,15 +150,30 @@ var Bills = {
             }
             return updateData;
         };
-
-        bills.prototype.insertBills = function (parentId, nextSiblingId,isUserAdd) {//是否是用户新增的
+        bills.prototype.insertSpecialBill=function(parentId, nextSiblingId,isUserAdd,type){
             var insertData = this.tree.getInsertData(parentId, nextSiblingId);
             var that = this, newData = null;
             insertData.forEach(function (data) {
                 if (data.type === idTree.updateType.new) {
-                    if(isUserAdd==true){//如果是用户新增的,类型为1
-                        data.data.type = 1;
+                    if(isUserAdd==true){//如果是用户新增的
+                        data.data.isAdd = 1;
                     }
+                    data.data.type = type;
+                    newData = data.data;
+                }
+            });
+            this.project.pushNow('insertBills', [this.getSourceType(), this.project.projCounter()],
+                [ tools.coverseTreeUpdateData(insertData, this.project.ID()), this.getCounterData()]);
+            //project.pushNow('insertBills', ModuleNames.bills, tools.coverseTreeUpdateData(insertData));
+
+            this.datas.push(newData);
+            return this.tree.insertByData(newData,parentId, nextSiblingId);
+        };
+        bills.prototype.insertBills = function (parentId, nextSiblingId) {//是否是用户新增的
+            var insertData = this.tree.getInsertData(parentId, nextSiblingId);
+            var that = this, newData = null;
+            insertData.forEach(function (data) {
+                if (data.type === idTree.updateType.new) {
                     newData = data.data;
                 }
             });
@@ -367,7 +382,6 @@ var Bills = {
             let nodes = this.getLeavesBillNodes(techNode);
             return  _.map(nodes,"data.ID");
         };
-
         bills.prototype.getLeavesBillNodes = function (rnode) {//取该节点下的所有清单叶子节点
             let leaves = [];
             getLeaves(rnode,leaves);
@@ -385,6 +399,21 @@ var Bills = {
                 }
             }
         };
+        bills.prototype.getRootNode = function (node) {
+            if(node.parent){
+                return this.getRootNode(node.parent)
+            }else {
+                return node
+            }
+        };
+        bills.prototype.isFBFX = function (node) {//判读是否属于分部分项
+           let rootNode = this.getRootNode(node);
+            if(isFlag(rootNode.data)&&rootNode.data.flagsIndex.fixed.flag==fixedFlag.SUB_ENGINERRING){
+                return true
+            }else {
+                return false
+            }
+        };
         return new bills(project);
     }
 };

+ 12 - 0
web/building_saas/main/js/models/main_consts.js

@@ -175,3 +175,15 @@ const fixedFlag = {
 
 const gljKeyArray =['code','name','specs','unit','type'];
 const gljLibKeyArray =['code', 'name', 'specs', 'unit', 'gljType'];
+const billType ={
+    DXFY:1,//大项费用
+    FB:2,//分部
+    FX:3,//分项
+    BILL:4//清单
+};
+const billText = {
+    1:'费用',
+    2:'分部',
+    3:'分项',
+    4:'清单'
+};

+ 2 - 2
web/building_saas/main/js/models/ration.js

@@ -253,7 +253,7 @@ var Ration = {
             let updateData = [];
             for (let node of nodes) {
                 if (node.children.length > 0) {
-                    updateData = updateData.concat(this.getDeleteDataByBills[node.children]);
+                    updateData = updateData.concat(this.getDeleteDataByBill(node.children));
                 } else {
                     let rations = this.getBillsSortRation(node.getID());
                     for (let r of rations) {
@@ -266,7 +266,7 @@ var Ration = {
         ration.prototype.deleteByBills = function (nodes) {
             for (let node of nodes) {
                 if (node.children.length > 0) {
-                    this.deleteByBills([node.children]);
+                    this.deleteByBills(node.children);
                 } else {
                     let rations = this.getBillsSortRation(node.getID());
                     for (let r of rations) {

+ 15 - 14
web/building_saas/main/js/views/main_tree_col.js

@@ -6,7 +6,7 @@ let MainTreeCol = {
     getText: {
         subType: function (node) {
             if (node.sourceType === projectObj.project.Bills.getSourceType()) {
-                return '';
+                return billText[node.data.type];
                 // CSL, 2017-11-29
             } else if (node.sourceType === projectObj.project.Ration.getSourceType()) {
                 if (node.data.type == 1 || node.data.type == undefined)    // 兼容旧定额
@@ -38,7 +38,7 @@ let MainTreeCol = {
     readOnly: {
         // CSL, 2017-11-28
         subType: function (node) {
-            return (node.data.type != 2 && node.data.type != 3 && !MainTreeCol.readOnly.glj(node)) || (node.data.type == rationType.gljRation && MainTreeCol.readOnly.non_editSubType(node));
+            return MainTreeCol.readOnly.bills(node)||(node.data.type != 2 && node.data.type != 3 && !MainTreeCol.readOnly.glj(node)) || (node.data.type == rationType.gljRation && MainTreeCol.readOnly.non_editSubType(node));
         },
         calcProgramName: function (node) {
             if (
@@ -170,19 +170,20 @@ let MainTreeCol = {
 
         // CSL, 2017-11-28
         subType: function (node) {
-            if (node.data.type == rationType.volumePrice || node.data.type == rationType.gljRation || node.sourceType === projectObj.project.ration_glj.getSourceType()) {
-                let VPType = sheetCommonObj.getDynamicCombo();
-                if (node.data.type == rationType.volumePrice)
-                    VPType.itemHeight(5).items(["人工", "材料", "机械", "主材", "设备"])
-                else if (node.data.type == rationType.gljRation || node.sourceType === projectObj.project.ration_glj.getSourceType())
-                    if (!MainTreeCol.readOnly.non_editSubType(node)) {
-                        VPType.itemHeight(3).items(["材料", "主材", "设备"]);
-                    } else {
-                        return null;
-                    }
-                return VPType;
+            if(node.sourceType!=projectObj.project.Bills.getSourceType()){
+                if (node.data.type == rationType.volumePrice || node.data.type == rationType.gljRation || node.sourceType === projectObj.project.ration_glj.getSourceType()) {
+                    let VPType = sheetCommonObj.getDynamicCombo();
+                    if (node.data.type == rationType.volumePrice)
+                        VPType.itemHeight(5).items(["人工", "材料", "机械", "主材", "设备"])
+                    else if (node.data.type == rationType.gljRation || node.sourceType === projectObj.project.ration_glj.getSourceType())
+                        if (!MainTreeCol.readOnly.non_editSubType(node)) {
+                            VPType.itemHeight(3).items(["材料", "主材", "设备"]);
+                        } else {
+                            return null;
+                        }
+                    return VPType;
+                }
             }
-            ;
         },
     },
     getEvent: function (eventName) {

+ 65 - 2
web/building_saas/main/js/views/project_view.js

@@ -491,7 +491,64 @@ var projectObj = {
                         ProjectController.addRootBill(project, controller);
                     },
                     visible: function(key, opt){
-                        return false;//project.mainTree.selected&&project.mainTree.selected.parent ==null;;
+                        return project.mainTree.selected&&project.mainTree.selected.parent==null;
+                    }
+                },
+                "insertFB": {
+                    name: "插入分部",
+                    icon: 'fa-sign-in',
+                    disabled: function () {
+                        let selected = project.mainTree.selected;
+                        if(selected.sourceType==project.Bills.getSourceType()){
+                            if(selected.data.type==billType.FB){
+                                return false;
+                            }
+                            if(isFlag(selected.data)&&selected.data.flagsIndex.fixed.flag==fixedFlag.SUB_ENGINERRING){//焦点行是分部分项工程
+                                if(selected.children.length>0){
+                                   return selected.children[0].data.type==billType.FX;//焦点行是分部分项工程,且子项是分项
+                                }
+                            }
+                        }
+                        return true;//除了清单,其它类型都只读
+                    },
+                    callback: function (key, opt) {
+                        ProjectController.addFB(project, controller);
+                    },
+                    visible: function(key, opt){
+                        return project.Bills.isFBFX(project.mainTree.selected );//不属于分部分项的话隐藏
+                    }
+                },
+                "insertFX": {
+                    name: "插入分项",
+                    icon: 'fa-sign-in',
+                    disabled: function () {
+                        let selected = project.mainTree.selected;
+                        if(selected.sourceType==project.Bills.getSourceType()){
+                            if(selected.data.type==billType.FX){//焦点行是分项,有效显示
+                                return false
+                            }
+                            if(selected.data.type==billType.FB){//点行是分部,
+                                if(selected.children.length>0){//且有子项,子项是分部,灰显。
+                                    return selected.children[0].data.type == billType.FB
+                                }else {
+                                    return false;
+                                }
+                            }
+                            if(isFlag(selected.data)&&selected.data.flagsIndex.fixed.flag==fixedFlag.SUB_ENGINERRING){//焦点行是分部分项工程
+                                if(selected.children.length>0){
+                                    return selected.children[0].data.type==billType.FB;//焦点行是分部分项工程,且子项是分部时灰显
+                                }else {
+                                    return false
+                                }
+                            }
+                        }
+                        return true;//除了清单,其它类型都只读
+                    },
+                    callback: function (key, opt) {
+                        ProjectController.addFX(project, controller);
+                    },
+                    visible: function(key, opt){
+                        return project.Bills.isFBFX(project.mainTree.selected );//不属于分部分项的话隐藏
                     }
                 },
                 "insertBills": {
@@ -501,8 +558,14 @@ var projectObj = {
                         return project.mainTree.selected ? project.mainTree.selected.sourceType !== project.Bills.getSourceType() : false;
                     },
                     callback: function (key, opt) {
+                        if(project.mainTree.selected.data.type == billType.DXFY){
+
+                        }
                         ProjectController.addBills(project, controller);
-                    }
+                    },
+                     visible: function(key, opt){
+                         return  project.Bills.isFBFX(project.mainTree.selected)==true?false:true;//不属于分部分项的话隐藏
+                     }
                 },
                 "insertRation": {
                     name: "插入定额",