|
@@ -19,7 +19,7 @@ import { textRenderer, registerRenderer } from 'handsontable/renderers';
|
|
|
import Button from '@mui/material/Button';
|
|
import Button from '@mui/material/Button';
|
|
|
import ButtonGroup from '@mui/material/ButtonGroup';
|
|
import ButtonGroup from '@mui/material/ButtonGroup';
|
|
|
import {danxiangdinge_index} from './utils';
|
|
import {danxiangdinge_index} from './utils';
|
|
|
-import {shanchu, push_op, quanbushanchu, danxiangdinge} from './editor';
|
|
|
|
|
|
|
+import {shanchu, undo, redo, quanbushanchu, danxiangdinge, updateDercj} from './editor';
|
|
|
import { HyperFormula } from 'hyperformula';
|
|
import { HyperFormula } from 'hyperformula';
|
|
|
|
|
|
|
|
registerAllModules();
|
|
registerAllModules();
|
|
@@ -48,8 +48,7 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
// initialize it with the `'internal-use-in-handsontable'` license key
|
|
// initialize it with the `'internal-use-in-handsontable'` license key
|
|
|
licenseKey: 'internal-use-in-handsontable',
|
|
licenseKey: 'internal-use-in-handsontable',
|
|
|
});
|
|
});
|
|
|
- const memory = React.useRef([]);
|
|
|
|
|
- const mem_pointer = React.useRef(0);
|
|
|
|
|
|
|
+
|
|
|
function coverRenderer(_instance, td, _row, _col, _prop, value, _cellProperties) {
|
|
function coverRenderer(_instance, td, _row, _col, _prop, value, _cellProperties) {
|
|
|
|
|
|
|
|
let z = _instance.getDataAtRow(_row);
|
|
let z = _instance.getDataAtRow(_row);
|
|
@@ -64,8 +63,7 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
|
});*/
|
|
});*/
|
|
|
button.addEventListener('mousedown', (event) => {
|
|
button.addEventListener('mousedown', (event) => {
|
|
|
- setDetail(shanchu(hotRef, selectedRow, detailRef));
|
|
|
|
|
- push_op(memory, mem_pointer, detailRef);
|
|
|
|
|
|
|
+ setDetail(shanchu(hotRef, selectedRow));
|
|
|
//console.log(plugin);
|
|
//console.log(plugin);
|
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
|
});
|
|
});
|
|
@@ -76,8 +74,7 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
button.innerText="全部删除";
|
|
button.innerText="全部删除";
|
|
|
//img.src = value;
|
|
//img.src = value;
|
|
|
button.addEventListener('mousedown', (event) => {
|
|
button.addEventListener('mousedown', (event) => {
|
|
|
- setDetail(quanbushanchu(hotRef, selectedRow, detailRef));
|
|
|
|
|
- push_op(memory, mem_pointer, detailRef);
|
|
|
|
|
|
|
+ setDetail(quanbushanchu(hotRef, selectedRow));
|
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
|
});
|
|
});
|
|
|
td.innerText = '';
|
|
td.innerText = '';
|
|
@@ -90,13 +87,20 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- registerRenderer('customStylesRenderer', (hotInstance, TD, ...rest) => {
|
|
|
|
|
- textRenderer(hotInstance, TD, ...rest);
|
|
|
|
|
- TD.style.fontWeight = 'bold';
|
|
|
|
|
- TD.style.color = 'green';
|
|
|
|
|
- TD.style.background = '#d7f1e1';
|
|
|
|
|
|
|
+ registerRenderer('customStylesRenderer', (hotInstance, TD, row, column, ...rest) => {
|
|
|
|
|
+ textRenderer(hotInstance, TD, row, column, ...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';
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
});
|
|
});
|
|
|
registerRenderer('highlightRowRenderer', (hotInstance, TD, row, column, ...rest) => {
|
|
registerRenderer('highlightRowRenderer', (hotInstance, TD, row, column, ...rest) => {
|
|
|
|
|
+ if (row == selectedRow.current) {
|
|
|
if(column > 0 ) {
|
|
if(column > 0 ) {
|
|
|
textRenderer(hotInstance, TD, row, column, ...rest);
|
|
textRenderer(hotInstance, TD, row, column, ...rest);
|
|
|
TD.style.color = 'green';
|
|
TD.style.color = 'green';
|
|
@@ -105,6 +109,9 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
if (column == 0) {
|
|
if (column == 0) {
|
|
|
coverRenderer(hotInstance, TD, row, column, ...rest);
|
|
coverRenderer(hotInstance, TD, row, column, ...rest);
|
|
|
}
|
|
}
|
|
|
|
|
+ } else {
|
|
|
|
|
+ textRenderer(hotInstance, TD, row, column, ...rest);
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
@@ -127,16 +134,16 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
"综合人工工日" : null,
|
|
"综合人工工日" : null,
|
|
|
"备注" : null}]
|
|
"备注" : null}]
|
|
|
);
|
|
);
|
|
|
- const detailRef = React.useRef(null);
|
|
|
|
|
const [value, setValue] = React.useState("1");
|
|
const [value, setValue] = React.useState("1");
|
|
|
const [rcjhl, setRcjhl] = React.useState([]);
|
|
const [rcjhl, setRcjhl] = React.useState([]);
|
|
|
const [rcjhl2, setRcjhl2] = React.useState([]);
|
|
const [rcjhl2, setRcjhl2] = React.useState([]);
|
|
|
const [fuzhu, setFuzhu] = React.useState([]);
|
|
const [fuzhu, setFuzhu] = React.useState([]);
|
|
|
const [tuijian, setTuijian] = React.useState([]);
|
|
const [tuijian, setTuijian] = React.useState([]);
|
|
|
- const [highlight, setHighlight] = React.useState([]);
|
|
|
|
|
|
|
+ const highlight = React.useRef([]);
|
|
|
const selectedRow = React.useRef(-1);
|
|
const selectedRow = React.useRef(-1);
|
|
|
const hotRef = React.useRef(null);
|
|
const hotRef = React.useRef(null);
|
|
|
const hotRcjRef = React.useRef(null);
|
|
const hotRcjRef = React.useRef(null);
|
|
|
|
|
+ const hotTuijianRef = React.useRef(null);
|
|
|
const rgdeRef = React.useRef(null);
|
|
const rgdeRef = React.useRef(null);
|
|
|
const jxdeRef = React.useRef(null);
|
|
const jxdeRef = React.useRef(null);
|
|
|
const cldeRef = React.useRef(null);
|
|
const cldeRef = React.useRef(null);
|
|
@@ -153,10 +160,7 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
//});
|
|
//});
|
|
|
|
|
|
|
|
setDetail(x);
|
|
setDetail(x);
|
|
|
- memory.current = [copy(x)];
|
|
|
|
|
- mem_pointer.current = 0;
|
|
|
|
|
|
|
|
|
|
- detailRef.current = x;
|
|
|
|
|
setRcjhl([]);
|
|
setRcjhl([]);
|
|
|
selectedRow.current = -1;
|
|
selectedRow.current = -1;
|
|
|
});
|
|
});
|
|
@@ -184,7 +188,7 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
jxdeRef.current = jxde;
|
|
jxdeRef.current = jxde;
|
|
|
cldeRef.current = clde;
|
|
cldeRef.current = clde;
|
|
|
if (isQdrcj.current) {
|
|
if (isQdrcj.current) {
|
|
|
- setHighlight([]);
|
|
|
|
|
|
|
+ highlight.current = [];
|
|
|
} else {
|
|
} else {
|
|
|
let toHighlight = [];
|
|
let toHighlight = [];
|
|
|
for(let i = 1; i < rcjhl.length; i++) {
|
|
for(let i = 1; i < rcjhl.length; i++) {
|
|
@@ -252,7 +256,7 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
//console.log(toHighlight);
|
|
//console.log(toHighlight);
|
|
|
- setHighlight(toHighlight);
|
|
|
|
|
|
|
+ highlight.current = toHighlight;
|
|
|
}
|
|
}
|
|
|
let bzrcjhl = [["人材机编码", "名称", "单位", "单价", "合价", "含量"]]
|
|
let bzrcjhl = [["人材机编码", "名称", "单位", "单价", "合价", "含量"]]
|
|
|
if (rgde)
|
|
if (rgde)
|
|
@@ -277,6 +281,17 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
setValue(newValue);
|
|
setValue(newValue);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ 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, column) => {
|
|
const handleSelection = (row, column) => {
|
|
|
selectedRow.current = row;
|
|
selectedRow.current = row;
|
|
|
let selected = hotRef.current?.hotInstance?.getData()[row];
|
|
let selected = hotRef.current?.hotInstance?.getData()[row];
|
|
@@ -284,13 +299,15 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
if (selected[1] != null) {
|
|
if (selected[1] != null) {
|
|
|
Service.generateQingdanrcj(name, bh,bt,selected[2]).then(x=>{
|
|
Service.generateQingdanrcj(name, bh,bt,selected[2]).then(x=>{
|
|
|
|
|
|
|
|
- setRcjhl(x);
|
|
|
|
|
|
|
+ //setRcjhl(x);
|
|
|
|
|
+ hotRcjRef.current?.hotInstance?.loadData(x);
|
|
|
|
|
|
|
|
isQdrcj.current = true;
|
|
isQdrcj.current = true;
|
|
|
- setHighlight([]);
|
|
|
|
|
|
|
+ highlight.current = [];
|
|
|
});
|
|
});
|
|
|
Service.generateQingdanTuijian(name, bh,bt,selected[2]).then(x=>{
|
|
Service.generateQingdanTuijian(name, bh,bt,selected[2]).then(x=>{
|
|
|
- setTuijian(x);
|
|
|
|
|
|
|
+ //setTuijian(x);
|
|
|
|
|
+ hotTuijianRef.current?.hotInstance?.loadData(x);
|
|
|
//isQdrcj.current = true;
|
|
//isQdrcj.current = true;
|
|
|
//setHighlight([]);
|
|
//setHighlight([]);
|
|
|
});
|
|
});
|
|
@@ -308,7 +325,8 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
clickCallback(qdbm, selected[2]);
|
|
clickCallback(qdbm, selected[2]);
|
|
|
Service.generateDingercj(name, bh,bt,qdbm, selected[2], selected[6]).then(x=>{
|
|
Service.generateDingercj(name, bh,bt,qdbm, selected[2], selected[6]).then(x=>{
|
|
|
console.log(x);
|
|
console.log(x);
|
|
|
- setRcjhl(x);
|
|
|
|
|
|
|
+ //setRcjhl(x);
|
|
|
|
|
+ hotRcjRef.current?.hotInstance?.loadData(x);
|
|
|
isQdrcj.current = false;
|
|
isQdrcj.current = false;
|
|
|
let toHighlight = [];
|
|
let toHighlight = [];
|
|
|
for(let i = 1; i < x.length; i++) {
|
|
for(let i = 1; i < x.length; i++) {
|
|
@@ -374,10 +392,13 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
toHighlight.push({row: i, col: 1, renderer: "customStylesRenderer"});
|
|
toHighlight.push({row: i, col: 1, renderer: "customStylesRenderer"});
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- setHighlight(toHighlight);
|
|
|
|
|
|
|
+ highlight.current = toHighlight;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ hotRef.current?.hotInstance?.render();
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
@@ -387,38 +408,22 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
<Box>
|
|
<Box>
|
|
|
<Stack direction='row' spacing={2}>
|
|
<Stack direction='row' spacing={2}>
|
|
|
<Button variant="outlined" onClick={() => {
|
|
<Button variant="outlined" onClick={() => {
|
|
|
- //console.log(memory.current);
|
|
|
|
|
- const [success, data] = danxiangdinge(hotRef, selectedRow, detailRef);
|
|
|
|
|
|
|
+ const [success, data] = danxiangdinge(selectedRow.current);
|
|
|
if(success) {
|
|
if(success) {
|
|
|
setDetail(data);
|
|
setDetail(data);
|
|
|
- push_op(memory, mem_pointer, detailRef);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
}}
|
|
}}
|
|
|
>单项定额</Button>
|
|
>单项定额</Button>
|
|
|
<Button variant="outlined" onClick={() => {
|
|
<Button variant="outlined" onClick={() => {
|
|
|
- //console.log(memory.current);
|
|
|
|
|
- if (mem_pointer.current > 0) {
|
|
|
|
|
- setDetail(memory.current[mem_pointer.current - 1]);
|
|
|
|
|
- detailRef.current = memory.current[mem_pointer.current - 1];
|
|
|
|
|
- mem_pointer.current = mem_pointer.current - 1;
|
|
|
|
|
- console.log("after undo");
|
|
|
|
|
- console.log(memory.current);
|
|
|
|
|
- console.log(mem_pointer.current);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ setDetail(undo());
|
|
|
|
|
+
|
|
|
}}
|
|
}}
|
|
|
>撤销</Button>
|
|
>撤销</Button>
|
|
|
<Button variant="outlined" onClick={() => {
|
|
<Button variant="outlined" onClick={() => {
|
|
|
- //console.log(memory.current);
|
|
|
|
|
- if (mem_pointer.current + 1 != memory.current.length) {
|
|
|
|
|
- setDetail(memory.current[mem_pointer.current + 1]);
|
|
|
|
|
- detailRef.current = memory.current[mem_pointer.current + 1];
|
|
|
|
|
- mem_pointer.current = mem_pointer.current + 1;
|
|
|
|
|
- console.log("after redo");
|
|
|
|
|
- console.log(memory.current);
|
|
|
|
|
- console.log(mem_pointer.current);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ setDetail(redo());
|
|
|
|
|
+
|
|
|
}}
|
|
}}
|
|
|
>重做</Button>
|
|
>重做</Button>
|
|
|
|
|
|
|
@@ -428,23 +433,26 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
nestedRows={true}
|
|
nestedRows={true}
|
|
|
data={detail
|
|
data={detail
|
|
|
}
|
|
}
|
|
|
- afterUpdateData={(x)=>{
|
|
|
|
|
- //-console.log(x);
|
|
|
|
|
- hotRef.current?.hotInstance?.scrollViewportTo({ row: selectedRow.current });
|
|
|
|
|
- //handleSelection(selectedRow.current, 0);
|
|
|
|
|
|
|
+ afterUpdateData={afterUpdateData}
|
|
|
|
|
+ beforeUpdateData={(a,b,c)=>{
|
|
|
|
|
+ let plugin = hotRef.current?.hotInstance.getPlugin("NestedRows");
|
|
|
|
|
+ let ui = plugin.collapsingUI;
|
|
|
|
|
+ console.log(ui);
|
|
|
|
|
+
|
|
|
|
|
|
|
|
}}
|
|
}}
|
|
|
|
|
|
|
|
|
|
+ //afterSelection={handleSelection}
|
|
|
afterSelection={handleSelection}
|
|
afterSelection={handleSelection}
|
|
|
ref = {hotRef}
|
|
ref = {hotRef}
|
|
|
cells={(row, col, prop) => {
|
|
cells={(row, col, prop) => {
|
|
|
- if (row == selectedRow.current) {
|
|
|
|
|
|
|
+
|
|
|
return {
|
|
return {
|
|
|
// row options, which apply to each cell of the second row
|
|
// row options, which apply to each cell of the second row
|
|
|
// and to each cell of the fifth row
|
|
// and to each cell of the fifth row
|
|
|
renderer: "highlightRowRenderer"
|
|
renderer: "highlightRowRenderer"
|
|
|
};
|
|
};
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
colWidths={(index) => {
|
|
colWidths={(index) => {
|
|
@@ -513,7 +521,7 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
nestedRows={false}
|
|
nestedRows={false}
|
|
|
data={rcjhl
|
|
data={rcjhl
|
|
|
}
|
|
}
|
|
|
- cell={highlight}
|
|
|
|
|
|
|
+ //cell={highlight}
|
|
|
manualColumnResize={true}
|
|
manualColumnResize={true}
|
|
|
rowHeaders={true}
|
|
rowHeaders={true}
|
|
|
colHeaders={true}
|
|
colHeaders={true}
|
|
@@ -525,19 +533,23 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
|
|
|
|
|
cells={(row, col) => {
|
|
cells={(row, col) => {
|
|
|
if (row === 0) {
|
|
if (row === 0) {
|
|
|
- return { readOnly: true };
|
|
|
|
|
|
|
+ return { readOnly: true, renderer: "customStylesRenderer" };
|
|
|
}
|
|
}
|
|
|
if (col <= 1 || col === 11) {
|
|
if (col <= 1 || col === 11) {
|
|
|
- return { readOnly: true };
|
|
|
|
|
|
|
+ return { readOnly: true, renderer: "customStylesRenderer" };
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return {};
|
|
|
|
|
|
|
+ return {renderer: "customStylesRenderer"};
|
|
|
}}
|
|
}}
|
|
|
fixedRowsTop={1}
|
|
fixedRowsTop={1}
|
|
|
selectionMode="single"
|
|
selectionMode="single"
|
|
|
autoWrapRow={false}
|
|
autoWrapRow={false}
|
|
|
autoWrapCol={false}
|
|
autoWrapCol={false}
|
|
|
ref = {hotRcjRef}
|
|
ref = {hotRcjRef}
|
|
|
|
|
+ afterChange={(changes, source) => {
|
|
|
|
|
+ //console.log(hotRcjRef.current?.hotInstance?.getData());
|
|
|
|
|
+ updateDercj(selectedRow.current, hotRcjRef.current?.hotInstance?.getData());
|
|
|
|
|
+ }}
|
|
|
licenseKey="non-commercial-and-evaluation" // for non-commercial use only
|
|
licenseKey="non-commercial-and-evaluation" // for non-commercial use only
|
|
|
/>
|
|
/>
|
|
|
|
|
|
|
@@ -583,6 +595,7 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
nestedRows={false}
|
|
nestedRows={false}
|
|
|
data={tuijian
|
|
data={tuijian
|
|
|
}
|
|
}
|
|
|
|
|
+ ref = {hotTuijianRef}
|
|
|
manualColumnResize={true}
|
|
manualColumnResize={true}
|
|
|
rowHeaders={true}
|
|
rowHeaders={true}
|
|
|
colHeaders={true}
|
|
colHeaders={true}
|