Commit 8bd6355e authored by 涂伟's avatar 涂伟

fix: '1.增加已附加字段取消附加功能2.运维表编辑内部字段删除按钮disabled'

parent f6388316
Pipeline #70774 passed with stages
...@@ -67,6 +67,7 @@ const EditableCell = ({ ...@@ -67,6 +67,7 @@ const EditableCell = ({
dataSource, dataSource,
tableDataCount, tableDataCount,
defaultData, defaultData,
setDefaultData,
...restProps ...restProps
}) => { }) => {
const [editing, setEditing] = useState(false); const [editing, setEditing] = useState(false);
...@@ -85,7 +86,7 @@ const EditableCell = ({ ...@@ -85,7 +86,7 @@ const EditableCell = ({
[dataIndex]: record[dataIndex], [dataIndex]: record[dataIndex],
}); });
} }
}, []); }, [dataSource]);
useEffect(() => { useEffect(() => {
if (editing && inputRef.current) { if (editing && inputRef.current) {
...@@ -125,6 +126,13 @@ const EditableCell = ({ ...@@ -125,6 +126,13 @@ const EditableCell = ({
[dataIndex]: values.IsAddFieldConfig, [dataIndex]: values.IsAddFieldConfig,
}); });
handleSave({ ...record, ...values, index }); handleSave({ ...record, ...values, index });
let defaultArr = JSON.parse(JSON.stringify(defaultData));
defaultArr.forEach(item => {
if (item.Name === record.Name) {
item.IsAddFieldConfig = values.IsAddFieldConfig;
}
});
setDefaultData(defaultArr);
}; };
const rendeFrom = val => { const rendeFrom = val => {
...@@ -596,15 +604,24 @@ const TableView = props => { ...@@ -596,15 +604,24 @@ const TableView = props => {
} }
setDataSource(list); setDataSource(list);
}; };
const deleteAddField = (index, name) => { const deleteAddField = (row, index) => {
let arr = JSON.parse(JSON.stringify(dataSource)); let arr = JSON.parse(JSON.stringify(dataSource));
arr.forEach(item => { arr.forEach(item => {
if (item.Name === name) { if (item.Name === row.Name) {
item.IsAddFieldConfig = false; item.IsAddFieldConfig = false;
} }
}); });
console.log(arr, name, 'arrarrarrarrarrarr'); if (!showDefault) {
let defaultArr = JSON.parse(JSON.stringify(defaultData));
defaultArr.forEach(item => {
if (item.Name === row.Name) {
item.IsAddFieldConfig = false;
}
});
setDefaultData(defaultArr);
}
setDataSource(arr); setDataSource(arr);
// }
}; };
// 表格设置 // 表格设置
const components = { const components = {
...@@ -717,10 +734,16 @@ const TableView = props => { ...@@ -717,10 +734,16 @@ const TableView = props => {
render: (_, record, index) => render: (_, record, index) =>
dataSource.length >= 1 ? ( dataSource.length >= 1 ? (
<Tooltip title="删除"> <Tooltip title="删除">
<DeleteOutlined <Button
style={{ border: 'none', padding: '4px 5px', background: 'none' }}
onClick={() => handleDelete(record, index)} onClick={() => handleDelete(record, index)}
style={{ fontSize: '16px', color: `${record.ReadOnly ? '#ccc' : '#e86060'}` }} disabled={record.ReadOnly}
/> >
<DeleteOutlined
style={{ fontSize: '16px', color: `${record.ReadOnly ? '#ccc' : '#e86060'}` }}
disabled={record.ReadOnly}
/>
</Button>
</Tooltip> </Tooltip>
) : null, ) : null,
}, },
...@@ -743,6 +766,7 @@ const TableView = props => { ...@@ -743,6 +766,7 @@ const TableView = props => {
dataSource, dataSource,
tableDataCount, tableDataCount,
defaultData, defaultData,
setDefaultData,
handleSave, handleSave,
}), }),
}; };
...@@ -858,10 +882,7 @@ const TableView = props => { ...@@ -858,10 +882,7 @@ const TableView = props => {
item.IsAddFieldConfig ? ( item.IsAddFieldConfig ? (
<div className={styles.subItem}> <div className={styles.subItem}>
<span>{item.Alias || item.Name}</span>{' '} <span>{item.Alias || item.Name}</span>{' '}
<span <span className={styles.deleteItem} onClick={() => deleteAddField(item, index)}>
className={styles.deleteItem}
onClick={() => deleteAddField(index, item.Name)}
>
X X
</span> </span>
</div> </div>
......
...@@ -40,7 +40,9 @@ ...@@ -40,7 +40,9 @@
// cursor: pointer; // cursor: pointer;
// } // }
.deleteItem { .deleteItem {
display: none; &:hover {
cursor: pointer;
}
} }
} }
} }
......
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