diff --git a/src/pages/crontab/index.less b/src/pages/crontab/index.less index 6e2d5598..47e103b9 100644 --- a/src/pages/crontab/index.less +++ b/src/pages/crontab/index.less @@ -155,7 +155,7 @@ .view-create-modal-sorts { display: flex; - .ant-space-item:nth-child(2) { + .ant-space-item:nth-child(1) { flex: 1; } } diff --git a/src/pages/crontab/viewCreateModal.tsx b/src/pages/crontab/viewCreateModal.tsx index ac798772..27696b2c 100644 --- a/src/pages/crontab/viewCreateModal.tsx +++ b/src/pages/crontab/viewCreateModal.tsx @@ -70,6 +70,7 @@ const ViewCreateModal = ({ const [form] = Form.useForm(); const [loading, setLoading] = useState(false); const [filterRelation, setFilterRelation] = useState<'and' | 'or'>('and'); + const filtersValue = Form.useWatch('filters', form); const handleOk = async (values: any) => { setLoading(true); @@ -126,7 +127,7 @@ const ViewCreateModal = ({ }; const typeElement = ( - {SORTTYPES.map((x) => ( {x.name} @@ -204,7 +205,7 @@ const ViewCreateModal = ({ position: 'absolute', top: '50%', translate: '-50% -50%', - padding: '0 0 0 3px', + padding: '0 3px', cursor: 'pointer', }} onClick={() => { @@ -221,9 +222,9 @@ const ViewCreateModal = ({ )}
- {fields.map(({ key, name, ...restField }, index) => ( + {fields.map(({ key, name, ...restField }) => ( { - const preOperation = - EOperation[ - get(prevValues, ['filters', name, 'operation']) - ]; - const nextOperation = - EOperation[ - get(nextValues, ['filters', name, 'operation']) - ]; - const flag = preOperation !== nextOperation; - if (flag) { - form.setFieldValue( - ['filters', name, 'value'], - nextOperation === 'select' ? [] : '', - ); - } - return flag; - }} + {...restField} + name={[name, 'value']} + rules={[{ required: true, message: '请输入内容' }]} > - {() => { - const property = form.getFieldValue([ - 'filters', - index, - 'property', - ]) as 'status'; - const operate = form.getFieldValue([ - 'filters', - name, - 'operation', - ]); - return ( - - {EOperation[operate] === 'select' ? ( - statusElement(property) - ) : ( - - )} - - ); - }} + {EOperation[filtersValue[name]['operation']] === + 'select' ? ( + statusElement(filtersValue[name]['property']) + ) : ( + + )} - {index !== 0 && ( + {name !== 0 && ( remove(name)} /> )} @@ -318,39 +282,77 @@ const ViewCreateModal = ({ {(fields, { add, remove }) => ( - <> - {fields.map(({ key, name, ...restField }, index) => ( - 1 ? 'active' : '' + }`} + > + {fields.length > 1 && ( +
- - - {propertyElement(PROPERTIES, { width: 240 })} - - - {typeElement} - - remove(name)} /> - + +
+ )} +
+ {fields.map(({ key, name, ...restField }) => ( + + + + {propertyElement(PROPERTIES)} + + + {typeElement} + + remove(name)} /> + + + ))} + + add({ property: 'command', type: 'ASC' })}> + + 新增排序方式 + - ))} - - add({ property: 'command', type: 'ASC' })}> - - 新增排序方式 - - - +
+
)}