|
|
|
@ -66,7 +66,7 @@ function EditableCell({ value, onChange, columnType, record, dataIndex }) {
|
|
|
|
return <span>{value}</span>;
|
|
|
|
return <span>{value}</span>;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function EditableTable({ onDataUpdate, initialData = [] }) {
|
|
|
|
function EditableTable({ onDataUpdate, initialData = [], visible }) {
|
|
|
|
const [data, setData] = useState([]);
|
|
|
|
const [data, setData] = useState([]);
|
|
|
|
|
|
|
|
|
|
|
|
// 当初始数据变化时,更新表格数据
|
|
|
|
// 当初始数据变化时,更新表格数据
|
|
|
|
@ -81,6 +81,10 @@ function EditableTable({ onDataUpdate, initialData = [] }) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, [initialData]);
|
|
|
|
}, [initialData]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
if (!visible) setData([]);
|
|
|
|
|
|
|
|
}, [visible]);
|
|
|
|
|
|
|
|
|
|
|
|
const handleValueChange = (key, dataIndex, value) => {
|
|
|
|
const handleValueChange = (key, dataIndex, value) => {
|
|
|
|
const newData = data.map(item => {
|
|
|
|
const newData = data.map(item => {
|
|
|
|
if (item.key === key) {
|
|
|
|
if (item.key === key) {
|
|
|
|
|