92 lines
3.5 KiB
Vue
92 lines
3.5 KiB
Vue
<template>
|
|
<div class="app-container">
|
|
<Form :formList="formList" :ruleFormData="ruleForm" :config="paramsData && paramsData.readonly ? config : {}" @fnClick="callback"></Form>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup name="Handle">
|
|
import Form from '@/components/form/index.vue';
|
|
import {addAlarmPush, getAlarmPush, updateAlarmPush} from "@/api/disRevenue/resource"
|
|
export default {
|
|
name: 'messagePushDetails',
|
|
components: {Form},
|
|
dicts: ['alarm_type', 'push_method'],
|
|
data() {
|
|
return {
|
|
ruleForm: {},
|
|
formList: [],
|
|
config: {
|
|
buttonGroup: [{title: '返回', fnCode: 'goBack'}]
|
|
},
|
|
paramsData: {}
|
|
}
|
|
},
|
|
created() {
|
|
this.paramsData = this.$route && this.$route.query;
|
|
if (this.paramsData && this.paramsData.id) {
|
|
this.getFormDataList(this.paramsData.id);
|
|
}
|
|
this.fnFormList();
|
|
},
|
|
methods: {
|
|
// formList集合
|
|
fnFormList(objVal) {
|
|
let spanNum = this.paramsData && this.paramsData.readonly ? 12 : 16;
|
|
this.formList = [{
|
|
config: {title: '基本信息', readonly: this.paramsData && this.paramsData.readonly},
|
|
controls: {
|
|
id: {label: 'ID',hidden: true},
|
|
configName: {label: '配置名称', span: spanNum, type: 'input', required: true},
|
|
pushMethod: {label: '推送方式', span: spanNum, type: 'select', options: this.dict.type.push_method, required: true},
|
|
pushAddress: {label: '推送地址', span: spanNum, type: 'input', required: true},
|
|
pushAlarmTypes: {label: '推送告警类型', span: spanNum, type: 'select', options: this.dict.type.alarm_type, required: true},
|
|
contactPhones: {label: '提示人手机号', span: spanNum, type: 'input'},
|
|
createBy: {label: '创建人', span: spanNum, type: 'input', hidden: !(this.paramsData && this.paramsData.readonly)},
|
|
createTime: {label: '创建时间', span: spanNum, type: 'datetime', hidden: !(this.paramsData && this.paramsData.readonly)},
|
|
updateTime: {label: '修改时间', span: spanNum, type: 'datetime', hidden: !(this.paramsData && this.paramsData.readonly)},
|
|
messageContent: {label: '消息内容', span: spanNum, type: 'textarea', required: true, warningTitle: '可引用的告警字段包括[告警时间]、[管理网-公网IP]、[告警类型]、[告警设备]、[告警内容]'}
|
|
}
|
|
}];
|
|
},
|
|
// 获取详情
|
|
getFormDataList(id) {
|
|
getAlarmPush(id).then(val => {
|
|
if (val && val.data) {
|
|
this.ruleForm = val.data;
|
|
}
|
|
}).catch(() => {
|
|
this.$modal.msgError("操作失败")
|
|
});
|
|
},
|
|
// 监听事件
|
|
callback(result, dataVal, formVal) {
|
|
if (result && result.fnCode) {
|
|
switch (result.fnCode) {
|
|
case 'submit':
|
|
let fnType = addAlarmPush;
|
|
if (dataVal && dataVal.id) {
|
|
fnType = updateAlarmPush;
|
|
}
|
|
if(this.loading) return;
|
|
this.loading = true;
|
|
fnType(dataVal).then(response => {
|
|
this.$modal.msgSuccess(response.msg);
|
|
this.$router.push("/resource/messagePush");
|
|
this.loading = false;
|
|
}).catch(() => {
|
|
this.$modal.msgError("操作失败")
|
|
});
|
|
break;
|
|
case 'cancel':
|
|
this.$router.push("/resource/messagePush");
|
|
break;
|
|
default:
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
<style>
|
|
</style>
|