Xiaopeng Zhang vor 6 Monaten
Ursprung
Commit
5d3d743915
5 geänderte Dateien mit 183 neuen und 32 gelöschten Zeilen
  1. 8 1
      front/src/App2.js
  2. 100 21
      front/src/Qingdan.js
  3. 2 4
      front/src/Qufei.js
  4. 6 6
      front/src/Service.js
  5. 67 0
      subdir/db.py

+ 8 - 1
front/src/App2.js

@@ -306,6 +306,13 @@ const MUI_X_PRODUCTS = [
       });
     };
 
+    const qufeiCallback = (id, data) => {
+      setOpen(true); 
+      Service.applyFL(id, data).then(x=>{
+        setOpen(false);
+      });
+    };
+
     const tihuanCallback = (row, col) => {
         setDopen(true);
         tihuanRowRef.current = row;
@@ -918,7 +925,7 @@ const MUI_X_PRODUCTS = [
                     autoWrapCol={false}
                     licenseKey="non-commercial-and-evaluation" // for non-commercial use only
                   />}
-            {!qingdan && !cuoshi && qufei && <Qufei id={location['id']}
+            {!qingdan && !cuoshi && qufei && <Qufei id={location['id']} qufeiCallback={qufeiCallback}
                   />}
 
             {!nest && qingdan && !cuoshi && !qufei &&  <TabContext value={value}>

+ 100 - 21
front/src/Qingdan.js

@@ -163,16 +163,7 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu/*后台
     React.useEffect(
         () => {
           Service.generateQingdanmingxi(name, bh, bt).then(x=>{
-          //console.log(x);
-          //let y = x.map(t=>{
-           //    t["操作"]=`<div style="text-align:center"> <button>全部删除</button></div>`;
-          //     return t;
-          //});
-          /*
-          let y = [{'操作' : '', '序号' : '', '清单编码' : '', '名称' : '', '项目特征' : '', '计算规则' : '', '单位' : '',
-           '数量' : '', '综合单价' : '', '合价' : '', '人工费' : '', '主材费' : '', '设备费' : '',
-            '辅材费' : '', '材料费' : '', '机械费' : '', '管理费' : '', '利润' : '',
-             '暂估价' : '', '综合人工工日' : '', '备注' : '',  'key' : '1'}]; */
+          //切换清单将重置缓存和操作栈
             
           setDetail(x);
           detailRef.current = x;
@@ -654,17 +645,105 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu/*后台
                                       
                               }
                          },
-                         { dataIndex: '综合单价' ,   title : '综合单价'  ,   key : '综合单价'     , width : 100        },
-                         { dataIndex: '合价'   ,      title : '合价'   ,      key : '合价'        , width : 100         },
-                         { dataIndex: '人工费'  ,     title : '人工费'  ,     key : '人工费'      , width : 100         },
-                         { dataIndex: '主材费'  ,     title : '主材费'  ,     key : '主材费'      , width : 100         },
-                         { dataIndex: '设备费'  ,     title : '设备费'  ,     key : '设备费'      , width : 100         },
-                         { dataIndex: '辅材费'  ,     title : '辅材费'  ,     key : '辅材费'      , width : 100         },
-                         { dataIndex: '材料费'   ,    title : '材料费'  ,     key : '材料费'      , width : 100         },
-                         { dataIndex: '机械费'   ,    title : '机械费'  ,     key : '机械费'      , width : 100         },
-                         { dataIndex: '管理费'  ,     title : '管理费'  ,     key : '管理费'      , width : 100         },
-                         { dataIndex: '利润'   ,      title : '利润'   ,      key : '利润'        , width : 100         },
-                         { dataIndex: '暂估价'  ,     title : '暂估价'  ,     key : '暂估价'      , width : 100         },
+                         { dataIndex: '综合单价' ,   title : '综合单价'  ,   key : '综合单价'     , width : 100  ,
+                             render: (text, record) => {
+                              let temp = Number(text);
+                              let temp2 = temp.toFixed(2);
+                              let temp3 = temp2.toString();
+                              return ( <plaintext>{temp3}</plaintext> );
+
+                             }
+                         },
+                         { dataIndex: '合价'   ,      title : '合价'   ,      key : '合价'        , width : 100  ,
+                         render: (text, record) => {
+                              let temp = Number(text);
+                              let temp2 = temp.toFixed(2);
+                              let temp3 = temp2.toString();
+                              return ( <plaintext>{temp3}</plaintext> );
+
+                             }
+                         },
+                         { dataIndex: '人工费'  ,     title : '人工费'  ,     key : '人工费'      , width : 100     ,
+                         render: (text, record) => {
+                              let temp = Number(text);
+                              let temp2 = temp.toFixed(2);
+                              let temp3 = temp2.toString();
+                              return ( <plaintext>{temp3}</plaintext> );
+
+                             }
+                         },
+                         { dataIndex: '主材费'  ,     title : '主材费'  ,     key : '主材费'      , width : 100    ,
+                         render: (text, record) => {
+                              let temp = Number(text);
+                              let temp2 = temp.toFixed(2);
+                              let temp3 = temp2.toString();
+                              return ( <plaintext>{temp3}</plaintext> );
+
+                             }
+                         },
+                         { dataIndex: '设备费'  ,     title : '设备费'  ,     key : '设备费'      , width : 100   ,
+                         render: (text, record) => {
+                              let temp = Number(text);
+                              let temp2 = temp.toFixed(2);
+                              let temp3 = temp2.toString();
+                              return ( <plaintext>{temp3}</plaintext> );
+
+                             }
+                         },
+                         { dataIndex: '辅材费'  ,     title : '辅材费'  ,     key : '辅材费'      , width : 100   ,
+                         render: (text, record) => {
+                              let temp = Number(text);
+                              let temp2 = temp.toFixed(2);
+                              let temp3 = temp2.toString();
+                              return ( <plaintext>{temp3}</plaintext> );
+
+                             }
+                         },
+                         { dataIndex: '材料费'   ,    title : '材料费'  ,     key : '材料费'      , width : 100  ,
+                         render: (text, record) => {
+                              let temp = Number(text);
+                              let temp2 = temp.toFixed(2);
+                              let temp3 = temp2.toString();
+                              return ( <plaintext>{temp3}</plaintext> );
+
+                             }
+                         },
+                         { dataIndex: '机械费'   ,    title : '机械费'  ,     key : '机械费'      , width : 100     ,
+                         render: (text, record) => {
+                              let temp = Number(text);
+                              let temp2 = temp.toFixed(2);
+                              let temp3 = temp2.toString();
+                              return ( <plaintext>{temp3}</plaintext> );
+
+                             }
+                         },
+                         { dataIndex: '管理费'  ,     title : '管理费'  ,     key : '管理费'      , width : 100    ,
+                         render: (text, record) => {
+                              let temp = Number(text);
+                              let temp2 = temp.toFixed(2);
+                              let temp3 = temp2.toString();
+                              return ( <plaintext>{temp3}</plaintext> );
+
+                             }
+                         },
+                         { dataIndex: '利润'   ,      title : '利润'   ,      key : '利润'        , width : 100  ,
+                         render: (text, record) => {
+                              let temp = Number(text);
+                              let temp2 = temp.toFixed(2);
+                              let temp3 = temp2.toString();
+                              return ( <plaintext>{temp3}</plaintext> );
+
+                             }
+                         },
+                         { dataIndex: '暂估价'  ,     title : '暂估价'  ,     key : '暂估价'      , width : 100 ,
+                         render: (text, record) => {
+                              let temp = Number(text);
+                              let temp2 = temp.toFixed(2);
+                              let temp3 = temp2.toString();
+                              return ( <plaintext>{temp3}</plaintext> );
+
+                             }
+                         },
                          { dataIndex: '综合人工工日', title : '综合人工工日', key : '综合人工工日', width : 100         },
                          { dataIndex: '备注'     ,    title : '备注'   ,      key : '备注'        , width : 100         },
                          

+ 2 - 4
front/src/Qufei.js

@@ -23,7 +23,7 @@ import Button from '@mui/material/Button';
 
 import {copy} from './utils';
 
-export default function Qufei({id}) {
+export default function Qufei({id, qufeiCallback}) {
     
   const [detail, setDetail] = React.useState([
     {"序号": null, "清单编码" : null, "名称" : null,"项目特征" : null,
@@ -54,9 +54,7 @@ const [selectedRowKeys, setSelectedRowKeys] = React.useState([]);
 const apply = () => {
   let checked = check(detail);
   if (checked) {
-    Service.applyFL(id, detail).then(x=>{
-
-    });
+    qufeiCallback(id, detail);
   }
 };
 

+ 6 - 6
front/src/Service.js

@@ -1125,14 +1125,14 @@ 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.toFixed(2);
-                qd["children"][i]['合价'] = (sum * shuliang * desl).toFixed(2);
-                qd["children"][i]['辅材费'] = clf_sum.toFixed(2);
-                qd["children"][i]['材料费'] = clf_sum.toFixed(2);
-                qd["children"][i]['人工费'] = rgf_sum.toFixed(2);
+                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.toFixed(2);
+                qd["children"][i]['机械费'] = jxf_sum;
                 qd["children"][i]['管理费'] = 0;
                 qd["children"][i]['利润'] = 0;
                 qd["children"][i]["dercj"] = copy(data);

+ 67 - 0
subdir/db.py

@@ -716,5 +716,72 @@ async def applyFL(client, id, data):
     collection = db["qufei"]
     
     await collection.replace_one({"biao_id": id}, {"biao_id": id, "qufei": data})
+    collection = db['qdxm']
+    xm = data[0]
+    for dxgc in xm["children"]:
+        for dwgc in dxgc["children"]:
+            bh = dwgc['key']
+            glf = float(dwgc['管理费(%)'])
+            lr = float(dwgc['利润(%)'])
+            bz = dwgc['备注']
+            ##print(bh+glf+lr+bz)
+            async for post in collection.find({'biao_id': id, "Dwgcbh": bh}):
+                rgfs = float(post['人工费'])
+                clfs = float(post['材料费'])
+                jxfs = float(post['机械费'])
+                sl = float(post['数量'])
+                if rgfs < 0.0001 and clfs < 0.0001 and jxfs < 0.0001:
+                    continue
+                danxiang = False
+                
+                for child in post['__children']:
+                    bm = child['清单编码']
+                    if bm.startswith("D"):
+                        danxiang = True
+                        break
+                    rgf = float(child['人工费'])
+                    clf = float(child['材料费'])
+                    jxf = float(child['机械费'])
+                    zhdj = float(child['综合单价'])
+                    sl_ = float(child['数量'])
+                    if len(bz) == 0:
+                        ##常规计算
+                        child['管理费'] = (rgf + jxf) * glf / float(100)
+                        child['利润'] = (rgf + jxf) * lr / float(100)
+                        child['综合单价'] = rgf + clf + jxf + child['管理费'] + child['利润']
+                        child['合价'] = sl * sl_ * child['综合单价'] 
+
+                    else:
+                        child['管理费'] = (rgf) * glf / float(100)
+                        child['利润'] = (rgf) * lr / float(100)
+                        child['综合单价'] = rgf + clf + jxf + child['管理费'] + child['利润']
+                        child['合价'] = sl * sl_ * child['综合单价'] 
+                if not danxiang:
+                    if len(bz) == 0:
+                    ##常规计算
+                        post['管理费'] = (rgfs + jxfs) * glf / float(100)
+                        post['利润'] = (rgfs + jxfs) * lr / float(100)
+                        post['综合单价'] = rgfs + clfs + jxfs + post['管理费'] + post['利润']
+                        post['合价'] = sl * post['综合单价'] 
+                        if post['清单编码'] == "010101001001":
+                            print(post['人工费'])
+                            print(post['材料费'])
+                            print(post['机械费'])
+                            print(post['管理费'])
+                            print(post['利润'])
+                            print(post['综合单价'])
+                            print(sl)
+                            print(post['合价'])
+
+                    else:
+                        post['管理费'] = (rgfs) * glf / float(100)
+                        post['利润'] = (rgfs) * lr / float(100)
+                        post['综合单价'] = rgfs + clfs + jxfs + post['管理费'] + post['利润']
+                        post['合价'] = sl * post['综合单价'] 
+                
+
+                await collection.replace_one({'_id': post['_id']}, post )
+
+
 
     return {"result": "ok"}