diff --git a/src/pages/crontab/viewCreateModal.tsx b/src/pages/crontab/viewCreateModal.tsx index 92e6f02c..5634f492 100644 --- a/src/pages/crontab/viewCreateModal.tsx +++ b/src/pages/crontab/viewCreateModal.tsx @@ -23,6 +23,12 @@ const PROPERTIES = [ // { name: '标签', value: 'labels' }, ]; +const EOperation: any = { + Reg: '', + NotReg: '', + In: 'select', + Nin: 'select', +}; const OPERATIONS = [ { name: '包含', value: 'Reg' }, { name: '不包含', value: 'NotReg' }, @@ -131,7 +137,7 @@ const ViewCreateModal = ({ const statusElement = (property: keyof typeof STATUS_MAP) => { return ( - {STATUS_MAP[property]?.map((x) => ( {x.name} @@ -247,10 +253,22 @@ const ViewCreateModal = ({ { - return ( - get(prevValues, ['filters', name, 'operation']) !== - get(nextValues, ['filters', name, 'operation']) - ); + 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; }} > {() => { @@ -272,7 +290,7 @@ const ViewCreateModal = ({ { required: true, message: '请输入内容' }, ]} > - {['In', 'Nin'].includes(operate) ? ( + {EOperation[operate] === 'select' ? ( statusElement(property) ) : (