| | |
| | | <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 style="width: 100%" v-model="sendForm.provider" @change="changeProvider"> |
| | | <el-option v-for="item in providerList" :key="item.configEntity.provider" :label="item.name" :value="item.configEntity.provider"/> |
| | | </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 style="width: 100%" v-model="sendForm.type" disabled> |
| | | <el-option v-for="item in providerInfos" :key="item.type" :label="item.name" :value="item.type"/> |
| | | </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 label="接收人" prop="notifiedParty"> |
| | | <el-input v-model="sendForm.notifiedParty" 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-col :span="24" v-for="(item,index) in sendContentForm.properties"> |
| | | <el-form-item :label="item.name" v-if="item.property != 'content' && item.property != 'attachments'"> |
| | | <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'"> |
| | | <!-- 内容-富文本 --> |
| | | <el-form-item :label="item.name" v-if="item.property == 'content'"> |
| | | <avue-ueditor v-model="item.value" v-bind="options"></avue-ueditor> |
| | | </el-form-item> |
| | | <!-- <el-form-item :label="item.name" v-if="item.property == 'content'"> |
| | | <div class="array-content"> |
| | | <el-row v-for="(item1,index1) in item.value"> |
| | | <el-col v-for="(item2,index2) in item1" :span="7"> |
| | |
| | | </el-col> |
| | | </el-row> |
| | | </div> |
| | | </el-form-item> |
| | | </el-col> --> |
| | | </el-form-item> --> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | |
| | | emits: ['success', 'closed'], |
| | | data() { |
| | | return { |
| | | options: { |
| | | //普通上传地址 |
| | | action: "/api/blade-resource/oss/endpoint/put-file", |
| | | customConfig: {},//wangEditor编辑的配置 |
| | | headers:{Authorization: "Basic c2FiZXI6c2FiZXJfc2VjcmV0"}, |
| | | data:{}, |
| | | propsHttp: { |
| | | home:'', |
| | | url:'url', |
| | | res: 'data' |
| | | }, |
| | | }, |
| | | tableData: {}, |
| | | sendContentForm: {}, |
| | | providerInfos: [], |
| | | providerList: [], |
| | | serviceproviders: "", |
| | |
| | | isSaveing: false, |
| | | //表单数据 |
| | | sendForm: { |
| | | provider: "" |
| | | provider: "", |
| | | notifiedParty: "", |
| | | template: "", |
| | | type: "" |
| | | }, |
| | | //验证规则 |
| | | sendRules: { |
| | | pname:[{required: true, message: '请输入接收人'}] |
| | | notifiedParty:[{required: true, message: '请输入接收人'}] |
| | | }, |
| | | } |
| | | }, |
| | | mounted() { |
| | | }, |
| | | methods: { |
| | | changeProvider(val) { |
| | | var id = ""; |
| | | this.providerList.forEach(item=> { |
| | | if(item.configEntity.provider == val) { |
| | | id = item.id; |
| | | } |
| | | }) |
| | | this.getServiceProviders(id); |
| | | }, |
| | | addpro(index,index1) { |
| | | this.sendForm.configuration[index].value.push([ |
| | | {name: 'name', value: ''}, |
| | |
| | | }, |
| | | //显示 |
| | | open(tableData,mode='add'){ |
| | | this.providerInfos = tableData[0].providerInfos; //服务商 |
| | | this.getMetadata(); //内容 |
| | | this.tableData = tableData; |
| | | 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.providerList = providerList; //通知方式list |
| | | this.getServiceProviders(this.providerList[0].id); //获取供应商 |
| | | this.mode = mode; |
| | | this.visible = true; |
| | | return this |
| | | }, |
| | | getMetadata() { |
| | | this.$HTTP.get(`/api/blade-notify/notifier/template/dingTalk/dingTalkMessage/config/metadata`).then(res=> { |
| | | getServiceProviders(id) { |
| | | console.log(id,this.tableData) |
| | | this.tableData.forEach(item=> { |
| | | if(item.id == id) { |
| | | this.providerInfos = item.providerInfos; //服务商 |
| | | this.sendForm.provider = item.configEntity.provider; |
| | | this.sendForm.type = item.id; |
| | | } |
| | | }) |
| | | this.$nextTick(()=> { |
| | | this.getMetadata(this.sendForm.provider); //内容 |
| | | }) |
| | | }, |
| | | getMetadata(val) { |
| | | var url = ""; |
| | | if(val == "dingTalkMessage") { |
| | | url = `/api/blade-notify/notifier/template/dingTalk/dingTalkMessage/config/metadata`; |
| | | }else if(val == "qyTextMessage") { |
| | | url = `/api/blade-notify/notifier/template/weiXinQY/qyTextMessage/config/metadata`; |
| | | }else if(val == "systemDefault") { |
| | | url = `/api/blade-notify/notifier/template/internalMessage/systemDefault/config/metadata`; |
| | | }else if(val == "embedded") { |
| | | url = `/api/blade-notify/notifier/template/email/embedded/config/metadata`; |
| | | } |
| | | this.$HTTP.get(url).then(res=> { |
| | | if(res.code == 200) { |
| | | |
| | | this.sendContentForm = res.data; |
| | | console.log(this.sendContentForm,8) |
| | | }else { |
| | | this.$message.error(res.msg); |
| | | } |
| | |
| | | }, |
| | | //表单提交方法 |
| | | sendSubmit(){ |
| | | var configuration = {}; |
| | | this.sendForm.configuration.forEach(item=> { |
| | | configuration[item.name] = item.value; |
| | | var template = {}; |
| | | this.sendContentForm.properties.forEach(item=> { |
| | | template[item['property']] = item.value; |
| | | }) |
| | | var obj = { |
| | | configuration: configuration, |
| | | notifiedParty: this.sendForm.notifiedParty, |
| | | provider: this.sendForm.provider, |
| | | template: JSON.stringify(template), |
| | | type: this.sendForm.type |
| | | } |
| | | 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; |
| | | var id = ""; |
| | | this.providerList.forEach(item=> { |
| | | if(item.id == this.sendForm.type){ |
| | | id = item.configEntity.id; |
| | | } |
| | | } |
| | | 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.$HTTP.post(`/api/blade-notify/notifier/${id}/send`,obj).then(res=> { |
| | | this.isSaveing = false; |
| | | if(res.code == 200) { |
| | | this.$emit('success', this.sendForm, this.mode); |
| | | this.visible = false; |
| | | this.$message.success("编辑成功"); |
| | | this.$message.success("发送成功"); |
| | | }else { |
| | | this.$alert(res.message, "提示", {type: 'error'}); |
| | | } |