lalala hace 6 años
padre
commit
e452ebede3

+ 3 - 3
admin-update/src/components/module/operate-line.vue

@@ -11,7 +11,7 @@
 		<div class="operate-wrap">
 			<div class="operate-list" v-for="(item, index) in data.children" :key="index">
 				<i class="iconfont iconcaozuojihuo" @click.stop="listDel(index)"></i>
-				<div class="btn-text" @click="listClick(item)">{{ item.name }}</div>
+				<div class="btn-text" @click="listClick(item, index)">{{ item.name }}</div>
 			</div>
 			<div
 				class="operate-list operate-list-add"
@@ -51,8 +51,8 @@ export default {
 		showFn() {
 			this.$emit('show', this.data);
 		},
-		listClick(item) {
-			this.$emit('click', item);
+		listClick(item, index) {
+			this.$emit('click', {...item, ...{index: index}});
 		},
 		listDel(index) {
 			this.$emit('del', index);

+ 29 - 9
admin-update/src/views/setting/wx-menu.vue

@@ -87,6 +87,7 @@
 				isAdd: false,
 				addDialog: false,
 				activeIndex: null,
+				subActiveIndex: null,
 				menuData: [],
 				// 常用链接
 				urlIndex: null,
@@ -128,12 +129,12 @@
 					this.commonUrlData = res;
 				});
 			},
-			submitFn() {
+			async submitFn() {
 				console.log(this.menuData);
 				// return false;
-				this.$service.setting.updateMenu(this.menuData).then(res => {
+				await this.$service.setting.updateMenu(this.menuData).then(res => {
 					this.$message.success(res.msg || '提交');
-					this.closeOperate();
+					// this.closeOperate();
 					this.resetForm();
 				});
 			},
@@ -161,6 +162,7 @@
 			operateClickFn(item) {
 				this.isModifyParents = false;
 				this.isAdd = false;
+				this.subActiveIndex = item.index;
 				console.log('item', item);
 				// this.dialogData = item;
 				item.targetId = item.targetId ? parseInt(item.targetId) : 0;
@@ -177,7 +179,7 @@
 				this.addDialog = true;
 				if (this.$refs['form']) {
 					console.log('asdf');
-					this.$refs['form'].resetFields();
+					this.resetForm()
 				}
 			},
 			operateDelFn(index) {
@@ -190,6 +192,7 @@
 			closeOperate() {
 				this.activeIndex = null;
 				this.operateShow = this.operateShow.map(e => (e = false));
+				this.addDialog = false;
 				// if (this.addDialog) {
 				// 	this.resetForm();
 				// }
@@ -212,19 +215,36 @@
 				} else {
 					// 如果是子菜单操作时
 					if (this.isAdd) {
+						this.$set(this.operateShow, this.activeIndex, false);
 						this.operateData.push(form);
 					} else {
-						this.operateData = form;
+						this.operateData[this.subActiveIndex] = form;
 					}
+
+					console.log('this.operateData', this.operateData)
+					
+					this.menuData[this.activeIndex].children = JSON.parse(JSON.stringify(this.operateData));
 				}
-				setTimeout(() => {
-					this.$set(this.operateShow, this.activeIndex, true);
+				this.submitFn().then(res => {
+					console.log('this.activeIndex', this.activeIndex);
+					
+					this.addDialog = false;
+					if (this.isAdd) {
+						setTimeout(() => {
+							this.$set(this.operateShow, this.activeIndex, true);
+						});
+					}
 				});
-				this.submitFn();
 			},
 			resetForm() {
+				this.form = {
+					name: '',
+					menuOption: '0',
+					replyUrl: '',
+					targetId: 0
+				};
 				this.$refs['form'].resetFields();
-				this.addDialog = false;
+				// this.addDialog = false;
 			}
 		}
 	};