|
@@ -22,8 +22,10 @@ import {
|
|
|
executeJmJob,
|
|
|
updateJmJobStatus,
|
|
|
getCronNext,
|
|
|
+ getApi,
|
|
|
} from '../services'
|
|
|
import copy from 'copy-to-clipboard'
|
|
|
+import moment from 'moment'
|
|
|
|
|
|
const TaskMgmtWrapper = styled.div`
|
|
|
padding: 20px;
|
|
@@ -49,22 +51,33 @@ const TaskMgmtView = () => {
|
|
|
|
|
|
const navigate = useNavigate()
|
|
|
|
|
|
+ //执行状态
|
|
|
+ const [running, setRunning] = useState(false)
|
|
|
+ // 开关加载状态
|
|
|
+ const [switchLoading, setSwitchLoading] = useState(false)
|
|
|
+
|
|
|
// 切换状态
|
|
|
const changeTaskState = async (checked, id) => {
|
|
|
+ setSwitchLoading(true)
|
|
|
const { data } = await updateJmJobStatus({ id, status: checked ? 1 : 0 })
|
|
|
if (data.code === 200) {
|
|
|
message.success(data.data.status ? '开启成功' : '关闭成功')
|
|
|
} else {
|
|
|
message.error(data.msg)
|
|
|
}
|
|
|
+ setSwitchLoading(false)
|
|
|
}
|
|
|
//执行
|
|
|
const runTimeOnce = async id => {
|
|
|
- const { data } = await executeJmJob(id)
|
|
|
- if (data.code === 200) {
|
|
|
- message.success('开始执行')
|
|
|
- } else {
|
|
|
- message.error(data.msg)
|
|
|
+ if (!running) {
|
|
|
+ setRunning(true)
|
|
|
+ const { data } = await executeJmJob(id)
|
|
|
+ if (data.code === 200) {
|
|
|
+ message.success('执行完成')
|
|
|
+ } else {
|
|
|
+ message.error(data.msg)
|
|
|
+ }
|
|
|
+ setRunning(false)
|
|
|
}
|
|
|
}
|
|
|
//删除
|
|
@@ -78,10 +91,15 @@ const TaskMgmtView = () => {
|
|
|
}
|
|
|
}
|
|
|
//Api调用
|
|
|
- const getApiUri = id => {
|
|
|
- const url = `${process.env.REACT_APP_BASE_URL}/jpt/jm_job_info/execute/${id}`
|
|
|
- copy(url)
|
|
|
- message.success('复制成功')
|
|
|
+ const getApiUri = async id => {
|
|
|
+ const { data } = await getApi(id)
|
|
|
+ if (data.code === 200) {
|
|
|
+ const url = `${process.env.REACT_APP_BASE_URL}${data.data}`
|
|
|
+ copy(url)
|
|
|
+ message.success('复制成功')
|
|
|
+ } else {
|
|
|
+ message.error(data.msg)
|
|
|
+ }
|
|
|
}
|
|
|
//编辑
|
|
|
const editTask = id => {
|
|
@@ -118,6 +136,9 @@ const TaskMgmtView = () => {
|
|
|
item.cron_type === 1 ? '执行一次' : item.cron_expression,
|
|
|
historicalRuntime: item.history,
|
|
|
taskState: item.status === 1,
|
|
|
+ update_time: item.update_time
|
|
|
+ ? moment(item.update_time * 1000).format('YYYY.MM.DD HH:mm:ss')
|
|
|
+ : '无',
|
|
|
}
|
|
|
})
|
|
|
setJogList(list)
|
|
@@ -145,7 +166,7 @@ const TaskMgmtView = () => {
|
|
|
key: 'taskTag',
|
|
|
},
|
|
|
{
|
|
|
- title: '执行周期',
|
|
|
+ title: '定时规则',
|
|
|
dataIndex: 'executionCycle',
|
|
|
key: 'executionCycle',
|
|
|
},
|
|
@@ -177,6 +198,11 @@ const TaskMgmtView = () => {
|
|
|
</Popover>
|
|
|
),
|
|
|
},
|
|
|
+ {
|
|
|
+ title: '更新时间',
|
|
|
+ dataIndex: 'update_time',
|
|
|
+ key: 'update_time',
|
|
|
+ },
|
|
|
{
|
|
|
title: '历史运行情况',
|
|
|
dataIndex: 'historicalRuntime',
|
|
@@ -205,6 +231,7 @@ const TaskMgmtView = () => {
|
|
|
<Switch
|
|
|
checkedChildren="开启"
|
|
|
unCheckedChildren="关闭"
|
|
|
+ loading={switchLoading}
|
|
|
defaultChecked={val}
|
|
|
onChange={checked => changeTaskState(checked, record.key)}
|
|
|
/>
|
|
@@ -219,7 +246,11 @@ const TaskMgmtView = () => {
|
|
|
onClick={() => {
|
|
|
runTimeOnce(record.key)
|
|
|
}}
|
|
|
- style={{ color: '#1881DA', cursor: 'pointer' }}>
|
|
|
+ style={
|
|
|
+ running
|
|
|
+ ? { color: '#bfbfbf', cursor: 'no-drop' }
|
|
|
+ : { color: '#1881DA', cursor: 'pointer' }
|
|
|
+ }>
|
|
|
执行一次
|
|
|
</span>
|
|
|
<span
|