Commit e0302c82 by zhaochengxiang

去掉多余代码

parent 8cae8b87
...@@ -366,13 +366,10 @@ const UpdateField = (props) => { ...@@ -366,13 +366,10 @@ const UpdateField = (props) => {
form.setFieldsValue({...record, dataType: dataTypeJson}); form.setFieldsValue({...record, dataType: dataTypeJson});
setEditingKey(record?.name); setEditingKey(record?.name);
editingKeyRef.current = record?.name; editingKeyRef.current = record?.name;
console.log('editing current', record?.name);
} catch { } catch {
form.setFieldsValue({...record, dataType: {}}); form.setFieldsValue({...record, dataType: {}});
setEditingKey(record?.name); setEditingKey(record?.name);
editingKeyRef.current = record?.name; editingKeyRef.current = record?.name;
console.log('editing current', record?.name);
} }
} }
...@@ -448,8 +445,8 @@ const UpdateField = (props) => { ...@@ -448,8 +445,8 @@ const UpdateField = (props) => {
const moveRow = useCallback( const moveRow = useCallback(
(dragIndex, hoverIndex) => { (dragIndex, hoverIndex) => {
const dragRow = dataRef.current[dragIndex]; const dragRow = data[dragIndex];
const newData = update(dataRef.current, { const newData = update(data, {
$splice: [ $splice: [
[dragIndex, 1], [dragIndex, 1],
[hoverIndex, 0, dragRow], [hoverIndex, 0, dragRow],
...@@ -460,7 +457,7 @@ const UpdateField = (props) => { ...@@ -460,7 +457,7 @@ const UpdateField = (props) => {
dataRef.current = newData; dataRef.current = newData;
onChange && onChange(newData); onChange && onChange(newData);
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
}, []); }, [data]);
const onTableRow = (record, index) => { const onTableRow = (record, index) => {
let rowParams = { let rowParams = {
...@@ -545,7 +542,26 @@ const UpdateField = (props) => { ...@@ -545,7 +542,26 @@ const UpdateField = (props) => {
row: (editable&&editingKey===null&&keyword==='')?DragableBodyRow:null, row: (editable&&editingKey===null&&keyword==='')?DragableBodyRow:null,
}, },
}} }}
onRow={onTableRow} onRow={(record, index) => {
let attr = {
index,
id: `field-${record.name}`,
};
if (!isEditing(record)) {
attr = {
index,
id: `field-${record.name}`,
onClick: (event) => {
event.stopPropagation();
editItem(record);
},
moveRow
};
}
return attr;
}}
/> />
</Form> </Form>
</DndProvider> </DndProvider>
......
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