feat:2.4.0

1. 重构重试的场景列表页和新增场景
This commit is contained in:
byteblogs168 2023-10-23 23:38:45 +08:00
parent 4d057510d3
commit 53992db4d1
14 changed files with 1049 additions and 25 deletions

View File

@ -30,12 +30,15 @@ public class SceneConfigServiceImpl implements SceneConfigService {
PageDTO<SceneConfig> pageDTO = new PageDTO<>(queryVO.getPage(), queryVO.getSize()); PageDTO<SceneConfig> pageDTO = new PageDTO<>(queryVO.getPage(), queryVO.getSize());
LambdaQueryWrapper<SceneConfig> sceneConfigLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SceneConfig> sceneConfigLambdaQueryWrapper = new LambdaQueryWrapper<>();
if (StrUtil.isNotBlank(queryVO.getGroupName())) {
sceneConfigLambdaQueryWrapper.eq(SceneConfig::getGroupName, queryVO.getGroupName());
}
if (StrUtil.isNotBlank(queryVO.getSceneName())) { if (StrUtil.isNotBlank(queryVO.getSceneName())) {
sceneConfigLambdaQueryWrapper.eq(SceneConfig::getSceneName, queryVO.getSceneName()); sceneConfigLambdaQueryWrapper.eq(SceneConfig::getSceneName, queryVO.getSceneName());
} }
pageDTO = sceneConfigMapper.selectPage(pageDTO, sceneConfigLambdaQueryWrapper pageDTO = sceneConfigMapper.selectPage(pageDTO, sceneConfigLambdaQueryWrapper.orderByDesc(SceneConfig::getCreateDt));
.eq(SceneConfig::getGroupName, queryVO.getGroupName()).orderByDesc(SceneConfig::getCreateDt));
return new PageResult<>(pageDTO, SceneConfigResponseVOConverter.INSTANCE.batchConvert(pageDTO.getRecords())); return new PageResult<>(pageDTO, SceneConfigResponseVOConverter.INSTANCE.batchConvert(pageDTO.getRecords()));

View File

@ -58,6 +58,25 @@ export const asyncRouterMap = [
redirect: '/retry/list', redirect: '/retry/list',
meta: { title: '重试任务管理', icon: 'schedule', hideChildrenInMenu: true, keepAlive: true, permission: ['retryTask'] }, meta: { title: '重试任务管理', icon: 'schedule', hideChildrenInMenu: true, keepAlive: true, permission: ['retryTask'] },
children: [ children: [
{
path: '/retry/scene/list',
name: 'SceneList',
component: () => import('@/views/task/SceneList'),
meta: { title: '场景列表', icon: 'profile', keepAlive: true, permission: ['retryTask'] }
},
{
path: '/retry/scene/config',
name: 'SceneFrom',
hidden: true,
component: () => import('@/views/task/form/SceneFrom'),
meta: { title: '场景配置', icon: 'profile', keepAlive: true, permission: ['retryTask'] }
},
{
path: '/retry/notify/list',
name: 'NotifyList',
component: () => import('@/views/task/NotifyList'),
meta: { title: '通知配置', icon: 'profile', keepAlive: true, permission: ['retryTask'] }
},
{ {
path: '/retry/list', path: '/retry/list',
name: 'RetryTaskList', name: 'RetryTaskList',

View File

@ -0,0 +1,141 @@
const enums = {
sceneStatus: {
'0': {
'name': '停用',
'color': '#9c1f1f'
},
'1': {
'name': '启用',
'color': '#f5a22d'
}
},
backOffLabels: {
'1': {
'name': '延迟等级',
'color': '#d06892'
},
'2': {
'name': '固定时间',
'color': '#f5a22d'
},
'3': {
'name': 'CRON表达式',
'color': '#e1f52d'
},
'4': {
'name': '随机等待',
'color': '#a127f3'
}
},
triggerInterval: {
'1': {
'name': 'CRON表达式',
'color': '#d06892'
},
'2': {
'name': '固定时间',
'color': '#f5a22d'
}
},
blockStrategy: {
'1': {
'name': '丢弃策略',
'color': '#d06892'
},
'2': {
'name': '覆盖',
'color': '#f5a22d'
},
'3': {
'name': '并行',
'color': '#e1f52d'
}
},
executorType: {
'1': {
'name': 'Java',
'color': '#d06892'
}
},
routeKey: {
'4': {
'name': '轮询',
'color': '#8f68d2'
},
'1': {
'name': '一致性Hash',
'color': '#d06892'
},
'2': {
'name': '随机',
'color': '#f5a22d'
},
'3': {
'name': 'LRU',
'color': '#e1f52d'
}
},
taskBatchStatus: {
'1': {
'name': '待处理',
'color': '#64a6ea'
},
'2': {
'name': '运行中',
'color': '#1b7ee5'
},
'3': {
'name': '成功',
'color': '#087da1'
},
'4': {
'name': '失败',
'color': '#f52d80'
},
'5': {
'name': '停止',
'color': '#ac2df5'
},
'6': {
'name': '取消',
'color': '#f5732d'
}
},
operationReason: {
'0': {
'name': ''
},
'1': {
'name': '执行超时',
'color': '#64a6ea'
},
'2': {
'name': '无客户端节点',
'color': '#1b7ee5'
},
'3': {
'name': '任务已关闭',
'color': '#087da1'
}
},
taskStatus: {
'2': {
'name': '运行中',
'color': '#1b7ee5'
},
'3': {
'name': '成功',
'color': '#087da1'
},
'4': {
'name': '失败',
'color': '#f52d80'
},
'5': {
'name': '停止',
'color': '#ac2df5'
}
}
}
module.exports = enums

View File

@ -1,17 +1,17 @@
<template> <template>
<div> <div>
<page-header-wrapper content="配置组、场景、通知配置" @back="() => $router.go(-1)" style='margin: -24px -1px 0'> <page-header-wrapper content="配置组、场景、通知配置" @back="() => $router.go(-1)" style="margin: -24px -1px 0">
<div></div> <div></div>
</page-header-wrapper> </page-header-wrapper>
<a-card class="card" title="组配置" :bordered="false"> <a-card class="card" title="组配置" :bordered="false">
<group-form ref="groupConfig" :showSubmit="false" /> <group-form ref="groupConfig" :showSubmit="false" />
</a-card> </a-card>
<a-card class="card" title="通知配置" :bordered="false"> <!-- <a-card class="card" title="通知配置" :bordered="false">-->
<notify-list ref="notify"></notify-list> <!-- <notify-list ref="notify"></notify-list>-->
</a-card> <!-- </a-card>-->
<a-card class="card" title="场景配置" :bordered="false"> <!-- <a-card class="card" title="场景配置" :bordered="false">-->
<scene-list ref="scene"></scene-list> <!-- <scene-list ref="scene"></scene-list>-->
</a-card> <!-- </a-card>-->
<!-- fixed footer toolbar --> <!-- fixed footer toolbar -->
<footer-tool-bar :is-mobile="isMobile" :collapsed="sideCollapsed" style="width: 100%"> <footer-tool-bar :is-mobile="isMobile" :collapsed="sideCollapsed" style="width: 100%">
@ -38,7 +38,7 @@
<script> <script>
import GroupForm from './GroupForm' import GroupForm from './GroupForm'
import SceneList from './SceneList' import SceneList from './SceneList'
import NotifyList from './NotifyList' // import NotifyList from '../../task/NotifyList.vue'
import FooterToolBar from '@/components/FooterToolbar' import FooterToolBar from '@/components/FooterToolbar'
import { baseMixin } from '@/store/app-mixin' import { baseMixin } from '@/store/app-mixin'
import { saveGroup } from '@/api/manage' import { saveGroup } from '@/api/manage'
@ -55,8 +55,8 @@ export default {
components: { components: {
FooterToolBar, FooterToolBar,
GroupForm, GroupForm,
SceneList, SceneList
NotifyList // NotifyList
}, },
data () { data () {
return { return {

View File

@ -47,7 +47,7 @@
<script> <script>
import { jobBatchDetail, jobTaskList } from '@/api/jobApi' import { jobBatchDetail, jobTaskList } from '@/api/jobApi'
import moment from 'moment' import moment from 'moment'
import enums from '@/utils/enum' import enums from '@/utils/jobEnum'
import JobTaskList from './JobTaskList' import JobTaskList from './JobTaskList'
export default { export default {

View File

@ -160,7 +160,7 @@ import AInput from 'ant-design-vue/es/input/Input'
import { STable } from '@/components' import { STable } from '@/components'
import { jobBatchList, jobNameList } from '@/api/jobApi' import { jobBatchList, jobNameList } from '@/api/jobApi'
import { getAllGroupNameList } from '@/api/manage' import { getAllGroupNameList } from '@/api/manage'
const enums = require('@/utils/enum') const enums = require('@/utils/jobEnum')
export default { export default {
name: 'JobBatchList', name: 'JobBatchList',

View File

@ -79,7 +79,7 @@
<script> <script>
import { getJobDetail } from '@/api/jobApi' import { getJobDetail } from '@/api/jobApi'
import moment from 'moment' import moment from 'moment'
import enums from '@/utils/enum' import enums from '@/utils/jobEnum'
export default { export default {
name: 'JobInfo', name: 'JobInfo',
@ -103,11 +103,6 @@ export default {
if (id && groupName) { if (id && groupName) {
getJobDetail(id).then(res => { getJobDetail(id).then(res => {
this.jobInfo = res.data this.jobInfo = res.data
// this.queryParam = {
// groupName: this.retryTaskInfo.groupName,
// uniqueId: this.retryTaskInfo.uniqueId
// }
// this.$refs.retryTaskLogMessageListRef.refreshTable(this.queryParam)
}) })
} else { } else {
this.$router.push({ path: '/404' }) this.$router.push({ path: '/404' })

View File

@ -157,7 +157,7 @@ import AInput from 'ant-design-vue/es/input/Input'
import { STable } from '@/components' import { STable } from '@/components'
import { delJob, getJobList, updateJobStatus } from '@/api/jobApi' import { delJob, getJobList, updateJobStatus } from '@/api/jobApi'
import { getAllGroupNameList } from '@/api/manage' import { getAllGroupNameList } from '@/api/manage'
import enums from '@/utils/enum' import enums from '@/utils/jobEnum'
export default { export default {
name: 'JobList', name: 'JobList',

View File

@ -116,7 +116,7 @@ import AInput from 'ant-design-vue/es/input/Input'
import { STable } from '@/components' import { STable } from '@/components'
import { jobTaskList } from '@/api/jobApi' import { jobTaskList } from '@/api/jobApi'
import { getAllGroupNameList } from '@/api/manage' import { getAllGroupNameList } from '@/api/manage'
import enums from '@/utils/enum' import enums from '@/utils/jobEnum'
import JobLogMessageList from './JobLogMessageList' import JobLogMessageList from './JobLogMessageList'
export default { export default {
name: 'JobTaskList', name: 'JobTaskList',

View File

@ -322,7 +322,7 @@ import { getJobDetail, saveJob, updateJob } from '@/api/jobApi'
import pick from 'lodash.pick' import pick from 'lodash.pick'
import CronModal from '@/views/job/from/CronModal' import CronModal from '@/views/job/from/CronModal'
const enums = require('@/utils/enum') const enums = require('@/utils/jobEnum')
export default { export default {
name: 'JobFrom', name: 'JobFrom',

View File

@ -1,5 +1,16 @@
<template> <template>
<div> <div>
<s-table
ref="table"
size="default"
:rowKey="(record) => record.id"
:columns="notifyColumns"
:data="loadData"
:alert="options.alert"
:rowSelection="options.rowSelection"
:scroll="{ x: 2000 }"
>
</s-table>
<a-table <a-table
:columns="notifyColumns" :columns="notifyColumns"
:dataSource="data" :dataSource="data"
@ -89,8 +100,6 @@
</span> </span>
</template> </template>
</a-table> </a-table>
<a-button style="width: 100%; margin-top: 16px; margin-bottom: 8px" type="dashed" icon="plus" @click="newMember">新增成员</a-button>
<a-modal :visible="visible" title="添加配置" @ok="handleOk" @cancel="handlerCancel" width="1000px"> <a-modal :visible="visible" title="添加配置" @ok="handleOk" @cancel="handlerCancel" width="1000px">
<a-form :form="form" @submit="handleSubmit" :body-style="{padding: '0px 0px'}" v-bind="formItemLayout" > <a-form :form="form" @submit="handleSubmit" :body-style="{padding: '0px 0px'}" v-bind="formItemLayout" >
<a-form-item <a-form-item
@ -195,9 +204,11 @@
<script> <script>
import { getNotifyConfigList } from '@/api/manage' import { getNotifyConfigList } from '@/api/manage'
import pick from 'lodash.pick' import pick from 'lodash.pick'
import { STable } from '@/components'
export default { export default {
name: 'NotifyList', name: 'NotifyList',
components: { STable },
data () { data () {
return { return {
notifyColumns: [ notifyColumns: [
@ -251,6 +262,28 @@ export default {
labelCol: { lg: { span: 7 }, sm: { span: 7 } }, labelCol: { lg: { span: 7 }, sm: { span: 7 } },
wrapperCol: { lg: { span: 10 }, sm: { span: 17 } } wrapperCol: { lg: { span: 10 }, sm: { span: 17 } }
}, },
loadData: (parameter) => {
return getNotifyConfigList(Object.assign(parameter, this.queryParam)).then((res) => {
return res
})
},
selectedRowKeys: [],
selectedRows: [],
// custom table alert & rowSelection
options: {
alert: {
show: true,
clear: () => {
this.selectedRowKeys = []
}
},
rowSelection: {
selectedRowKeys: this.selectedRowKeys,
onChange: this.onSelectChange
}
},
optionAlertShow: false,
memberLoading: false, memberLoading: false,
notifyScene: { notifyScene: {
'1': '重试数量超过阈值', '1': '重试数量超过阈值',

View File

@ -0,0 +1,514 @@
<template>
<div>
<a-card :bordered="false">
<div class="table-page-search-wrapper">
<a-form layout="inline">
<a-row :gutter="48">
<template>
<a-col :md="8" :sm="24">
<a-form-item label="场景名称">
<a-input v-model="queryParam.sceneName" placeholder="请输入场景名称" allowClear/>
</a-form-item>
</a-col>
</template>
<a-col :md="!advanced && 8 || 24" :sm="24">
<span class="table-page-search-submitButtons" :style="advanced && { float: 'right', overflow: 'hidden' } || {} ">
<a-button type="primary" @click="queryChange()">查询</a-button>
<a-button style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button>
</span>
</a-col>
</a-row>
</a-form>
</div>
<div class="table-operator">
<a-button type="primary" icon="plus" @click="handleNew()">新增</a-button>
<!-- <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0">-->
<!-- <a-menu slot="overlay" @click="onClick">-->
<!-- <a-menu-item key="1"><a-icon type="delete" />删除</a-menu-item>-->
<!-- <a-menu-item key="2"><a-icon type="edit" />更新</a-menu-item>-->
<!-- </a-menu>-->
<!-- <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /> </a-button>-->
<!-- </a-dropdown>-->
</div>
<s-table
ref="table"
size="default"
:rowKey="(record) => record.id"
:columns="sceneColumns"
:data="loadData"
:alert="options.alert"
:rowSelection="options.rowSelection"
:scroll="{ x: 1500 }"
>
<span slot="serial" slot-scope="text, record">
{{ record.id }}
</span>
<span slot="sceneStatus" slot-scope="text">
<a-tag :color="sceneStatus[text].color">
{{ sceneStatus[text].name }}>
</a-tag>
</span>
<span slot="backOff" slot-scope="text">
<a-tag :color="backOffLabels[text].color">
{{ backOffLabels[text].name }}
</a-tag>
</span>
<span slot="triggerInterval" slot-scope="text">
{{ text }}
</span>
</s-table>
</a-card>
<!-- <a-table-->
<!-- :columns="sceneColumns"-->
<!-- :row-key="record => record.key"-->
<!-- :dataSource="data"-->
<!-- :pagination="pagination"-->
<!-- :loading="memberLoading"-->
<!-- @change="handleTableChange"-->
<!-- :scroll="{ x: 1800 }"-->
<!-- >-->
<!-- <template v-for="(col, i) in ['sceneName', 'description']" :slot="col" slot-scope="text, record">-->
<!-- <a-input-->
<!-- :key="col"-->
<!-- v-if="record.editable"-->
<!-- style="margin: -5px 0"-->
<!-- :value="text"-->
<!-- :placeholder="sceneColumns.find(item => item.key === col).title"-->
<!-- @change="e => handleChange(e.target.value, record.key, col)"-->
<!-- />-->
<!-- <template v-else>{{ text }}</template>-->
<!-- </template>-->
<!-- <template slot="sceneStatus" slot-scope="text, record">-->
<!-- <a-select-->
<!-- v-if="record.editable"-->
<!-- placeholder="场景状态"-->
<!-- style="width: 100%;"-->
<!-- :value="text === 0 ? '1': text"-->
<!-- @change="value => handleChange(value, record.key, 'sceneStatus')">-->
<!-- <a-select-option value="0">停用</a-select-option>-->
<!-- <a-select-option value="1">启用</a-select-option>-->
<!-- </a-select>-->
<!-- <template v-else>{{ sceneStatus[text] }}</template>-->
<!-- </template>-->
<!-- <template slot="backOff" slot-scope="text, record">-->
<!-- <a-select-->
<!-- v-if="record.editable"-->
<!-- placeholder="退避策略"-->
<!-- style="width: 100%;"-->
<!-- :value="text === 0 ? null: text"-->
<!-- @change="value => handleChange(value, record.key, 'backOff')">-->
<!-- <a-select-option value="1">延迟等级</a-select-option>-->
<!-- <a-select-option value="2">固定时间</a-select-option>-->
<!-- <a-select-option value="3">CRON表达式</a-select-option>-->
<!-- <a-select-option value="4">随机等待</a-select-option>-->
<!-- </a-select>-->
<!-- <template v-else>{{ backOffLabels[text] }}</template>-->
<!-- </template>-->
<!-- <template slot="maxRetryCount" slot-scope="text, record">-->
<!-- <a-input-number-->
<!-- v-if="record.editable"-->
<!-- :min="1"-->
<!-- :max="max"-->
<!-- style="width: 100%;"-->
<!-- :value="text"-->
<!-- :placeholder="maxRetryCount[data.find(item => item.key === record.key).backOff].placeholder"-->
<!-- @change="value => handleChange(value, record.key, 'maxRetryCount')">-->
<!-- </a-input-number>-->
<!-- <template v-else>{{ text }}</template>-->
<!-- </template>-->
<!-- <template slot="deadlineRequest" slot-scope="text, record">-->
<!-- <a-input-number-->
<!-- v-if="record.editable"-->
<!-- :min="100"-->
<!-- :max="60000"-->
<!-- style="width: 100%;"-->
<!-- :value="text"-->
<!-- placeholder="调用链超时时间(毫秒)"-->
<!-- @change="value => handleChange(value, record.key, 'deadlineRequest')"/>-->
<!-- <template v-else>{{ text }}(毫秒)</template>-->
<!-- </template>-->
<!-- <template slot="triggerInterval" slot-scope="text, record">-->
<!-- <a-input-->
<!-- v-if="record.editable"-->
<!-- style="margin: -5px 0"-->
<!-- :placeholder="triggerInterval[data.find(item => item.key === record.key).backOff].placeholder"-->
<!-- :value="text"-->
<!-- :disabled="data.find(item => item.key === record.key).backOff === '1'"-->
<!-- @change="e => handleChange(e.target.value, record.key, 'triggerInterval')"-->
<!-- >-->
<!-- <a-tooltip slot="suffix" :title="triggerInterval[data.find(item => item.key === record.key).backOff].tooltip">-->
<!-- <a-icon type="info-circle" style="color: rgba(0, 0, 0, 0.45)" />-->
<!-- </a-tooltip>-->
<!-- </a-input>-->
<!-- <template v-else>{{ text }}()</template>-->
<!-- </template>-->
<!-- <template slot="operation" slot-scope="text, record">-->
<!-- <template v-if="record.editable">-->
<!-- <span v-if="record.isNew">-->
<!-- <a @click="saveRow(record)">添加</a>-->
<!-- <a-divider type="vertical" />-->
<!-- <a-popconfirm title="是否要删除此行?" @confirm="remove(record.key)">-->
<!-- <a>删除</a>-->
<!-- </a-popconfirm>-->
<!-- </span>-->
<!-- <span v-else>-->
<!-- <a @click="saveRow(record)">保存</a>-->
<!-- <a-divider type="vertical" />-->
<!-- <a @click="cancel(record.key)">取消</a>-->
<!-- </span>-->
<!-- </template>-->
<!-- <span v-else>-->
<!-- <a @click="toggle(record.key)">编辑</a>-->
<!-- <a-divider type="vertical" />-->
<!-- <a-popconfirm title="是否要删除此行?" @confirm="remove(record.key)">-->
<!-- <a>删除</a>-->
<!-- </a-popconfirm>-->
<!-- </span>-->
<!-- </template>-->
<!-- </a-table>-->
<!-- <a-button style="width: 100%; margin-top: 16px; margin-bottom: 8px" type="dashed" icon="plus" @click="newMember">新增成员</a-button>-->
</div>
</template>
<script>
import { getScenePage } from '@/api/manage'
import { STable } from '@/components'
const enums = require('@/utils/retryEnum')
export default {
name: 'SceneList',
components: {
STable
},
data () {
return {
sceneColumns: [
{
title: '场景名称',
dataIndex: 'sceneName',
width: '15%'
},
{
title: '场景状态',
dataIndex: 'sceneStatus',
width: '8%',
scopedSlots: { customRender: 'sceneStatus' }
},
{
title: '退避策略',
dataIndex: 'backOff',
key: 'backOff',
width: '12%',
scopedSlots: { customRender: 'backOff' }
},
{
title: '最大重试次数',
dataIndex: 'maxRetryCount',
key: 'maxRetryCount',
width: '10%',
scopedSlots: { customRender: 'maxRetryCount' }
},
{
title: '调用链超时时间',
dataIndex: 'deadlineRequest',
key: 'deadlineRequest',
width: '10%',
scopedSlots: { customRender: 'deadlineRequest' }
},
{
title: '间隔时间',
dataIndex: 'triggerInterval',
key: 'triggerInterval',
width: '15%',
scopedSlots: { customRender: 'triggerInterval' }
},
{
title: '描述',
dataIndex: 'description',
key: 'description',
width: '18%',
scopedSlots: { customRender: 'description' }
},
{
title: '操作',
key: 'action',
fixed: 'right',
scopedSlots: { customRender: 'operation' }
}
],
data: [],
pagination: {},
backOffLabels: enums.backOffLabels,
sceneStatus: enums.sceneStatus,
triggerInterval: {
'1': {
placeholder: '',
tooltip: ''
},
'2': {
placeholder: '请输入固定间隔时间',
tooltip: '请输入固定间隔时间'
},
'3': {
placeholder: '请输入CRON表达式',
tooltip: '通过CRON表达式计算执行时间'
},
'4': {
placeholder: '请输入最大间隔时间',
tooltip: '随机生成范围在[0, x]内的延迟时间; 其中x代表最大间隔时间'
}
},
maxRetryCount: {
'1': {
placeholder: '请输入延迟等级(max:26)',
tooltip: '请输入延迟等级max:26)'
},
'2': {
placeholder: '请输入最大重试次数',
tooltip: '请输入最大重试次数'
},
'3': {
placeholder: '请输入最大重试次数',
tooltip: '请输入最大重试次数'
},
'4': {
placeholder: '请输入最大重试次数',
tooltip: '请输入最大重试次数'
}
},
queryParam: {},
loadData: (parameter) => {
return getScenePage(Object.assign(parameter, this.queryParam)).then((res) => {
return res
})
},
selectedRowKeys: [],
selectedRows: [],
// custom table alert & rowSelection
options: {
alert: {
show: true,
clear: () => {
this.selectedRowKeys = []
}
},
rowSelection: {
selectedRowKeys: this.selectedRowKeys,
onChange: this.onSelectChange
}
},
optionAlertShow: false
}
},
created () {
const groupName = this.$route.query.groupName
if (groupName) {
this.fetch({
groupName: groupName,
size: 6,
page: 1
}
)
}
},
methods: {
handleNew () {
this.$router.push({ path: '/retry/scene/config' })
},
reset () {
this.formData = []
this.data = []
const groupName = this.$route.query.groupName
if (groupName) {
this.fetch({
groupName: groupName,
size: 6,
page: 1
}
)
}
},
handleTableChange (pagination, filters, sorter) {
console.log(pagination)
const pager = { ...this.pagination }
pager.current = pagination.current
this.pagination = pager
this.fetch({
groupName: this.$route.query.groupName,
size: pagination.pageSize,
page: pagination.current,
sortField: sorter.field,
sortOrder: sorter.order,
...filters
})
},
queryChange () {
this.fetch({
groupName: this.$route.query.groupName,
size: 6,
page: 1,
sceneName: this.queryParam.sceneName
}
)
},
fetch (params = {}) {
this.loading = true
getScenePage(params).then(res => {
this.data = []
res.data.map(record => {
this.loading = false
const { id, sceneName, sceneStatus, maxRetryCount, backOff, triggerInterval, description, deadlineRequest } = record
this.data.push({
key: id,
sceneName: sceneName,
sceneStatus: sceneStatus.toString(),
maxRetryCount: maxRetryCount,
backOff: backOff.toString(),
triggerInterval: triggerInterval,
description: description,
deadlineRequest: deadlineRequest,
editable: false,
isNew: false
})
})
const pagination = { ...this.pagination }
pagination.pageSize = res.size
pagination.current = res.page
pagination.total = res.total
this.pagination = pagination
})
},
remove (delKey) {
const delData = this.data.find(item => item.key === delKey)
const { key, sceneName, sceneStatus, maxRetryCount, backOff, triggerInterval, description, deadlineRequest } = delData
this.formData.push({
key: key,
sceneName: sceneName,
sceneStatus: sceneStatus,
maxRetryCount: maxRetryCount,
backOff: backOff,
triggerInterval: triggerInterval,
deadlineRequest: deadlineRequest,
description: description,
isDeleted: 1
})
const newData = this.data.filter(item => item.key !== delKey)
this.data = newData
},
saveRow (record) {
this.memberLoading = true
const { key, sceneName, sceneStatus, maxRetryCount, backOff, triggerInterval, description, deadlineRequest } = record
if (!sceneName || !sceneStatus || !maxRetryCount || !backOff || (backOff === '1' ? false : !triggerInterval)) {
this.memberLoading = false
this.$message.error('请填写完整成员信息。')
return
}
const regex = /^[A-Za-z0-9_]{1,64}$/
if (!regex.test(sceneName)) {
this.memberLoading = false
this.$message.error('场景名称: 仅支持长度为:1~64位字符.格式为:数字、字母、下划线。')
return
}
if (description.length > 256) {
this.memberLoading = false
this.$message.error('描述: 仅支持长度为:1~256位字符')
return
}
if ((backOff === '2' || backOff === '4') && triggerInterval < 10) {
this.memberLoading = false
this.$message.error('描述: 间隔时间最小为10秒')
return
}
const target = this.formData.find(item => key === item.key)
if (!target) {
this.formData.push({
key: key,
sceneName: sceneName,
sceneStatus: sceneStatus,
maxRetryCount: maxRetryCount,
backOff: backOff,
triggerInterval: triggerInterval,
description: description,
deadlineRequest: deadlineRequest,
isDeleted: 0
})
}
new Promise((resolve) => {
setTimeout(() => {
resolve({ loop: false })
}, 200)
}).then(() => {
const target = this.data.find(item => item.key === key)
target.editable = false
target.isNew = false
this.memberLoading = false
this.$message.warning('请点击右下角提交按钮以保存所有页面数据')
})
},
toggle (key) {
const target = this.data.find(item => item.key === key)
target._originalData = { ...target }
target.editable = !target.editable
},
getRowByKey (key, newData) {
const data = this.data
return (newData || data).find(item => item.key === key)
},
cancel (key) {
const target = this.data.find(item => item.key === key)
Object.keys(target).forEach(key => { target[key] = target._originalData[key] })
target._originalData = undefined
},
handleChange (value, key, column) {
if (column === 'backOff') {
switch (value) {
case '1':
this.triggerIntervalDisabled = true
this.max = 26
break
default:
this.triggerIntervalDisabled = false
this.max = 99999
}
}
const newData = [...this.data]
const target = newData.find(item => key === item.key)
if (target) {
target[column] = value
this.data = newData
}
},
newMember () {
const length = this.data.length
this.data.unshift({
key: length === 0 ? '1' : (parseInt(this.data[length - 1].key) + 1).toString(),
sceneName: '',
sceneStatus: '1',
maxRetryCount: null,
backOff: '1',
triggerInterval: '',
deadlineRequest: '60000',
description: '',
editable: true,
isNew: true
})
}
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,319 @@
<template>
<div>
<page-header-wrapper content="场景配置" @back="() => $router.go(-1)" style="margin: -24px -1px 0">
<div></div>
</page-header-wrapper>
<a-card :body-style="{padding: '24px 32px'}" :bordered="false" :loading="loading">
<a-form @submit="handleSubmit" :form="form" class="form-row" layout="vertical" style="width: 40%;margin: auto;">
<a-row class="form-row" :gutter="16">
<a-col :lg="24" :md="24" :sm="24">
<a-form-item>
<a-input
hidden
v-decorator="['id']" />
</a-form-item>
<a-form-item label="场景名称" >
<a-input
placeholder="请输入场景名称"
:maxLength="64"
v-decorator="[
'sceneName',
{rules: [{ required: true, message: '请输入场景名称', whitespace: true},{required: true, max: 64, message: '最多支持64个字符'}]}
]" />
</a-form-item>
</a-col>
</a-row>
<a-row class="form-row" :gutter="16">
<a-col :lg="18" :md="18" :sm="24">
<a-form-item label="组">
<a-select
placeholder="请选择组"
v-decorator="['groupName', { rules: [{ required: true, message: '请选择组' }] }]"
>
<a-select-option v-for="item in groupNameList" :value="item" :key="item">{{ item }}</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :sm="24">
<a-form-item label="状态">
<a-select
placeholder="请选择状态"
v-decorator="[
'sceneStatus',
{
initialValue: '1',
rules: [{ required: true, message: '请选择状态'}]
}
]" >
<a-select-option :value="index" v-for="(item, index) in sceneStatus" :key="index">{{ item.name }}</a-select-option>
</a-select>
</a-form-item>
</a-col>
</a-row>
<a-row class="form-row" :gutter="16">
<a-col :lg="8" :md="12" :sm="12">
<a-form-item label="退避策略">
<a-select
placeholder="请选择退避策略"
@change="handleChange"
v-decorator="[
'backOff',
{
initialValue: '2',
rules: [{ required: true, message: '请选择退避策略'}]
}
]" >
<a-select-option :value="index" v-for="(item, index) in backOffLabels" :key="index">{{ item.name }}</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :lg="16" :md="12" :sm="12">
<a-form-item label="间隔时长">
<a-input
v-if="backOff === '1'"
placeholder="1 2 4 5"
disabled
/>
<a-input-number
v-if="backOff === '2' || backOff === '4'"
style="width: -webkit-fill-available"
placeholder="请输入间隔时长(秒)"
:min="1"
v-decorator="[
'triggerInterval',
{initialValue: '60',
rules: [ { required: true, message: '请输入间隔时长'}]}
]" />
<a-input
v-if="backOff === '3'"
@click="handlerCron"
placeholder="请输入间隔时长"
v-decorator="[
'triggerInterval',
{rules: [{ required: true, message: '请输入间隔时长', whitespace: true}]}
]" />
</a-form-item>
</a-col>
</a-row>
<a-row class="form-row" :gutter="16">
<a-col :lg="8" :md="12" :sm="24">
<a-form-item label="路由策略">
<a-select
placeholder="请选择路由策略"
v-decorator="[
'routeKey',
{
initialValue: '4',
rules: [{ required: true, message: '请选择路由策略'}]
}
]" >
<a-select-option :value="index" v-for="(item, index) in routeKey" :key="index">{{ item.name }}</a-select-option>
</a-select>
</a-form-item>
</a-col>
</a-row>
<a-row class="form-row" :gutter="16">
<a-col :lg="8" :md="24" :sm="24">
<a-form-item label="超时时间(秒)">
<a-input-number
id="inputNumber"
:min="1"
:max="36000"
style="width: -webkit-fill-available"
v-decorator="[
'executorTimeout',
{
initialValue: '60',
rules: [{ required: true, message: '请输入超时时间'}]
}
]" />
</a-form-item>
</a-col>
<a-col :lg="8" :md="24" :sm="24">
<a-form-item label="最大重试次数">
<a-input-number
:min="1"
style="width: -webkit-fill-available"
v-decorator="[
'maxRetryCount',
{
initialValue: '3',
rules: [{ required: true, message: '请输入最大重试次数'}]
}
]" />
</a-form-item>
</a-col>
<a-col :lg="8" :md="24" :sm="24">
<a-form-item label="调用链超时时间(毫秒)">
<a-input-number
style="width: -webkit-fill-available"
:min="100"
:max="60000"
v-decorator="[
'deadlineRequest',
{
initialValue: '60000',
rules: [{ required: true, message: '请输入调用链超时时间(毫秒)'}]
}
]" />
</a-form-item>
</a-col>
</a-row>
<a-row class="form-row" :gutter="16">
</a-row>
<a-row class="form-row" :gutter="16">
<a-col :lg="24" :md="24" :sm="24">
<a-form-item label="描述">
<a-input
placeholder="请输入描述"
type="textarea"
v-decorator="[
'description',
{rules: [{required: false, max: 256, message: '最多支持256个字符'}]}
]" />
</a-form-item>
</a-col>
</a-row>
<a-form-item
:wrapperCol="{ span: 24 }"
style="text-align: center"
>
<a-button htmlType="submit" type="primary">提交</a-button>
<a-button style="margin-left: 8px">重置</a-button>
</a-form-item>
</a-form>
</a-card>
<cron-modal ref="cronModalRef" @getCron="getCron"/>
</div>
</template>
<script>
import { getAllGroupNameList } from '@/api/manage'
import { getJobDetail, saveJob, updateJob } from '@/api/jobApi'
import pick from 'lodash.pick'
import CronModal from '@/views/job/from/CronModal'
const enums = require('@/utils/retryEnum')
export default {
name: 'JobFrom',
components: { CronModal },
props: {},
comments: {
CronModal
},
data () {
return {
form: this.$form.createForm(this),
formItemLayout: {
labelCol: { lg: { span: 7 }, sm: { span: 7 } },
wrapperCol: { lg: { span: 10 }, sm: { span: 17 } }
},
formItemLayoutWithOutLabel: {
wrapperCol: {
xs: { span: 24, offset: 0 },
sm: { span: 20, offset: 4 }
}
},
formType: 'create',
groupNameList: [],
blockStrategy: enums.blockStrategy,
executorType: enums.executorType,
routeKey: enums.routeKey,
backOffLabels: enums.backOffLabels,
sceneStatus: enums.sceneStatus,
loading: false,
visible: false,
count: 0,
backOff: '1'
}
},
beforeCreate () {
this.dynamicForm = this.$form.createForm(this, { name: 'dynamic_form_item' })
this.dynamicForm.getFieldDecorator('keys', { initialValue: [], preserve: true })
},
mounted () {
getAllGroupNameList().then((res) => {
this.groupNameList = res.data
})
this.$nextTick(() => {
const id = this.$route.query.id
if (id) {
this.loading = true
getJobDetail(id).then(res => {
this.loadEditInfo(res.data)
this.loading = false
})
}
})
},
methods: {
handleChange (value) {
console.log(value)
this.backOff = value
this.form.setFieldsValue({
triggerInterval: null
})
},
handlerCron () {
const backOff = this.form.getFieldValue('backOff')
if (backOff === '3') {
let triggerInterval = this.form.getFieldValue('triggerInterval')
if (triggerInterval === null || triggerInterval === '') {
triggerInterval = '* * * * * ?'
}
this.$refs.cronModalRef.isShow(triggerInterval)
}
},
getCron (cron) {
this.form.setFieldsValue({
triggerInterval: cron
})
},
handleSubmit (e) {
e.preventDefault()
this.form.validateFields((err, values) => {
if (!err) {
if (this.formType === 'create') {
saveJob(values).then(res => {
this.$message.success('任务新增完成')
this.form.resetFields()
this.$router.go(-1)
})
} else {
updateJob(values).then(res => {
this.$message.success('任务更新完成')
this.form.resetFields()
this.$router.go(-1)
})
}
}
})
},
loadEditInfo (data) {
this.formType = 'edit'
const { form } = this
// ajax
new Promise((resolve) => {
setTimeout(resolve, 100)
}).then(() => {
const formData = pick(data, [
'id', 'jobName', 'groupName', 'jobStatus', 'executorInfo', 'argsStr', 'executorTimeout', 'description',
'maxRetryTimes', 'parallelNum', 'retryInterval', 'triggerType', 'blockStrategy', 'executorType', 'taskType', 'triggerInterval'])
formData.jobStatus = formData.jobStatus.toString()
formData.taskType = formData.taskType.toString()
formData.executorType = formData.executorType.toString()
formData.blockStrategy = formData.blockStrategy.toString()
formData.triggerType = formData.triggerType.toString()
this.triggerTypeValue = formData.triggerType
form.setFieldsValue(formData)
})
}
}
}
</script>