Przeglądaj źródła

formatter of 2 digits of precision

Xiaopeng Zhang 6 miesięcy temu
rodzic
commit
a0119f009a
5 zmienionych plików z 67 dodań i 33 usunięć
  1. 6 0
      front/src/App2.js
  2. 7 3
      front/src/Qingdan.js
  3. 47 24
      front/src/Service.js
  4. 1 6
      front/src/editor.js
  5. 6 0
      front/src/utils.js

+ 6 - 0
front/src/App2.js

@@ -309,6 +309,8 @@ const MUI_X_PRODUCTS = [
     const qufeiCallback = (id, data) => {
       setOpen(true); 
       Service.applyFL(id, data).then(x=>{
+        Service.clearCache();
+        Service.setQufei(data);
         setOpen(false);
       });
     };
@@ -781,6 +783,10 @@ const MUI_X_PRODUCTS = [
     React.useEffect(
       () => {
         console.log(location);
+        Service.generateQufei(location["id"]).then(x=>{
+
+          Service.setQufei(x);
+          });
         Service.generateOutline2(location["id"]).then(x=>{
 
         setOutline(x);

+ 7 - 3
front/src/Qingdan.js

@@ -20,7 +20,7 @@ import { textRenderer, registerRenderer } from 'handsontable/renderers';
 import Button from '@mui/material/Button';
 import ButtonGroup from '@mui/material/ButtonGroup';
 import {extractFuzhu} from './utils';
-import {shanchu, undo, redo, quanbushanchu, danxiangdinge, updateDercj, changguidinge, handleBeizhu, huan, updateShuliang} from './editor';
+import {shanchu, undo, redo, danxiangdinge, updateDercj, changguidinge, handleBeizhu, huan, updateShuliang} from './editor';
 import { ConfigValueTooSmallError, HyperFormula } from 'hyperformula';
 import Backdrop from '@mui/material/Backdrop';
 import CircularProgress from '@mui/material/CircularProgress';
@@ -84,8 +84,12 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu/*后台
 
 
 
-     registerRenderer('customStylesRenderer', (hotInstance, TD, row, column, ...rest) => {
-         textRenderer(hotInstance, TD, row, column, ...rest);
+     registerRenderer('customStylesRenderer', (hotInstance, TD, row, column, prop, value, ...rest) => {
+          let newValue = value; 
+          if ((column == 10 || column == 11) && row > 0) {
+            newValue = Number(value).toFixed(2).toString();
+         }
+          textRenderer(hotInstance, TD, row, column, prop, newValue, ...rest);
          for (let i = 0; i < highlight.current.length; i++) {
           let entry = highlight.current[i];
           if (entry.row == row && entry.col == column) {

+ 47 - 24
front/src/Service.js

@@ -7,12 +7,38 @@ class Service{
         this.cache = [];
         this.memory = [];
         this.mem_pointer = -1;
+        this.qufei = [];
+        this.qufeiEntry = null;
     }
     
     ip() {
         return "http://127.0.0.1"
     }
 
+    clearCache() {
+        this.cache = [];
+        this.memory = [];
+        this.mem_pointer = -1;
+    }
+
+    setQufei(data) {
+        let result = [];
+        for(let i = 0; i < data[0]['children'].length; i++) {
+            let child = data[0]['children'][i];
+            for(let j = 0; j < child['children'].length; j++) {
+                let grandchild = child['children'][j];
+                //console.log(grandchild);
+                result.push(grandchild);
+            }
+        }
+        this.qufei = result;
+    }
+
+    setQufeiEntry(bh) {
+        this.qufeiEntry = this.qufei.filter(x=>x['key'] == bh)[0];
+
+    }
+
     processQingdanmingxi(mingxi) {
         this.cache = copy(mingxi);
         for(let i = 0; i < this.cache.length; i++) {
@@ -521,6 +547,7 @@ class Service{
         } else {
             const data = await response.json();
             this.processQingdanmingxi(data);
+            this.setQufeiEntry(bh);
             return copy(this.cache);
         }
         } else {
@@ -1003,25 +1030,6 @@ async generateQingdanTuijian(name, bh, bt, bm) {
 
     }
 
-    quanbushanchu(qdbm) {
-        let newData = this.cache.map(x=>{
-            if (x["清单编码"] == qdbm) {
-                let y = copy(x);
-                
-                y["__children"] = [];
-                return y;
-            } else {
-                return x;
-            }
-        });
-        let summarized = this.summarize(newData);
-        this.push_op(summarized);
-        /////////////////
-        this.cache = copy(summarized);
-        return copy(this.cache);
-
-
-    }
 
     updateDercj_(row, data, xuhao) {///change 一条定额 inplace, 汇总一条定额的rcj, xuhao is for rename
         console.log("data updated");
@@ -1067,7 +1075,7 @@ async generateQingdanTuijian(name, bh, bt, bm) {
                     }
                     de['dercj'][j][2] = data[j][2];//名称
                     de['dercj'][j][1] = data[j][1];//编号
-                    de['dercj'][j][5] = de['rcjdg'][j][5];
+                    de['dercj'][j][5] = de['rcjdg'][j][5];//单价
                     de['dercj'][j][10] =  origin;
                     de['dercj'][j][11] = Number(de['dercj'][j][5]) * origin;
                 }
@@ -1125,16 +1133,31 @@ async generateQingdanTuijian(name, bh, bt, bm) {
             if(qd["children"][i]['key'] == row) {
                 let desl = Number(qd["children"][i]['数量']);
                 let oldname = qd["children"][i]['清单编码'];
-                qd["children"][i]['综合单价'] = sum;
-                qd["children"][i]['合价'] = (sum * shuliang * desl);
+                
                 qd["children"][i]['辅材费'] = clf_sum;
                 qd["children"][i]['材料费'] = clf_sum;
                 qd["children"][i]['人工费'] = rgf_sum;
                 qd["children"][i]['主材费'] = 0;
                 qd["children"][i]['设备费'] = 0;
                 qd["children"][i]['机械费'] = jxf_sum;
-                qd["children"][i]['管理费'] = 0;
-                qd["children"][i]['利润'] = 0;
+                if (oldname.startsWith("D")) {//单项清单
+                    qd["children"][i]['管理费'] = 0;
+                    qd["children"][i]['利润'] = 0;
+                } else {
+                    if (this.qufeiEntry['备注'].length == 0) {
+                        //changuiqufei
+                        qd["children"][i]['管理费'] = (rgf_sum + jxf_sum) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
+                        qd["children"][i]['利润'] = (rgf_sum + jxf_sum) * Number(this.qufeiEntry['利润(%)']) / Number(100);
+                    } else {
+                        qd["children"][i]['管理费'] = (rgf_sum) * Number(this.qufeiEntry['管理费(%)']) / Number(100);
+                        qd["children"][i]['利润'] = (rgf_sum) * Number(this.qufeiEntry['利润(%)']) / Number(100);
+                    }
+                }
+                qd["children"][i]['综合单价'] = sum + qd["children"][i]['管理费'] + qd["children"][i]['利润'];
+                qd["children"][i]['合价'] = (qd["children"][i]['综合单价'] * shuliang * desl);
+                
+                
+                
                 qd["children"][i]["dercj"] = copy(data);
                 qd["children"][i]['清单编码'] = renameDingE(oldname, xuhao, huan);
 

+ 1 - 6
front/src/editor.js

@@ -31,12 +31,7 @@ export const shanchu = ( selectedRow) => {
 
 
 
-export const quanbushanchu = (hotRef, selectedRow) => {
-    let qdbm = hotRef.current?.hotInstance?.getData()[selectedRow.current][2];
-    
-    let newData = Service.quanbushanchu(qdbm);
-    return newData;
-  };
+
 
 
 export const danxiangdinge = (selectedRow) => {

+ 6 - 0
front/src/utils.js

@@ -79,6 +79,12 @@ export const match_target = (input ,target) => {
         } else {
             return false;
         }
+    } else if (target == 'J00000') {//普世机械费
+        if (input.startsWith('99')) {
+            return true;
+        } else {
+            return false;
+        }
     }
     return input == target;
 };