Commit 51f420c0 by zhaochengxiang

bug fix

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