Xiaopeng Zhang 5 місяців тому
батько
коміт
50569fcd55
7 змінених файлів з 382 додано та 13 видалено
  1. 58 1
      src/App2.js
  2. 68 7
      src/Djcs3.js
  3. 3 0
      src/Qingdan3.js
  4. 134 2
      src/Service.js
  5. 106 0
      src/SimpleQingdan.js
  6. 3 3
      src/Tabulator.css
  7. 10 0
      src/editor.js

+ 58 - 1
src/App2.js

@@ -27,6 +27,7 @@ import Rcjhz from './Rcjhz';
 import Qtxm from './Qtxm';
 import Zlje from './Zlje';
 import Zygczgj from './Zygczgj';
+import SimpleQingdan from './SimpleQingdan';
 import Jrg from './Jrg';
 import Zcbfwf from './Zcbfwf';
 import Fbrgycl from './Fbrgycl';
@@ -73,7 +74,9 @@ import Tooltip from '@mui/material/Tooltip';
 
 
   export default function App2() {
-
+    const [azfySelect, setAzfySelect] = React.useState([]);
+    const [azfyConfirm, setAzfyConfirm] = React.useState(null);
+    const [azfybh, setAzfybh] = React.useState();
     const [updatetime, setUpdatetime] = React.useState(null);//tiaojia callback
     const [outline, setOutline] = React.useState([]);
     const [peibishu, setPeibishu] = React.useState([]);
@@ -124,6 +127,7 @@ import Tooltip from '@mui/material/Tooltip';
     const [dopen, setDopen] = React.useState(false);
 
     const [dopen2, setDopen2] = React.useState(false);
+    const [dopen3, setDopen3] = React.useState(false);
 
     const [dingeclick, setDingeclick] = React.useState(null);
     const [tihuanClick, setTihuanClick] = React.useState(null);
@@ -214,6 +218,16 @@ import Tooltip from '@mui/material/Tooltip';
       setDopen2(true);
     };
 
+    const azfycallback = (bh, dinge) => {
+      console.log(dinge);
+      setAzfybh(bh);
+      setDopen3(true);
+    };
+    const azfycallback2 = (table) => {
+      //console.log(table);
+      setAzfySelect(table.getSelectedData());
+    };
+
     const loadingCallback_djcs = () => {
       setOpen(true); 
       Service.save_djcs().then(x=>{
@@ -294,6 +308,16 @@ import Tooltip from '@mui/material/Tooltip';
       setDopen2(false);
     };
 
+    const handleClose3 = () => {
+      setDopen3(false);
+    };
+    const handleClose4 = () => {
+      console.log(azfySelect);
+      setAzfyConfirm(new Date());
+      setDopen3(false);
+      
+    };
+
 
     const handleGenerateSingleDingeXilie = (x) => {
       let res = JSON.parse(x);
@@ -1119,6 +1143,9 @@ import Tooltip from '@mui/material/Tooltip';
                          loadingCallback={loadingCallback_djcs}
                          dingeclick={dingeclick}
                          beizhuFK={beizhuFK}
+                         azfycallback={azfycallback}
+                         azfySelect={azfySelect}
+                         azfyConfirm={azfyConfirm}
 
 
                      />
@@ -1266,6 +1293,36 @@ import Tooltip from '@mui/material/Tooltip';
           
            </DialogContent>
          </Dialog>
+         <Dialog
+           onClose={handleClose3}
+           aria-labelledby="customized-dialog-title"
+           open={dopen3}
+           fullWidth={true}
+           maxWidth="xl"
+          >
+            <DialogTitle sx={{ m: 0, p: 2 }} id="customized-dialog-title">
+             选择清单项目
+            </DialogTitle>
+            <IconButton
+             aria-label="close"
+             onClick={handleClose3}
+             sx={(theme) => ({
+               position: 'absolute',
+               right: 8,
+               top: 8,
+               color: theme.palette.grey[500],
+             })}
+            >
+             <CloseIcon />
+            </IconButton>
+            <DialogContent dividers>
+            <SimpleQingdan  id={location["id"]} bh={azfybh} azfycallback={azfycallback2}></SimpleQingdan>
+          
+           </DialogContent>
+           <DialogActions>
+            <Button onClick={handleClose4}>确认</Button>
+           </DialogActions>
+         </Dialog>
             
         </Box>
     );

+ 68 - 7
src/Djcs3.js

@@ -16,7 +16,7 @@ import {TabulatorFull as Tabulator} from "tabulator-tables"; //import Tabulator
 import './Tabulator.css';
 import {extractFuzhu, match_target} from './utils';
 import Button from '@mui/material/Button';
-import {shanchu_djcs, undo_djcs, redo_djcs, danxiangdinge_djcs, updateDercj_djcs, changguidinge_djcs, handleBeizhu_djcs, huan, updateShuliang_djcs} from './editor';
+import {shanchu_djcs, undo_djcs, redo_djcs, danxiangdinge_djcs, updateDercj_djcs, changguidinge_djcs, handleBeizhu_djcs, huan, updateShuliang_djcs, azfy_djcs_eligible, azfy_djcs} from './editor';
 import {copy} from './utils';
 
 const {Column, HeaderCell, Cell} = Table;
@@ -28,7 +28,7 @@ function number_equal(a, b) {
      }
      return false;
 }
-export default function Djcs3({name, bh, rgde, jxde, clde, beizhu, beizhuFK, clickCallback, loadingCallback, dingeclick}) {
+export default function Djcs3({name, bh, rgde, jxde, clde, beizhu, beizhuFK, clickCallback, loadingCallback, dingeclick, azfycallback, azfySelect, azfyConfirm}) {
 
     
      var editCheck = function(cell){
@@ -55,6 +55,9 @@ export default function Djcs3({name, bh, rgde, jxde, clde, beizhu, beizhuFK, cli
           if (cell._cell.row.getData()['人材机编码'] == '31130104') {//
                return false;
           }
+          if (cell._cell.row.getData()['人材机编码'].includes('000FE')) {//
+               return false;
+          }
           return true;
       }
 
@@ -315,7 +318,7 @@ export default function Djcs3({name, bh, rgde, jxde, clde, beizhu, beizhuFK, cli
     };
    
     const highlight = React.useRef([]);
-
+    //const [azfyDe, setAzfyDe] = React.useState(null);
     
     const rgdeRef = React.useRef(null);
     const jxdeRef = React.useRef(null);
@@ -489,6 +492,43 @@ export default function Djcs3({name, bh, rgde, jxde, clde, beizhu, beizhuFK, cli
           beizhuFKRef.current = beizhuFK;
      }, [beizhuFK]
    );
+
+   React.useEffect(
+     () => {
+          console.log(dingeclick);
+          console.log(azfySelect);
+          if (dingeclick != null && selectedRowKeysTable.current != null && azfy_djcs_eligible(selectedRowKeysTable.current[0])) {
+               const [success, data, key] = azfy_djcs(selectedRowKeysTable.current[0], dingeclick, azfySelect);
+              myTable.current.deselectRow();
+                   
+                         myTable.current.updateData(data.filter(x=>x['key'] == selectedRowKeysTableParent.current)).then(function(){
+                              let getRow = myTable.current.getRows(); //get array of currently selected row components.
+                              let component = null;
+                              for(let i = 0; i < getRow.length; i++) {
+                                   let entry = getRow[i]._row.modules.dataTree.children;
+                                   for(let j = 0; j < entry.length; j++) {
+                                        let child = entry[j];
+                                        if(child.data['key'] == key) {
+                                             //console.log(child);
+                                             component = child.component;
+                                             break;
+                                        }
+                                        
+                                   }
+
+                              }
+                              
+                              component.select();
+                              handleSelect(component);
+
+                                   
+                               
+                          });
+                    
+                   
+          }
+     }, [azfyConfirm]
+   );
  
     React.useEffect(
         () => {
@@ -574,6 +614,7 @@ export default function Djcs3({name, bh, rgde, jxde, clde, beizhu, beizhuFK, cli
                             dataTree: false,
                             selectableRows:1, //make rows selectable
                             editTriggerEvent:"dblclick",
+                            renderVertical: "basic",
                             
                             columns: [ //Define Table Columns
                                          {title:"ID", field:"ID", width:80, headerSort:false, },
@@ -586,7 +627,7 @@ export default function Djcs3({name, bh, rgde, jxde, clde, beizhu, beizhuFK, cli
                                          {title:"供应厂商", field:"供应厂商", width:80, headerSort:false, },
                                          {title:"人材机类别", field:"人材机类别", width:120, headerSort:false, },
                                          {title:"甲供标志", field:"甲供标志", width:80 , headerSort:false, formatter:"textarea"},
-                                         {title:"含量", field:"含量", width:80 , headerSort:false, formatter:"money", formatterParams:{precision:4}, editor: "input", editable: editCheckRcj },
+                                         {title:"含量", field:"含量", width:120 , headerSort:false, formatter:"money", formatterParams:{precision:4}, editor: "input", editable: editCheckRcj },
                                          {title:"合价", field:"合价", width:80 , headerSort:false, formatter:"money"},
                                          {title:"暂估价标志", field:"暂估价标志", width:80 , headerSort:false, formatter:"textarea"},
                                          {title:"主要材料标志", field:"主要材料标志", width:100 , headerSort:false, formatter:"textarea"},
@@ -646,9 +687,26 @@ export default function Djcs3({name, bh, rgde, jxde, clde, beizhu, beizhuFK, cli
       React.useEffect(
           () => {
                let input = JSON.parse(dingeclick);
-               myTable.current.deselectRow();
-               //console.log(dingeclick);
-               if (selectedRowKeysTable.current.length > 0 ) {
+               if (input == null) {
+                    return;
+               }
+               if (!input.hasOwnProperty("DEBH")) {
+                    return;
+               }
+               let bh_ = Object.values(input['DEBH'])[0];
+               if (bh_.includes('-F')) {
+                    if (selectedRowKeysTable.current.length > 0 ) {
+                         if (azfy_djcs_eligible(selectedRowKeysTable.current[0])) {
+                              //setAzfyDe(input);
+                              azfycallback(bh, input);
+                         }
+                         
+                    }
+                    
+               } else {
+                    myTable.current.deselectRow();
+                   //console.log(dingeclick);
+                   if (selectedRowKeysTable.current.length > 0 ) {
                     const [success, data, key] = changguidinge_djcs(input, selectedRowKeysTable.current[0]);
                     if (success) {
                          myTable.current.updateData(data.filter(x=>x['key'] == selectedRowKeysTableParent.current)).then(function(){
@@ -675,7 +733,10 @@ export default function Djcs3({name, bh, rgde, jxde, clde, beizhu, beizhuFK, cli
                                
                           });
                     }
+                   }
                }
+
+               
                
           }, [dingeclick]//常规添加定额
       );

+ 3 - 0
src/Qingdan3.js

@@ -874,10 +874,13 @@ export default function Qingdan3({name, bh, bt, rgde, jxde, clde, beizhu/*后台
      
      
            myTable.current.on("tableBuilt", () => {
+               if (bh != null) {
                Service.generateQingdanmingxi(name, bh, bt).then(x=>{
                     myTable.current.replaceData(x);
                     });
+               }
              });
+          
          
         }, [bh, bt]);
 

+ 134 - 2
src/Service.js

@@ -470,8 +470,32 @@ class Service{
     /////////////////////////////////////qingdan//////////////////////////////////////
 
     async generateQingdanmingxi(name, bh, bt) {
-        if (this.cache.length == 0 || this.cache[0]["biao_id"] != name || this.cache[0]["Dwgcbh"] != bh ||
-        this.cache[0]["bt"] != bt) {
+        if (bt == 'ALL') {
+            const response = await fetch(this.ip().concat("/qingdanmingxi/"), {
+                method : "POST",
+                headers: {
+                    "Content-type": "application/json"
+                },
+                body: JSON.stringify(
+                    {
+                        "bh": bh,
+                        "bt": bt,
+                        "name": name
+                    }
+                )
+            });
+            if (!response.ok) {
+                //const error = await response.json();
+                console.error('error');
+            } else {
+                const data = await response.json();
+                
+                
+                return data;
+            }
+
+        } else {
+        if (this.cache.length == 0 || this.cache[0]["biao_id"] != name || this.cache[0]["Dwgcbh"] != bh || this.cache[0]["bt"] != bt) {
         const response = await fetch(this.ip().concat("/qingdanmingxi/"), {
             method : "POST",
             headers: {
@@ -498,6 +522,7 @@ class Service{
             return copy(this.cache);
         }
     }
+    }
 
 
     async generateQingdanrcj(name, bh, bt, bm) {
@@ -1974,6 +1999,107 @@ async generateQingdanTuijian(name, bh, bt, bm) {
 
 
 
+    }
+
+    azfy_djcs_eligible(selectedRow) {
+        if (this.cache_djcs.filter(x=>x['key'] == selectedRow).length > 0) {
+            return true;
+        } else {
+            return false;
+        }
+
+    }
+
+    azfy_djcs(row, dinge, selected) {
+        let res = JSON.parse(dinge);
+        let keys = Object.keys(res['DEBH']);
+        let key = keys[0];
+        let tips = azfy(res['DEBH'][key], res['GCLMC'][key]);
+
+        if (tips != null) {
+            res['rgde'] = tips['rgde'];
+            res['clde'] = tips['clde'];
+            res['jxde'] = tips['jxde'];
+            res['azfytag'] = tips['azfytag'];
+        }
+        let qd = this.cache_djcs.filter(x=>x['key'] == row)[0];
+        let dercj = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地", 
+                "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]];
+        for(let i = 0; i < selected.length; i++) {
+            let rgf = selected[i]['人工费'];
+            let clf = selected[i]['材料费'];
+            let jxf = selected[i]['机械费'];
+            let sl = selected[i]['数量'];
+            if (res['azfytag'][0] == '人工费') {
+                let sum = Number(sl) * Number(rgf) * Number(res['azfytag'][1]) / Number(100);
+                dercj.push(['', res['rgde'][0]['CLBH'], res['rgde'][0]['CLMC'], '', '元', 
+                    '1', '', '', '1', '', Number(sum) * Number(res['azfytag'][2]) / Number(100), Number(sum) * Number(res['azfytag'][2]) / Number(100),
+                    '', '', '', '' ]);
+                dercj.push(['', res['clde'][0]['CLBH'], res['clde'][0]['CLMC'], '', '元', 
+                    '1', '', '', '2', '', Number(sum) * Number(res['azfytag'][3]) / Number(100), Number(sum) * Number(res['azfytag'][3]) / Number(100),
+                    '', '', '', '' ]);
+                dercj.push(['', res['jxde'][0]['jxbh'], res['jxde'][0]['jxmc'], '', '元', 
+                    '1', '', '', '3', '', Number(sum) * Number(res['azfytag'][4]) / Number(100), Number(sum) * Number(res['azfytag'][4]) / Number(100),
+                    '', '', '', '' ]);
+            } else if (res['azfytag'][0] == '人工费+机械费') {
+                let sum = Number(sl) * (Number(jxf) + Number(rgf)) * Number(res['azfytag'][1]) / Number(100);
+                dercj.push(['', res['rgde'][0]['CLBH'], res['rgde'][0]['CLMC'], '', '元', 
+                    '1', '', '', '1', '', Number(sum) * Number(res['azfytag'][2]) / Number(100), Number(sum) * Number(res['azfytag'][2]) / Number(100),
+                    '', '', '', '' ]);
+                dercj.push(['', res['clde'][0]['CLBH'], res['clde'][0]['CLMC'], '', '元', 
+                    '1', '', '', '2', '', Number(sum) * Number(res['azfytag'][3]) / Number(100), Number(sum) * Number(res['azfytag'][3]) / Number(100),
+                    '', '', '', '' ]);
+                dercj.push(['', res['jxde'][0]['jxbh'], res['jxde'][0]['jxmc'], '', '元', 
+                    '1', '', '', '3', '', Number(sum) * Number(res['azfytag'][4]) / Number(100), Number(sum) * Number(res['azfytag'][4]) / Number(100),
+                    '', '', '', '' ]);
+
+            }
+        }
+
+        let newKey = uuidv4();
+        if (!qd.hasOwnProperty('_children')) {
+            qd["_children"] = [];
+        }
+        qd["_children"].push({
+                    '操作': '',
+                    '序号': null,
+                    '清单编码': res['DEBH'][key],
+                    '名称': res['GCLMC'][key],
+                    '项目特征': null,
+                    '计算规则': tips != null ? tips['sm'] : '',
+                    '单位': res['DW'][key],
+                    '数量': '1',
+                    '综合单价': '0',
+                    '合价': '0',
+                    '人工费': '0',
+                    '主材费': '0',
+                    '设备费': '0',
+                    '辅材费': '0',
+                    '材料费': '0',
+                    '机械费': '0',
+                    '管理费': '0',
+                    '利润': '0',
+                    '暂估价': null,
+                    '综合人工工日': null,
+                    '备注': null,
+                    "dercj": dercj,
+                    'rcjdg': copy(dercj),
+                    'key' :   newKey,
+                    "fuzhuEnable": false,
+                    'yuban': [],
+                    'rcjbc': [],
+                    'azfytag': []
+    
+                    
+        });
+
+        this.updateDercj_djcs_(newKey, dercj, []);
+        let summarized = this.summarize_djcs(this.cache_djcs);
+        this.push_op_djcs(copy(summarized));
+        this.cache_djcs = copy(summarized);
+                
+        return [true, copy(this.cache_djcs), newKey];
+
     }
 
 
@@ -2019,6 +2145,9 @@ async generateQingdanTuijian(name, bh, bt, bm) {
                     '', '', '', '' ]);
                 }
                 let newKey = uuidv4();
+                if (!qd.hasOwnProperty('_children')) {
+                    qd["_children"] = [];
+                }
                 qd["_children"].push({
                     '操作': '',
                     '序号': null,
@@ -2112,6 +2241,9 @@ async generateQingdanTuijian(name, bh, bt, bm) {
                     '', '', '', '' ]);
                 }
                 let newKey = uuidv4();
+                if (!qd.hasOwnProperty('_children')) {
+                    qd["_children"] = [];
+                }
                 qd["_children"].push({
                     '操作': '',
                     '序号': null,

+ 106 - 0
src/SimpleQingdan.js

@@ -0,0 +1,106 @@
+import * as React from 'react';
+
+import Service from './Service';
+import { v4 as uuidv4 } from 'uuid';
+
+
+import {copy} from './utils';
+import {TabulatorFull as Tabulator, RowComponent} from "tabulator-tables"; //import Tabulator library
+import './Tabulator.css';
+export default function SimpleQingdan({id, bh, azfycallback}) {
+  const myTable = React.useRef(null);
+  const myRef = React.useRef(null);
+  const [detail, setDetail] = React.useState([]);
+ 
+
+
+
+
+
+
+  React.useEffect(() => {
+    myTable.current = new Tabulator(myRef.current, {
+         index: "key",
+         height: 600,
+       data: detail, //link data to table
+       reactiveData: false, //enable data reactivity
+       dataTreeStartExpanded:true,
+       dataTree: true,
+       renderVertical: "basic",
+       rowHeader: {headerSort: false, resizable: false, frozen: true, headerHozAlign: "center", hozAlign: "center", formatter: function(cell, formatterParams, onRendered){
+        if (cell._cell.row.getData()['序号'] != null ) {
+            var checkbox = document.createElement("input");
+            var blocked = false;
+            checkbox.type="checkbox";
+            checkbox.setAttribute("aria-label", "Select Row");
+            checkbox.addEventListener("click", (e)=>{
+              e.stopPropagation();
+            });
+            if (typeof cell.getRow == 'function') {
+              var row = cell.getRow();
+              if (row instanceof RowComponent) {
+                checkbox.addEventListener("change", (e) => {
+                  row.toggleSelect();
+                  azfycallback(this.table);
+                });
+                checkbox.checked = row.isSelected && row.isSelected();
+                this.table.modules.selectRow.registerRowSelectCheckbox(row, checkbox);
+              } else {
+                checkbox = "";
+              }
+            } else {
+              //checkbox.addEventListener();
+              this.table.modules.selectRow.registerHeaderSelectCheckbox(checkbox);
+            }
+            return checkbox;
+        }
+       }},
+       
+       columns: [ //Define Table Columns
+                          {title:"序号", field:"序号", width:80, headerSort:false, frozen: true}, //never hide this column
+                          {title:"清单编码", field:"清单编码", width:120,headerSort:false, frozen: true ,formatter:"textarea" },
+                          {title:"名称", field:"名称", width:150, headerSort:false, formatter:"textarea", }, //hide this column first
+                          {title:"项目特征", field:"项目特征", width:200 , headerSort:false, formatter:"textarea"},
+                          {title:"计算规则", field:"计算规则", width:300, headerSort:false, formatter:"textarea"},
+                          {title:"单位", field:"单位", width:100, headerSort:false},
+                          {title:"数量", field:"数量", width:100, headerSort:false,   },
+                          {title:"综合单价", field:"综合单价", width:100, headerSort:false, formatter:"money"},
+                          {title:"合价", field:"合价", width:100, headerSort:false, formatter:"money"},
+                          {title:"人工费", field:"人工费", width:100, headerSort:false, formatter:"money"},
+                          {title:"主材费", field:"主材费", width:100, headerSort:false, formatter:"money"},
+                          {title:"设备费", field:"设备费", width:100, headerSort:false, formatter:"money"},
+                          {title:"辅材费", field:"辅材费", width:100, headerSort:false, formatter:"money"},
+                          {title:"材料费", field:"材料费", width:100, headerSort:false, formatter:"money"},
+                          {title:"机械费", field:"机械费", width:100, headerSort:false, formatter:"money"},
+                          {title:"管理费", field:"管理费", width:100, headerSort:false, formatter:"money"},
+                          {title:"利润", field:"利润", width:100, headerSort:false, formatter:"money"},
+                          {title:"暂估价", field:"暂估价", width:100, headerSort:false, formatter:"money"},
+                          {title:"综合人工工日", field:"综合人工工日", width:100, headerSort:false},
+                  ]
+     }); 
+     
+    
+
+   
+     
+
+   
+
+
+     myTable.current.on("tableBuilt", () => {
+      
+        Service.generateQingdanmingxi(id, bh, "ALL").then(x=>{
+             myTable.current.replaceData(x);
+             });
+       });
+   
+  }, [id, bh]);
+
+    return (
+      <div ref={myRef}> 
+      </div>
+
+
+
+    );
+}

+ 3 - 3
src/Tabulator.css

@@ -1444,11 +1444,11 @@
   }
   
   .tabulator-row .tabulator-cell:first-child {
-    border-left: 10px solid #1976D2;
+    border-left: 0px solid #1976D2;
   }
   
   .tabulator-row .tabulator-cell.tabulator-row-header {
-    background-color: #1976D2;
+    background-color: #fff;
     color: #fff;
   }
   
@@ -1461,7 +1461,7 @@
   }
   
   .tabulator-row:nth-child(even) .tabulator-cell:first-child {
-    border-left: 10px solid #1976D2;
+    border-left: 0px solid #1976D2;
   }
   
   .tabulator-row:nth-child(even) .tabulator-cell.tabulator-row-header {

+ 10 - 0
src/editor.js

@@ -104,6 +104,16 @@ export const changguidinge_djcs = (dingeclick, selectedRow) => {
 
 };
 
+export const azfy_djcs_eligible = (selectedRow) => {
+    return Service.azfy_djcs_eligible(selectedRow);
+
+};
+
+export const azfy_djcs = (selectedRow, dinge, selected) => {
+    return Service.azfy_djcs(selectedRow, dinge, selected);
+
+};
+
 export const handleYuban = (derow, select ) => {
     return Service.handleYuban(derow, select);