| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137 |
- "use client";
- import {fetchApi, fetchFile} from "@/app/_modules/func";
- import {
- CaretDownOutlined,
- CheckOutlined,
- ClockCircleOutlined,
- CloseOutlined,
- DeleteOutlined,
- ExclamationCircleFilled,
- EyeOutlined,
- PlayCircleOutlined,
- PlusOutlined,
- ReloadOutlined,
- ScheduleOutlined,
- } from "@ant-design/icons";
- import type {ActionType, ProColumns, ProFormInstance,} from "@ant-design/pro-components";
- import {
- ModalForm,
- PageContainer,
- ProDescriptions,
- ProForm,
- ProFormRadio,
- ProFormSelect,
- ProFormText,
- ProTable,
- } from "@ant-design/pro-components";
- import {Button, Dropdown, Input, Modal, Space, Switch,} from "antd";
- import {useRouter} from "next/navigation";
- import {faDownload, faPenToSquare, faToggleOff, faToggleOn,} from "@fortawesome/free-solid-svg-icons";
- import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
- import "./styles.scss";
- import {ReQuartzCron} from "@sbzen/re-cron";
- import {useRef, useState} from "react";
- import {MortnonCronLocalization} from "@/app/_modules/definies";
- import globalMessage from "@/app/_modules/globalMessage";
- //查询表格数据API
- const queryAPI = "/api/monitor/job/list";
- //新建数据API
- const newAPI = "/api/monitor/job";
- //修改数据API
- const modifyAPI = "/api/monitor/job";
- //查询详情数据API
- const queryDetailAPI = "/api/monitor/job";
- //删除API
- const deleteAPI = "/api/monitor/job";
- //导出API
- const exportAPI = "/api/monitor/job/export";
- //导出文件前缀名
- const exportFilePrefix = "job";
- //变更任务状态API
- const changeJobStatusAPI = "/api/monitor/job/changeStatus";
- //执行任务API
- const runAPI = "/api/monitor/job/run";
- export default function Job() {
- const { push } = useRouter();
- // 添加用于控制删除确认模态框的状态
- const [deleteModalVisible, setDeleteModalVisible] = useState(false);
- const [deleteJobId, setDeleteJobId] = useState<string | number | null>(null);
- // 添加用于控制切换状态确认模态框的状态
- const [statusModalVisible, setStatusModalVisible] = useState(false);
- const [statusChecked, setStatusChecked] = useState<boolean>(true);
- const [statusRecord, setStatusRecord] = useState<any>(null);
- // 添加用于控制执行任务确认模态框的状态
- const [runModalVisible, setRunModalVisible] = useState(false);
- const [runRecord, setRunRecord] = useState<any>(null);
- //表格列定义
- const columns: ProColumns[] = [
- {
- title: "任务编号",
- dataIndex: "jobId",
- search: false,
- },
- {
- title: "任务名称",
- fieldProps: {
- placeholder: "请输入任务名称",
- },
- dataIndex: "jobName",
- ellipsis: true,
- order: 3,
- },
- {
- title: "任务组名",
- dataIndex: "jobGroup",
- valueType: "select",
- valueEnum: {
- DEFAULT: {
- text: "默认",
- status: "DEFAULT",
- },
- SYSTEM: {
- text: "系统",
- status: "SYSTEM",
- },
- },
- sorter: true,
- order: 2,
- },
- {
- title: "调用目标字符串",
- dataIndex: "invokeTarget",
- search: false,
- },
- {
- title: "Cron执行表达式",
- dataIndex: "cronExpression",
- search: false,
- },
- {
- title: "状态",
- fieldProps: {
- placeholder: "请选择任务状态",
- },
- dataIndex: "status",
- valueType: "select",
- order: 2,
- valueEnum: {
- 0: {
- text: "正常",
- status: "0",
- },
- 1: {
- text: "停用",
- status: "1",
- },
- },
- render: (text, record) => {
- return (
- <Space>
- <Switch
- checkedChildren={<CheckOutlined />}
- unCheckedChildren={<CloseOutlined />}
- defaultChecked={record.status === "0"}
- checked={rowStatusMap[record.jobId]}
- onChange={(checked, event) => {
- showSwitchJobStatusModal(checked, record);
- }}
- />
- </Space>
- );
- },
- },
- {
- title: "操作",
- key: "option",
- search: false,
- render: (_, record) => [
- <Button
- key="modifyBtn"
- type="link"
- icon={<FontAwesomeIcon icon={faPenToSquare} />}
- onClick={() => onClickShowRowModifyModal(record)}
- >
- 修改
- </Button>,
- <Button
- key="deleteBtn"
- type="link"
- danger
- icon={<DeleteOutlined />}
- onClick={() => onClickDeleteRow(record)}
- >
- 删除
- </Button>,
- <Dropdown
- key="moreDrop"
- menu={{
- items: [
- {
- key: "1",
- label: (
- <a
- onClick={() => {
- showRunOnceModal(record);
- }}
- >
- 执行一次
- </a>
- ),
- icon: <PlayCircleOutlined />,
- },
- {
- key: "2",
- label: <a onClick={() => showRowModal(record)}>任务详情</a>,
- icon: <EyeOutlined />,
- },
- {
- key: "3",
- label: (
- <a
- onClick={() =>
- push(`/monitor/job-log/index/${record.jobId}`)
- }
- >
- 调度日志
- </a>
- ),
- icon: <ScheduleOutlined />,
- },
- ],
- }}
- >
- <a onClick={(e) => e.preventDefault()}>
- <Space>
- 更多
- <CaretDownOutlined />
- </Space>
- </a>
- </Dropdown>,
- ],
- },
- ];
- //0.查询表格数据
- const queryTableData = async (params: any, sorter: any, filter: any) => {
- const searchParams = {
- pageNum: params.current,
- ...params,
- };
- delete searchParams.current;
- const queryParams = new URLSearchParams(searchParams);
- Object.keys(sorter).forEach((key) => {
- queryParams.append("orderByColumn", key);
- if (sorter[key] === "ascend") {
- queryParams.append("isAsc", "ascending");
- } else {
- queryParams.append("isAsc", "descending");
- }
- });
- const body = await fetchApi(`${queryAPI}?${queryParams}`, push);
- if (body !== undefined) {
- body.rows.forEach((row: any) => {
- setRowStatusMap({ ...rowStatusMap, [row.userId]: row.status === "0" });
- });
- }
- return body;
- };
- //1.新建
- //新建对话框表单引用
- const addFormRef = useRef<ProFormInstance>(null);
- //确定新建数据
- const executeAddData = async (values: any) => {
- const body = await fetchApi(newAPI, push, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify(values),
- });
- if (body != undefined) {
- if (body.code == 200) {
- globalMessage.success(body.msg);
- if (actionTableRef.current) {
- actionTableRef.current.reload();
- }
- return true;
- }
- globalMessage.error(body.msg);
- return false;
- }
- return false;
- };
- //2.修改
- //控制行的状态值的恢复
- const [rowStatusMap, setRowStatusMap] = useState<{ [key: number]: boolean }>(
- {}
- );
- //展示切换任务状态对话框
- const showSwitchJobStatusModal = (checked: boolean, record: any) => {
- setRowStatusMap({ ...rowStatusMap, [record.jobId]: checked });
-
- setStatusChecked(checked);
- setStatusRecord(record);
- setStatusModalVisible(true);
- };
- //确认变更任务状态
- const executeSwitchStatus = async (
- checked: boolean,
- jobId: string,
- erroCallback: () => void
- ) => {
- const modifyData = {
- jobId: jobId,
- status: checked ? "0" : "1",
- };
- const body = await fetchApi(changeJobStatusAPI, push, {
- method: "PUT",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify(modifyData),
- });
- if (body !== undefined) {
- if (body.code == 200) {
- globalMessage.success(body.msg);
- } else {
- globalMessage.error(body.msg);
- erroCallback();
- }
- }
- };
- //确定切换状态
- const confirmSwitchStatus = () => {
- if (!statusRecord) return;
-
- executeSwitchStatus(statusChecked, statusRecord.jobId, () => {
- setRowStatusMap({ ...rowStatusMap, [statusRecord.jobId]: !statusChecked });
- });
- setStatusModalVisible(false);
- setStatusRecord(null);
- };
- //取消切换状态
- const cancelSwitchStatus = () => {
- if (!statusRecord) return;
-
- setRowStatusMap({ ...rowStatusMap, [statusRecord.jobId]: !statusChecked });
- setStatusModalVisible(false);
- setStatusRecord(null);
- };
- //是否展示修改对话框
- const [isShowModifyDataModal, setIsShowModifyDataModal] = useState(false);
- //展示修改对话框
- const onClickShowRowModifyModal = (record?: any) => {
- queryRowData(record);
- setIsShowModifyDataModal(true);
- };
- //修改数据表单引用
- const modifyFormRef = useRef<ProFormInstance>(null);
- //操作当前数据的附加数据
- const [operatRowData, setOperateRowData] = useState<{
- [key: string]: any;
- }>({});
- //查询并加载待修改数据的详细信息
- const queryRowData = async (record?: any) => {
- const jobId = record !== undefined ? record.jobId : selectedRow.jobId;
- operatRowData["jobId"] = jobId;
- setOperateRowData(operatRowData);
- if (jobId !== undefined) {
- const body = await fetchApi(`${queryDetailAPI}/${jobId}`, push);
- if (body !== undefined) {
- if (body.code == 200) {
- modifyFormRef?.current?.setFieldsValue({
- //需要加载到修改表单中的数据
- jobName: body.data.jobName,
- jobGroup: body.data.jobGroup,
- invokeTarget: body.data.invokeTarget,
- cronExpression: body.data.cronExpression,
- status: body.data.status,
- misfirePolicy: body.data.misfirePolicy,
- concurrent: body.data.concurrent,
- });
- setCronValue(body.data.cronExpression);
- }
- }
- }
- };
- //确认修改数据
- const executeModifyData = async (values: any) => {
- values["jobId"] = operatRowData["jobId"];
- const body = await fetchApi(modifyAPI, push, {
- method: "PUT",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify(values),
- });
- if (body !== undefined) {
- if (body.code == 200) {
- globalMessage.success(body.msg);
- //刷新列表
- if (actionTableRef.current) {
- actionTableRef.current.reload();
- }
- setIsShowModifyDataModal(false);
- return true;
- }
- globalMessage.error(body.msg);
- return false;
- }
- };
- //3.删除
- //点击删除按钮,展示删除确认框
- const onClickDeleteRow = (record?: any) => {
- const jobId = record !== undefined ? record.jobId : selectedRowKeys.join(",");
- setDeleteJobId(jobId);
- setDeleteModalVisible(true);
- };
- //确定删除选中的数据
- const executeDeleteRow = async () => {
- if (deleteJobId === null) return;
-
- const body = await fetchApi(`${deleteAPI}/${deleteJobId}`, push, {
- method: "DELETE",
- });
- if (body !== undefined) {
- if (body.code == 200) {
- globalMessage.success("删除成功");
- //修改按钮变回不可点击
- setRowCanModify(false);
- //删除按钮变回不可点击
- setRowCanDelete(false);
- //选中行数据重置为空
- setSelectedRowKeys([]);
- //刷新列表
- if (actionTableRef.current) {
- actionTableRef.current.reload();
- }
- } else {
- globalMessage.error(body.msg);
- }
- }
- setDeleteModalVisible(false);
- setDeleteJobId(null);
- };
- //4.导出
- //导出表格数据
- const exportTable = async () => {
- if (searchTableFormRef.current) {
- const formData = new FormData();
- const data = {
- pageNum: page,
- pageSize: pageSize,
- ...searchTableFormRef.current.getFieldsValue(),
- };
- Object.keys(data).forEach((key) => {
- if (data[key] !== undefined) {
- formData.append(key, data[key]);
- }
- });
- await fetchFile(
- exportAPI,
- push,
- {
- method: "POST",
- body: formData,
- },
- `${exportFilePrefix}_${new Date().getTime()}.xlsx`
- );
- }
- };
- //5.选择行
- //选中行操作
- const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
- const [selectedRow, setSelectedRow] = useState(undefined as any);
- //修改按钮是否可用,选中行时才可用
- const [rowCanModify, setRowCanModify] = useState(false);
- //删除按钮是否可用,选中行时才可用
- const [rowCanDelete, setRowCanDelete] = useState(false);
- //ProTable rowSelection
- const rowSelection = {
- onChange: (newSelectedRowKeys: React.Key[], selectedRows: any[]) => {
- setSelectedRowKeys(newSelectedRowKeys);
- setRowCanDelete(newSelectedRowKeys && newSelectedRowKeys.length > 0);
- if (newSelectedRowKeys && newSelectedRowKeys.length == 1) {
- setSelectedRow(selectedRows[0]);
- setRowCanModify(true);
- } else {
- setRowCanModify(false);
- setSelectedRow(undefined);
- }
- },
- //复选框的额外禁用判断
- // getCheckboxProps: (record) => ({
- // disabled: record.userId == 1,
- // }),
- };
- //搜索栏显示状态
- const [showSearch, setShowSearch] = useState(true);
- //action对象引用
- const actionTableRef = useRef<ActionType>(null);
- //搜索表单对象引用
- const searchTableFormRef = useRef<ProFormInstance>(null!);
- //当前页数和每页条数
- const [page, setPage] = useState(1);
- const defaultPageSize = 10;
- const [pageSize, setPageSize] = useState(defaultPageSize);
- const pageChange = (page: number, pageSize: number) => {
- setPage(page);
- setPageSize(pageSize);
- };
- //是否展示Cron表达式生成框
- const [isCronShow, setIsCronShow] = useState(false);
- //Cron表达式值
- const [cronValue, setCronValue] = useState("");
- //当前是新建还是修改触发的Cron生成框
- const [isNew, setIsNew] = useState(true);
- //用于重置Cron生成框的key值
- const [modalKey, setModalKey] = useState(0);
- //展示Cron对话框,区分新建用还是修改用
- const showCronModal = (isNew: boolean) => {
- setIsNew(isNew);
- setIsCronShow(true);
- };
- //回写Cron数据
- const getCronData = () => {
- setIsCronShow(false);
- if (isNew) {
- addFormRef?.current?.setFieldsValue({
- cronExpression: cronValue,
- });
- } else {
- modifyFormRef?.current?.setFieldsValue({
- cronExpression: cronValue,
- });
- }
- //重置Cron数据
- setCronValue("");
- setModalKey((preKey) => preKey + 1);
- };
- //执行任务一次
- const showRunOnceModal = (record: any) => {
- setRunRecord(record);
- setRunModalVisible(true);
- };
- //执行任务
- const executeJob = async (record: any) => {
- const runData = {
- jobId: record.jobId,
- jobGroup: record.jobGroup,
- };
- const body = await fetchApi(runAPI, push, {
- method: "PUT",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify(runData),
- });
- if (body !== undefined) {
- if (body.code == 200) {
- globalMessage.success("执行成功");
- } else {
- globalMessage.error(body.msg);
- }
- }
- setRunModalVisible(false);
- setRunRecord(null);
- };
- //取消执行任务
- const cancelRunJob = () => {
- setRunModalVisible(false);
- setRunRecord(null);
- };
- //是否展示任务详情框
- const [isShowDetail, setIsShowDetail] = useState(false);
- //展示行详情框
- const showRowModal = async (record: any) => {
- const jobId = record.jobId;
- if (jobId !== undefined) {
- const body = await fetchApi(`${queryDetailAPI}/${jobId}`, push);
- setSelectedRow(body.data);
- }
- setIsShowDetail(true);
- };
- return (
- <PageContainer title={false}>
- <ProTable
- formRef={searchTableFormRef}
- rowKey="jobId"
- rowSelection={{
- selectedRowKeys,
- ...rowSelection,
- }}
- columns={columns}
- request={async (params: any, sorter: any, filter: any) => {
- // 表单搜索项会从 params 传入,传递给后端接口。
- const data = await queryTableData(params, sorter, filter);
- if (data !== undefined) {
- return Promise.resolve({
- data: data.rows,
- success: true,
- total: data.total,
- });
- }
- return Promise.resolve({
- data: [],
- success: true,
- });
- }}
- pagination={{
- defaultPageSize: defaultPageSize,
- showQuickJumper: true,
- showSizeChanger: true,
- onChange: pageChange,
- }}
- search={
- showSearch
- ? {
- defaultCollapsed: false,
- searchText: "搜索",
- }
- : false
- }
- dateFormatter="string"
- actionRef={actionTableRef}
- toolbar={{
- actions: [
- <ModalForm
- formRef={addFormRef}
- key="addmodal"
- layout="horizontal"
- title="添加任务"
- trigger={
- <Button icon={<PlusOutlined />} type="primary">
- 新建
- </Button>
- }
- autoFocusFirstInput
- modalProps={{
- destroyOnHidden: true,
- }}
- submitTimeout={2000}
- onFinish={executeAddData}
- >
- <ProForm.Group>
- <ProFormText
- width="md"
- name="jobName"
- label="任务名称"
- placeholder="请输入任务名称"
- rules={[{ required: true, message: "请输入任务名称" }]}
- />
- <ProFormSelect
- width="md"
- name="jobGroup"
- label="任务分组"
- valueEnum={{
- DEFAULT: {
- text: "默认",
- status: "DEFAULT",
- },
- SYSTEM: {
- text: "系统",
- status: "SYSTEM",
- },
- }}
- />
- </ProForm.Group>
- <ProForm.Group>
- <ProFormText
- width="lg"
- name="invokeTarget"
- label="调用方法"
- placeholder="请输入调用方法的字符串"
- tooltip="Bean调用示例:ryTask.ryParams('ry')
- Class调用示例:com.ruoyi.quartz.task.RyTask.ryParams('ry')
- 参数说明:支持字符串,布尔类型,长整型,浮点型,整型"
- rules={[
- { required: true, message: "请输入调用方法的字符串" },
- ]}
- />
- </ProForm.Group>
- <ProForm.Group>
- <Space.Compact>
- <ProFormText
- width="lg"
- name="cronExpression"
- label="Cron表达式"
- placeholder="请输入Cron表达式"
- rules={[{ required: true, message: "请输入Cron表达式" }]}
- />
- <Button
- icon={<ClockCircleOutlined />}
- onClick={() => showCronModal(true)}
- >
- 生成表达式
- </Button>
- </Space.Compact>
- </ProForm.Group>
- <ProForm.Group>
- <ProFormRadio.Group
- width="md"
- name="misfirePolicy"
- label="执行策略"
- initialValue="1"
- options={[
- {
- label: "立即执行",
- value: "1",
- },
- {
- label: "执行一次",
- value: "2",
- },
- {
- label: "放弃执行",
- value: "3",
- },
- ]}
- />
- <ProFormRadio.Group
- name="concurrent"
- width="md"
- label="是否并发"
- initialValue="0"
- options={[
- {
- label: "允许",
- value: "0",
- },
- {
- label: "禁止",
- value: "1",
- },
- ]}
- />
- </ProForm.Group>
- </ModalForm>,
- <ModalForm
- key="modifymodal"
- title="修改岗位"
- layout="horizontal"
- formRef={modifyFormRef}
- trigger={
- <Button
- icon={<FontAwesomeIcon icon={faPenToSquare} />}
- disabled={!rowCanModify}
- onClick={() => onClickShowRowModifyModal()}
- >
- 修改
- </Button>
- }
- open={isShowModifyDataModal}
- autoFocusFirstInput
- modalProps={{
- destroyOnHidden: true,
- onCancel: () => {
- setIsShowModifyDataModal(false);
- },
- }}
- submitTimeout={2000}
- onFinish={executeModifyData}
- >
- <ProForm.Group>
- <ProFormText
- width="md"
- name="jobName"
- label="任务名称"
- placeholder="请输入任务名称"
- rules={[{ required: true, message: "请输入任务名称" }]}
- />
- <ProFormSelect
- width="md"
- name="jobGroup"
- label="任务分组"
- valueEnum={{
- DEFAULT: {
- text: "默认",
- status: "DEFAULT",
- },
- SYSTEM: {
- text: "系统",
- status: "SYSTEM",
- },
- }}
- />
- </ProForm.Group>
- <ProForm.Group>
- <ProFormText
- width="lg"
- name="invokeTarget"
- label="调用方法"
- placeholder="请输入调用方法的字符串"
- tooltip="Bean调用示例:ryTask.ryParams('ry')
- Class调用示例:com.ruoyi.quartz.task.RyTask.ryParams('ry')
- 参数说明:支持字符串,布尔类型,长整型,浮点型,整型"
- rules={[
- { required: true, message: "请输入调用方法的字符串" },
- ]}
- />
- </ProForm.Group>
- <ProForm.Group>
- <Space.Compact>
- <ProFormText
- width="lg"
- name="cronExpression"
- label="Cron表达式"
- placeholder="请输入Cron表达式"
- rules={[{ required: true, message: "请输入Cron表达式" }]}
- />
- <Button
- icon={<ClockCircleOutlined />}
- onClick={() => showCronModal(false)}
- >
- 生成表达式
- </Button>
- </Space.Compact>
- </ProForm.Group>
- <ProForm.Group>
- <ProFormRadio.Group
- name="status"
- width="md"
- label="状态"
- initialValue="0"
- options={[
- {
- label: "正常",
- value: "0",
- },
- {
- label: "暂停",
- value: "1",
- },
- ]}
- />
- </ProForm.Group>
- <ProForm.Group>
- <ProFormRadio.Group
- width="md"
- name="misfirePolicy"
- label="执行策略"
- initialValue="1"
- options={[
- {
- label: "立即执行",
- value: "1",
- },
- {
- label: "执行一次",
- value: "2",
- },
- {
- label: "放弃执行",
- value: "3",
- },
- ]}
- />
- <ProFormRadio.Group
- name="concurrent"
- width="md"
- label="是否并发"
- initialValue="0"
- options={[
- {
- label: "允许",
- value: "0",
- },
- {
- label: "禁止",
- value: "1",
- },
- ]}
- />
- </ProForm.Group>
- </ModalForm>,
- <Button
- key="danger"
- danger
- icon={<DeleteOutlined />}
- disabled={!rowCanDelete}
- onClick={() => onClickDeleteRow()}
- >
- 删除
- </Button>,
- <Button
- key="export"
- type="primary"
- icon={<FontAwesomeIcon icon={faDownload} />}
- onClick={exportTable}
- >
- 导出
- </Button>,
- ],
- settings: [
- {
- key: "switch",
- icon: showSearch ? (
- <FontAwesomeIcon icon={faToggleOn} />
- ) : (
- <FontAwesomeIcon icon={faToggleOff} />
- ),
- tooltip: showSearch ? "隐藏搜索栏" : "显示搜索栏",
- onClick: (key: string | undefined) => {
- setShowSearch(!showSearch);
- },
- },
- {
- key: "refresh",
- tooltip: "刷新",
- icon: <ReloadOutlined />,
- onClick: (key: string | undefined) => {
- if (actionTableRef.current) {
- actionTableRef.current.reload();
- }
- },
- },
- ],
- }}
- />
- <Modal
- title="Cron表达式生成器"
- key={modalKey}
- zIndex={10000}
- open={isCronShow}
- onOk={getCronData}
- onCancel={() => setIsCronShow(false)}
- // confirmLoading={confirmLoading}
- >
- <Input prefix={<ClockCircleOutlined />} value={cronValue} />
- <div style={{ maxHeight: 450, overflow: "auto" }}>
- <ReQuartzCron
- cssClassPrefix="cron-"
- localization={MortnonCronLocalization}
- value={cronValue}
- onChange={setCronValue}
- renderYearsFrom={new Date().getFullYear()}
- />
- </div>
- </Modal>
- {selectedRow !== undefined && (
- <Modal
- title="任务详情"
- footer={<Button onClick={() => setIsShowDetail(false)}>关闭</Button>}
- open={isShowDetail}
- onCancel={() => setIsShowDetail(false)}
- >
- <ProDescriptions column={2}>
- <ProDescriptions.Item label="任务编号">
- {selectedRow.jobId}
- </ProDescriptions.Item>
- <ProDescriptions.Item
- label="任务分组"
- valueEnum={{
- DEFAULT: {
- text: "默认",
- status: "DEFAULT",
- },
- SYSTEM: {
- text: "系统",
- status: "SYSTEM",
- },
- }}
- >
- {selectedRow.jobGroup}
- </ProDescriptions.Item>
- <ProDescriptions.Item label="任务名称">
- {selectedRow.jobName}
- </ProDescriptions.Item>
- <ProDescriptions.Item label="创建时间">
- {selectedRow.createTime}
- </ProDescriptions.Item>
- <ProDescriptions.Item label="Cron表达式">
- {selectedRow.cronExpression}
- </ProDescriptions.Item>
- <ProDescriptions.Item label="下次执行时间">
- {selectedRow.nextValidTime}
- </ProDescriptions.Item>
- </ProDescriptions>
- <ProDescriptions column={1}>
- <ProDescriptions.Item label="调用目标方法">
- {selectedRow.invokeTarget}
- </ProDescriptions.Item>
- </ProDescriptions>
- <ProDescriptions column={2}>
- <ProDescriptions.Item
- label="任务状态"
- valueEnum={{
- 0: {
- text: "正常",
- status: "0",
- },
- 1: {
- text: "暂停",
- status: "1",
- },
- }}
- >
- {selectedRow.status}
- </ProDescriptions.Item>
- <ProDescriptions.Item
- label="是否并发"
- valueEnum={{
- 0: {
- text: "允许",
- status: "0",
- },
- 1: {
- text: "禁止",
- status: "1",
- },
- }}
- >
- {selectedRow.concurrent}
- </ProDescriptions.Item>
- <ProDescriptions.Item
- label="执行策略"
- valueEnum={{
- 1: {
- text: "立即执行",
- status: "1",
- },
- 2: {
- text: "执行一次",
- status: "2",
- },
- 3: {
- text: "放弃执行",
- status: "3",
- },
- }}
- >
- {selectedRow.misfirePolicy}
- </ProDescriptions.Item>
- </ProDescriptions>
- </Modal>
- )}
-
- {/* 删除确认模态框 */}
- <Modal
- title={
- <div style={{ display: 'flex', alignItems: 'center' }}>
- <ExclamationCircleFilled style={{ color: '#faad14', marginRight: 8 }} />
- <span>系统提示</span>
- </div>
- }
- open={deleteModalVisible}
- onOk={executeDeleteRow}
- onCancel={() => {
- setDeleteModalVisible(false);
- setDeleteJobId(null);
- }}
- okText="确认"
- cancelText="取消"
- >
- <p>{`确定删除任务编号为“${deleteJobId}”的数据项?`}</p>
- </Modal>
-
- {/* 切换状态确认模态框 */}
- <Modal
- title={
- <div style={{ display: 'flex', alignItems: 'center' }}>
- <ExclamationCircleFilled style={{ color: '#faad14', marginRight: 8 }} />
- <span>系统提示</span>
- </div>
- }
- open={statusModalVisible}
- onOk={confirmSwitchStatus}
- onCancel={cancelSwitchStatus}
- okText="确认"
- cancelText="取消"
- >
- <p>{`确认要${statusChecked ? "启用" : "停用"}"${statusRecord?.jobName}"任务吗?`}</p>
- </Modal>
-
- {/* 执行任务确认模态框 */}
- <Modal
- title={
- <div style={{ display: 'flex', alignItems: 'center' }}>
- <ExclamationCircleFilled style={{ color: '#faad14', marginRight: 8 }} />
- <span>系统提示</span>
- </div>
- }
- open={runModalVisible}
- onOk={() => executeJob(runRecord)}
- onCancel={cancelRunJob}
- okText="确认"
- cancelText="取消"
- >
- <p>{`确定要立即执行一次任务“${runRecord?.jobName}”吗?`}</p>
- </Modal>
- </PageContainer>
- );
- }
|