From bb2e8cb28745c3ae569b829d25e7d4b559494a07 Mon Sep 17 00:00:00 2001 From: whyour Date: Fri, 9 Dec 2022 22:59:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B0=83=E8=AF=95=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E6=96=87=E4=BB=B6=E9=BB=98=E8=AE=A4=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E5=92=8C=E4=BB=BB=E5=8A=A1=E8=A7=86=E5=9B=BE=E5=88=9B=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/crontab/viewCreateModal.tsx | 82 ++++++++++++++++++--------- src/pages/script/editModal.tsx | 2 +- src/pages/script/saveModal.tsx | 4 +- 3 files changed, 59 insertions(+), 29 deletions(-) diff --git a/src/pages/crontab/viewCreateModal.tsx b/src/pages/crontab/viewCreateModal.tsx index 19ed4bfe..92e6f02c 100644 --- a/src/pages/crontab/viewCreateModal.tsx +++ b/src/pages/crontab/viewCreateModal.tsx @@ -13,19 +13,21 @@ import { request } from '@/utils/http'; import config from '@/utils/config'; import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'; import IconFont from '@/components/iconfont'; +import get from 'lodash/get'; const PROPERTIES = [ { name: '命令', value: 'command' }, { name: '名称', value: 'name' }, { name: '定时规则', value: 'schedule' }, { name: '状态', value: 'status' }, + // { name: '标签', value: 'labels' }, ]; const OPERATIONS = [ { name: '包含', value: 'Reg' }, { name: '不包含', value: 'NotReg' }, - { name: '属于', value: 'In' }, - { name: '不属于', value: 'Nin' }, + { name: '属于', value: 'In', type: 'select' }, + { name: '不属于', value: 'Nin', type: 'select' }, // { name: '等于', value: 'Eq' }, // { name: '不等于', value: 'Ne' }, // { name: '为空', value: 'IsNull' }, @@ -37,11 +39,13 @@ const SORTTYPES = [ { name: '倒序', value: 'DESC' }, ]; -const STATUS = [ - { name: '运行中', value: 0 }, - { name: '空闲中', value: 1 }, - { name: '已禁用', value: 2 }, -]; +const STATUS_MAP = { + status: [ + { name: '运行中', value: 0 }, + { name: '空闲中', value: 1 }, + { name: '已禁用', value: 2 }, + ], +}; enum ViewFilterRelation { 'and' = '且', @@ -125,15 +129,17 @@ const ViewCreateModal = ({ ); - const statusElement = ( - - ); + const statusElement = (property: keyof typeof STATUS_MAP) => { + return ( + + ); + }; return ( { + return ( + get(prevValues, ['filters', name, 'operation']) !== + get(nextValues, ['filters', name, 'operation']) + ); + }} > - {['In', 'Nin'].includes( - form.getFieldValue(['filters', index, 'operation']), - ) ? ( - statusElement - ) : ( - - )} + {() => { + const property = form.getFieldValue([ + 'filters', + index, + 'property', + ]) as 'status'; + const operate = form.getFieldValue([ + 'filters', + name, + 'operation', + ]); + return ( + + {['In', 'Nin'].includes(operate) ? ( + statusElement(property) + ) : ( + + )} + + ); + }} {index !== 0 && ( remove(name)} /> diff --git a/src/pages/script/editModal.tsx b/src/pages/script/editModal.tsx index 1349c6a3..89dd6fff 100644 --- a/src/pages/script/editModal.tsx +++ b/src/pages/script/editModal.tsx @@ -272,7 +272,7 @@ const EditModal = ({ content: editorRef.current && editorRef.current.getValue().replace(/\r\n/g, '\n'), - filename: cNode?.title, + ...cNode, }} /> { setLoading(true); - const payload = { ...file, ...values, originFilename: file.filename }; + const payload = { ...file, ...values, originFilename: file.title }; request .post(`${config.apiPrefix}scripts`, { data: payload, @@ -60,7 +60,7 @@ const SaveModal = ({ form={form} layout="vertical" name="script_modal" - initialValues={file} + initialValues={{ filename: file?.title, path: file?.parent || '' }} >