feat:2.5.0
1、https://gitee.com/aizuda/easy-retry/issues/I8CKC8 2、通知列表选条件改为下拉联动 3、通知新增修改页面修改 .通知场景新增任务重试数量超过阈值、任务失败进入死信队列 .新增限制流状态、每秒限流阈值字段 .钉钉和飞书配置属性新增被@联系人 4、mysql、postgre库的 notify_config表 新增场景名称、限流状态、每秒限流阈值字段
This commit is contained in:
parent
150097764e
commit
598d6e2481
@ -26,11 +26,14 @@ CREATE TABLE `notify_config`
|
||||
(
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`group_name` varchar(64) NOT NULL COMMENT '组名称',
|
||||
`notify_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '组状态 0、未启用 1、启用',
|
||||
`scene_name` varchar(64) NOT NULL COMMENT '场景名称',
|
||||
`notify_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '通知状态 0、未启用 1、启用',
|
||||
`notify_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '通知类型 1、钉钉 2、邮件 3、企业微信',
|
||||
`notify_attribute` varchar(512) NOT NULL COMMENT '配置属性',
|
||||
`notify_threshold` int(11) NOT NULL DEFAULT '0' COMMENT '通知阈值',
|
||||
`notify_scene` tinyint(4) NOT NULL DEFAULT '0' COMMENT '通知场景',
|
||||
`rate_limiter_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '限流状态 0、未启用 1、启用',
|
||||
`rate_limiter_threshold` int(11) NOT NULL DEFAULT '0' COMMENT '每秒限流阈值',
|
||||
`description` varchar(256) NOT NULL DEFAULT '' COMMENT '描述',
|
||||
`create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||
|
@ -34,11 +34,14 @@ CREATE TABLE notify_config
|
||||
(
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
group_name VARCHAR(64) NOT NULL,
|
||||
scene_name VARCHAR(64) NOT NULL,
|
||||
notify_status SMALLINT NOT NULL DEFAULT 0,
|
||||
notify_type SMALLINT NOT NULL DEFAULT 0,
|
||||
notify_attribute VARCHAR(512) NOT NULL,
|
||||
notify_threshold INT NOT NULL DEFAULT 0,
|
||||
notify_scene SMALLINT NOT NULL DEFAULT 0,
|
||||
rate_limiter_status SMALLINT NOT NULL DEFAULT 0,
|
||||
rate_limiter_threshold INT NOT NULL DEFAULT 0,
|
||||
description VARCHAR(256) NOT NULL DEFAULT '',
|
||||
create_dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
update_dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
@ -48,11 +51,14 @@ CREATE INDEX idx_group_name ON notify_config (group_name);
|
||||
|
||||
COMMENT ON COLUMN "notify_config"."id" IS '主键';
|
||||
COMMENT ON COLUMN "notify_config"."group_name" IS '组名称';
|
||||
COMMENT ON COLUMN "notify_config"."scene_name" IS '场景名称';
|
||||
COMMENT ON COLUMN "notify_config"."notify_status" IS '通知状态 0、未启用 1、启用';
|
||||
COMMENT ON COLUMN "notify_config"."notify_type" IS '通知类型 1、钉钉 2、邮件 3、企业微信';
|
||||
COMMENT ON COLUMN "notify_config"."notify_attribute" IS '配置属性';
|
||||
COMMENT ON COLUMN "notify_config"."notify_threshold" IS '通知阈值';
|
||||
COMMENT ON COLUMN "notify_config"."notify_scene" IS '通知场景';
|
||||
COMMENT ON COLUMN "notify_config"."rate_limiter_status" IS '限流状态 0、未启用 1、启用';
|
||||
COMMENT ON COLUMN "notify_config"."rate_limiter_threshold" IS '每秒限流阈值';
|
||||
COMMENT ON COLUMN "notify_config"."description" IS '描述';
|
||||
COMMENT ON COLUMN "notify_config"."create_dt" IS '创建时间';
|
||||
COMMENT ON COLUMN "notify_config"."update_dt" IS '修改时间';
|
||||
|
@ -52,6 +52,17 @@ public interface ConfigAccess<T> extends Access<T> {
|
||||
*/
|
||||
List<NotifyConfig> getNotifyConfigByGroupName(String groupName, Integer notifyScene);
|
||||
|
||||
|
||||
/**
|
||||
* 获取通知配置
|
||||
*
|
||||
* @param groupName 组名称
|
||||
* @param groupName 场景名称
|
||||
* @param notifyScene {@link NotifySceneEnum} 场景类型
|
||||
* @return {@link NotifyConfig} 场景配置
|
||||
*/
|
||||
List<NotifyConfig> getNotifyConfigByGroupNameAndSceneName(String groupName,String sceneName, Integer notifyScene);
|
||||
|
||||
/**
|
||||
* 获取通知配置
|
||||
*
|
||||
@ -88,6 +99,14 @@ public interface ConfigAccess<T> extends Access<T> {
|
||||
*/
|
||||
List<GroupConfig> getAllConfigGroupList();
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有场景配置信息
|
||||
*
|
||||
* @return 场景配置列表
|
||||
*/
|
||||
List<SceneConfig> getAllConfigSceneList();
|
||||
|
||||
/**
|
||||
* 获取配置版本号
|
||||
*
|
||||
|
@ -50,6 +50,12 @@ public abstract class AbstractConfigAccess<T> implements ConfigAccess<T> {
|
||||
.eq(NotifyConfig::getNotifyScene, notifyScene));
|
||||
}
|
||||
|
||||
private List<NotifyConfig> getByGroupIdAndSceneIdAndNotifyScene(String groupName, String sceneName, Integer notifyScene) {
|
||||
return notifyConfigMapper.selectList(new LambdaQueryWrapper<NotifyConfig>().eq(NotifyConfig::getGroupName, groupName)
|
||||
.eq(NotifyConfig::getSceneName, sceneName)
|
||||
.eq(NotifyConfig::getNotifyScene, notifyScene));
|
||||
}
|
||||
|
||||
protected SceneConfig getByGroupNameAndSceneName(String groupName, String sceneName) {
|
||||
return sceneConfigMapper.selectOne(new LambdaQueryWrapper<SceneConfig>()
|
||||
.eq(SceneConfig::getGroupName, groupName).eq(SceneConfig::getSceneName, sceneName));
|
||||
@ -89,6 +95,11 @@ public abstract class AbstractConfigAccess<T> implements ConfigAccess<T> {
|
||||
return getByGroupIdAndNotifyScene(shardingGroupId, notifyScene);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NotifyConfig> getNotifyConfigByGroupNameAndSceneName(String shardingGroupId,String shardingSceneId, Integer notifyScene) {
|
||||
return getByGroupIdAndSceneIdAndNotifyScene(shardingGroupId,shardingSceneId, notifyScene);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NotifyConfig> getNotifyListConfigByGroupName(String shardingGroupId) {
|
||||
return getNotifyConfigs(shardingGroupId);
|
||||
@ -138,6 +149,15 @@ public abstract class AbstractConfigAccess<T> implements ConfigAccess<T> {
|
||||
return allSystemConfigGroupList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SceneConfig> getAllConfigSceneList() {
|
||||
List<SceneConfig> allSystemConfigSceneList = sceneConfigMapper.selectList(new LambdaQueryWrapper<SceneConfig>().orderByAsc(SceneConfig::getId));
|
||||
if (CollectionUtils.isEmpty(allSystemConfigSceneList)) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
return allSystemConfigSceneList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getConfigVersion(String groupName) {
|
||||
GroupConfig groupConfig = getGroupConfigByGroupName(groupName);
|
||||
|
@ -3,7 +3,6 @@ package com.aizuda.easy.retry.template.datasource.persistence.po;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@ -15,6 +14,8 @@ public class NotifyConfig implements Serializable {
|
||||
|
||||
private String groupName;
|
||||
|
||||
private String sceneName;
|
||||
|
||||
private Integer notifyStatus;
|
||||
|
||||
private Integer notifyType;
|
||||
@ -25,6 +26,10 @@ public class NotifyConfig implements Serializable {
|
||||
|
||||
private Integer notifyScene;
|
||||
|
||||
private Integer rateLimiterStatus;
|
||||
|
||||
private Integer rateLimiterThreshold;
|
||||
|
||||
private String description;
|
||||
|
||||
private LocalDateTime createDt;
|
||||
|
@ -7,6 +7,11 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author zuojunlin
|
||||
* @date 2023-11-19 22:05:25
|
||||
* @since 2.5.0
|
||||
*/
|
||||
@Data
|
||||
public class SceneConfig implements Serializable {
|
||||
|
||||
|
@ -12,15 +12,14 @@ import com.aizuda.easy.retry.server.common.schedule.AbstractSchedule;
|
||||
import com.aizuda.easy.retry.server.common.util.DateUtils;
|
||||
import com.aizuda.easy.retry.template.datasource.access.AccessTemplate;
|
||||
import com.aizuda.easy.retry.template.datasource.access.TaskAccess;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.GroupConfig;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.NotifyConfig;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.RetryDeadLetter;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.SceneConfig;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
@ -38,7 +37,8 @@ import java.util.List;
|
||||
public class RetryErrorMoreThresholdAlarmSchedule extends AbstractSchedule implements Lifecycle {
|
||||
private static String retryErrorMoreThresholdTextMessageFormatter =
|
||||
"<font face=\"微软雅黑\" color=#ff0000 size=4>{}环境 重试失败数据监控</font> \n" +
|
||||
"> 名称:{} \n" +
|
||||
"> 组名称:{} \n" +
|
||||
"> 场景名称:{} \n" +
|
||||
"> 时间窗口:{} ~ {} \n" +
|
||||
"> **共计:{}** \n";
|
||||
|
||||
@ -60,32 +60,30 @@ public class RetryErrorMoreThresholdAlarmSchedule extends AbstractSchedule imple
|
||||
@Override
|
||||
protected void doExecute() {
|
||||
LogUtils.info(log, "retryErrorMoreThreshold time[{}] ip:[{}]", LocalDateTime.now(), HostUtils.getIp());
|
||||
|
||||
for (GroupConfig groupConfig : accessTemplate.getGroupConfigAccess().getAllConfigGroupList()) {
|
||||
List<NotifyConfig> notifyConfigs = accessTemplate.getNotifyConfigAccess().getNotifyConfigByGroupName(groupConfig.getGroupName(), NotifySceneEnum.MAX_RETRY_ERROR.getNotifyScene());
|
||||
for (SceneConfig sceneConfig : accessTemplate.getSceneConfigAccess().getAllConfigSceneList()) {
|
||||
List<NotifyConfig> notifyConfigs = accessTemplate.getNotifyConfigAccess().getNotifyConfigByGroupNameAndSceneName(sceneConfig.getGroupName(),sceneConfig.getSceneName(), NotifySceneEnum.MAX_RETRY_ERROR.getNotifyScene());
|
||||
if (CollectionUtils.isEmpty(notifyConfigs)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// x分钟内进入死信队列的数据量
|
||||
// x分钟内、x组、x场景进入死信队列的数据量
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
TaskAccess<RetryDeadLetter> retryDeadLetterAccess = accessTemplate.getRetryDeadLetterAccess();
|
||||
|
||||
long count = retryDeadLetterAccess.count(groupConfig.getGroupName(), new LambdaQueryWrapper<RetryDeadLetter>()
|
||||
.between(RetryDeadLetter::getCreateDt, now.minusMinutes(30), now));
|
||||
long count = retryDeadLetterAccess.count(sceneConfig.getGroupName(), new LambdaQueryWrapper<RetryDeadLetter>().
|
||||
between(RetryDeadLetter::getCreateDt, now.minusMinutes(30), now)
|
||||
.eq(RetryDeadLetter::getGroupName,sceneConfig.getGroupName())
|
||||
.eq(RetryDeadLetter::getSceneName,sceneConfig.getSceneName()));
|
||||
for (NotifyConfig notifyConfig : notifyConfigs) {
|
||||
if (count > notifyConfig.getNotifyThreshold()) {
|
||||
// 预警
|
||||
AlarmContext context = AlarmContext.build()
|
||||
.text(retryErrorMoreThresholdTextMessageFormatter,
|
||||
AlarmContext context = AlarmContext.build().text(retryErrorMoreThresholdTextMessageFormatter,
|
||||
EnvironmentUtils.getActiveProfile(),
|
||||
groupConfig.getGroupName(),
|
||||
DateUtils.format(now.minusMinutes(30), DateUtils.NORM_DATETIME_PATTERN),
|
||||
DateUtils.toNowFormat(DateUtils.NORM_DATETIME_PATTERN),
|
||||
count)
|
||||
.title("组:[{}] 环境重试失败数据监控", groupConfig.getGroupName())
|
||||
sceneConfig.getGroupName(),
|
||||
sceneConfig.getSceneName(),
|
||||
DateUtils.format(now.minusMinutes(30),
|
||||
DateUtils.NORM_DATETIME_PATTERN),
|
||||
DateUtils.toNowFormat(DateUtils.NORM_DATETIME_PATTERN), count)
|
||||
.title("组:[{}] 场景:[{}] 环境重试失败数据监控", sceneConfig.getGroupName(),sceneConfig.getSceneName())
|
||||
.notifyAttribute(notifyConfig.getNotifyAttribute());
|
||||
|
||||
Alarm<AlarmContext> alarmType = easyRetryAlarmFactory.getAlarmType(notifyConfig.getNotifyType());
|
||||
alarmType.asyncSendMessage(context);
|
||||
}
|
||||
|
@ -12,9 +12,9 @@ import com.aizuda.easy.retry.server.common.Lifecycle;
|
||||
import com.aizuda.easy.retry.server.common.schedule.AbstractSchedule;
|
||||
import com.aizuda.easy.retry.server.common.util.DateUtils;
|
||||
import com.aizuda.easy.retry.template.datasource.access.AccessTemplate;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.GroupConfig;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.NotifyConfig;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.RetryTask;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.SceneConfig;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -40,6 +40,7 @@ public class RetryTaskMoreThresholdAlarmSchedule extends AbstractSchedule implem
|
||||
private static String retryTaskMoreThresholdTextMessageFormatter =
|
||||
"<font face=\"微软雅黑\" color=#ff0000 size=4>{}环境 重试数据监控</font> \n" +
|
||||
"> 组名称:{} \n" +
|
||||
"> 场景名称:{} \n" +
|
||||
"> 告警时间:{} \n" +
|
||||
"> **共计:{}** \n";
|
||||
|
||||
@ -59,15 +60,14 @@ public class RetryTaskMoreThresholdAlarmSchedule extends AbstractSchedule implem
|
||||
@Override
|
||||
protected void doExecute() {
|
||||
LogUtils.info(log, "retryTaskMoreThreshold time[{}] ip:[{}]", LocalDateTime.now(), HostUtils.getIp());
|
||||
|
||||
for (GroupConfig groupConfig : accessTemplate.getGroupConfigAccess().getAllConfigGroupList()) {
|
||||
List<NotifyConfig> notifyConfigs = accessTemplate.getNotifyConfigAccess().getNotifyConfigByGroupName(groupConfig.getGroupName(), NotifySceneEnum.MAX_RETRY.getNotifyScene());
|
||||
for (SceneConfig sceneConfig : accessTemplate.getSceneConfigAccess().getAllConfigSceneList()) {
|
||||
List<NotifyConfig> notifyConfigs = accessTemplate.getNotifyConfigAccess().getNotifyConfigByGroupNameAndSceneName(sceneConfig.getGroupName(),sceneConfig.getSceneName(), NotifySceneEnum.MAX_RETRY.getNotifyScene());
|
||||
if (CollectionUtils.isEmpty(notifyConfigs)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
long count = accessTemplate.getRetryTaskAccess().count(groupConfig.getGroupName(), new LambdaQueryWrapper<RetryTask>()
|
||||
.eq(RetryTask::getGroupName, groupConfig.getGroupName())
|
||||
long count = accessTemplate.getRetryTaskAccess().count(sceneConfig.getGroupName(), new LambdaQueryWrapper<RetryTask>()
|
||||
.eq(RetryTask::getGroupName, sceneConfig.getGroupName())
|
||||
.eq(RetryTask::getSceneName,sceneConfig.getSceneName())
|
||||
.eq(RetryTask::getRetryStatus, RetryStatusEnum.RUNNING.getStatus()));
|
||||
for (NotifyConfig notifyConfig : notifyConfigs) {
|
||||
if (count > notifyConfig.getNotifyThreshold()) {
|
||||
@ -75,12 +75,12 @@ public class RetryTaskMoreThresholdAlarmSchedule extends AbstractSchedule implem
|
||||
AlarmContext context = AlarmContext.build()
|
||||
.text(retryTaskMoreThresholdTextMessageFormatter,
|
||||
EnvironmentUtils.getActiveProfile(),
|
||||
groupConfig.getGroupName(),
|
||||
sceneConfig.getGroupName(),
|
||||
sceneConfig.getSceneName(),
|
||||
DateUtils.toNowFormat(DateUtils.NORM_DATETIME_PATTERN),
|
||||
count)
|
||||
.title("组:[{}])重试数据过多", groupConfig.getGroupName())
|
||||
.title("组:[{}] 场景:[{}] 重试数据过多", sceneConfig.getGroupName(),sceneConfig.getSceneName())
|
||||
.notifyAttribute(notifyConfig.getNotifyAttribute());
|
||||
|
||||
Alarm<AlarmContext> alarmType = easyRetryAlarmFactory.getAlarmType(notifyConfig.getNotifyType());
|
||||
alarmType.asyncSendMessage(context);
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ public class NotifyConfigRequestVO {
|
||||
@Pattern(regexp = "^[A-Za-z0-9_]{1,64}$", message = "仅支持长度为1~64字符且类型为数字、字母和下划线")
|
||||
private String groupName;
|
||||
|
||||
private String sceneName;
|
||||
|
||||
@NotNull(message = "通知状态不能为空")
|
||||
private Integer notifyStatus;
|
||||
|
||||
@ -34,6 +36,10 @@ public class NotifyConfigRequestVO {
|
||||
@NotNull(message = "通知场景不能为空")
|
||||
private Integer notifyScene;
|
||||
|
||||
@NotNull(message = "限流状态不能为空")
|
||||
private Integer rateLimiterStatus;
|
||||
|
||||
private Integer rateLimiterThreshold;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
|
@ -12,6 +12,8 @@ public class NotifyConfigResponseVO implements Serializable {
|
||||
|
||||
private String groupName;
|
||||
|
||||
private String sceneName;
|
||||
|
||||
private Integer notifyStatus;
|
||||
|
||||
private String notifyName;
|
||||
@ -24,6 +26,10 @@ public class NotifyConfigResponseVO implements Serializable {
|
||||
|
||||
private Integer notifyScene;
|
||||
|
||||
private Integer rateLimiterStatus;
|
||||
|
||||
private Integer rateLimiterThreshold;
|
||||
|
||||
private String description;
|
||||
|
||||
private LocalDateTime createDt;
|
||||
|
@ -40,7 +40,9 @@ public class NotifyConfigServiceImpl implements NotifyConfigService {
|
||||
if (StrUtil.isNotBlank(queryVO.getGroupName())) {
|
||||
queryWrapper.eq(NotifyConfig::getGroupName, queryVO.getGroupName());
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(queryVO.getSceneName())) {
|
||||
queryWrapper.eq(NotifyConfig::getSceneName, queryVO.getSceneName());
|
||||
}
|
||||
List<NotifyConfig> notifyConfigs = accessTemplate.getNotifyConfigAccess().listPage(pageDTO, queryWrapper).getRecords();
|
||||
return new PageResult<>(pageDTO, NotifyConfigResponseVOConverter.INSTANCE.batchConvert(notifyConfigs));
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ export const asyncRouterMap = [
|
||||
path: '/retry/notify/list',
|
||||
name: 'NotifyList',
|
||||
component: () => import('@/views/task/NotifyList'),
|
||||
meta: { title: '通知配置', icon: 'profile', keepAlive: true, permission: ['retryTask'] }
|
||||
meta: { title: '通知列表', icon: 'profile', keepAlive: true, permission: ['retryTask'] }
|
||||
},
|
||||
{
|
||||
path: '/retry/notify/config',
|
||||
|
@ -39,11 +39,11 @@ const enums = {
|
||||
},
|
||||
notifyScene: {
|
||||
'1': {
|
||||
'name': '重试数量超过阈值',
|
||||
'name': '场景重试数量超过阈值',
|
||||
'color': '#d06892'
|
||||
},
|
||||
'2': {
|
||||
'name': '重试失败数量超过阈值',
|
||||
'name': '场景重试失败数量超过阈值',
|
||||
'color': '#f5a22d'
|
||||
},
|
||||
'3': {
|
||||
@ -53,6 +53,14 @@ const enums = {
|
||||
'4': {
|
||||
'name': '客户端组件异常',
|
||||
'color': '#a127f3'
|
||||
},
|
||||
'5': {
|
||||
'name': '任务重试数量超过阈值',
|
||||
'color': '#f5a22d'
|
||||
},
|
||||
'6': {
|
||||
'name': '任务失败进入死信队列',
|
||||
'color': '#f5a22d'
|
||||
}
|
||||
},
|
||||
routeKey: {
|
||||
@ -87,6 +95,16 @@ const enums = {
|
||||
'color': '#087da1'
|
||||
}
|
||||
},
|
||||
rateLimiterStatus: {
|
||||
'0': {
|
||||
'name': '未启用',
|
||||
'color': '#9c1f1f'
|
||||
},
|
||||
'1': {
|
||||
'name': '启用',
|
||||
'color': '#f5a22d'
|
||||
}
|
||||
},
|
||||
notifyStatus: {
|
||||
'0': {
|
||||
'name': '停用',
|
||||
|
@ -7,19 +7,23 @@
|
||||
<template>
|
||||
<a-col :md="8" :sm="24">
|
||||
<a-form-item label="组名称">
|
||||
<a-select
|
||||
v-model="queryParam.groupName"
|
||||
placeholder="请输入组名称"
|
||||
>
|
||||
<a-select v-model="queryParam.groupName" placeholder="请输入组名称" @change="value => handleChange(value)" allowClear>
|
||||
<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 :md="8" :sm="24">
|
||||
<a-form-item label="场景名称">
|
||||
<a-select v-model="queryParam.sceneName" placeholder="请选择场景名称" allowClear>
|
||||
<a-select-option v-for="item in sceneList" :value="item.sceneName" :key="item.sceneName"> {{ item.sceneName }}</a-select-option>
|
||||
</a-select>
|
||||
</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>
|
||||
<a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
|
||||
<a-button style="margin-left: 8px" @click="resetFiled">重置</a-button>
|
||||
</span>
|
||||
</a-col>
|
||||
</a-row>
|
||||
@ -45,13 +49,18 @@
|
||||
:rowSelection="options.rowSelection"
|
||||
>
|
||||
<span slot="notifyType" slot-scope="text">
|
||||
<a-tag :color="notifyType[text].color">
|
||||
{{ notifyType[text].name }}
|
||||
<a-tag :color="notifyTypeList[text].color">
|
||||
{{ notifyTypeList[text].name }}
|
||||
</a-tag>
|
||||
</span>
|
||||
<span slot="notifyStatus" slot-scope="text">
|
||||
<a-tag :color="notifyStatusList[text].color">
|
||||
{{ notifyStatusList[text].name }}
|
||||
</a-tag>
|
||||
</span>
|
||||
<span slot="notifyScene" slot-scope="text">
|
||||
<a-tag :color="notifyScene[text].color">
|
||||
{{ notifyScene[text].name }}
|
||||
<a-tag :color="notifySceneList[text].color">
|
||||
{{ notifySceneList[text].name }}
|
||||
</a-tag>
|
||||
</span>
|
||||
<span slot="notifyAttribute" slot-scope="text, record">
|
||||
@ -72,7 +81,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getAllGroupNameList, getNotifyConfigList } from '@/api/manage'
|
||||
import { getAllGroupNameList, getNotifyConfigList, getSceneList } from '@/api/manage'
|
||||
import { STable } from '@/components'
|
||||
const enums = require('@/utils/retryEnum')
|
||||
|
||||
@ -82,6 +91,26 @@ export default {
|
||||
data () {
|
||||
return {
|
||||
notifyColumns: [
|
||||
{
|
||||
title: '组名',
|
||||
dataIndex: 'groupName',
|
||||
key: 'groupName',
|
||||
width: '10%',
|
||||
scopedSlots: { customRender: 'groupName' }
|
||||
},
|
||||
{
|
||||
title: '场景名称',
|
||||
dataIndex: 'sceneName',
|
||||
key: 'sceneName',
|
||||
width: '10%',
|
||||
scopedSlots: { customRender: 'sceneName' }
|
||||
},
|
||||
{
|
||||
title: '通知状态',
|
||||
dataIndex: 'notifyStatus',
|
||||
width: '10%',
|
||||
scopedSlots: { customRender: 'notifyStatus' }
|
||||
},
|
||||
{
|
||||
title: '通知类型',
|
||||
dataIndex: 'notifyType',
|
||||
@ -103,13 +132,6 @@ export default {
|
||||
width: '10%',
|
||||
scopedSlots: { customRender: 'notifyThreshold' }
|
||||
},
|
||||
{
|
||||
title: '配置属性',
|
||||
dataIndex: 'notifyAttribute',
|
||||
key: 'notifyAttribute',
|
||||
width: '30%',
|
||||
scopedSlots: { customRender: 'notifyAttribute' }
|
||||
},
|
||||
{
|
||||
title: '描述',
|
||||
dataIndex: 'description',
|
||||
@ -154,18 +176,24 @@ export default {
|
||||
},
|
||||
optionAlertShow: false,
|
||||
memberLoading: false,
|
||||
notifyScene: enums.notifyScene,
|
||||
notifyType: enums.notifyType,
|
||||
notifyStatus: enums.notifyStatus,
|
||||
notifySceneList: enums.notifyScene,
|
||||
notifyTypeList: enums.notifyType,
|
||||
notifyStatusList: enums.notifyStatus,
|
||||
visible: false,
|
||||
key: '',
|
||||
notifyTypeValue: '1',
|
||||
groupNameList: []
|
||||
groupNameList: [],
|
||||
sceneList: []
|
||||
}
|
||||
},
|
||||
created () {
|
||||
getAllGroupNameList().then((res) => {
|
||||
this.groupNameList = res.data
|
||||
if (this.groupNameList !== null && this.groupNameList.length > 0) {
|
||||
this.queryParam['groupName'] = this.groupNameList[0]
|
||||
this.$refs.table.refresh(true)
|
||||
this.handleChange(this.groupNameList[0])
|
||||
}
|
||||
})
|
||||
|
||||
const groupName = this.$route.query.groupName
|
||||
@ -174,32 +202,20 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
resetFiled () {
|
||||
this.queryParam = {}
|
||||
this.sceneList = []
|
||||
},
|
||||
handleNew () {
|
||||
this.$router.push({ path: '/retry/notify/config' })
|
||||
},
|
||||
handleEdit (record) {
|
||||
this.$router.push({ path: '/retry/notify/config', query: { id: record.id } })
|
||||
},
|
||||
parseJson (text, record) {
|
||||
if (!text) {
|
||||
return null
|
||||
}
|
||||
|
||||
let s =
|
||||
'用户名:' + text['user'] + ';\r\n' +
|
||||
'密码:' + text['pass'] + ';\r\n' +
|
||||
'SMTP地址:' + text['host'] + ';\r\n' +
|
||||
'SMTP端口:' + text['port'] + ';\r\n' +
|
||||
'发件人:' + text['from'] + ';\r\n' +
|
||||
'收件人:' + text['tos'] + ';'
|
||||
|
||||
if (record.notifyType === 1) {
|
||||
s = text['dingDingUrl']
|
||||
} else if (record.notifyType === 4) {
|
||||
s = text['larkUrl']
|
||||
}
|
||||
|
||||
return s
|
||||
handleChange (value) {
|
||||
getSceneList({ groupName: value }).then((res) => {
|
||||
this.sceneList = res.data
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@
|
||||
<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="$refs.table.refresh(true)">查询</a-button>
|
||||
<a-button style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button>
|
||||
<a-button style="margin-left: 8px" @click="resetFiled">重置</a-button>
|
||||
<a @click="toggleAdvanced" style="margin-left: 8px">
|
||||
{{ advanced ? '收起' : '展开' }}
|
||||
<a-icon :type="advanced ? 'up' : 'down'"/>
|
||||
@ -167,7 +167,7 @@ export default {
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '场景id',
|
||||
title: '场景名称',
|
||||
dataIndex: 'sceneName',
|
||||
ellipsis: true
|
||||
},
|
||||
@ -241,6 +241,10 @@ export default {
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
resetFiled () {
|
||||
this.queryParam = {}
|
||||
this.sceneList = []
|
||||
},
|
||||
handleNew () {
|
||||
this.$router.push('/form/basic-config')
|
||||
},
|
||||
|
@ -37,7 +37,7 @@
|
||||
<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="$refs.table.refresh(true)">查询</a-button>
|
||||
<a-button style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button>
|
||||
<a-button style="margin-left: 8px" @click="resetFiled">重置</a-button>
|
||||
<a @click="toggleAdvanced" style="margin-left: 8px">
|
||||
{{ advanced ? '收起' : '展开' }}
|
||||
<a-icon :type="advanced ? 'up' : 'down'"/>
|
||||
@ -157,7 +157,7 @@ export default {
|
||||
width: '10%'
|
||||
},
|
||||
{
|
||||
title: '场景id',
|
||||
title: '场景名称',
|
||||
dataIndex: 'sceneName',
|
||||
ellipsis: true,
|
||||
width: '10%'
|
||||
@ -236,6 +236,10 @@ export default {
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
resetFiled () {
|
||||
this.queryParam = {}
|
||||
this.sceneList = []
|
||||
},
|
||||
handleNew () {
|
||||
this.$router.push('/form/basic-config')
|
||||
},
|
||||
|
@ -55,7 +55,7 @@
|
||||
:style="(advanced && { float: 'right', overflow: 'hidden' }) || {}"
|
||||
>
|
||||
<a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
|
||||
<a-button style="margin-left: 8px" @click="() => (queryParam = {})">重置</a-button>
|
||||
<a-button style="margin-left: 8px" @click="resetFiled">重置</a-button>
|
||||
<a @click="toggleAdvanced" style="margin-left: 8px">
|
||||
{{ advanced ? '收起' : '展开' }}
|
||||
<a-icon :type="advanced ? 'up' : 'down'" />
|
||||
@ -324,6 +324,10 @@ export default {
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
resetFiled () {
|
||||
this.queryParam = {}
|
||||
this.sceneList = []
|
||||
},
|
||||
handleNew () {
|
||||
this.$refs.saveRetryTask.isShow(true, null)
|
||||
},
|
||||
|
@ -7,24 +7,23 @@
|
||||
<template>
|
||||
<a-col :md="8" :sm="24">
|
||||
<a-form-item label="组名称">
|
||||
<a-select
|
||||
v-model="queryParam.groupName"
|
||||
placeholder="请输入组名称"
|
||||
>
|
||||
<a-select v-model="queryParam.groupName" placeholder="请输入组名称" @change="value => handleChange(value)" allowClear>
|
||||
<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 :md="8" :sm="24">
|
||||
<a-form-item label="场景名称">
|
||||
<a-input v-model="queryParam.sceneName" placeholder="请输入场景名称" allowClear/>
|
||||
<a-select v-model="queryParam.sceneName" placeholder="请选择场景名称" allowClear>
|
||||
<a-select-option v-for="item in sceneList" :value="item.sceneName" :key="item.sceneName"> {{ item.sceneName }}</a-select-option>
|
||||
</a-select>
|
||||
</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="$refs.table.refresh(true)">查询</a-button>
|
||||
<a-button style="margin-left: 8px" @click="() => (queryParam = {})">重置</a-button>
|
||||
<a-button style="margin-left: 8px" @click="resetFiled">重置</a-button>
|
||||
</span>
|
||||
</a-col>
|
||||
</a-row>
|
||||
@ -89,7 +88,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getAllGroupNameList, getScenePage } from '@/api/manage'
|
||||
import { getAllGroupNameList, getSceneList, getScenePage } from '@/api/manage'
|
||||
import { STable } from '@/components'
|
||||
const enums = require('@/utils/retryEnum')
|
||||
export default {
|
||||
@ -100,6 +99,13 @@ export default {
|
||||
data () {
|
||||
return {
|
||||
sceneColumns: [
|
||||
{
|
||||
title: '组名',
|
||||
dataIndex: 'groupName',
|
||||
key: 'groupName',
|
||||
width: '10%',
|
||||
scopedSlots: { customRender: 'groupName' }
|
||||
},
|
||||
{
|
||||
title: '场景名称',
|
||||
dataIndex: 'sceneName',
|
||||
@ -203,20 +209,35 @@ export default {
|
||||
}
|
||||
},
|
||||
optionAlertShow: false,
|
||||
groupNameList: []
|
||||
groupNameList: [],
|
||||
sceneList: []
|
||||
}
|
||||
},
|
||||
created () {
|
||||
getAllGroupNameList().then((res) => {
|
||||
this.groupNameList = res.data
|
||||
if (this.groupNameList !== null && this.groupNameList.length > 0) {
|
||||
this.queryParam['groupName'] = this.groupNameList[0]
|
||||
this.$refs.table.refresh(true)
|
||||
this.handleChange(this.groupNameList[0])
|
||||
}
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
resetFiled () {
|
||||
this.queryParam = {}
|
||||
this.sceneList = []
|
||||
},
|
||||
handleNew () {
|
||||
this.$router.push({ path: '/retry/scene/config' })
|
||||
},
|
||||
handleEdit (record) {
|
||||
this.$router.push({ path: '/retry/scene/config', query: { id: record.id } })
|
||||
},
|
||||
handleChange (value) {
|
||||
getSceneList({ groupName: value }).then((res) => {
|
||||
this.sceneList = res.data
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,11 +21,11 @@
|
||||
'notifyScene',
|
||||
{
|
||||
initialValue: '1',
|
||||
rules: [{ required: true, message: '请选择状态'}]
|
||||
rules: [{ required: true, message: '请选通知场景'}]
|
||||
}
|
||||
]"
|
||||
>
|
||||
<a-select-option :value="index" v-for="(item, index) in notifyScene" :key="index">{{ item.name }}</a-select-option>
|
||||
<a-select-option :value="index" v-for="(item, index) in notifySceneList" :key="index">{{ item.name }}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
@ -50,33 +50,21 @@
|
||||
rules: [{ required: !notifyThresholdDisabled.includes(this.notifySceneValue), message: '请输入通知阈值'}]
|
||||
}
|
||||
]" />
|
||||
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row class="form-row" :gutter="16">
|
||||
<a-col :lg="18" :md="18" :sm="24">
|
||||
<a-col :lg="18" :md="12" :sm="24">
|
||||
<a-form-item label="组">
|
||||
<a-select
|
||||
placeholder="请选择组"
|
||||
v-decorator="['groupName', { rules: [{ required: true, message: '请选择组' }] }]"
|
||||
>
|
||||
<a-select placeholder="请选择组" v-decorator="['groupName', { rules: [{ required: true, message: '请选择组' }] }]" @change="value => changeGroup(value)">
|
||||
<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="[
|
||||
'notifyStatus',
|
||||
{
|
||||
initialValue: '1',
|
||||
rules: [{ required: true, message: '请选择状态'}]
|
||||
}
|
||||
]" >
|
||||
<a-select-option :value="index" v-for="(item, index) in notifyStatus" :key="index">{{ item.name }}</a-select-option>
|
||||
<a-form-item label="场景">
|
||||
<a-select :disabled="sceneNameDisabled.includes(this.notifySceneValue)" placeholder="请选择场景" v-decorator="['sceneName', { rules: [{ required: !sceneNameDisabled.includes(this.notifySceneValue), message: '请选择场景' }] }]" >
|
||||
<a-select-option v-for="item in sceneList" :value="item.sceneName" :key="item.sceneName">{{ item.sceneName }}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
@ -92,11 +80,11 @@
|
||||
'notifyType',
|
||||
{
|
||||
initialValue: '1',
|
||||
rules: [{ required: true, message: '请选择状态'}]
|
||||
rules: [{ required: true, message: '请选择通知类型'}]
|
||||
}
|
||||
]"
|
||||
>
|
||||
<a-select-option :value="index" v-for="(item, index) in notifyType" :key="index">{{ item.name }}</a-select-option>
|
||||
<a-select-option :value="index" v-for="(item, index) in notifyTypeList" :key="index">{{ item.name }}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
@ -109,7 +97,35 @@
|
||||
'notifyAttribute',
|
||||
{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 :disabled="rateLimiterStatusDisabled.includes(this.notifySceneValue)" placeholder="请选择限流状态" @change="changeRateLimiterStatus" v-decorator="['rateLimiterStatus',{initialValue: '0', rules: [{ required: true, message: '请选择限流状态'}]}]" >
|
||||
<a-select-option :value="index" v-for="(item, index) in rateLimiterStatusList" :key="index">{{ item.name }}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :lg="8" :md="12" :sm="24">
|
||||
<a-form-item label="每秒限流阈值">
|
||||
<a-input-number :disabled="rateLimiterThresholdDisabled.includes(this.rateLimiterStatusValue)" id="inputNumber" :min="1" style="width: -webkit-fill-available" v-decorator= "['rateLimiterThreshold',{initialValue: '100',rules: [{ required: !rateLimiterThresholdDisabled.includes(this.rateLimiterStatusValue), message: '请输入通知阈值' }]}]" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :lg="8" :md="12" :sm="24">
|
||||
<a-form-item label="状态">
|
||||
<a-select
|
||||
placeholder="请选择状态"
|
||||
v-decorator="[
|
||||
'notifyStatus',
|
||||
{
|
||||
initialValue: '1',
|
||||
rules: [{ required: true, message: '请选择状态'}]
|
||||
}
|
||||
]" >
|
||||
<a-select-option :value="index" v-for="(item, index) in notifyStatusList" :key="index">{{ item.name }}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
@ -131,11 +147,9 @@
|
||||
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>
|
||||
|
||||
<a-modal :visible="visible" title="添加配置" @ok="handleOk" @cancel="handlerCancel" width="1000px">
|
||||
<a-form :form="notifyAttributeForm" @submit="handleSubmit" :body-style="{padding: '0px 0px'}" v-bind="formItemLayout" >
|
||||
<a-form-item
|
||||
@ -144,20 +158,43 @@
|
||||
<a-input
|
||||
placeholder="请输入钉钉URL"
|
||||
v-decorator="[
|
||||
'dingDingUrl',
|
||||
'webhookUrl',
|
||||
{rules: [{ required: true, message: '请输入钉钉URL', whitespace: true}]}
|
||||
]" />
|
||||
</a-form-item>
|
||||
<a-form-item v-if="this.notifyTypeValue === '1'">
|
||||
<span slot="label">被@负责人手机号 <a :href="officialWebsite + '/pages/32e4a0/#被@负责人手机号是何物' +''" target="_blank"> <a-icon type="question-circle-o" /></a></span>
|
||||
<a-input
|
||||
placeholder="请输入被@负责人手机号"
|
||||
type="textarea"
|
||||
v-if="this.notifyTypeValue === '1'"
|
||||
v-decorator="[
|
||||
'ats',
|
||||
{rules: [{ required: true, message: '请输入被@负责人手机号', whitespace: true}]}
|
||||
]" />
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
v-if="this.notifyTypeValue === '4'"
|
||||
label="飞书URL">
|
||||
<a-input
|
||||
placeholder="请输入飞书URL"
|
||||
v-decorator="[
|
||||
'larkUrl',
|
||||
'webhookUrl',
|
||||
{rules: [{ required: true, message: '请输入飞书URL', whitespace: true}]}
|
||||
]" />
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
v-if="this.notifyTypeValue === '4'">
|
||||
<span slot="label">被@负责人用户id <a :href="officialWebsite + '/pages/32e4a0/#被@负责人用户id是何物' +''" target="_blank"> <a-icon type="question-circle-o" /></a></span>
|
||||
<a-input
|
||||
placeholder="请输入被@负责人用户id"
|
||||
type="textarea"
|
||||
v-if="this.notifyTypeValue === '4'"
|
||||
v-decorator="[
|
||||
'ats',
|
||||
{rules: [{ required: true, message: '请输入被@负责人用户id', whitespace: true}]}
|
||||
]" />
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
v-if="this.notifyTypeValue === '2'"
|
||||
label="用户名">
|
||||
@ -237,15 +274,14 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getAllGroupNameList } from '@/api/manage'
|
||||
import { getAllGroupNameList, getSceneList } from '@/api/manage'
|
||||
import { getNotifyConfigDetail, saveNotify, updateNotify } from '@/api/retryApi'
|
||||
import pick from 'lodash.pick'
|
||||
import CronModal from '@/views/job/from/CronModal'
|
||||
|
||||
import { officialWebsite } from '@/utils/util'
|
||||
const enums = require('@/utils/retryEnum')
|
||||
export default {
|
||||
name: 'NotifyFrom',
|
||||
components: { CronModal },
|
||||
props: {},
|
||||
comments: {
|
||||
CronModal
|
||||
@ -257,6 +293,7 @@ export default {
|
||||
labelCol: { lg: { span: 7 }, sm: { span: 7 } },
|
||||
wrapperCol: { lg: { span: 10 }, sm: { span: 17 } }
|
||||
},
|
||||
officialWebsite: officialWebsite(),
|
||||
formItemLayoutWithOutLabel: {
|
||||
wrapperCol: {
|
||||
xs: { span: 24, offset: 0 },
|
||||
@ -265,17 +302,24 @@ export default {
|
||||
},
|
||||
formType: 'create',
|
||||
groupNameList: [],
|
||||
notifyScene: enums.notifyScene,
|
||||
notifyType: enums.notifyType,
|
||||
notifyStatus: enums.notifyStatus,
|
||||
sceneList: [],
|
||||
notifySceneList: enums.notifyScene,
|
||||
notifyTypeList: enums.notifyType,
|
||||
notifyStatusList: enums.notifyStatus,
|
||||
rateLimiterStatusList: enums.rateLimiterStatus,
|
||||
loading: false,
|
||||
visible: false,
|
||||
count: 0,
|
||||
notifyTypeValue: '1',
|
||||
notifyAttribute: '',
|
||||
notifyThresholdDisabled: ['3', '4'],
|
||||
notifySceneValue: '1'
|
||||
|
||||
notifyThresholdDisabled: ['3', '4', '6'],
|
||||
sceneNameDisabled: ['3', '4'],
|
||||
rateLimiterStatusDisabled: ['1', '2', '3', '4'],
|
||||
rateLimiterThresholdDisabled: ['0'],
|
||||
notifySceneValue: '1',
|
||||
rateLimiterStatusValue: '0',
|
||||
defaultRateLimiterStatusValue: '0',
|
||||
defaultRateLimiterThreshold: '100'
|
||||
}
|
||||
},
|
||||
beforeCreate () {
|
||||
@ -299,24 +343,55 @@ export default {
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
resetFiled () {
|
||||
this.form.resetFields()
|
||||
},
|
||||
buildNotifyAttribute (formData) {
|
||||
formData.ats = formData.ats && formData.ats.replace(/\s+/g, '').split(',')
|
||||
return JSON.stringify(formData)
|
||||
},
|
||||
handleChange (notifyType) {
|
||||
this.notifyTypeValue = notifyType
|
||||
},
|
||||
changeGroup (value) {
|
||||
getSceneList({ groupName: value }).then((res) => {
|
||||
this.sceneList = res.data
|
||||
})
|
||||
},
|
||||
changeRateLimiterStatus (rateLimiterStatus) {
|
||||
this.rateLimiterStatusValue = rateLimiterStatus
|
||||
},
|
||||
changeNotifyScene (notifyScene) {
|
||||
console.log(notifyScene)
|
||||
this.notifySceneValue = notifyScene
|
||||
const { form } = this
|
||||
if (this.sceneNameDisabled.includes(notifyScene)) {
|
||||
form.setFieldsValue({
|
||||
sceneName: ''
|
||||
})
|
||||
}
|
||||
if (this.rateLimiterStatusDisabled.includes(notifyScene)) {
|
||||
form.setFieldsValue({
|
||||
rateLimiterStatus: this.defaultRateLimiterStatusValue,
|
||||
rateLimiterThreshold: this.defaultRateLimiterThreshold
|
||||
})
|
||||
this.changeRateLimiterStatus(this.defaultRateLimiterStatusValue)
|
||||
}
|
||||
},
|
||||
handleBlur () {
|
||||
new Promise((resolve) => {
|
||||
setTimeout(resolve, 100)
|
||||
}).then(() => {
|
||||
if (this.formType === 'edit') {
|
||||
const formData = pick(JSON.parse(this.notifyAttribute), ['dingDingUrl', 'larkUrl', 'user', 'pass', 'host', 'port', 'from', 'tos'])
|
||||
console.log(formData)
|
||||
|
||||
this.notifyAttributeForm.getFieldDecorator(`dingDingUrl`, { initialValue: formData.dingDingUrl, preserve: true })
|
||||
const formData = pick(JSON.parse(this.notifyAttribute), ['webhookUrl', 'ats', 'user', 'pass', 'host', 'port', 'from', 'tos'])
|
||||
this.notifyAttributeForm.getFieldDecorator(`webhookUrl`, { initialValue: formData.webhookUrl, preserve: true })
|
||||
this.notifyAttributeForm.getFieldDecorator(`ats`, { initialValue: formData.ats.join(','), preserve: true })
|
||||
this.notifyAttributeForm.getFieldDecorator(`user`, { initialValue: formData.user, preserve: true })
|
||||
this.notifyAttributeForm.getFieldDecorator(`pass`, { initialValue: formData.pass, preserve: true })
|
||||
this.notifyAttributeForm.getFieldDecorator(`host`, { initialValue: formData.host, preserve: true })
|
||||
this.notifyAttributeForm.getFieldDecorator(`port`, { initialValue: formData.port, preserve: true })
|
||||
this.notifyAttributeForm.getFieldDecorator(`from`, { initialValue: formData.from, preserve: true })
|
||||
this.notifyAttributeForm.getFieldDecorator(`tos`, { initialValue: formData.tos, preserve: true })
|
||||
}
|
||||
|
||||
this.visible = !this.visible
|
||||
})
|
||||
},
|
||||
@ -326,11 +401,9 @@ export default {
|
||||
handleOk () {
|
||||
this.notifyAttributeForm.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
console.log(values)
|
||||
const { form } = this
|
||||
const formData = pick(values, ['dingDingUrl', 'larkUrl', 'user', 'pass', 'host', 'port', 'from', 'tos'])
|
||||
console.log(this.parseJson(formData))
|
||||
this.notifyAttribute = JSON.stringify(formData)
|
||||
const formData = pick(values, ['webhookUrl', 'ats', 'user', 'pass', 'host', 'port', 'from', 'tos'])
|
||||
this.notifyAttribute = this.buildNotifyAttribute(formData)
|
||||
form.setFieldsValue({
|
||||
notifyAttribute: this.parseJson(formData)
|
||||
})
|
||||
@ -364,19 +437,24 @@ export default {
|
||||
const { form } = this
|
||||
// ajax
|
||||
new Promise((resolve) => {
|
||||
setTimeout(resolve, 100)
|
||||
setTimeout(async () => {
|
||||
await this.changeGroup(data.groupName)
|
||||
resolve()
|
||||
}, 100)
|
||||
}).then(() => {
|
||||
const formData = pick(data, [
|
||||
'id', 'notifyAttribute', 'groupName', 'notifyStatus', 'notifyScene', 'notifyThreshold', 'notifyType', 'notifyThreshold', 'description'])
|
||||
'id', 'notifyAttribute', 'groupName', 'sceneName', 'notifyStatus', 'notifyScene', 'notifyThreshold', 'notifyType', 'description', 'rateLimiterStatus', 'rateLimiterThreshold'])
|
||||
formData.notifyStatus = formData.notifyStatus.toString()
|
||||
formData.notifyScene = formData.notifyScene.toString()
|
||||
formData.notifyType = formData.notifyType.toString()
|
||||
formData.notifyThreshold = formData.notifyThreshold.toString()
|
||||
formData.rateLimiterStatus = formData.rateLimiterStatus.toString()
|
||||
formData.rateLimiterThreshold = formData.rateLimiterThreshold.toString()
|
||||
this.notifyTypeValue = formData.notifyType
|
||||
this.notifyAttribute = formData.notifyAttribute
|
||||
this.notifySceneValue = formData.notifyScene
|
||||
this.rateLimiterStatusValue = formData.rateLimiterStatus
|
||||
formData.notifyAttribute = this.parseJson(JSON.parse(formData.notifyAttribute))
|
||||
console.log(formData)
|
||||
form.setFieldsValue(formData)
|
||||
})
|
||||
},
|
||||
@ -394,11 +472,14 @@ export default {
|
||||
'收件人:' + json['tos'] + ';'
|
||||
|
||||
if (this.notifyTypeValue === '1') {
|
||||
s = json['dingDingUrl']
|
||||
s =
|
||||
'钉钉Url:' + json['webhookUrl'] + ';' +
|
||||
'被@负责人手机号:' + json['ats'] + ';'
|
||||
} else if (this.notifyTypeValue === '4') {
|
||||
s = json['larkUrl']
|
||||
s =
|
||||
'飞书Url:' + json['webhookUrl'] + ';' +
|
||||
'被@负责人用户id:' + json['ats'] + ';'
|
||||
}
|
||||
|
||||
return s
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +187,7 @@
|
||||
style="text-align: center"
|
||||
>
|
||||
<a-button htmlType="submit" type="primary">提交</a-button>
|
||||
<a-button style="margin-left: 8px">重置</a-button>
|
||||
<a-button style="margin-left: 8px" @click="resetFiled">重置</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-card>
|
||||
@ -245,6 +245,9 @@ export default {
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
resetFiled () {
|
||||
this.form.resetFields()
|
||||
},
|
||||
handleChange (value) {
|
||||
console.log(value)
|
||||
this.backOff = value
|
||||
|
Loading…
Reference in New Issue
Block a user