Selaa lähdekoodia

support 修改定额数量

Xiaopeng Zhang 6 kuukautta sitten
vanhempi
commit
54fdc5afcb
5 muutettua tiedostoa jossa 159 lisäystä ja 6 poistoa
  1. 1 0
      front/package.json
  2. 83 0
      front/src/Editable.js
  3. 40 6
      front/src/Qingdan.js
  4. 30 0
      front/src/Service.js
  5. 5 0
      front/src/editor.js

+ 1 - 0
front/package.json

@@ -11,6 +11,7 @@
   "author": "",
   "license": "ISC",
   "dependencies": {
+    "@chakra-ui/react": "^3.21.0",
     "@emotion/react": "latest",
     "@emotion/styled": "latest",
     "@handsontable/react": "^11.0.0",

+ 83 - 0
front/src/Editable.js

@@ -0,0 +1,83 @@
+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 { registerPlugin, NestedRows } from 'handsontable/plugins';
+//registerPlugin(NestedRows);
+import Qingdan from './Qingdan';
+import Zjcs from './Zjcs';
+import Djcs from './Djcs';
+import Service from './Service';
+import {useLocation} from "react-router";
+import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
+import Typography from '@mui/material/Typography';
+import InputLabel from '@mui/material/InputLabel';
+import MenuItem from '@mui/material/MenuItem';
+import FormControl from '@mui/material/FormControl';
+import Select from '@mui/material/Select';
+import Accordion from '@mui/material/Accordion';
+import AccordionActions from '@mui/material/AccordionActions';
+import AccordionSummary from '@mui/material/AccordionSummary';
+import AccordionDetails from '@mui/material/AccordionDetails';
+import Stack from '@mui/material/Stack';
+import { DataGrid } from '@mui/x-data-grid';
+
+import Button from '@mui/material/Button';
+import TextField from '@mui/material/TextField';
+
+
+
+
+  export default function Editable({ initialText,  onChange }) {
+    const [isEditing, setIsEditing] = React.useState(false);
+    const [textValue, setTextValue] = React.useState(initialText);
+    
+    React.useEffect(
+      () => {
+        setTextValue(initialText);
+      }, [initialText]
+    );
+    return (
+
+        <Box>
+        {isEditing ? (
+            <TextField id="outlined-basic" value={textValue} size="small"
+            autoFocus
+             variant="outlined"
+             onChange={(event) => {
+              setTextValue(event.target.value);
+              }} 
+            onKeyDown={(e)=> {
+              if (e.key == "Enter") {
+                
+                setIsEditing(false);
+                onChange(textValue);
+                
+
+              }
+            }}
+            onBlur={()=> {
+              setIsEditing(false);
+              onChange(textValue);
+            }}
+            />
+          ) : (
+            <Button disableRipple variant="text" color="#000000"
+               onDoubleClick={()=>{
+                setIsEditing(true);
+               }}
+            >{textValue}</Button>
+          )}
+        </Box>
+    
+    );
+  }

+ 40 - 6
front/src/Qingdan.js

@@ -3,7 +3,7 @@ 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 { Table, ConfigProvider } from "antd";
+import { Table, ConfigProvider, Button as AButton } from "antd";
 import {HotTable} from "@handsontable/react-wrapper";
 import { registerAllModules } from 'handsontable/registry';
 import {RichTreeView } from "@mui/x-tree-view/RichTreeView";
@@ -20,7 +20,7 @@ import { textRenderer, registerRenderer } from 'handsontable/renderers';
 import Button from '@mui/material/Button';
 import ButtonGroup from '@mui/material/ButtonGroup';
 import {extractFuzhu} from './utils';
-import {shanchu, undo, redo, quanbushanchu, danxiangdinge, updateDercj, changguidinge, handleBeizhu, huan} from './editor';
+import {shanchu, undo, redo, quanbushanchu, danxiangdinge, updateDercj, changguidinge, handleBeizhu, huan, updateShuliang} from './editor';
 import { ConfigValueTooSmallError, HyperFormula } from 'hyperformula';
 import Backdrop from '@mui/material/Backdrop';
 import CircularProgress from '@mui/material/CircularProgress';
@@ -29,6 +29,14 @@ import { useHotEditor } from "@handsontable/react-wrapper";
 import Dialog from '@mui/material/Dialog';
 import DialogTitle from '@mui/material/DialogTitle';
 import DialogContent from '@mui/material/DialogContent';
+import IconButton from '@mui/material/IconButton';
+import Typography from '@mui/material/Typography';
+import Editable from './Editable';
+import {
+
+     SettingFilled,
+
+   } from '@ant-design/icons';
 registerAllModules();
 
 
@@ -43,9 +51,9 @@ registerAllModules();
  */
 
 
-function copy(input) {
-     return JSON.parse(JSON.stringify(input));
-}
+
+
+
 
 
 
@@ -619,7 +627,32 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, beizhuF
                          { dataIndex: '项目特征' ,    title : '项目特征' ,    key : '项目特征'    , width : 300         },
                          { dataIndex: '计算规则' ,    title : '计算规则' ,    key : '计算规则'    , width : 300         },
                          { dataIndex: '单位'    ,     title : '单位'  ,       key : '单位'        , width : 100         },
-                         { dataIndex: '数量'    ,     title : '数量'  ,       key : '数量'        , width : 100         },
+                         { dataIndex: '数量'    ,     title : '数量'  ,       key : '数量'        , width : 100    ,
+                         
+                         render: (text, record) => {
+                              console.log("column render");
+                              console.log("text".concat(text));
+                              //console.log(record);
+                                      if(record['序号']) {
+                                        return ( <plaintext>{text}</plaintext> );
+                                      } else {
+                                        return ( 
+                                             <Editable initialText={text}  onChange={(value)=>{
+                                                  let [success, data] = updateShuliang(value, selectedRowKeys[0]);
+                                                  if (success) {
+                                                       setDetail(data);
+                                                       detailRef.current = data;
+                                                       handleSelection(selectedRowKeys);
+                                                  }
+                                             }}
+                                             >
+                                            </Editable>
+                                         );
+                                      }
+                                      //console.log(text);
+                                      
+                              }
+                         },
                          { dataIndex: '综合单价' ,   title : '综合单价'  ,   key : '综合单价'     , width : 100        },
                          { dataIndex: '合价'   ,      title : '合价'   ,      key : '合价'        , width : 100         },
                          { dataIndex: '人工费'  ,     title : '人工费'  ,     key : '人工费'      , width : 100         },
@@ -633,6 +666,7 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, beizhuF
                          { dataIndex: '暂估价'  ,     title : '暂估价'  ,     key : '暂估价'      , width : 100         },
                          { dataIndex: '综合人工工日', title : '综合人工工日', key : '综合人工工日', width : 100         },
                          { dataIndex: '备注'     ,    title : '备注'   ,      key : '备注'        , width : 100         },
+                         
                         
 
                          

+ 30 - 0
front/src/Service.js

@@ -1187,6 +1187,36 @@ async generateQingdanTuijian(name, bh, bt, bm) {
 
 
 
+    }
+
+    updateShuliang(value, row) {
+        let qd = this.cache.filter(x=>x["children"].filter(y=>y['key']==row).length > 0)[0];
+        let de = qd["children"].filter(x=>x['key'] == row)[0];
+        let origin = de['数量']
+        if (Number(origin) - Number(value) < 0.0001 && Number(origin) - Number(value) > -0.0001) {
+            return [false, null];
+        }
+        console.log("shuliang update");
+        de['数量'] = value;
+        de['合价'] = Number(qd['数量']) * Number(de['综合单价']) * Number(de['数量']);
+        let newData = this.cache.map(x=>{
+            if (x['key'] == qd['key']) {
+                return qd;
+            } else {
+                return x;
+            }
+        });
+        let summarized = this.summarize(newData);
+        this.push_op(summarized);
+        /////////////////
+        this.cache = copy(summarized);
+        return [true, copy(this.cache)];
+
+
+
+
+
+
     }
 
 

+ 5 - 0
front/src/editor.js

@@ -53,6 +53,11 @@ export const huan = (replaceState, row) => {
 
 };
 
+export const updateShuliang = (data, row) => {
+    return Service.updateShuliang(data, row);
+
+};
+
 export const changguidinge = (dingeclick, selectedRow) => {
     return Service.changguidinge(dingeclick, selectedRow);