From 7acf1eace33a73666ce1004da429e547ae591215 Mon Sep 17 00:00:00 2001 From: whyour Date: Fri, 9 Dec 2022 23:34:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B7=BB=E5=8A=A0=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E8=A7=86=E5=9B=BE=E7=AD=9B=E9=80=89=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/crontab/viewCreateModal.tsx | 30 +++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) 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) ) : (