|
|
@@ -162,6 +162,8 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
const cldeRef = React.useRef(null);
|
|
|
const isQdrcj = React.useRef(false);
|
|
|
const [selectedRowKeys, setSelectedRowKeys] = React.useState([]);
|
|
|
+
|
|
|
+ const [expandedRowKeys, setExpandedRowKeys] = React.useState([]);
|
|
|
const rowSelection = {
|
|
|
selectedRowKeys,
|
|
|
onChange: (selectedRowKeys) => {
|
|
|
@@ -326,7 +328,12 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
|
|
|
|
|
|
const handleSelection = (row) => {
|
|
|
- if (row == null || row.length == 0) return;
|
|
|
+ if (row == null || row.length == 0) {
|
|
|
+ setRcjhl([]);
|
|
|
+ isQdrcj.current = true;
|
|
|
+ highlight.current = [];
|
|
|
+ return;
|
|
|
+ }
|
|
|
let qd = detail.filter(x=>x['key'] == row[0]);
|
|
|
if (qd.length > 0) {
|
|
|
Service.generateQingdanrcj(name, bh,bt,qd[0]['清单编码']).then(x=>{
|
|
|
@@ -439,21 +446,52 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
<Box>
|
|
|
<Stack direction='row' spacing={2}>
|
|
|
<Button variant="outlined" onClick={() => {
|
|
|
- const [success, data] = danxiangdinge(selectedRow.current);
|
|
|
- if(success) {
|
|
|
- setDetail(data);
|
|
|
+ if (selectedRowKeys.length > 0) {
|
|
|
+ const [success, data] = danxiangdinge(selectedRowKeys[0]);
|
|
|
+ if(success) {
|
|
|
+ setDetail(data);
|
|
|
+ setExpandedRowKeys([...expandedRowKeys, selectedRowKeys[0]]);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
}}
|
|
|
>单项定额</Button>
|
|
|
+ <Button variant="outlined" onClick={() => {
|
|
|
+ if (selectedRowKeys.length > 0) {
|
|
|
+ let newData = shanchu(selectedRowKeys[0]);
|
|
|
+ setDetail(newData);
|
|
|
+ if (newData.filter(x=>x['key'] == selectedRowKeys[0]).length == 0) {
|
|
|
+ setSelectedRowKeys([]);
|
|
|
+ handleSelection([]);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }}
|
|
|
+ >删除</Button>
|
|
|
<Button variant="outlined" onClick={() => {
|
|
|
- setDetail(undo());
|
|
|
+ let newData = undo();
|
|
|
+ setDetail(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([]);
|
|
|
+ }
|
|
|
|
|
|
}}
|
|
|
>撤销</Button>
|
|
|
<Button variant="outlined" onClick={() => {
|
|
|
- setDetail(redo());
|
|
|
+ let newData = redo();
|
|
|
+ setDetail(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([]);
|
|
|
+ }
|
|
|
|
|
|
}}
|
|
|
>重做</Button>
|
|
|
@@ -469,6 +507,14 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
ref = {hotRef}
|
|
|
expandable = {
|
|
|
{
|
|
|
+ expandedRowKeys,
|
|
|
+ onExpand: (expandable, record) => {
|
|
|
+ if (expandable) {
|
|
|
+ setExpandedRowKeys([...expandedRowKeys, record.key]);
|
|
|
+ } else {
|
|
|
+ setExpandedRowKeys(expandedRowKeys.filter((id) => record.key !== id));
|
|
|
+ }
|
|
|
+ },
|
|
|
expandRowByClick: true
|
|
|
}
|
|
|
}
|
|
|
@@ -556,7 +602,7 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
ref = {hotRcjRef}
|
|
|
afterChange={(changes, source) => {
|
|
|
//console.log(hotRcjRef.current?.hotInstance?.getData());
|
|
|
- updateDercj(selectedRow.current, hotRcjRef.current?.hotInstance?.getData());
|
|
|
+ updateDercj(hotRcjRef.current?.hotInstance?.getData());
|
|
|
}}
|
|
|
licenseKey="non-commercial-and-evaluation" // for non-commercial use only
|
|
|
/>
|