瀏覽代碼

support danxiangdinge

Xiaopeng Zhang 6 月之前
父節點
當前提交
3e2bc7228f
共有 3 個文件被更改,包括 161 次插入31 次删除
  1. 17 6
      front/src/Qingdan.js
  2. 142 23
      front/src/Service.js
  3. 2 2
      front/src/editor.js

+ 17 - 6
front/src/Qingdan.js

@@ -316,6 +316,16 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
         setValue(newValue);
       };
 
+      const afterChange = (changes, source) => {
+          if (changes == null) {
+
+          } else {
+          
+          let newData = updateDercj(selectedRowKeys[0], hotRcjRef.current?.hotInstance?.getData());
+          setDetail(newData);
+          }
+        };
+
       const afterUpdateData = (x, initial, source)=>{
           
               console.log(source);
@@ -480,6 +490,8 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
                       && newData.filter(x=>x["children"].filter(y=>y['key']==selectedRowKeys[0]).length > 0).length == 0) {
                          setSelectedRowKeys([]);
                          handleSelection([]);
+                     } else {
+                         handleSelection(selectedRowKeys);
                      }
                       
                       }}
@@ -491,6 +503,8 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
                       && newData.filter(x=>x["children"].filter(y=>y['key']==selectedRowKeys[0]).length > 0).length == 0) {
                          setSelectedRowKeys([]);
                          handleSelection([]);
+                     } else {
+                         handleSelection(selectedRowKeys);
                      }
                       
                       }}
@@ -529,8 +543,8 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
                     pagination={{ position: ['none', 'none'] }}
                     columns = {[
                          
-                         { dataIndex: '操作',        title : '操作',        key : '操作'          , width : 100 , fixed: 'left'   },
-                         { dataIndex: '序号'  ,       title : '序号'   ,      key : '序号'        , width : 100   , fixed: 'left'      },
+                         { dataIndex: '操作',        title : '操作',        key : '操作'          , width : 50 , fixed: 'left'   },
+                         { dataIndex: '序号'  ,       title : '序号'   ,      key : '序号'        , width : 50   , fixed: 'left'      },
                          { dataIndex: '清单编码'  ,   title : '清单编码' ,    key : '清单编码'    , width : 100     , fixed: 'left'    },
                          { dataIndex: '名称'   ,      title : '名称'  ,       key : '名称'        , width : 100         },
                          { dataIndex: '项目特征' ,    title : '项目特征' ,    key : '项目特征'    , width : 300         },
@@ -600,10 +614,7 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
                              autoWrapRow={false}
                              autoWrapCol={false}
                              ref = {hotRcjRef}
-                             afterChange={(changes, source) => {
-                              //console.log(hotRcjRef.current?.hotInstance?.getData());
-                              updateDercj(hotRcjRef.current?.hotInstance?.getData());
-                            }}
+                             afterChange={afterChange}
                              licenseKey="non-commercial-and-evaluation" // for non-commercial use only
                            />
 

+ 142 - 23
front/src/Service.js

@@ -563,7 +563,7 @@ class Service{
         }
         let qd = this.cache.filter(x=>x["清单编码"] == qdbm)[0];
         let de = qd["children"].filter(x=>x["清单编码"]==debm)[0];
-        return de["dercj"];
+        return copy(de["dercj"]);
         
         
           
@@ -773,6 +773,84 @@ async generateQingdanTuijian(name, bh, bt, bm) {
         }
     }
 
+
+
+
+    ///////////////////////////////////editor//////////////////////////////////
+
+
+    summarize_one(qd) {
+        let dict = {};
+        for(let i = 0; i < qd["children"].length; i++) {
+            let de = qd["children"][i];
+            let dercj = de['dercj'];
+            for (let j = 1; j < dercj.length; j++) {
+                let hl = dercj[j];
+                let a = hl[1];//"人材机编码", 
+                let b = a.concat(hl[2]);//"名称", 
+                let c = b.concat(hl[4]);// "单位"
+                if (dict.hasOwnProperty(c)) {
+                    dict[c].push(hl);
+                } else {
+                    dict[c] = [hl];
+                }
+
+            }
+        }
+        let result = [];
+        for(const key in dict) {
+            let list = dict[key];
+            let sum = 0;
+            let danjia = Number(list[0][5]);
+            for (let i =0 ;i < list.length; i++) {
+                sum += Number(list[i][10]);
+            }
+            let entry = [list[0][0], list[0][1], list[0][2], list[0][3], list[0][4], danjia,
+             list[0][6], list[0][7], list[0][8], list[0][9], sum, sum * danjia, list[0][12],
+             list[0][13], list[0][14], list[0][15]
+             ];
+             result.push(entry);
+
+        }
+        let gongri = 0;
+        for(let i = 0; i < result.length; i++) {
+            if (result[i][4] == '工日') {
+                gongri += result[i][10];
+            }
+        }
+        result.sort((a, b) => Number(a[8]) - Number(b[8]));
+        qd['rcj'] = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地", 
+        "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]].concat(result);
+        qd["综合人工工日"] = gongri;
+        qd['综合单价'] = 0;
+        qd['合价'] = 0;
+        qd['人工费'] = 0;
+        qd['主材费'] = 0;
+        qd['设备费'] = 0;
+        qd['辅材费'] = 0;
+        qd['材料费'] = 0;
+        qd['机械费'] = 0;
+        qd['管理费'] = 0;
+        qd['利润'] = 0;
+        for(let i = 0; i < qd["children"].length; i++) {
+            qd['综合单价'] += Number(qd['children'][i]['数量']) * Number(qd['children'][i]['综合单价']);
+            qd['合价'] += Number(qd['children'][i]['合价']);
+            qd['人工费'] += Number(qd['children'][i]['数量']) * Number(qd['children'][i]['人工费']);
+            qd['主材费'] += Number(qd['children'][i]['数量']) * Number(qd['children'][i]['主材费']);
+            qd['设备费'] += Number(qd['children'][i]['数量']) * Number(qd['children'][i]['设备费']);
+            qd['辅材费'] += Number(qd['children'][i]['数量']) * Number(qd['children'][i]['辅材费']);
+            qd['材料费'] += Number(qd['children'][i]['数量']) * Number(qd['children'][i]['材料费']);
+            qd['机械费'] += Number(qd['children'][i]['数量']) * Number(qd['children'][i]['机械费']);
+            qd['管理费'] += Number(qd['children'][i]['数量']) * Number(qd['children'][i]['管理费']);
+            qd['利润'] += Number(qd['children'][i]['数量']) * Number(qd['children'][i]['利润']);   
+        }
+
+        return qd;
+    }
+    summarize(data) {
+        return data.map(x=>this.summarize_one(x));
+    }
+
     push_op(newData) {
         if(this.memory.length == this.mem_pointer + 1) {
             this.memory.push(copy(newData));
@@ -791,7 +869,7 @@ async generateQingdanTuijian(name, bh, bt, bm) {
             let newData = this.memory[this.mem_pointer - 1];
             this.mem_pointer = this.mem_pointer - 1;
             this.cache = copy(newData);
-            return newData;
+            return copy(newData);
            
         }
 
@@ -803,7 +881,7 @@ async generateQingdanTuijian(name, bh, bt, bm) {
             let newData = this.memory[this.mem_pointer + 1];
             this.mem_pointer = this.mem_pointer + 1;
             this.cache = copy(newData);
-            return newData;
+            return copy(newData);
             }
 
         return copy(this.cache);
@@ -822,11 +900,11 @@ async generateQingdanTuijian(name, bh, bt, bm) {
                     return x;
                 }
             });
-            //////////push op
-            this.push_op(newData);
-            /////////////////
-            this.cache = copy(newData);
-            return newData;
+            let summarized = this.summarize(newData);
+            this.push_op(summarized);
+             /////////////////
+             this.cache = copy(summarized);
+            return copy(this.cache);
 
         } else {
             let qd = this.cache.filter(x=>x["children"].filter(y=>y['key'] == key).length > 0)[0];
@@ -842,11 +920,11 @@ async generateQingdanTuijian(name, bh, bt, bm) {
                     return x;
                 }
             });
-            //////////push op
-        this.push_op(newData);
-        /////////////////
-        this.cache = copy(newData);
-        return newData;
+            let summarized = this.summarize(newData);
+            this.push_op(summarized);
+            /////////////////
+            this.cache = copy(summarized);
+            return copy(this.cache);
         }
         
         
@@ -865,17 +943,57 @@ async generateQingdanTuijian(name, bh, bt, bm) {
                 return x;
             }
         });
-        //////////push op
-        this.push_op(newData);
+        let summarized = this.summarize(newData);
+        this.push_op(summarized);
         /////////////////
-        this.cache = copy(newData);
-        return newData;
+        this.cache = copy(summarized);
+        return copy(this.cache);
 
 
     }
 
-    updateDercj(row, change) {
-        //this.cache[row]
+    updateDercj(row, data) {
+        console.log("data updated");
+        console.log(this.cache);
+        let sum = 0;
+        for(let i = 1; i < data.length; i++) {
+            sum += Number(data[i][11]);//11-> hejia
+        }
+        console.log("sum=".concat(sum));
+        let qd = this.cache.filter(x=>x["children"].filter(y=>y['key']==row).length > 0)[0];
+        let shuliang = Number(qd['数量']);
+        for(let i = 0; i< qd["children"].length; i++) {
+            if(qd["children"][i]['key'] == row) {
+                qd["children"][i]['综合单价'] = sum;
+                qd["children"][i]['合价'] = sum * shuliang;
+                qd["children"][i]['辅材费'] = sum;
+                qd["children"][i]['材料费'] = sum;
+                qd["children"][i]['人工费'] = 0;
+                qd["children"][i]['主材费'] = 0;
+                qd["children"][i]['设备费'] = 0;
+                qd["children"][i]['机械费'] = 0;
+                qd["children"][i]['管理费'] = 0;
+                qd["children"][i]['利润'] = 0;
+                qd["children"][i]["dercj"] = copy(data);
+                for (let j = 1; j < qd["children"][i]["dercj"].length; j++) {
+                    qd["children"][i]["dercj"][j][11] = "=F2*K2";
+                }
+
+            }
+        }
+        let newData = this.cache.map(x=>{
+            if (x['key'] == qd['key']) {
+                return qd;
+            } else {
+                return x;
+            }
+        });
+        let summarized = this.summarize(newData);
+        this.push_op(summarized);
+        /////////////////
+        this.cache = copy(summarized);
+        return copy(this.cache);
+
 
     }
 
@@ -915,10 +1033,11 @@ async generateQingdanTuijian(name, bh, bt, bm) {
 
                 
             });
-
-            this.cache = copy(this.cache);
-            this.push_op(copy(this.cache));
-            return [true, this.cache];
+            let summarized = this.summarize(this.cache);
+            this.push_op(summarized);
+            this.cache = copy(summarized);
+            
+            return [true, copy(this.cache)];
         } else {
             return [false,null];
         }

+ 2 - 2
front/src/editor.js

@@ -43,8 +43,8 @@ export const danxiangdinge = (selectedRow) => {
     return Service.danxiangdinge(selectedRow);
 };
 
-export const updateDercj = (row, change) => {
-    Service.updateDercj(row, change);
+export const updateDercj = (row, data) => {
+    return Service.updateDercj(row, data);
 
 };