ソースを参照

try djcs with tabulator instead of antd , need continue

Xiaopeng Zhang 6 ヶ月 前
コミット
28a0a06c82
11 ファイル変更642 行追加68 行削除
  1. 1 0
      front/package.json
  2. 5 4
      front/src/App2.js
  3. 549 0
      front/src/Djcs2.js
  4. 4 10
      front/src/Qingdan.js
  5. 64 45
      front/src/Service.js
  6. 1 0
      front/src/Tabulator.css
  7. 8 1
      main.py
  8. 1 1
      qufei.py
  9. 2 1
      subdir/db.py
  10. 6 6
      subdir/service.py
  11. 1 0
      test.py

+ 1 - 0
front/package.json

@@ -30,6 +30,7 @@
     "react-router": "latest",
     "react-router-dom": "^7.6.1",
     "react-use-websocket": "^4.13.0",
+    "tabulator-tables": "^6.3.1",
     "uuid": "latest"
   },
   "devDependencies": {

+ 5 - 4
front/src/App2.js

@@ -21,7 +21,7 @@ import TabPanel from "@mui/lab/TabPanel";
 //registerPlugin(NestedRows);
 import Qingdan from './Qingdan';
 import Zjcs from './Zjcs';
-import Djcs from './Djcs';
+import Djcs2 from './Djcs2';
 import Service from './Service';
 import Qufei from './Qufei';
 import {useLocation, useParams} from "react-router";
@@ -966,16 +966,17 @@ const MUI_X_PRODUCTS = [
                    <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
                       <TabList scrollButtons='auto' 
                               variant="scrollable"
+                              sx={{minHeight: '24px'}}
                       onChange={handleChange} aria-label="lab API tabs example">
-                        <Tab label="总价措施" value="1" />
-                        <Tab label="单价措施" value="2" />
+                        <Tab sx={{p: 0, minHeight: '24px'}} label="总价措施" value="1" />
+                        <Tab sx={{p: 0, minHeight: '24px'}} label="单价措施" value="2" />
                       </TabList>
                    </Box>
                    <TabPanel sx={{p: 1}} value="1">
                      <Zjcs name={location["id"]} bh={dwgc}/>
                    </TabPanel>
                    <TabPanel sx={{p: 1}} value="2">
-                     <Djcs 
+                     <Djcs2 
                          name={location["id"]} 
                          bh={dwgc}
                          rgde={rgde}

+ 549 - 0
front/src/Djcs2.js

@@ -0,0 +1,549 @@
+import * as React from 'react';
+import Box from "@mui/material/Box";
+import 'handsontable/dist/handsontable.full.min.css';
+//import 'handsontable/styles/ht-theme-main.min.css';
+import { HandsonTable } from 'handsontable/base';
+import {HotTable} from "@handsontable/react";
+//import { registerAllModules } from 'handsontable/registry';
+import {RichTreeView } from "@mui/x-tree-view/RichTreeView";
+import { Grid } from '@mui/material';
+import Tab from "@mui/material/Tab";
+import TabContext from "@mui/lab/TabContext";
+import TabList from "@mui/lab/TabList";
+import TabPanel from "@mui/lab/TabPanel";
+import Stack from "@mui/material/Stack";
+//import { registerPlugin, NestedRows } from 'handsontable/plugins';
+//registerPlugin(NestedRows);
+import Service from './Service';
+import {TabulatorFull as Tabulator} from "tabulator-tables"; //import Tabulator library
+import "tabulator-tables/dist/css/tabulator.min.css"; //import Tabulator stylesheet
+import './Tabulator.css';
+import { DataGrid } from '@mui/x-data-grid';
+import {extractFuzhu} from './utils';
+import Button from '@mui/material/Button';
+
+import { textRenderer, registerRenderer } from 'handsontable/renderers';
+
+
+
+
+function number_equal(a, b) {
+     if (Number(a) - Number(b) < 0.0001 && Number(a) - Number(b) > -0.0001) {
+          return true;
+     }
+     return false;
+}
+export default function Djcs2({name, bh, rgde, jxde, clde, beizhu, clickCallback}) {
+     
+    registerRenderer('customStylesRenderer', (hotInstance, TD, row, column,  prop, value, ...rest) => {
+         let newValue = value; 
+          if ((column == 10 || column == 11 || column == 5) && 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) {
+               TD.style.fontWeight = 'bold';
+               TD.style.color = 'green';
+               TD.style.background = '#d7f1e1';
+          }
+         }
+       });
+
+       
+    const [detail, setDetail] = React.useState([
+                    
+    ]);
+    const myRef = React.useRef(null);
+    const myTable = React.useRef(null);
+    const [value, setValue] = React.useState("1");
+    const [rcjhl, setRcjhl] = React.useState([]);
+    const [rcjhl2, setRcjhl2] = React.useState([]);
+    const [fuzhu, setFuzhu] = React.useState([]);
+    const [tuijian, setTuijian] = React.useState([]);
+    const [fuzhuEnable, setFuzhuEnable] = React.useState(false);
+    const [rowSelectionModel, setRowSelectionModel] = React.useState({
+     type: 'include',
+     ids: new Set(),
+   });
+    const highlight = React.useRef([]);
+
+    
+    const rgdeRef = React.useRef(null);
+    const jxdeRef = React.useRef(null);
+    const cldeRef = React.useRef(null);
+    const isQdrcj = React.useRef(false);
+    const debmRef = React.useRef(null);
+
+
+    React.useEffect(() => {
+     myTable.current = new Tabulator(myRef.current, {
+          height: 380,
+        data: detail, //link data to table
+        reactiveData: false, //enable data reactivity
+        dataTreeStartExpanded:true,
+        dataTree: true,
+        selectableRows:1, //make rows selectable
+        editTriggerEvent:"dblclick", //trigger edit on double click
+        dataTreeStartExpanded:function(row, level){
+            //console.log(row);
+            //console.log(level);
+            return true; //expand rows where the "driver" data field is true;
+        },
+        columns: [ //Define Table Columns
+                     {title:"序号", field:"序号", width:80, headerSort:false, frozen: true}, //never hide this column
+                     {title:"清单编码", field:"清单编码", width:120,headerSort:false, frozen: true },
+                     {title:"名称", field:"名称", width:150, headerSort:false, formatter:"textarea"}, //hide this column first
+                     {title:"项目特征", field:"项目特征", width:150 , headerSort:false, formatter:"textarea"},
+                     {title:"计算规则", field:"计算规则", width:150, headerSort:false, formatter:"textarea"},
+                     {title:"单位", field:"单位", width:100, headerSort:false},
+                     {title:"数量", field:"数量", width:100, headerSort:false},
+                     {title:"综合单价", field:"综合单价", width:100, headerSort:false},
+                     {title:"合价", field:"合价", width:100, headerSort:false},
+                     {title:"人工费", field:"人工费", width:100, headerSort:false},
+                     {title:"主材费", field:"主材费", width:100, headerSort:false},
+                     {title:"设备费", field:"设备费", width:100, headerSort:false},
+                     {title:"辅材费", field:"辅材费", width:100, headerSort:false},
+                     {title:"材料费", field:"材料费", width:100, headerSort:false},
+                     {title:"机械费", field:"机械费", width:100, headerSort:false},
+                     {title:"管理费", field:"管理费", width:100, headerSort:false},
+                     {title:"利润", field:"利润", width:100, headerSort:false},
+                     {title:"暂估价", field:"暂估价", width:100, headerSort:false},
+                     {title:"综合人工工日", field:"综合人工工日", width:100, headerSort:false},
+             ]
+      }); 
+      
+      myTable.current.on("cellDblClick", function(e, cell){
+          //e - the click event object
+          //cell - cell component
+          console.log(cell);
+      });
+
+      myTable.current.on("rowSelected", function(row){
+          //e - the click event object
+          //cell - cell component
+          console.log(row);
+          let bt = "Djcs" ;
+          
+          if (row._row.data['序号'] != null && row._row.data['序号'].length >0) {
+               Service.generateQingdanrcj(name, bh,bt,row._row.data['清单编码']).then(x=>{
+                    setRcjhl(x);
+                    isQdrcj.current=true;
+                    highlight.current = [];
+               });
+               Service.generateQingdanTuijian(name, bh,bt,row._row.data['清单编码']).then(x=>{
+                    setTuijian(x);
+               });
+          } else {
+               
+               let row_parent = row._row;
+               while(row_parent.modules.dataTree.parent) {
+                   row_parent = row_parent.modules.dataTree.parent;
+               }
+               debmRef.current = row._row['data']['清单编码'];
+
+                             clickCallback(row_parent['data']['清单编码'], row._row['data']['清单编码']);
+                             Service.generateDingercj(name, bh,bt,row_parent['data']['清单编码'], row._row['data']['清单编码']).then(x=>{
+                               setRcjhl(x[0]);
+                               isQdrcj.current = false;
+                               setFuzhuEnable(x[1]);
+                               let toHighlight = [];
+                               for(let i = 1; i < x[0].length; i++) {
+                                   let entry = x[0][i];
+                                   let bianhao = entry[1];
+                                   let rcjlb = entry[8];
+                                   if (Number(rcjlb) == 1 &&  rgdeRef.current  ) {
+                                      for (let j = 0;j < rgdeRef.current.length; j++) {
+                                         if (rgdeRef.current[j]["CLBH"] == bianhao) {
+                                              let danjia = Number(entry[5]);
+                                              if (!number_equal(danjia , rgdeRef.current[j]["YSJG"])) {
+                                                   console.log(`[${i},5]danjia bu yizhi`);
+                                                   toHighlight.push({row: i, col: 5, });
+                                              }
+                                              let hanliang = Number(entry[10]);
+                                              if (!number_equal(hanliang , rgdeRef.current[j]["gr"])) {
+                                                   console.log(`[${i}, 10]hanliang bu yizhi`);
+                                                   toHighlight.push({row: i, col: 10, });
+                                              }
+                                         }
+                                      }
+
+                                   }   
+                                   if (Number(rcjlb) == 3 && jxdeRef.current  ) {
+                                      for (let j = 0; j < jxdeRef.current.length; j++) {
+                                         if (jxdeRef.current[j]["jxbh"] == bianhao) {
+                                               let danjia = Number(entry[5]);
+                                               if (!number_equal(danjia , jxdeRef.current[j]["tbdj"])) {
+                                                    console.log(`[${i},5]danjia bu yizhi`);
+                                                    toHighlight.push({row: i, col: 5, });
+                                               }
+                                               let hanliang = Number(entry[10]);
+                                               if (!number_equal(hanliang , jxdeRef.current[j]["sl"])) {
+                                                    console.log(`[${i}, 10]hanliang bu yizhi`);
+                                                    toHighlight.push({row: i, col: 10, });
+                                               }
+                                         }
+                                      }
+
+                                   }   
+                                   if (Number(rcjlb) == 2 && cldeRef.current  ) {
+                                      for (let j = 0; j < cldeRef.current.length; j++) {
+                                         if (cldeRef.current[j]["CLBH"] == bianhao) {
+                                               let danjia = Number(entry[5]);
+                                               if (!number_equal(danjia , cldeRef.current[j]["YSJG"])) {
+                                                    console.log(`[${i},5]danjia bu yizhi`);
+                                                    toHighlight.push({row: i, col: 5, });
+                                               }
+                                               let hanliang = Number(entry[10]);
+                                               if (!number_equal(hanliang , cldeRef.current[j]["SL"])) {
+                                                    console.log(`[${i}, 10]hanliang bu yizhi`);
+                                                    toHighlight.push({row: i, col: 10, });
+                                               }
+                                         }
+                                      }
+
+                                   }   
+                               }
+                               highlight.current = toHighlight;
+                             });
+          }
+      });
+
+      myTable.current.on("cellEdited", function(cell){
+          console.log("edited");
+          console.log(cell._cell.row.data);
+          let row = cell._cell.row
+          while(row.modules.dataTree.parent) {
+              row = row.modules.dataTree.parent;
+          }
+          cell._cell.row.component.select();          
+          console.log(row);
+      });
+
+
+      myTable.current.on("tableBuilt", () => {
+          Service.generateDjcs(name, bh).then(x=>{
+               myTable.current.replaceData(x);
+               });
+        });
+    
+   }, [bh]);
+
+
+    /*React.useEffect(
+        () => {
+          Service.generateDjcs(name, bh).then(x=>{
+          myTable.current.replaceData(x);
+          });
+        }, [bh]
+      );*/
+    React.useEffect(
+        () => {
+            console.log(beizhu);
+            let result = [];
+            if (beizhu != null) { 
+                let keys = Object.keys(beizhu["BZBH"]);
+                for(let i = 0; i < keys.length; i++) {
+                    let key = keys[i];
+                    result.push({'id': i+1, '序号': i+1, '编号': beizhu["BZBH"][key], '说明': beizhu["SM"][key]});//序号很重要
+                }
+                setFuzhu(result);
+                setRowSelectionModel({type: 'include', 
+                ids: new Set(extractFuzhu(debmRef.current))});
+            }
+        }, [beizhu]
+      );
+
+    React.useEffect(
+        () => {
+          console.log("rgde changed");
+          console.log(rgde);
+          rgdeRef.current = rgde;
+          jxdeRef.current = jxde;
+          cldeRef.current = clde;
+          if (isQdrcj.current) {
+             highlight.current = [];
+          } else {
+          let toHighlight = [];
+          for(let i = 1; i < rcjhl.length; i++) {
+              let entry = rcjhl[i];
+              let bianhao = entry[1];
+              let rcjlb = entry[8];
+              if (Number(rcjlb) == Number(1) && rgde) {
+                  for (let j = 0; j < rgde.length; j++) {
+                      if (rgde[j]["CLBH"] == bianhao) {
+                          let danjia = Number(entry[5]);
+                          if (!number_equal(danjia , rgde[j]["YSJG"])) {
+                               console.log(`[${i},5]danjia bu yizhi`);
+                               toHighlight.push({row: i, col: 5});
+                          }
+                          let hanliang = Number(entry[10]);
+                          if (!number_equal(hanliang , rgde[j]["gr"])) {
+                               console.log(`[${i}, 10]hanliang bu yizhi`);
+                               toHighlight.push({row: i, col: 10});
+                          }
+
+                      }              
+                  }
+
+              }   
+              if (Number(rcjlb) == Number(3) && jxde ) {
+                   for (let j = 0; j < jxde.length; j++) {
+                      if (jxde[j]["jxbh"] == bianhao) {
+                         let danjia = Number(entry[5]);
+                         if (!number_equal(danjia , jxde[j]["tbdj"])) {
+                              console.log(`[${i},5]danjia bu yizhi`);
+                              toHighlight.push({row: i, col: 5, });
+                         }
+                         let hanliang = Number(entry[10]);
+                         if (!number_equal(hanliang , jxde[j]["sl"])) {
+                              console.log(`[${i}, 10]hanliang bu yizhi`);
+                              toHighlight.push({row: i, col: 10, });
+                         }
+                      }
+                   }
+
+              }   
+              if (Number(rcjlb) == Number(2) && clde ) {
+                   for (let j = 0; j < clde.length; j++) {
+                      if (clde[j]["CLBH"] == bianhao) {
+                         let danjia = Number(entry[5]);
+                         if (!number_equal(danjia , clde[j]["YSJG"])) {
+                              console.log(`[${i},5]danjia bu yizhi`);
+                              toHighlight.push({row: i, col: 5, });
+                         }
+                         let hanliang = Number(entry[10]);
+                         if (!number_equal(hanliang ,clde[j]["SL"])) {
+                              console.log(`[${i}, 10]hanliang bu yizhi`);
+                              toHighlight.push({row: i, col: 10, });
+                         }
+                      }
+                   }
+
+              }   
+          }
+          console.log(toHighlight);
+          highlight.current = toHighlight;
+          }
+
+
+          let bzrcjhl = [["人材机编码", "名称", "单位", "单价", "合价", "含量"]] 
+          if (rgde)
+          for (let i = 0; i  < rgde.length; i++) {
+               bzrcjhl.push([rgde[i]["CLBH"], rgde[i]["CLMC"], rgde[i]["JLDW"], rgde[i]["YSJG"], rgde[i]["gf"], rgde[i]["gr"]]);
+          }
+          
+          if (clde)
+          for (let i = 0; i  < clde.length; i++) {
+               bzrcjhl.push([clde[i]["CLBH"], clde[i]["CLMC"], clde[i]["JLDW"], clde[i]["YSJG"], clde[i]["HJ"], clde[i]["SL"]]);
+          }
+          if (jxde)
+          for (let i = 0; i  < jxde.length; i++) {
+               bzrcjhl.push([jxde[i]["jxbh"], jxde[i]["jxmc"], jxde[i]["DW"], jxde[i]["tbdj"], jxde[i]["hj"], jxde[i]["sl"]]);
+          }
+          setRcjhl2(bzrcjhl);
+        }, [rgde, jxde, clde]
+      );
+
+      const handleChange = (event, newValue) => {
+        setValue(newValue);
+      };
+
+
+    return (
+
+               <Stack spacing={1}>
+                         <Stack direction='row' spacing={2}>
+                   <Button variant="outlined" size="small" onClick={() => {
+                      if (selectedRowKeys.length > 0) {
+                         const [success, data] = danxiangdinge(selectedRowKeys[0]);
+                         if(success) {
+                            setDetail(data);
+                            detailRef.current = data;
+                            setExpandedRowKeys([...expandedRowKeys, selectedRowKeys[0]]);
+                         }
+                      }
+                 
+                      
+                      }}
+                   >单项定额</Button>
+                      <Button variant="outlined" size="small" onClick={() => {
+                      if (selectedRowKeys.length > 0) {
+                          let newData = shanchu(selectedRowKeys[0]);
+                          setDetail(newData);
+                          detailRef.current = newData;
+                          if (newData.filter(x=>x['key'] == selectedRowKeys[0]).length == 0) {
+                              setSelectedRowKeys([]);
+                              handleSelection([]);
+                          }
+                          
+                          
+                      }
+                      
+                 
+                      
+                      }}
+                   >删除</Button>
+                   <Button variant="outlined" size="small" onClick={() => {
+                      let newData = undo();
+                      setDetail(newData);
+                      detailRef.current = newData;
+                      if (newData.filter(x=>x['key'] == selectedRowKeys[0]).length == 0
+                      && newData.filter(x=>x["children"].filter(y=>y['key']==selectedRowKeys[0]).length > 0).length == 0) {
+                         setSelectedRowKeys([]);
+                         handleSelection([]);
+                     } else {
+                         handleSelection(selectedRowKeys);
+                     }
+                      
+                      }}
+                   >撤销</Button>
+                   <Button variant="outlined" size="small" onClick={() => {
+                      let newData = redo();
+                      setDetail(newData);
+                      detailRef.current = newData;
+                      if (newData.filter(x=>x['key'] == selectedRowKeys[0]).length == 0
+                      && newData.filter(x=>x["children"].filter(y=>y['key']==selectedRowKeys[0]).length > 0).length == 0) {
+                         setSelectedRowKeys([]);
+                         handleSelection([]);
+                     } else {
+                         handleSelection(selectedRowKeys);
+                     }
+                      
+                      }}
+                   >重做</Button>
+                   <Button variant="outlined" size="small" onClick={() => {
+                            console.log("save to cloud");
+                            loadingCallback();
+                      
+                      }}
+                   >保存</Button>
+
+                  
+                   </Stack>
+                 <div ref={myRef}> 
+                  </div>
+                   <Box >
+                   
+                   <TabContext value={value}>
+                       <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
+                         <TabList onChange={handleChange} aria-label="lab API tabs example"  sx={{minHeight: '24px'}}   >
+                           <Tab sx={{p: 0, minHeight: '24px'}} label="人材机含量" value="1" />
+                           <Tab sx={{p: 0, minHeight: '24px'}} label="标准定额人材机含量" value="2" />
+                           <Tab sx={{p: 0, minHeight: '24px'}} label="定额附注" value="3" />
+                           <Tab sx={{p: 0, minHeight: '24px'}} label="组价推荐" value="4" />
+                         </TabList>
+                       </Box>
+                       <TabPanel value="1">
+                          <HotTable 
+                          nestedRows={false}
+                             data={rcjhl
+                             }
+                             cells={(row, col) => {
+                              return { readOnly: true, renderer: "customStylesRenderer" };
+                              
+                            }}
+                             manualColumnResize={true}
+                             rowHeaders={true}
+                             colHeaders={true}
+                             height="200"
+                             readOnly={true}
+                             fixedRowsTop={1}
+                             selectionMode="single"
+                             autoWrapRow={false}
+                             autoWrapCol={false}
+                             licenseKey="non-commercial-and-evaluation" // for non-commercial use only
+                           />
+
+                       </TabPanel>
+                       <TabPanel value="2">
+                          <HotTable 
+                          nestedRows={false}
+                             data={rcjhl2
+                             }
+                             manualColumnResize={true}
+                             rowHeaders={true}
+                             colHeaders={true}
+                             height="200"
+                             readOnly={true}
+                             fixedRowsTop={1}
+                             selectionMode="single"
+                             autoWrapRow={false}
+                             autoWrapCol={false}
+                             licenseKey="non-commercial-and-evaluation" // for non-commercial use only
+                           />
+
+                       </TabPanel>
+                       <TabPanel value="3">
+                         <div style={{ height: 200}}>
+                       <DataGrid  disableColumnMenu
+                          getRowHeight={(params) => "auto"}
+                          localeText={{
+                              noRowsLabel: '无数据',
+                              paginationRowsPerPage: '每页行数',
+                              footerRowSelected: (count) => `共选中了${count.toLocaleString()}行`,
+                             
+                              
+                            }}
+                          columns={
+                              [
+                                   { field: '序号', headerName: '序号', },
+                                   {
+                                     field: '编号',
+                                     headerName: '编号',
+                                     
+                                   },
+                                   {
+                                     field: '说明',
+                                     headerName: '说明',
+                                     width: 550
+                                    
+                                   },
+                                  
+                                 ]
+                             }
+                         scroll={{ x: 'max-content' }}
+                         rows={fuzhu}
+                         hideFooter={true}
+                         checkboxSelection={fuzhuEnable}
+                         rowSelectionModel={rowSelectionModel}
+                         onRowSelectionModelChange={(newRowSelectionModel) => {
+                              console.log(newRowSelectionModel);
+                             
+                              setRowSelectionModel(newRowSelectionModel);
+                            
+                              
+                            }}
+                           />
+                           </div>
+
+                       </TabPanel>
+
+                       <TabPanel value="4">
+                          <HotTable 
+                          nestedRows={false}
+                             data={tuijian
+                             }
+                             manualColumnResize={true}
+                             rowHeaders={true}
+                             colHeaders={true}
+                             height="200"
+                             readOnly={true}
+                             fixedRowsTop={1}
+                             selectionMode="single"
+                             autoWrapRow={false}
+                             autoWrapCol={false}
+                             licenseKey="non-commercial-and-evaluation" // for non-commercial use only
+                           />
+
+                       </TabPanel>
+                     </TabContext>
+                  </Box>
+
+                  </Stack>
+
+
+
+    );
+}

+ 4 - 10
front/src/Qingdan.js

@@ -86,7 +86,7 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu/*后台
 
      registerRenderer('customStylesRenderer', (hotInstance, TD, row, column, prop, value, ...rest) => {
           let newValue = value; 
-          if ((column == 10 || column == 11) && row > 0) {
+          if ((column == 10 || column == 11 || column == 5) && row > 0) {
             newValue = Number(value).toFixed(2).toString();
          }
           textRenderer(hotInstance, TD, row, column, prop, newValue, ...rest);
@@ -373,15 +373,7 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu/*后台
           }
         };
 
-      const afterUpdateData = (x, initial, source)=>{
-          
-              console.log(source);
-              let plugin = hotRef.current?.hotInstance.getPlugin("NestedRows");
-               let ui = plugin.collapsingUI;
-               //ui.collapseRow(1);
-              hotRef.current?.hotInstance?.scrollViewportTo({ row: selectedRow.current });
-          
-     };
+  
 
       
       const handleSelection = (row) => {
@@ -832,6 +824,7 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu/*后台
 
                        </TabPanel>
                        <TabPanel sx={{p: 1}} value="3">
+                       <div style={{ height: 190}}>
                           <DataGrid  disableColumnMenu
                           getRowHeight={(params) => "auto"}
                           localeText={{
@@ -880,6 +873,7 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu/*后台
                               
                             }}
                            />
+                           </div>
 
                        </TabPanel>
                        <TabPanel sx={{p: 1}} value="4">

+ 64 - 45
front/src/Service.js

@@ -7,6 +7,9 @@ class Service{
         this.cache = [];
         this.memory = [];
         this.mem_pointer = -1;
+        this.cache_djcs = [];
+        this.memory_djcs = [];
+        this.mem_pointer_djcs = -1;
         this.qufei = [];
         this.qufeiEntry = null;
     }
@@ -15,10 +18,13 @@ class Service{
         return "http://127.0.0.1"
     }
 
-    clearCache() {
+    clearCache() {//set qufei will clear cache
         this.cache = [];
         this.memory = [];
         this.mem_pointer = -1;
+        this.cache_djcs = [];
+        this.memory_djcs = [];
+        this.mem_pointer_djcs = -1;
     }
 
     setQufei(data) {
@@ -39,6 +45,50 @@ class Service{
 
     }
 
+
+    processDjcsmingxi(mingxi) {
+        this.cache_djcs = copy(mingxi);
+        for(let i = 0; i < this.cache_djcs.length; i++) {
+            let zimu = this.cache_djcs[i];
+            if (!zimu.hasOwnProperty("_children")) {
+                zimu["_children"] = [];
+            }
+            if (!zimu.hasOwnProperty("rcj")) {
+                zimu["rcj"] = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地", 
+                "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]];
+            }
+
+        }
+        for(let i = 0; i < this.cache_djcs.length; i++) {
+            let zimu = this.cache_djcs[i];
+            for(let j = 0; j < zimu["_children"].length; j++) {
+                let de = zimu["_children"][j];
+                if (!de.hasOwnProperty("dercj")) {
+                    de["dercj"] = [["ID", "人材机编码", "名称", "规格型号", "单位", "单价", "产地", 
+                    "供应厂商", "人材机类别", "甲供标志", "含量", "合价", "暂估价标志", "主要材料标志", "主材标志", "设备标志" ]];
+                }
+            }
+        }
+        this.cache_djcs = this.cache_djcs.map(x=>{
+            //x["children"] = x["__children"];
+
+            x["key"] = x["序号"];
+            x["_children"] = x["_children"].map(y=>{
+                if (!y.hasOwnProperty('key')) {
+                    y['key'] = uuidv4();
+                }
+                return y;
+            })
+            return x;
+        });
+        this.memory_djcs = [];
+        this.memory_djcs.push(copy(this.cache_djcs));
+        this.mem_pointer_djcs = 0;
+
+    }
+
+
+
     processQingdanmingxi(mingxi) {
         this.cache = copy(mingxi);
         for(let i = 0; i < this.cache.length; i++) {
@@ -558,27 +608,8 @@ class Service{
 
     async generateQingdanrcj(name, bh, bt, bm) {
         if (bt == "Djcs") {
-            const response = await fetch(this.ip().concat( ":8000/qingdanrcj/"), {
-                method : "POST",
-                headers: {
-                    "Content-type": "application/json"
-                },
-                body: JSON.stringify(
-                    {
-                        "bh": bh,
-                        "bt": bt,
-                        "bm": bm,
-                        "name": name
-                    }
-                )
-            });
-            if (!response.ok) {
-                //const error = await response.json();
-                console.error('error');
-            } else {
-                const data = await response.json();
-                return data;
-            }
+            let qd = this.cache_djcs.filter(x=>x["清单编码"] == bm)[0];
+            return copy(qd["rcj"]);
         }
         let qd = this.cache.filter(x=>x["清单编码"] == bm)[0];
         return copy(qd["rcj"]);
@@ -588,28 +619,10 @@ class Service{
         console.log('generateDingercj');
         console.log(debm);
         if (bt == 'Djcs') {
-            const response = await fetch(this.ip().concat( ":8000/dingercj/"), {
-                method : "POST",
-                headers: {
-                    "Content-type": "application/json"
-                },
-                body: JSON.stringify(
-                    {
-                        "bh": bh,
-                        "bt": bt,
-                        "qdbm": qdbm,
-                        "debm" : debm,
-                        "name": name
-                    }
-                )
-            });
-            if (!response.ok) {
-                //const error = await response.json();
-                console.error('error');
-            } else {
-                const data = await response.json();
-                return data;
-            }
+            let qd = this.cache_djcs.filter(x=>x["清单编码"] == qdbm)[0];
+            let de = qd["_children"].filter(x=>x["清单编码"]==debm)[0];
+            return [copy(de["dercj"]), de["fuzhuEnable"]];
+        
         }
         let qd = this.cache.filter(x=>x["清单编码"] == qdbm)[0];
         let de = qd["children"].filter(x=>x["清单编码"]==debm)[0];
@@ -669,6 +682,7 @@ async generateQingdanTuijian(name, bh, bt, bm) {
         }
     }
     async generateDjcs(name, bh) {
+        if (this.cache_djcs.length == 0 || this.cache_djcs[0]["biao_id"] != name || this.cache_djcs[0]["Dwgcbh"] != bh) {
         const response = await fetch(this.ip().concat( ":8000/djcs/"), {
             method : "POST",
             headers: {
@@ -686,7 +700,12 @@ async generateQingdanTuijian(name, bh, bt, bm) {
             console.error('error');
         } else {
             const data = await response.json();
-            return data;
+            this.processDjcsmingxi(data);
+            this.setQufeiEntry(bh);
+            return copy(this.cache_djcs);
+        }
+        } else {
+            return copy(this.cache_djcs);
         }
     }
     async generateFiles() {

+ 1 - 0
front/src/Tabulator.css

@@ -0,0 +1 @@
+.tabulator{background-color:#E8E9EB;}

+ 8 - 1
main.py

@@ -365,7 +365,14 @@ async def read_zjcs(item : Zjcs):
 
 @app.post("/djcs/")
 async def read_djcs(item : Zjcs):
-    return await db.getDjcs(client, item.name, item.bh)
+    raw = await db.getDjcs(client, item.name, item.bh)
+    raw2 = []
+    for entry in raw:
+        if "__children" in entry:
+            entry["_children"] = entry["__children"]
+            del entry["__children"]
+        raw2.append(entry)
+    return raw2
 
 @app.post("/files/")
 async def read_files():

+ 1 - 1
qufei.py

@@ -31,7 +31,7 @@ async def resolve(data):
 
 
 import os
-ttt = ['685be235156b8e6675e2b39f', '685be248ba168dc7c2b52b96', '685be25244c5be685dd5c7c8']
+ttt = ['68651aaa941fef4a206f964b', '68651ac15cf50e4e273abcb4', '68651acc48f5c13072c0cd96']
 
 asyncio.run(resolve(ttt[2]))
 

+ 2 - 1
subdir/db.py

@@ -376,6 +376,7 @@ async def resolve(manager, websocket, data, client):
                 for child in children:
                     dercj = getDjcsDingercj_(root, entry["bh"], "", cs["清单编码"], child["清单编码"])
                     child["dercj"] = dercj
+                    child['fuzhuEnable'] = False
             await collection.insert_one(cs)
 
     collection = db["qdxm"]
@@ -613,7 +614,7 @@ async def getDjcs(client, objectid, id):
     async for post in collection.find({"Dwgcbh": id, "biao_id": objectid}):
         ##post["ID"] = post["_id"]
         del post["_id"]
-        del post["rcj"]
+        ##print( post["rcj"])
         del post["DogNum"]
         result.append(post)
 

+ 6 - 6
subdir/service.py

@@ -1723,9 +1723,9 @@ def getSingleDeXilie_tj(debh):
             clde_["CLBH"] = CLBH
             clde_["CLMC"] = CLMC
             clde_["JLDW"] = JLDW
-            clde_["YSJG"] = YSJG
-            clde_["SL"] = SL
-            clde_["HJ"] = HJ
+            clde_["YSJG"] = YSJG.item() if type(YSJG) == float64 else YSJG
+            clde_["SL"] = SL.item() if type(SL) == float64 else SL
+            clde_["HJ"] = HJ.item() if type(HJ) == float64 else HJ
             clde.append(clde_)
         else:
             detail = pd.read_csv("de/tj/JD_PeiBi.csv")
@@ -1738,9 +1738,9 @@ def getSingleDeXilie_tj(debh):
                 clde_["CLBH"] = CLBH
                 clde_["CLMC"] = CLMC
                 clde_["JLDW"] = JLDW
-                clde_["YSJG"] = YSJG
-                clde_["SL"] = SL
-                clde_["HJ"] = HJ
+                clde_["YSJG"] = YSJG.item() if type(YSJG) == float64 else YSJG
+                clde_["SL"] = SL.item() if type(SL) == float64 else SL
+                clde_["HJ"] = HJ.item() if type(HJ) == float64 else HJ
                 clde.append(clde_)
     return filtered.to_json(force_ascii=False), id, rgde, jxde, clde, bz_selected.to_json(force_ascii=False) if len(bz_selected) > 0 else None, bz_selected2.to_json(force_ascii=False) if len(bz_selected2) > 0 else None
 

+ 1 - 0
test.py

@@ -375,6 +375,7 @@ async def resolve(data):
                 for child in children:
                     dercj = getDjcsDingercj_(root, entry["bh"], "", cs["清单编码"], child["清单编码"])
                     child["dercj"] = dercj
+                    child['fuzhuEnable'] = False
             await collection.insert_one(cs)
 
     collection = db["qdxm"]