修复调试保存文件默认目录和任务视图创建

This commit is contained in:
whyour 2022-12-09 22:59:38 +08:00
parent 3b389259c1
commit bb2e8cb287
3 changed files with 59 additions and 29 deletions

View File

@ -13,19 +13,21 @@ import { request } from '@/utils/http';
import config from '@/utils/config'; import config from '@/utils/config';
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'; import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
import IconFont from '@/components/iconfont'; import IconFont from '@/components/iconfont';
import get from 'lodash/get';
const PROPERTIES = [ const PROPERTIES = [
{ name: '命令', value: 'command' }, { name: '命令', value: 'command' },
{ name: '名称', value: 'name' }, { name: '名称', value: 'name' },
{ name: '定时规则', value: 'schedule' }, { name: '定时规则', value: 'schedule' },
{ name: '状态', value: 'status' }, { name: '状态', value: 'status' },
// { name: '标签', value: 'labels' },
]; ];
const OPERATIONS = [ const OPERATIONS = [
{ name: '包含', value: 'Reg' }, { name: '包含', value: 'Reg' },
{ name: '不包含', value: 'NotReg' }, { name: '不包含', value: 'NotReg' },
{ name: '属于', value: 'In' }, { name: '属于', value: 'In', type: 'select' },
{ name: '不属于', value: 'Nin' }, { name: '不属于', value: 'Nin', type: 'select' },
// { name: '等于', value: 'Eq' }, // { name: '等于', value: 'Eq' },
// { name: '不等于', value: 'Ne' }, // { name: '不等于', value: 'Ne' },
// { name: '为空', value: 'IsNull' }, // { name: '为空', value: 'IsNull' },
@ -37,11 +39,13 @@ const SORTTYPES = [
{ name: '倒序', value: 'DESC' }, { name: '倒序', value: 'DESC' },
]; ];
const STATUS = [ const STATUS_MAP = {
{ name: '运行中', value: 0 }, status: [
{ name: '空闲中', value: 1 }, { name: '运行中', value: 0 },
{ name: '已禁用', value: 2 }, { name: '空闲中', value: 1 },
]; { name: '已禁用', value: 2 },
],
};
enum ViewFilterRelation { enum ViewFilterRelation {
'and' = '且', 'and' = '且',
@ -125,15 +129,17 @@ const ViewCreateModal = ({
</Select> </Select>
); );
const statusElement = ( const statusElement = (property: keyof typeof STATUS_MAP) => {
<Select mode="multiple" allowClear placeholder="请选择状态"> return (
{STATUS.map((x) => ( <Select mode="tags" allowClear placeholder="回车输入自定义选项">
<Select.Option key={x.name} value={x.value}> {STATUS_MAP[property]?.map((x) => (
{x.name} <Select.Option key={x.name} value={x.value}>
</Select.Option> {x.name}
))} </Select.Option>
</Select> ))}
); </Select>
);
};
return ( return (
<Modal <Modal
@ -239,17 +245,41 @@ const ViewCreateModal = ({
{operationElement} {operationElement}
</Form.Item> </Form.Item>
<Form.Item <Form.Item
{...restField} noStyle
name={[name, 'value']} shouldUpdate={(prevValues, nextValues) => {
rules={[{ required: true, message: '请输入内容' }]} return (
get(prevValues, ['filters', name, 'operation']) !==
get(nextValues, ['filters', name, 'operation'])
);
}}
> >
{['In', 'Nin'].includes( {() => {
form.getFieldValue(['filters', index, 'operation']), const property = form.getFieldValue([
) ? ( 'filters',
statusElement index,
) : ( 'property',
<Input placeholder="请输入内容" /> ]) as 'status';
)} const operate = form.getFieldValue([
'filters',
name,
'operation',
]);
return (
<Form.Item
{...restField}
name={[name, 'value']}
rules={[
{ required: true, message: '请输入内容' },
]}
>
{['In', 'Nin'].includes(operate) ? (
statusElement(property)
) : (
<Input placeholder="请输入内容" />
)}
</Form.Item>
);
}}
</Form.Item> </Form.Item>
{index !== 0 && ( {index !== 0 && (
<MinusCircleOutlined onClick={() => remove(name)} /> <MinusCircleOutlined onClick={() => remove(name)} />

View File

@ -272,7 +272,7 @@ const EditModal = ({
content: content:
editorRef.current && editorRef.current &&
editorRef.current.getValue().replace(/\r\n/g, '\n'), editorRef.current.getValue().replace(/\r\n/g, '\n'),
filename: cNode?.title, ...cNode,
}} }}
/> />
<SettingModal <SettingModal

View File

@ -17,7 +17,7 @@ const SaveModal = ({
const handleOk = async (values: any) => { const handleOk = async (values: any) => {
setLoading(true); setLoading(true);
const payload = { ...file, ...values, originFilename: file.filename }; const payload = { ...file, ...values, originFilename: file.title };
request request
.post(`${config.apiPrefix}scripts`, { .post(`${config.apiPrefix}scripts`, {
data: payload, data: payload,
@ -60,7 +60,7 @@ const SaveModal = ({
form={form} form={form}
layout="vertical" layout="vertical"
name="script_modal" name="script_modal"
initialValues={file} initialValues={{ filename: file?.title, path: file?.parent || '' }}
> >
<Form.Item <Form.Item
name="filename" name="filename"