From 2ab23b07784e960efce40fc5629a57e92afb481a Mon Sep 17 00:00:00 2001
From: lzhe <181968431@qq.com>
Date: 星期四, 09 五月 2024 23:53:45 +0800
Subject: [PATCH] 1

---
 src/views/notification/editbusiness.vue |  148 ++++++++++++++---------------
 src/views/notification/business.vue     |  112 +++++++++++++++++++++-
 2 files changed, 178 insertions(+), 82 deletions(-)

diff --git a/src/views/notification/business.vue b/src/views/notification/business.vue
index 773e449..179b73e 100644
--- a/src/views/notification/business.vue
+++ b/src/views/notification/business.vue
@@ -42,12 +42,26 @@
 					<span class="ct-span">榛樿瀵硅薄</span>
 				</div>
 				<div class="template-content-box">
-				    <el-radio-group v-model="radio1">
+				    <el-radio-group v-model="radio1" @change="radio1Change">
 					    <el-radio :label="1">閮ㄩ棬</el-radio>
 					    <el-radio :label="2">鍛樺伐</el-radio>
 					</el-radio-group>
 					<div class="content">
-						<el-button type="primary" plain>鐐瑰嚮娣诲姞+</el-button>
+						<el-button type="primary" plain @click="addOrganization" v-show="isaddOrganization">鐐瑰嚮娣诲姞+</el-button>
+						<!-- 閮ㄩ棬閫夋嫨 -->
+						<span v-if="radio1 == 1" v-for="(item,index) in organizationLi" class="tagItem">{{item.name}}<el-icon @click="delOrganizationLi(index)" style="cursor: pointer;"><Close /></el-icon></span>
+						<el-select v-if="radio1 == 1" v-show="!isaddOrganization" v-model="organization" style="width: 20%" @change="organizationChange">
+							<el-option v-for="item in organizationList" :key="item.parentId" :label="item.name" :value="item.parentId"/>
+						</el-select>
+						<!-- 鍛樺伐閫夋嫨 -->
+						<span v-if="radio1 == 2" v-for="(item,index) in employeeLi" class="tagItem">{{item.name}}<el-icon @click="delEmployeeLi(index)" style="cursor: pointer;"><Close /></el-icon></span>
+						<el-select v-if="radio1 == 2" v-show="!isaddOrganization" v-model="employee" style="width: 20%" @change="employeeChange">
+							<el-option v-for="item in employeeList" :key="item.id" :label="item.organizationName + '-' + item.name" :value="item.id"/>
+						</el-select>
+					</div>
+					<div class="bottom-btn">
+						<el-button @click="resetData">閲嶇疆</el-button>
+						<el-button type="primary" :loading="isSaveing" @click="saveSubmit">淇濆瓨</el-button>
 					</div>
 				 </div>
 			</div>
@@ -66,6 +80,14 @@
 		name: "business",
 		data(){
 			return {
+				isSaveing: false,
+				employeeLi: [],
+				organizationLi: [],
+				isaddOrganization: true,
+				organizationList: [],
+				employeeList: [],
+				organization: "",
+				employee: "",
 				radio1: 1,
 				checked1: true,
 				tableData: [],
@@ -90,18 +112,83 @@
 		mounted(){
 			this.getTreeList();
 			this.getbusiness();
+			this.getgroupType();
+			this.getEmployeeList();
 		},
 		components: {
 			...ElementPlusIconsVue,saveDialog
 	    },
 		methods: {
+			saveSubmit() {
+				
+			},
+			resetData() {
+				this.employeeLi = [];
+				this.organizationLi = [];
+			},
+			radio1Change(val) {
+				this.getgroupType(val);
+			},
+			addOrganization() {
+				this.isaddOrganization = false;
+			},
+			organizationChange(val) {
+				var flag = this.organizationLi.some(function(item) {
+				    return item.parentId === val;
+				});
+				this.organizationList.forEach(item=> {
+					if(item.parentId == val && !flag) {
+						this.organizationLi.push(item);
+					}
+				})
+			},
+			employeeChange(val) {
+				var flag = this.employeeLi.some(function(item) {
+				    return item.id === val;
+				});
+				this.employeeList.forEach(item=> {
+					if(item.id == val && !flag) {
+						this.employeeLi.push(item);
+					}
+				})
+			},
+			delOrganizationLi(index) {
+				this.organizationLi.splice(index,1);
+			},
+			delEmployeeLi(index) {
+				this.employeeLi.splice(index,1);
+			},
+			getgroupType() {
+				this.$HTTP.get("/api/blade-cps/organization/list?groupType=group_organization&groupCategory=1").then(res=> {
+					if(res.code == 200) {
+						this.organizationList = res.data;
+					}
+				})
+			},
+			getEmployeeList() {
+				this.$HTTP.get("/api/blade-cps/employee/get/list?organizationCode=00001&status=1").then(res=> {
+					if(res.code == 200) {
+						this.employeeList = res.data;
+					}
+				})
+			},
 			table_edit(row){
+				if(row.notifyName == "閽夐拤") {
+					var url = `/api/blade-notify/notifier/template/dingTalk/dingTalkMessage/config/metadata`;
+				}else if(row.notifyName == "浼佷笟寰俊") {
+					var url = `/api/blade-notify/notifier/template/weiXinQY/qyTextMessage/config/metadata`;
+				}else if(row.notifyName == "绔欏唴淇�") {
+					var url = `/api/blade-notify/notifier/template/internalMessage/systemDefault/config/metadata`;
+				}else if(row.notifyName == "閭欢") {
+					var url = `/api/blade-notify/notifier/template/email/embedded/config/metadata`;
+				}
 				this.dialog.save = true
-				this.$HTTP.get(`/api/blade-notify/notifier/template/dingTalk/dingTalkMessage/config/metadata`).then(res=> {
+				this.$HTTP.get(url).then(res=> {
 					if(res.code == 200) {
 						this.dialog.save = true;
 						this.$nextTick(() => {
-							this.$refs.saveDialog.open('edit').setData(res.data);
+							var obj = Object.assign(row,res.data);
+							this.$refs.saveDialog.open('edit').setData(obj);
 						})
 					}
 				})
@@ -113,7 +200,6 @@
 							item.checked = (item.status == '0'?false: true);
 						})
 						this.contentData = res.data.businessNotifyDTOList;
-						console.log(this.contentData)
 					}
 				})
 			},
@@ -150,7 +236,7 @@
 			// 	})
 			// },
 			addbusinessSuccess() {
-				//this.getlist();
+				this.getbusiness();
 			}
 		}
 	}
@@ -257,4 +343,18 @@
 .box-top-btn span:nth-child(1) {
 	margin-right: 12px;
 }
+.tagItem {
+	margin: 10px 10px 10px 0;
+    background-color: #3b8e8e;
+    color: #fff;
+    border-color: #3b8e8e;
+    display: inline-block;
+    font-size: 12px;
+    padding: 4px 10px;
+    border-radius: 4px;
+}
+.bottom-btn {
+	margin-top: 20px;
+	text-align: center;
+}
 </style>
\ No newline at end of file
diff --git a/src/views/notification/editbusiness.vue b/src/views/notification/editbusiness.vue
index b684540..2f89a58 100644
--- a/src/views/notification/editbusiness.vue
+++ b/src/views/notification/editbusiness.vue
@@ -1,37 +1,41 @@
 <template>
 	<el-dialog :title="titleMap[mode]" v-model="visible" :width="800" destroy-on-close @closed="$emit('closed')">
-		<el-form :model="addDictForm" :rules="addDictRules" :disabled="mode=='show'" ref="dialogForm" label-width="120px" label-position="center">
+		<div class="modelTitle">
+			<span>鎵�灞炰笟鍔� {{addBusinessForm.businessName}}</span>
+			<span>閫氱煡绫诲瀷 {{addBusinessForm.notifyName}}</span>
+			<span>鏈嶅姟鍟� {{addBusinessForm.providerName}}</span>
+		</div>
+		<el-form :model="addBusinessForm" :rules="addBusinessRules" :disabled="mode=='show'" ref="dialogForm" label-width="120px" label-position="center">
 			<el-row>
 				<el-col :span="24">
-					<el-form-item label="瀛楀吀缂栧彿" prop="code">
-						<el-input v-model="addDictForm.code" placeholder="瀛楀吀缂栧彿" clearable></el-input>
+					<el-form-item label="妯$増鍚嶇О" prop="notifyTemplateName">
+						<el-input v-model="addBusinessForm.notifyTemplateName" placeholder="妯$増鍚嶇О" clearable></el-input>
 					</el-form-item>
 				</el-col>
-				<el-col :span="12">
-					<el-form-item label="瀛楀吀鍚嶇О" prop="dictValue">
-						<el-input v-model="addDictForm.dictValue" placeholder="瀛楀吀鍚嶇О" clearable></el-input>
+				<el-col :span="24" v-for="item in addBusinessForm.properties">
+					<el-form-item :label="item.name" v-if="(addBusinessForm.notifyName != '绔欏唴淇�' && addBusinessForm.notifyName != '閭欢') || (item.property != 'content' && item.property != 'attachments')">
+						<el-input v-model="addBusinessForm[item.property]" :placeholder="item.name" clearable></el-input>
+					</el-form-item>
+
+					<el-form-item :label="item.name" v-if="(addBusinessForm.notifyName == '绔欏唴淇�' || addBusinessForm.notifyName == '閭欢') && item.property == 'content'">
+						<avue-ueditor v-model="addBusinessForm.content" v-bind="options"></avue-ueditor>
 					</el-form-item>
 				</el-col>
-				<el-col :span="12">
-					<el-form-item label="瀛楀吀鎺掑簭" prop="sort">
-						<el-input v-model="addDictForm.sort" placeholder="瀛楀吀鎺掑簭" clearable></el-input>
+				<!-- <el-col :span="24">
+					<el-form-item label="鏍囬">
+						<el-input v-model="addBusinessForm.title" placeholder="鏍囬" clearable></el-input>
 					</el-form-item>
 				</el-col>
-				<el-col :span="12">
-					<el-form-item label="灏佸瓨">
-						<el-switch v-model="addDictForm.isSealed" />
+				<el-col :span="24">
+					<el-form-item label="鍐呭">
+						<el-input v-model="addBusinessForm.message" placeholder="鍐呭" clearable></el-input>
 					</el-form-item>
-				</el-col>
-				<el-col :span="12">
-					<el-form-item label="瀛楀吀澶囨敞">
-						<el-input v-model="addDictForm.remark" placeholder="瀛楀吀澶囨敞" clearable></el-input>
-					</el-form-item>
-				</el-col>
+				</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="dictSubmit()">淇� 瀛�</el-button>
+			<el-button @click="visible=false" >鍙栨秷</el-button>
+			<el-button v-if="mode!='show'" type="primary" :loading="isSaveing" @click="businessSubmit">纭畾</el-button>
 		</template>
 	</el-dialog>
 </template>
@@ -41,48 +45,40 @@
 		emits: ['success', 'closed'],
 		data() {
 			return {
-				value1: true,
+				options: {
+			        //鏅�氫笂浼犲湴鍧�
+			        action: "/api/blade-resource/oss/endpoint/put-file",
+			        customConfig: {},//wangEditor缂栬緫鐨勯厤缃�
+			        headers:{Authorization: "Basic c2FiZXI6c2FiZXJfc2VjcmV0"},
+			        data:{},
+			        propsHttp: {
+			          home:'',
+			          url:'url',
+			          res: 'data'
+			        },
+			    },
 				mode: "add",
 				titleMap: {
 					add: '鏂板',
-					edit: '淇敼',
+					edit: '缂栬緫妯$増',
 					show: '鏌ョ湅'
 				},
 				visible: false,
 				isSaveing: false,
 				//琛ㄥ崟鏁版嵁
-				addDictForm: {
-					code: "",
-					dictValue: "",
-					sort: "",
-					isSealed: false,
-					remark: "",
-					dictKey: "-1",
-					$isSealed: "鍚�"
+				addBusinessForm: {
+					notifyTemplateName: "",
+					agentId: "",
+					title: "",
+					message: ""
 				},
 				//楠岃瘉瑙勫垯
-				addDictRules: {
-					code:[{required: true, message: '璇疯緭鍏ュ瓧鍏哥紪鍙�'}],
-					dictValue:[{required: true, message: '璇疯緭鍏ュ瓧鍏稿悕绉�'}],
-					sort:[{required: true, message: '璇疯緭鍏ュ瓧鍏告帓搴�'}]
+				addBusinessRules: {
+					notifyTemplateName:[{required: true, message: '璇疯緭鍏ユā鐗堝悕绉�'}]
 				},
-				//鎵�闇�鏁版嵁閫夐」
-				groups: [],
-				groupsProps: {
-					value: "id",
-					multiple: true,
-					checkStrictly: true
-				},
-				depts: [],
-				deptsProps: {
-					value: "id",
-					checkStrictly: true
-				}
 			}
 		},
 		mounted() {
-			// this.getGroup()
-			// this.getDept()
 		},
 		methods: {
 			//鏄剧ず
@@ -91,34 +87,29 @@
 				this.visible = true;
 				return this
 			},
-			//鍔犺浇鏍戞暟鎹�
-			async getGroup(){
-				var res = await this.$API.system.role.list.get();
-				this.groups = res.data.rows;
-			},
-			async getDept(){
-				var res = await this.$API.system.dept.list.get();
-				this.depts = res.data;
-			},
 			//琛ㄥ崟鎻愪氦鏂规硶
-			dictSubmit(){
-				var obj = Object.assign({},this.addDictForm);
-				if(obj.isSealed === true) {
-					obj.$isSealed = "鏄�";
-					obj.isSealed = "1";
-				}else {
-					obj.$isSealed = "鍚�";
-					obj.isSealed = "0";
+			businessSubmit(){
+				var obj = Object.assign({},this.addBusinessForm);
+				obj.notifyType = obj.notifyType;
+				obj.id = obj.notifyTemplateId;
+				obj.business = obj.businessKey;
+				obj.name = obj.notifyTemplateName;
+				obj.provider = obj.providerType;
+				obj.type = obj.notifyType;
+				var template = JSON.parse(obj.template);
+				for(var key in template) {
+					template[key] = obj[key];
 				}
+				obj.template = JSON.stringify(template);
 				this.$refs.dialogForm.validate(async (valid) => {
 					if (valid) {
 						this.isSaveing = true;
-						this.$HTTP.post("/api/blade-system/dict/submit",obj).then(res=> {
+						this.$HTTP.put("/api/blade-notify/business-notify/modify",obj).then(res=> {
 							this.isSaveing = false;
 							if(res.code == 200) {
-								this.$emit('success', this.addDictForm, this.mode);
+								this.$emit('success', this.addBusinessForm, this.mode);
 								this.visible = false;
-								this.$message.success("鎿嶄綔鎴愬姛");
+								this.$message.success("缂栬緫鎴愬姛");
 							}else {
 								this.$alert(res.message, "鎻愮ず", {type: 'error'});
 							}
@@ -130,18 +121,23 @@
 			},
 			//琛ㄥ崟娉ㄥ叆鏁版嵁
 			setData(data){
-				console.log(data)
+				var template = JSON.parse(data.template);
+				Object.assign(data, template);
 				//鍙互鍜屼笂闈竴鏍峰崟涓敞鍏ワ紝涔熷彲浠ュ儚涓嬮潰涓�鏍风洿鎺ュ悎骞惰繘鍘�
-				if(data.isSealed == "1") {
-					data.isSealed = true;
-				}else {
-					data.isSealed = false;
-				}
-				Object.assign(this.addDictForm, data);
+				Object.assign(this.addBusinessForm, data);
+				console.log(this.addBusinessForm)
 			}
 		}
 	}
 </script>
 
-<style>
+<style scoped>
+.modelTitle {
+	padding-left: 45px;
+    padding-bottom: 20px;
+}
+.modelTitle span {
+	display: inline-block;
+	width:30%;
+}
 </style>

--
Gitblit v1.9.3