Jelajahi Sumber

变更主材

zhongzewei 7 tahun lalu
induk
melakukan
bac68445df

+ 3 - 2
web/maintain/std_glj_lib/js/components.js

@@ -71,13 +71,14 @@ let componentOprObj = {
         }
     },
     setShowGljList: function (gljList, clearChecked) {
-        //初始为所有工料机,机械类型可添加机械组成物、机上人工,混凝土,砂浆、配合比可添加普通材料
+        //初始为所有工料机,机械类型可添加机械组成物、机上人工,混凝土,砂浆、配合比可添加普通材料, 主材只能添加没有组成物的主材
         let machineArr = [302, 303];
         let materialArr = [202, 203, 204];//混凝土、砂浆、配合比, 201普通材料
         let that = repositoryGljObj, me = componentOprObj;
         for(let i = 0; i < gljList.length; i++){
             if(that.currentGlj.gljType === 301 && machineArr.indexOf(gljList[i].gljType) !== -1 ||
-                materialArr.indexOf(that.currentGlj.gljType) !== -1 && gljList[i].gljType === 201){
+                materialArr.indexOf(that.currentGlj.gljType) !== -1 && gljList[i].gljType === 201||
+                that.currentGlj.gljType === 4 && gljList[i].gljType === 4 && (!gljList[i].component || gljList[i].component.length === 0) && gljList[i].ID !== that.currentGlj.ID){
                 let isExist = false;
                 for(let j = 0; j < that.currentComponent.length; j++){
                     if(that.currentComponent[j].ID === gljList[i].ID){

+ 22 - 11
web/maintain/std_glj_lib/js/glj.js

@@ -36,20 +36,11 @@ let repositoryGljObj = {
     currentCache: null,
     parentNodeIds: {},
     gljList: [],
-    allowComponent: [202, 203, 204, 301],//可带组成物类型:混凝土、砂浆、配合比、机械台班
-    componentGljType: [201, 302, 303],//可成为组成物的工料机类型: 普通材料、 机械组成物、 机上人工
+    allowComponent: [202, 203, 204, 301, 4],//可带组成物类型:混凝土、砂浆、配合比、机械台班
+    componentGljType: [201, 302, 303, 4],//可成为组成物的工料机类型: 普通材料、 机械组成物、 机上人工
     distTypeTree: null,//add
     setting: {
         owner: "glj",
-        /*header:[
-            {headerName:"编码",headerWidth:120,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
-            {headerName:"名称",headerWidth:260,dataCode:"name", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
-            {headerName:"规格型号",headerWidth:220,dataCode:"specs", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
-            {headerName:"单位",headerWidth:120,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
-            {headerName:"基价单价",headerWidth:120,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"},
-            {headerName:"类型",headerWidth:120,dataCode:"gljType", dataType: "String", hAlign: "center", vAlign: "center"},
-            {headerName:"调整系数",headerWidth:80,dataCode:"adjCoe", dataType: "Number", hAlign: "center", vAlign: "center"},
-        ],*/
         header:[
             {headerName:"编码",headerWidth:80,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
             {headerName:"名称",headerWidth:160,dataCode:"name", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
@@ -213,6 +204,26 @@ let repositoryGljObj = {
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.LeaveCell, me.onLeaveCell);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.SelectionChanged, me.onSelectionChanged);
     },
+
+    isDef: function (v) {
+        return v !== undefined && v !== null;
+    },
+
+    //成为了组成物,暂时只需要判断主材的
+    isComponent: function (gljId, gljList) {
+        for(let i = 0, len = gljList.length; i < len; i++){
+            let gljComponent = gljList[i].component;
+            if(gljList[i].gljType === 4 && this.isDef(gljComponent) && gljComponent.length > 0){
+                for(let j = 0, jLen = gljComponent.length; j < jLen; j++){
+                    if(gljComponent[j].ID === gljId){
+                        return true;
+                    }
+                }
+            }
+        }
+        return false;
+    },
+
     getCurrentComponent: function (gljComponent) {
         let me = repositoryGljObj, rst = [];
         for(let i = 0; i < gljComponent.length; i++){

+ 4 - 2
web/maintain/std_glj_lib/js/gljComponent.js

@@ -156,7 +156,7 @@ let gljComponentOprObj = {
                     //控制按钮是否可用
                     let insertDis = false,
                         delDis = false;
-                    if(!(that.currentGlj && that.allowComponent.indexOf(that.currentGlj.gljType) !== -1)){
+                    if(!(that.currentGlj && that.allowComponent.indexOf(that.currentGlj.gljType) !== -1) || (that.currentGlj.gljType === 4 && that.isComponent(that.currentGlj.ID, that.gljList))){
                         insertDis = true;
                     }
                     if(!that.currentGlj || typeof that.currentComponent === 'undefined' || (typeof that.currentComponent !== 'undefined' && target.row >= that.currentComponent.length)){//右键定位在有组成物的行,删除键才显示可用
@@ -219,6 +219,7 @@ let gljComponentOprObj = {
         if(thatRow < that.currentCache.length){
             that.currentGlj = that.currentCache[thatRow];
             if(me.setting.view.lockedCols.indexOf(args.col) !== -1 || that.allowComponent.indexOf(that.currentGlj.gljType) === -1 ||
+                (that.currentGlj.gljType === 4 && that.isComponent(that.currentGlj.ID, that.gljList)) ||
                 (args.col === 4 && (!that.currentComponent|| args.row >= that.currentComponent.length))){
                 args.cancel = true;
             }
@@ -355,9 +356,10 @@ let gljComponentOprObj = {
     },
     onClipboardPasting: function (sender, info) {
         let me = gljComponentOprObj;
+        let that = repositoryGljObj;
         let maxCol = info.cellRange.col + info.cellRange.colCount - 1;
         //复制的列数超过正确的列数,不可复制
-        if(info.cellRange.col !== 0 && info.cellRange.col !== 4 || info.cellRange.colCount > 1){
+        if(info.cellRange.col !== 0 && info.cellRange.col !== 4 || info.cellRange.colCount > 1 || (that.currentGlj.gljType === 4 && that.isComponent(that.currentGlj.ID, that.gljList))){
             args.cancel = true;
         }
     },