Commit 6d5395a6 by zhaochengxiang

修改bug

parent 15f1846b
......@@ -345,19 +345,14 @@ const UpdateField = (props) => {
let newData = [...dataRef.current];
const index = newData.findIndex((item) => record.name === item.name);
if (index === 0) {
newData = [{name: ''}, ...newData];
setInsertIndex(0);
editItem(newData[0], false);
} else {
newData.splice(index, 0, {name: ''});
setInsertIndex(index);
editItem(newData[index], false);
}
setInsertIndex(index);
setData(newData);
dataRef.current = newData;
editItem(newData[index], false);
setTimeout(() => {
document.getElementById(`field-`)?.scrollIntoView();
}, 200)
......@@ -484,8 +479,8 @@ const UpdateField = (props) => {
const moveRow = useCallback(
(dragIndex, hoverIndex) => {
const dragRow = data[dragIndex];
const newData = update(data, {
const dragRow = dataRef.current[dragIndex];
const newData = update(dataRef.current, {
$splice: [
[dragIndex, 1],
[hoverIndex, 0, dragRow],
......@@ -495,10 +490,8 @@ const UpdateField = (props) => {
setData(newData);
dataRef.current = newData;
onChange && onChange(newData);
},
//eslint-disable-next-line react-hooks/exhaustive-deps
[data],
);
}, []);
const onTableRow = (record, index) => {
let rowParams = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment