Commit 51f420c0 by zhaochengxiang

bug fix

parent bcdf426a
......@@ -59,9 +59,11 @@ const FC = (props) => {
const save = async () => {
try {
const basicRows = await basicFormRef.current?.validate()
const strategyRows = await strategyRef.current?.validate()
const scheduleRows = await scheduleFormRef.current?.validate()
console.log('basicRows', basicRows)
console.log('strategyRows', strategyRows)
console.log('scheduleRows', scheduleRows)
setWaiting(true)
if (type === 'add') {
......@@ -70,6 +72,7 @@ const FC = (props) => {
payload: {
data: {
...basicRows,
strategyItemPropertyTypes: strategyRows,
jobSchedule: scheduleRows,
}
},
......@@ -87,6 +90,7 @@ const FC = (props) => {
data: {
...task,
...basicRows,
strategyItemPropertyTypes: strategyRows,
jobSchedule: scheduleRows,
}
},
......@@ -362,8 +366,15 @@ const Strategy = React.forwardRef(function ({ type, task }, ref) {
const [form] = Form.useForm()
const tableRef = React.useRef()
const tableDataRef = React.useRef()
const selectablePropertyTypeRef = React.useRef()
selectablePropertyTypeRef.current = selectablePropertyTypes
React.useImperativeHandle(ref, () => ({
validate: async () => {
await save()
return tableDataRef.current
},
}), [tableData, editingKey])
React.useEffect(() => {
setSelectablePropertyTypes(
......@@ -400,6 +411,9 @@ const Strategy = React.forwardRef(function ({ type, task }, ref) {
}
const save = async () => {
selectablePropertyTypeRef.current = selectablePropertyTypes
tableDataRef.current = tableData
if (!editingKey) return
try {
......@@ -420,9 +434,14 @@ const Strategy = React.forwardRef(function ({ type, task }, ref) {
metadataType: propertyTypes[modelIndex].supportedMetadataTypes[metadataIndex],
});
setTableData(newTableData)
selectablePropertyTypeRef.current = (propertyTypes??[]).filter(item =>
(newTableData??[]).map(_item => _item.modelType?.name).indexOf(item.modelType?.name)===-1
)
tableDataRef.current = newTableData
}
}
setEditingKey()
} catch (e) {
throw new Error()
......@@ -436,18 +455,19 @@ const Strategy = React.forwardRef(function ({ type, task }, ref) {
await save()
const currentSelectablePropertyTypes = [...selectablePropertyTypeRef.current??[]]
if (
(currentSelectablePropertyTypes??[]).length>0
&& (currentSelectablePropertyTypes[0].supportedOperatorTypes??[]).length>0
&& (currentSelectablePropertyTypes[0].supportedMetadataTypes??[]).length>0
) {
setTableData(prevTableData => {
return [...prevTableData??[], {
modelType: currentSelectablePropertyTypes[0].modelType,
operatorType: currentSelectablePropertyTypes[0].supportedOperatorTypes[0],
metadataType: currentSelectablePropertyTypes[0].supportedMetadataTypes[0],
}]
})
let newTableData = [...tableDataRef.current??[]]
newTableData = [...newTableData??[], {
modelType: currentSelectablePropertyTypes[0].modelType,
operatorType: currentSelectablePropertyTypes[0].supportedOperatorTypes[0],
metadataType: currentSelectablePropertyTypes[0].supportedMetadataTypes[0],
}]
setTableData(newTableData)
setEditingKey(currentSelectablePropertyTypes[0].modelType?.name)
setEditingModelKey(currentSelectablePropertyTypes[0].modelType?.name)
......@@ -467,12 +487,13 @@ const Strategy = React.forwardRef(function ({ type, task }, ref) {
const onBatchDeleteClick = (e) => {
e.stopPropagation()
setTableData(prevTableData => {
let newTableData = [...prevTableData??[]];
newTableData = (newTableData??[]).filter(item => (selectedRows??[]).map(_item => _item.modelType?.name).indexOf(item?.modelType?.name)===-1);
return newTableData;
})
return newTableData
})
const index = (selectedRows??[]).findIndex(item => item.modelType?.type === editingKey)
if (index !== -1) {
setEditingKey()
......@@ -506,8 +527,8 @@ const Strategy = React.forwardRef(function ({ type, task }, ref) {
let newTableData = [...prevTableData??[]];
const index = (newTableData??[]).findIndex(item => item.modelType?.name === record?.modelType?.name);
(newTableData??[]).splice(index, 1);
return newTableData;
})
return newTableData
})
}
const onRightMenuItemClick = (key, record) => {
......
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