From d58f901f9614d6fd3ad2334a2e4592addb77d8fa Mon Sep 17 00:00:00 2001
From: lzhe <181968431@qq.com>
Date: 星期日, 12 五月 2024 00:34:13 +0800
Subject: [PATCH] 1
---
src/views/notification/sendDebug.vue | 198 +++++++++++++++++++++++++++++++++
src/views/notification/configuration.vue | 58 +++++++--
src/views/notification/editconfiguration.vue | 57 +++++++--
3 files changed, 284 insertions(+), 29 deletions(-)
diff --git a/src/views/notification/configuration.vue b/src/views/notification/configuration.vue
index a88e523..c2b5b45 100644
--- a/src/views/notification/configuration.vue
+++ b/src/views/notification/configuration.vue
@@ -9,13 +9,13 @@
<template>
<div class="aposcope-main">
<div class="debugging">
- <el-button type="primary" plain style="width: 80px;">璋冭瘯</el-button>
+ <el-button type="primary" plain style="width: 80px;" @click="debugerBtn">璋冭瘯</el-button>
</div>
<div class="conList" v-for="item in tableData">
<div class="conTop">
<span class="titile">{{item.name}}</span>
</div>
- <div class="conBottom" v-if="item.isBindBusiness">
+ <div class="conBottom" v-if="item.configEntity != null">
<div class="first">
<div>{{item.id == "internalMessage"?"绔欏唴淇¢厤缃�":"閰嶇疆鍚嶇О"}}</div>
</div>
@@ -23,16 +23,17 @@
<div>{{item.pname}}</div>
</div>
<div class="thrid" v-if="item.id != 'internalMessage'">
- <span @click="table_edit(item, index)"><el-icon><EditPen /></el-icon>缂栬緫</span>
- <span><el-icon><Delete /></el-icon>鍒犻櫎</span>
+ <span @click="table_edit(item, index ,2)"><el-icon><EditPen /></el-icon>缂栬緫</span>
+ <span @click="table_del(item,index)"><el-icon><Delete /></el-icon>鍒犻櫎</span>
</div>
</div>
- <div class="conBottom" v-if="!item.isBindBusiness">
- <el-button type="primary" plain style="margin-left: 20px;" @click="addallocation">鏂板閰嶇疆</el-button>
+ <div class="conBottom" v-if="item.configEntity == null">
+ <el-button type="primary" plain style="margin-left: 20px;" @click="table_edit(item, index ,1)">鏂板閰嶇疆</el-button>
</div>
</div>
</div>
<save-dialog v-if="dialog.save" ref="saveDialog" @success="addconfigSuccess" @closed="dialog.save=false"></save-dialog>
+ <save-debug v-if="dialog.debugging" ref="saveDebugging" @success="adddebugSuccess" @closed="dialog.debugging=false"></save-debug>
</template>
<script>
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
@@ -41,12 +42,14 @@
icons.push(key)
}
import saveDialog from './editconfiguration'
+ import saveDebug from './sendDebug'
export default {
name: "configuration",
data(){
return {
dialog: {
- save: false
+ save: false,
+ debugging: false
},
tableData: []
}
@@ -58,19 +61,31 @@
this.getConfiguration();
},
components: {
- ...ElementPlusIconsVue,saveDialog
+ ...ElementPlusIconsVue,saveDialog,saveDebug
},
methods: {
- addallocation() {
- ///api/blade-notify/notifier/config/sms/aliyunSms/metadata
+ table_del(item,index) {
+ this.$confirm(`纭畾灏嗛�夋嫨鏁版嵁鍒犻櫎?`, '', {
+ type: 'warning'
+ }).then(() => {
+ this.$HTTP.delete(`/api/blade-notify/notifier/config/${item.configEntity.id}`).then(res=> {
+ if(res.code == 200) {
+ this.getConfiguration();
+ }else {
+ this.$message.error(res.msg);
+ }
+ })
+ }).catch(() => {
+
+ })
},
- table_edit(row){
+ table_edit(row,index,type){
if(row.name == "閽夐拤") {
var url = `/api/blade-notify/notifier/config/dingTalk/dingTalkMessage/metadata`;
}else if(row.name == "浼佷笟寰俊") {
var url = `/api/blade-notify/notifier/config/weiXinQY/qyTextMessage/metadata`;
- }else if(row.name == "绔欏唴淇�") {
- //var url = `/api/blade-notify/notifier/template/internalMessage/systemDefault/config/metadata`;
+ }else if(row.name == "鐭俊") {
+ var url = `/api/blade-notify/notifier/config/sms/aliyunSms/metadata`;
}else if(row.name == "閭欢") {
var url = `/api/blade-notify/notifier/config/email/embedded/metadata`;
}
@@ -80,9 +95,19 @@
this.dialog.save = true;
this.$nextTick(() => {
var obj = Object.assign(res.data,row);
- this.$refs.saveDialog.open('edit').setData(obj);
+ if(type == 1) {
+ this.$refs.saveDialog.open('add',obj);
+ }else if(type == 2) { //缂栬緫
+ this.$refs.saveDialog.open('edit',{}).setData(obj);
+ }
})
}
+ })
+ },
+ debugerBtn() {
+ this.dialog.debugging = true;
+ this.$nextTick(() => {
+ this.$refs.saveDebugging.open(this.tableData);
})
},
getConfiguration() {
@@ -100,7 +125,10 @@
})
},
addconfigSuccess() {
- this.getbusiness();
+ this.getConfiguration();
+ },
+ adddebugSuccess() {
+
}
}
}
diff --git a/src/views/notification/editconfiguration.vue b/src/views/notification/editconfiguration.vue
index 6adc22e..cb6daff 100644
--- a/src/views/notification/editconfiguration.vue
+++ b/src/views/notification/editconfiguration.vue
@@ -4,7 +4,7 @@
<span>閫氱煡绫诲瀷 {{addBusinessForm.name}}</span>
<span>
鏈嶅姟鍟�
- <el-select style="width: 80%" v-model="serviceproviders" disabled>
+ <el-select style="width: 80%" v-model="serviceproviders" :disabled="mode != 'add'">
<el-option v-for="item in addBusinessForm.providerInfos" :key="item.id" :label="item.name" :value="item.id"/>
</el-select>
</span>
@@ -12,7 +12,7 @@
<el-form :model="addBusinessForm" :rules="addBusinessRules" :disabled="mode=='show'" ref="dialogForm" label-width="140px" label-position="center">
<el-row>
<el-col :span="24">
- <el-form-item label="璇疯緭鍏ラ厤缃悕绉�" prop="notifyTemplateName">
+ <el-form-item label="璇疯緭鍏ラ厤缃悕绉�" prop="pname">
<el-input v-model="addBusinessForm.pname" placeholder="妯$増鍚嶇О" clearable></el-input>
</el-form-item>
</el-col>
@@ -57,7 +57,7 @@
serviceproviders: "",
mode: "add",
titleMap: {
- add: '鏂板',
+ add: '鏂板閰嶇疆',
edit: '缂栬緫閰嶇疆',
show: '鏌ョ湅'
},
@@ -73,7 +73,7 @@
},
//楠岃瘉瑙勫垯
addBusinessRules: {
- notifyTemplateName:[{required: true, message: '璇疯緭鍏ユā鐗堝悕绉�'}]
+ pname:[{required: true, message: '璇疯緭鍏ユā鐗堝悕绉�'}]
},
}
},
@@ -91,23 +91,53 @@
this.addBusinessForm.configuration[index].value.splice(index1,1);
},
//鏄剧ず
- open(mode='add'){
+ open(mode='add',obj){
+ if(mode == 'add') {
+ this.addBusinessForm = obj;
+ this.$nextTick(()=> {
+ this.serviceproviders = this.addBusinessForm.providerInfos[0].id;
+ })
+ var setArr = [];
+ obj.properties.forEach(item=> {
+ setArr.push({pname:item.name,value: "",name: item.name})
+ })
+ this.addBusinessForm.configuration = setArr;
+ }
this.mode = mode;
this.visible = true;
return this
},
//琛ㄥ崟鎻愪氦鏂规硶
businessSubmit(){
- var obj = Object.assign({},this.addBusinessForm);
- console.log(this.addBusinessForm);
+ var configuration = {};
+ this.addBusinessForm.configuration.forEach(item=> {
+ configuration[item.name] = item.value;
+ })
var obj = {
- configuration: {appKey: "3aa", appSecret: "4a"},
- id: "1001",
- name: "榛樿",
- provider: "dingTalkMessage",
- type: "dingTalk"
+ configuration: configuration,
}
- return;
+ if(this.mode == 'edit') {
+ obj.id = this.addBusinessForm.configEntity.id;
+ obj.name = this.addBusinessForm.configEntity.name;
+ obj.provider = this.addBusinessForm.configEntity.provider;
+ obj.type = this.addBusinessForm.configEntity.type;
+ if(this.addBusinessForm.configEntity.type == "email") { //閭欢
+ var newArr = [];
+ configuration.properties.forEach(item=> {
+ var formattedObject = {};
+ item.forEach(item => {
+ formattedObject[item.name] = item.value;
+ });
+ newArr.push(formattedObject);
+ })
+ configuration.properties = newArr;
+ }
+ }
+ if(this.mode == 'add') { //鏂板
+ obj.name = this.addBusinessForm.pname;
+ obj.provider = this.serviceproviders;
+ obj.type = this.addBusinessForm.id;
+ }
this.$refs.dialogForm.validate(async (valid) => {
if (valid) {
this.isSaveing = true;
@@ -163,7 +193,6 @@
}
})
})
- console.log(data.configuration,data)
//鍙互鍜屼笂闈竴鏍峰崟涓敞鍏ワ紝涔熷彲浠ュ儚涓嬮潰涓�鏍风洿鎺ュ悎骞惰繘鍘�
Object.assign(this.addBusinessForm,data);
this.$nextTick(()=> {
diff --git a/src/views/notification/sendDebug.vue b/src/views/notification/sendDebug.vue
new file mode 100644
index 0000000..d325e8d
--- /dev/null
+++ b/src/views/notification/sendDebug.vue
@@ -0,0 +1,198 @@
+<template>
+ <el-dialog :title="titleMap[mode]" v-model="visible" :width="800" destroy-on-close @closed="$emit('closed')">
+ <el-form :model="sendForm" :rules="sendRules" :disabled="mode=='show'" ref="dialogForm" label-width="140px" label-position="center">
+ <el-row>
+ <el-col :span="24">
+ <el-form-item label="閫氱煡鏂瑰紡">
+ <el-select style="width: 100%" v-model="sendForm.provider">
+ <el-option v-for="item in providerList" :key="item.id" :label="item.name" :value="item.id"/>
+ </el-select>
+ </el-form-item>
+ </el-col>
+ <el-col :span="24">
+ <el-form-item label="鏈嶅姟鍟�">
+ <el-select style="width: 100%" v-model="sendForm.type">
+ <el-option v-for="item in providerInfos" :key="item.id" :label="item.name" :value="item.id"/>
+ </el-select>
+ </el-form-item>
+ </el-col>
+ <el-col :span="24">
+ <el-form-item label="鎺ユ敹浜�">
+ <el-input v-model="sendForm.pname" placeholder="鎺ユ敹浜�" clearable></el-input>
+ </el-form-item>
+ </el-col>
+ <!-- <el-col :span="24" v-for="(item,index) in sendForm.configuration">
+ <el-form-item :label="item.pname" v-if="item.name != 'properties'">
+ <el-input v-model="item.value" :placeholder="item.name" clearable></el-input>
+ </el-form-item>
+ <el-form-item :label="item.pname" v-if="item.name == 'properties'">
+ <div class="array-content">
+ <el-row v-for="(item1,index1) in item.value">
+ <el-col v-for="(item2,index2) in item1" :span="7">
+ <el-input v-model="item2.value" placeholder ="璇疯緭鍏�" style="width: 76%;margin-right: 10px;"></el-input>
+ <el-icon style="vertical-align: -3px;"><ArrowRightBold /></el-icon>
+ </el-col>
+ <el-col :span="3" class="otherBtn">
+ <el-button type="primary" size="small" plain @click="addpro(index,index1)" v-show="index1 == (item.value.length-1)">娣诲姞</el-button>
+ <el-button type="danger" size="small" style="margin-left:0;" plain @click="delData(index,index1)" v-show="index1 != (item.value.length-1)">鍒犻櫎</el-button>
+ </el-col>
+ </el-row>
+ </div>
+ </el-form-item>
+ </el-col> -->
+ </el-row>
+ </el-form>
+ <template #footer>
+ <el-button @click="visible=false" >鍙栨秷</el-button>
+ <el-button v-if="mode!='show'" type="primary" :loading="isSaveing" @click="sendSubmit">纭畾</el-button>
+ </template>
+ </el-dialog>
+</template>
+
+<script>
+ export default {
+ emits: ['success', 'closed'],
+ data() {
+ return {
+ providerInfos: [],
+ providerList: [],
+ serviceproviders: "",
+ mode: "add",
+ titleMap: {
+ add: '閰嶇疆璋冭瘯',
+ edit: '缂栬緫閰嶇疆',
+ show: '鏌ョ湅'
+ },
+ visible: false,
+ isSaveing: false,
+ //琛ㄥ崟鏁版嵁
+ sendForm: {
+ provider: ""
+ },
+ //楠岃瘉瑙勫垯
+ sendRules: {
+ pname:[{required: true, message: '璇疯緭鍏ユ帴鏀朵汉'}]
+ },
+ }
+ },
+ mounted() {
+ },
+ methods: {
+ addpro(index,index1) {
+ this.sendForm.configuration[index].value.push([
+ {name: 'name', value: ''},
+ {name: 'value', value: ''},
+ {name: 'description', value: ''},
+ ])
+ },
+ delData(index,index1) {
+ this.sendForm.configuration[index].value.splice(index1,1);
+ },
+ //鏄剧ず
+ open(tableData,mode='add'){
+ this.providerInfos = tableData[0].providerInfos; //鏈嶅姟鍟�
+ this.getMetadata(); //鍐呭
+ var providerList = [];
+ tableData.forEach(item=> {
+ if(item.isBindBusiness) {
+ providerList.push(item);
+ }
+ })
+ this.providerList = providerList;
+ this.$nextTick(()=> {
+ this.sendForm.provider = this.providerList[0].id;
+ this.sendForm.type = this.providerInfos[0].id;
+
+ console.log(this.providerList,this.sendForm.provider)
+ })
+ this.mode = mode;
+ this.visible = true;
+ return this
+ },
+ getMetadata() {
+ this.$HTTP.get(`/api/blade-notify/notifier/template/dingTalk/dingTalkMessage/config/metadata`).then(res=> {
+ if(res.code == 200) {
+
+ }else {
+ this.$message.error(res.msg);
+ }
+ })
+ },
+ //琛ㄥ崟鎻愪氦鏂规硶
+ sendSubmit(){
+ var configuration = {};
+ this.sendForm.configuration.forEach(item=> {
+ configuration[item.name] = item.value;
+ })
+ var obj = {
+ configuration: configuration,
+ }
+ if(this.mode == 'edit') {
+ obj.id = this.sendForm.configEntity.id;
+ obj.name = this.sendForm.configEntity.name;
+ obj.provider = this.sendForm.configEntity.provider;
+ obj.type = this.sendForm.configEntity.type;
+ if(this.sendForm.configEntity.type == "email") { //閭欢
+ var newArr = [];
+ configuration.properties.forEach(item=> {
+ var formattedObject = {};
+ item.forEach(item => {
+ formattedObject[item.name] = item.value;
+ });
+ newArr.push(formattedObject);
+ })
+ configuration.properties = newArr;
+ }
+ }
+ if(this.mode == 'add') { //鏂板
+ obj.name = this.sendForm.pname;
+ obj.provider = this.serviceproviders;
+ obj.type = this.sendForm.id;
+ }
+ this.$refs.dialogForm.validate(async (valid) => {
+ if (valid) {
+ this.isSaveing = true;
+ this.$HTTP.put("/api/blade-notify/notifier/config",obj).then(res=> {
+ this.isSaveing = false;
+ if(res.code == 200) {
+ this.$emit('success', this.sendForm, this.mode);
+ this.visible = false;
+ this.$message.success("缂栬緫鎴愬姛");
+ }else {
+ this.$alert(res.message, "鎻愮ず", {type: 'error'});
+ }
+ })
+ }else{
+ return false;
+ }
+ })
+ },
+ //琛ㄥ崟娉ㄥ叆鏁版嵁
+ setData(data){
+
+ }
+ },
+ components: {},
+ }
+</script>
+
+<style scoped>
+.modelTitle {
+ padding-left: 45px;
+ padding-bottom: 20px;
+}
+.modelTitle span {
+ display: inline-block;
+ width:50%;
+}
+.array-content {
+ border: 1px solid #d8d8d8;
+ border-radius: 2px;
+ min-height: 200px;
+ width: 100%;
+ padding: 12px;
+}
+.otherBtn {
+ margin-bottom: 12px;
+}
+</style>
--
Gitblit v1.9.3