Ver código fonte

fix_azfy_and_add_jxs_and_cls

Xiaopeng Zhang 5 meses atrás
pai
commit
226ebb84bf
3 arquivos alterados com 272 adições e 25 exclusões
  1. 208 17
      src/App2.js
  2. 56 0
      src/Service.js
  3. 8 8
      src/utils.js

+ 208 - 17
src/App2.js

@@ -10,8 +10,10 @@ import { debounce } from '@mui/material/utils';
 import throttle from 'lodash/throttle';
 import {Tree as Tree_2} from 'rsuite';
 import './Tree.css';
+import PropTypes from 'prop-types';
 import Grid from '@mui/material/Grid';
 import Tab from "@mui/material/Tab";
+import Tabs from '@mui/material/Tabs';
 import TabContext from "@mui/lab/TabContext";
 import TabList from "@mui/lab/TabList";
 import TabPanel from "@mui/lab/TabPanel";
@@ -67,22 +69,56 @@ import Tooltip from '@mui/material/Tooltip';
 
 
 
+function TabPanel_(props) {
+  const { children, value, index, ...other } = props;
 
+  return (
+    <div
+      role="tabpanel"
+      hidden={value !== index}
+      id={`vertical-tabpanel-${index}`}
+      aria-labelledby={`vertical-tab-${index}`}
+      {...other}
+    >
+      {value === index && (
+          <Box>
+          {children}
+          </Box>
+       
+      )}
+    </div>
+  );
+}
+TabPanel_.propTypes = {
+  children: PropTypes.node,
+  index: PropTypes.number.isRequired,
+  value: PropTypes.number.isRequired,
+};
 
 
 
-
+function a11yProps(index) {
+  return {
+    id: `vertical-tab-${index}`,
+    'aria-controls': `vertical-tabpanel-${index}`,
+  };
+}
 
   export default function App2() {
+    const [tihuanValue, setTihuanValue] = React.useState(0);
     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([]);
+    const [jixieshu, setJixieshu] = React.useState([]);
+    const [cailiaoshu, setCailiaoshu] = React.useState([]);
     const [outlineDes, setOutlineDes] = React.useState([]);
     const [deXilie, setDeXilie] = React.useState([]);
     const [pbXilie, setPbXilie] = React.useState([]);
+    const [jxXilie, setJxXilie] = React.useState([]);
+    const [clXilie, setClXilie] = React.useState([]);
     const [nest, setNest] = React.useState(false);
     const [qingdan, setQingdan] = React.useState(false);
     const [cuoshi, setCuoshi] = React.useState(false);
@@ -144,7 +180,7 @@ import Tooltip from '@mui/material/Tooltip';
     const columns2 =[
     
       {field: '编号', headerName: '定额编号', sortable: false},
-      {field: '名称', headerName: '名称', width: 200, sortable: false}, 
+      {field: '名称', headerName: '名称', width: 250, sortable: false}, 
       {field: '单位', headerName: '单位', sortable: false},
       {field: '单价', headerName: '单价', sortable: false}
     ];
@@ -195,6 +231,13 @@ import Tooltip from '@mui/material/Tooltip';
       setJxde(null);
       setClde(null);
     };
+    const handleChangeTihuan = (event, newValue) => {
+      setTihuanValue(newValue);
+      setPbXilie([]);  
+      setJxXilie([]);  
+      setClXilie([]);  
+     
+    };
 
 
 
@@ -246,6 +289,7 @@ import Tooltip from '@mui/material/Tooltip';
 
     const tihuanCallback = (row, col) => {
         setPbXilie([]);  
+        setJxXilie([]);  
         setDopen(true);
         tihuanRowRef.current = row;
     };
@@ -463,6 +507,61 @@ import Tooltip from '@mui/material/Tooltip';
         }
       
     }
+    const handleItemSelectionToggleJxs = (itemId, event) => {
+      
+      console.log(itemId);
+      if (true) {
+          Service.generateJixieXilie(itemId['id'], zhuanye).then(x=>{
+              let y = JSON.parse(x);
+              console.log(y);
+             
+              let result = [];
+              let keys = Object.keys(y["jxbh"])
+              for(let i = 0; i < keys.length; i++) {
+                  let key = keys[i];
+                  let entry = {
+                    "id": y["ID"][key],
+                    "编号":  y["jxbh"][key], 
+                    "名称":  y["jxmc"][key],
+                    "单位":  y["DW"][key],
+                    "单价":  y["tbdj"][key]
+                  };
+                  result.push(entry);
+                  //setPbXilie(result);
+              }
+              setJxXilie(result);
+          });
+      }
+    
+  }
+
+  const handleItemSelectionToggleCls = (itemId, event) => {
+      
+    console.log(itemId);
+    if (true) {
+        Service.generateCailiaoXilie(itemId['id'], zhuanye).then(x=>{
+            let y = JSON.parse(x);
+            console.log(y);
+           
+            let result = [];
+            let keys = Object.keys(y["CLBH"])
+            for(let i = 0; i < keys.length; i++) {
+                let key = keys[i];
+                let entry = {
+                  "id": y["id"][key],
+                  "编号":  y["CLBH"][key], 
+                  "名称":  y["CLMC"][key],
+                  "单位":  y["JLDW"][key],
+                  "单价":  y["YSJG"][key]
+                };
+                result.push(entry);
+                //setPbXilie(result);
+            }
+            setClXilie(result);
+        });
+    }
+  
+}
 
     const handleDingEEvent = (row) => {
       
@@ -862,6 +961,12 @@ import Tooltip from '@mui/material/Tooltip';
         Service.generatePeibishu(zhuanye).then(x=>{
             setPeibishu(x);
         });
+        Service.generateJixieshu(zhuanye).then(x=>{
+          setJixieshu(x);
+      });
+      Service.generateCailiaoshu(zhuanye).then(x=>{
+        setCailiaoshu(x);
+    });
       }, [zhuanye]
     );
 
@@ -1176,7 +1281,8 @@ import Tooltip from '@mui/material/Tooltip';
            aria-labelledby="customized-dialog-title"
            open={dopen}
            fullWidth={true}
-           maxWidth="md"
+           maxWidth="lg"
+           maxHeight='lg'
           >
             <DialogTitle sx={{ m: 0, p: 2 }} id="customized-dialog-title">
              替换
@@ -1194,19 +1300,35 @@ import Tooltip from '@mui/material/Tooltip';
              <CloseIcon />
             </IconButton>
             <DialogContent dividers>
-            <Stack  direction="row" spacing={2}>
-               <Box sx={{ maxHeight: "350px", minWidth: "300px", maxWidth: "300px"}}>
+            <Box
+                  sx={{ flexGrow: 1, bgcolor: 'background.paper', display: 'flex' }}
+               >
+            <Tabs orientation="vertical"
+               variant="scrollable" value={tihuanValue}
+               onChange={handleChangeTihuan}
+               sx={{
+                borderRight: 1, borderColor: 'divider' ,
+                '& .MuiButtonBase-root': {
+                  maxWidth: '100px', // Adjust font size for cells
+                },
+              }}
+               >
+                <Tab label="配比" {...a11yProps(0)} />
+                <Tab label="机械" {...a11yProps(1)} />
+                <Tab label="材料" {...a11yProps(2)} />
+                </Tabs>
+                <TabPanel_ value={tihuanValue} index={0}>
+                
+                <Stack  direction="row" spacing={2}>
+                <Box sx={{ maxHeight: "350px", minWidth: "350px", maxWidth: "350px"}}>
                <Tree_2  
                       onSelect={handleItemSelectionTogglePbs}
                       defaultValue={null}
 
                      
-                     data={peibishu}/>
-                     </Box>
-                     
-               
-              
-               <div style={{ height: 350 }}>
+                    data={peibishu}/>
+                    </Box>
+                    <div style={{ height: 350 }}>
 
                     <DataGrid disableColumnMenu
                       sx={{
@@ -1226,12 +1348,81 @@ import Tooltip from '@mui/material/Tooltip';
                       localeText={zhCN.components.MuiDataGrid.defaultProps.localeText}
                      />
                     </div>
-              
-             
-              
-            </Stack>
-          
-          
+                </Stack>
+           
+            </TabPanel_>
+            <TabPanel_ value={tihuanValue} index={1}>
+                
+                <Stack  direction="row" spacing={2}>
+                <Box sx={{ maxHeight: "350px", minWidth: "350px", maxWidth: "350px"}}>
+               <Tree_2  
+                      onSelect={handleItemSelectionToggleJxs}
+                      defaultValue={null}
+
+                     
+                    data={jixieshu}/>
+                    </Box>
+                    <div style={{ height: 350 }}>
+
+                    <DataGrid disableColumnMenu
+                      sx={{
+                        '& .MuiDataGrid-cell': {
+                          fontSize: '0.8rem', // Adjust font size for cells
+                        }}}
+                       getRowHeight={() => 'auto'}
+                      rows={jxXilie}
+                      onRowDoubleClick={handleEvent}
+                      columns={columns2}
+                      hideFooter={false}
+                      disableColumnFilter
+                      disableColumnSelector
+                      disableDensitySelector
+                      slots={{ toolbar: CustomToolbar}}
+                      
+                      localeText={zhCN.components.MuiDataGrid.defaultProps.localeText}
+                     />
+                    </div>
+
+                </Stack>
+            
+                </TabPanel_>
+                <TabPanel_ value={tihuanValue} index={2}>
+                
+                <Stack  direction="row" spacing={2}>
+                <Box sx={{ maxHeight: "350px", minWidth: "350px", maxWidth: "350px"}}>
+               <Tree_2  
+                      onSelect={handleItemSelectionToggleCls}
+                      defaultValue={null}
+
+                     
+                    data={cailiaoshu}/>
+                    </Box>
+                    <div style={{ height: 350 }}>
+
+                    <DataGrid disableColumnMenu
+                      sx={{
+                        '& .MuiDataGrid-cell': {
+                          fontSize: '0.8rem', // Adjust font size for cells
+                        }}}
+                       getRowHeight={() => 'auto'}
+                      rows={clXilie}
+                      onRowDoubleClick={handleEvent}
+                      columns={columns2}
+                      hideFooter={false}
+                      disableColumnFilter
+                      disableColumnSelector
+                      disableDensitySelector
+                      slots={{ toolbar: CustomToolbar}}
+                      
+                      localeText={zhCN.components.MuiDataGrid.defaultProps.localeText}
+                     />
+                    </div>
+
+                </Stack>
+            
+                </TabPanel_>
+           
+          </Box>
            </DialogContent>
          </Dialog>
          <Dialog

+ 56 - 0
src/Service.js

@@ -670,6 +670,32 @@ async generateQingdanTuijian(name, bh, bt, bm) {
             return data;
         }
     }
+    async generateJixieXilie(id, zhuanye) {
+        const response = await fetch(this.ip().concat( "/jxxl/").concat(id).concat('/').concat(zhuanye.toString()), {
+            method : "GET",
+           
+        });
+        if (!response.ok) {
+            //const error = await response.json();
+            console.error('error');
+        } else {
+            const data = await response.json();
+            return data;
+        }
+    }
+    async generateCailiaoXilie(id, zhuanye) {
+        const response = await fetch(this.ip().concat( "/clxl/").concat(id).concat('/').concat(zhuanye.toString()), {
+            method : "GET",
+           
+        });
+        if (!response.ok) {
+            //const error = await response.json();
+            console.error('error');
+        } else {
+            const data = await response.json();
+            return data;
+        }
+    }
     async generatePeibishu(zhuanye) {
         
         const response = await fetch(this.ip().concat( "/pbs/").concat(zhuanye.toString()), {
@@ -685,6 +711,36 @@ async generateQingdanTuijian(name, bh, bt, bm) {
             return data;
         }
     }
+    async generateJixieshu(zhuanye) {
+        
+        const response = await fetch(this.ip().concat( "/jxs/").concat(zhuanye.toString()), {
+            method : "GET",
+            
+        });
+        if (!response.ok) {
+            //const error = await response.json();
+            console.error('error');
+        } else {
+            const data = await response.json();
+            
+            return data;
+        }
+    }
+    async generateCailiaoshu(zhuanye) {
+        
+        const response = await fetch(this.ip().concat( "/cls/").concat(zhuanye.toString()), {
+            method : "GET",
+            
+        });
+        if (!response.ok) {
+            //const error = await response.json();
+            console.error('error');
+        } else {
+            const data = await response.json();
+            
+            return data;
+        }
+    }
     async generateDingeshu(value) {
         
         const response = await fetch(this.ip().concat( "/des/").concat(value.toString()), {

+ 8 - 8
src/utils.js

@@ -429,7 +429,7 @@ export const azfy = (debh, gclmc) => {
             result['azfytag'] = rate;
             return result;
        }
-       if (debh.includes("-F3")) {
+       if (debh.includes("-F4")) {
             let index = predef['GCLMC'][2].indexOf(gclmc);
             let rate = predef['rate'][2][index];
             let result = {};
@@ -440,7 +440,7 @@ export const azfy = (debh, gclmc) => {
             result['azfytag'] = rate;
             return result;
        }
-       if (debh.includes("-F4")) {
+       if (debh.includes("-F5")) {
             let index = predef['GCLMC'][3].indexOf(gclmc);
             let rate = predef['rate'][3][index];
             let result = {};
@@ -451,7 +451,7 @@ export const azfy = (debh, gclmc) => {
             result['azfytag'] = rate;
             return result;
        }
-       if (debh.includes("4-F5")) {
+       if (debh.includes("4-F3")) {
             let index = predef['GCLMC'][4].indexOf(gclmc);
             let rate = predef['rate'][4][index];
             let result = {};
@@ -462,7 +462,7 @@ export const azfy = (debh, gclmc) => {
             result['azfytag'] = rate;
             return result;
        }
-       if (debh.includes("5-F5")) {
+       if (debh.includes("5-F3")) {
             let index = predef['GCLMC'][5].indexOf(gclmc);
             let rate = predef['rate'][5][index];
             let result = {};
@@ -473,7 +473,7 @@ export const azfy = (debh, gclmc) => {
             result['azfytag'] = rate;
             return result;
        }
-       if (debh.includes("7-F5")) {
+       if (debh.includes("7-F3")) {
             let index = predef['GCLMC'][6].indexOf(gclmc);
             let rate = predef['rate'][6][index];
             let result = {};
@@ -484,7 +484,7 @@ export const azfy = (debh, gclmc) => {
             result['azfytag'] = rate;
             return result;
        }
-       if (debh.includes("9-F5")) {
+       if (debh.includes("9-F3")) {
             let index = predef['GCLMC'][7].indexOf(gclmc);
             let rate = predef['rate'][7][index];
             let result = {};
@@ -495,7 +495,7 @@ export const azfy = (debh, gclmc) => {
             result['azfytag'] = rate;
             return result;
        }
-       if (debh.includes("10-F5")) {
+       if (debh.includes("10-F3")) {
             let index = predef['GCLMC'][8].indexOf(gclmc);
             let rate = predef['rate'][8][index];
             let result = {};
@@ -506,7 +506,7 @@ export const azfy = (debh, gclmc) => {
             result['azfytag'] = rate;
             return result;
        }
-       if (debh.includes("11-F5")) {
+       if (debh.includes("11-F3")) {
             let index = predef['GCLMC'][9].indexOf(gclmc);
             let rate = predef['rate'][9][index];
             let result = {};