|
|
@@ -20,6 +20,8 @@ import Button from '@mui/material/Button';
|
|
|
import ButtonGroup from '@mui/material/ButtonGroup';
|
|
|
import {danxiangdinge_index} from './utils';
|
|
|
import {shanchu, push_op, quanbushanchu, danxiangdinge} from './editor';
|
|
|
+import { HyperFormula } from 'hyperformula';
|
|
|
+
|
|
|
registerAllModules();
|
|
|
|
|
|
|
|
|
@@ -41,7 +43,11 @@ function copy(input) {
|
|
|
|
|
|
|
|
|
export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCallback}) {
|
|
|
-
|
|
|
+ const hyperformulaInstance = HyperFormula.buildEmpty({
|
|
|
+ // to use an external HyperFormula instance,
|
|
|
+ // initialize it with the `'internal-use-in-handsontable'` license key
|
|
|
+ licenseKey: 'internal-use-in-handsontable',
|
|
|
+ });
|
|
|
const memory = React.useRef([]);
|
|
|
const mem_pointer = React.useRef(0);
|
|
|
function coverRenderer(_instance, td, _row, _col, _prop, value, _cellProperties) {
|
|
|
@@ -130,6 +136,7 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
const [highlight, setHighlight] = React.useState([]);
|
|
|
const selectedRow = React.useRef(-1);
|
|
|
const hotRef = React.useRef(null);
|
|
|
+ const hotRcjRef = React.useRef(null);
|
|
|
const rgdeRef = React.useRef(null);
|
|
|
const jxdeRef = React.useRef(null);
|
|
|
const cldeRef = React.useRef(null);
|
|
|
@@ -270,64 +277,10 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
setValue(newValue);
|
|
|
};
|
|
|
|
|
|
-
|
|
|
- return (
|
|
|
- <Stack spacing={2}>
|
|
|
-
|
|
|
- <Box>
|
|
|
- <Stack direction='row' spacing={2}>
|
|
|
- <Button variant="outlined" onClick={() => {
|
|
|
- //console.log(memory.current);
|
|
|
- const [success, data] = danxiangdinge(hotRef, selectedRow, detailRef);
|
|
|
- if(success) {
|
|
|
- setDetail(data);
|
|
|
- push_op(memory, mem_pointer, detailRef);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }}
|
|
|
- >单项定额</Button>
|
|
|
- <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);
|
|
|
- }
|
|
|
- }}
|
|
|
- >撤销</Button>
|
|
|
- <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);
|
|
|
- }
|
|
|
- }}
|
|
|
- >重做</Button>
|
|
|
-
|
|
|
-
|
|
|
- </Stack>
|
|
|
- <HotTable
|
|
|
- nestedRows={true}
|
|
|
- data={detail
|
|
|
- }
|
|
|
- afterUpdateData={(x)=>{
|
|
|
- //console.log(x);
|
|
|
- hotRef.current?.hotInstance?.scrollViewportTo({ row: selectedRow.current });
|
|
|
-
|
|
|
- }}
|
|
|
-
|
|
|
- afterSelection={(row, column)=>{
|
|
|
- //console.log(row);
|
|
|
- selectedRow.current = row;
|
|
|
+ const handleSelection = (row, column) => {
|
|
|
+ selectedRow.current = row;
|
|
|
let selected = hotRef.current?.hotInstance?.getData()[row];
|
|
|
+ if (!selected) return;
|
|
|
if (selected[1] != null) {
|
|
|
Service.generateQingdanrcj(name, bh,bt,selected[2]).then(x=>{
|
|
|
|
|
|
@@ -353,7 +306,7 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
}
|
|
|
//console.log(name, bh,bt,qdbm, selected[1]);
|
|
|
clickCallback(qdbm, selected[2]);
|
|
|
- Service.generateDingercj(name, bh,bt,qdbm, selected[2]).then(x=>{
|
|
|
+ Service.generateDingercj(name, bh,bt,qdbm, selected[2], selected[6]).then(x=>{
|
|
|
console.log(x);
|
|
|
setRcjhl(x);
|
|
|
isQdrcj.current = false;
|
|
|
@@ -425,9 +378,64 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
});
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ return (
|
|
|
+ <Stack spacing={2}>
|
|
|
+
|
|
|
+ <Box>
|
|
|
+ <Stack direction='row' spacing={2}>
|
|
|
+ <Button variant="outlined" onClick={() => {
|
|
|
+ //console.log(memory.current);
|
|
|
+ const [success, data] = danxiangdinge(hotRef, selectedRow, detailRef);
|
|
|
+ if(success) {
|
|
|
+ setDetail(data);
|
|
|
+ push_op(memory, mem_pointer, detailRef);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }}
|
|
|
+ >单项定额</Button>
|
|
|
+ <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);
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ >撤销</Button>
|
|
|
+ <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);
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ >重做</Button>
|
|
|
+
|
|
|
+
|
|
|
+ </Stack>
|
|
|
+ <HotTable
|
|
|
+ nestedRows={true}
|
|
|
+ data={detail
|
|
|
+ }
|
|
|
+ afterUpdateData={(x)=>{
|
|
|
+ //-console.log(x);
|
|
|
+ hotRef.current?.hotInstance?.scrollViewportTo({ row: selectedRow.current });
|
|
|
+ //handleSelection(selectedRow.current, 0);
|
|
|
|
|
|
}}
|
|
|
+
|
|
|
+ afterSelection={handleSelection}
|
|
|
ref = {hotRef}
|
|
|
cells={(row, col, prop) => {
|
|
|
if (row == selectedRow.current) {
|
|
|
@@ -510,11 +518,26 @@ export default function Qingdan({name, bh, bt, rgde, jxde, clde, beizhu, clickCa
|
|
|
rowHeaders={true}
|
|
|
colHeaders={true}
|
|
|
height="300"
|
|
|
- readOnly={true}
|
|
|
+ formulas={{
|
|
|
+ engine: hyperformulaInstance,
|
|
|
+ sheetName: 'Rcj',
|
|
|
+ }}
|
|
|
+
|
|
|
+ cells={(row, col) => {
|
|
|
+ if (row === 0) {
|
|
|
+ return { readOnly: true };
|
|
|
+ }
|
|
|
+ if (col <= 1 || col === 11) {
|
|
|
+ return { readOnly: true };
|
|
|
+ }
|
|
|
+
|
|
|
+ return {};
|
|
|
+ }}
|
|
|
fixedRowsTop={1}
|
|
|
selectionMode="single"
|
|
|
autoWrapRow={false}
|
|
|
autoWrapCol={false}
|
|
|
+ ref = {hotRcjRef}
|
|
|
licenseKey="non-commercial-and-evaluation" // for non-commercial use only
|
|
|
/>
|
|
|
|