mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-17 17:54:32 +08:00
修改定时任务添加标签交互
This commit is contained in:
@@ -3,6 +3,7 @@ import { Modal, message, Input, Form, Button } from 'antd';
|
||||
import { request } from '@/utils/http';
|
||||
import config from '@/utils/config';
|
||||
import cronParse from 'cron-parser';
|
||||
import EditableTagGroup from '@/components/tag';
|
||||
|
||||
const CronModal = ({
|
||||
cron,
|
||||
@@ -20,11 +21,6 @@ const CronModal = ({
|
||||
setLoading(true);
|
||||
const method = cron ? 'put' : 'post';
|
||||
const payload = { ...values };
|
||||
if (typeof payload.labels === 'string') {
|
||||
payload.labels = values.labels.split(/,|,/);
|
||||
} else if (!payload.labels) {
|
||||
payload.labels = [];
|
||||
}
|
||||
if (cron) {
|
||||
payload.id = cron.id;
|
||||
}
|
||||
@@ -93,7 +89,7 @@ const CronModal = ({
|
||||
{ required: true },
|
||||
{
|
||||
validator: (rule, value) => {
|
||||
if (cronParse.parseExpression(value).hasNext()) {
|
||||
if (!value || cronParse.parseExpression(value).hasNext()) {
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
return Promise.reject('Cron表达式格式有误');
|
||||
@@ -105,7 +101,7 @@ const CronModal = ({
|
||||
<Input placeholder="秒(可选) 分 时 天 月 周" />
|
||||
</Form.Item>
|
||||
<Form.Item name="labels" label="标签">
|
||||
<Input placeholder="请输入任务标签" />
|
||||
<EditableTagGroup />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
@@ -128,9 +124,6 @@ const CronLabelModal = ({
|
||||
form
|
||||
.validateFields()
|
||||
.then(async (values) => {
|
||||
if (typeof values.labels === 'string') {
|
||||
values.labels = values.labels.split(/,|,/);
|
||||
}
|
||||
setLoading(true);
|
||||
const payload = { ids, labels: values.labels };
|
||||
const { code, data } = await request[action](
|
||||
@@ -179,7 +172,7 @@ const CronLabelModal = ({
|
||||
>
|
||||
<Form form={form} layout="vertical" name="form_in_label_modal">
|
||||
<Form.Item name="labels" label="标签">
|
||||
<Input placeholder="请输入任务标签" />
|
||||
<EditableTagGroup />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
Reference in New Issue
Block a user