mp:menu 前端的新增、删除操作的完善

plp
YunaiV 3 years ago
parent 02ec5d455c
commit c0b950257f

@ -60,11 +60,11 @@ SOFTWARE.
</div> </div>
</div> </div>
<!-- 一级菜单加号 --> <!-- 一级菜单加号 -->
<div class="menu_bottom menu_addicon" v-if="menuKeyLength < 3" @click="addMenu"><i class="el-icon-plus"></i></div> <div class="menu_bottom menu_addicon" v-if="this.menuList.length < 3" @click="addMenu"><i class="el-icon-plus"></i></div>
</div> </div>
<div class="save_div"> <div class="save_div">
<!--<el-button class="save_btn" type="warning" size="small" @click="saveFun"></el-button>--> <!--<el-button class="save_btn" type="warning" size="small" @click="saveFun"></el-button>-->
<el-button class="save_btn" type="success" size="small" @click="saveAndReleaseFun"></el-button> <el-button class="save_btn" type="success" size="small" @click="handleSaveAndReleaseFun"></el-button>
</div> </div>
</div> </div>
<!--右边配置--> <!--右边配置-->
@ -75,9 +75,9 @@ SOFTWARE.
</div> </div>
<div> <div>
<span>菜单名称</span> <span>菜单名称</span>
<el-input class="input_width" v-model="tempObj.name" placeholder="请输入菜单名称" :maxlength=nameMaxlength clearable></el-input> <el-input class="input_width" v-model="tempObj.name" placeholder="请输入菜单名称" :maxlength=nameMaxLength clearable></el-input>
</div> </div>
<div v-if="showConfigurContent"> <div v-if="showConfigureContent">
<div class="menu_content"> <div class="menu_content">
<span>菜单内容</span> <span>菜单内容</span>
<el-select v-model="tempObj.type" clearable placeholder="请选择" class="menu_option"> <el-select v-model="tempObj.type" clearable placeholder="请选择" class="menu_option">
@ -130,7 +130,7 @@ SOFTWARE.
</div> </div>
</div> </div>
<!-- 一进页面就显示的默认页面当点击左边按钮的时候就不显示了--> <!-- 一进页面就显示的默认页面当点击左边按钮的时候就不显示了-->
<div v-if="!showRightFlag" class="right"> <div v-else class="right">
<p>请选择菜单配置</p> <p>请选择菜单配置</p>
</div> </div>
</div> </div>
@ -138,7 +138,6 @@ SOFTWARE.
</template> </template>
<script> <script>
// import { save, saveAndRelease ,getList} from '@/api/wxmp/wxmenu'
import WxReplySelect from '@/views/mp/components/wx-news/main.vue' import WxReplySelect from '@/views/mp/components/wx-news/main.vue'
import WxNews from '@/views/mp/components/wx-news/main.vue'; import WxNews from '@/views/mp/components/wx-news/main.vue';
import WxMaterialSelect from '@/views/mp/components/wx-news/main.vue' import WxMaterialSelect from '@/views/mp/components/wx-news/main.vue'
@ -154,6 +153,7 @@ export default {
}, },
data(){ data(){
return { return {
// ======================== ========================
// //
loading: true, loading: true,
// //
@ -164,24 +164,28 @@ export default {
children: [], children: [],
}, },
showRightFlag:false, //
menu:{ // menu:{ //
button:[ button:[
] ]
}, },
// ======================== ========================
isActive: -1,// isActive: -1,//
isSubMenuActive: -1, // isSubMenuActive: -1, //
isSubMenuFlag: -1, // isSubMenuFlag: -1, //
// ======================== ========================
showRightFlag: false, //
nameMaxLength: 0, // 1 4 2 7
showConfigureContent: true, //
tempObj:{}, // tempObj:{}, //
tempSelfObj: { tempSelfObj: { // tempObjmenu
// tempObjmenu
}, },
visible2: false, // "" visible2: false, // ""
tableData:[], //, tableData:[], //,
menuName:'', menuName:'',
showConfigurContent:true,
nameMaxlength:0,//
menuOptions: [{ menuOptions: [{
value: 'view', value: 'view',
label: '跳转网页' label: '跳转网页'
@ -231,12 +235,6 @@ export default {
this.getList(); this.getList();
}) })
}, },
computed: {
menuKeyLength:function() {
// menuObj 3
return this.menu.button.length;
}
},
methods: { methods: {
// ======================== ======================== // ======================== ========================
/** 设置账号编号 */ /** 设置账号编号 */
@ -271,155 +269,149 @@ export default {
this.handleQuery() this.handleQuery()
}, },
// TODO // ======================== ========================
deleteTempObj(){
this.$delete(this.tempObj,'repName')
this.$delete(this.tempObj,'repUrl')
this.$delete(this.tempObj,'content')
},
openMaterial(){
this.dialogNewsVisible = true
},
selectMaterial(item){
if(item.content.articles.length>1){
this.$alert('您选择的是多图文,将默认跳转第一篇', '提示', {
confirmButtonText: '确定'
})
}
this.dialogNewsVisible = false
this.tempObj.article_id = item.articleId
this.tempObj.mediaName = item.name
this.tempObj.url = item.url
item.mediaType = this.tempObj.mediaType
item.content.articles = item.content.articles.slice(0,1)
this.tempObj.content = item.content
},
handleClick(tab, event){
this.tempObj.mediaType = tab.name
},
saveAndReleaseFun(){
this.$confirm('确定要保证并发布该菜单吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.loading = true
saveAndRelease({
strWxMenu:this.menu
}).then(response => {
this.loading = false
if(response.code == 200){
this.$message({
showClose: true,
message: '发布成功',
type: 'success'
})
}else{
this.$message.error(response.data.msg)
}
}).catch(() => {
this.loading = false
})
}).catch(() => {
})
},
// //
menuClick(i, item) { menuClick(i, item) {
this.hackResetWxReplySelect = false// //
this.$nextTick(() => { this.resetEditor();
this.hackResetWxReplySelect = true//
})
this.showRightFlag = true; // this.showRightFlag = true; //
this.tempObj = item; // flag this.tempObj = item; // flag
this.tempSelfObj.grand = "1"; // this.tempSelfObj.grand = "1"; //
this.tempSelfObj.index = i; // this.tempSelfObj.index = i; //
this.nameMaxLength = 4
this.showConfigureContent = !(item.children && item.children.length > 0); //
//
this.isActive = i; // this.isActive = i; //
this.isSubMenuFlag = i; // this.isSubMenuFlag = i; //
this.isSubMenuActive = -1; // this.isSubMenuActive = -1; //
this.nameMaxlength = 4
if(item.sub_button && item.sub_button.length > 0){
this.showConfigurContent = false
}else{
this.showConfigurContent = true
}
}, },
// //
subMenuClick(subItem, index, k) { subMenuClick(subItem, index, k) {
this.hackResetWxReplySelect = false// //
this.$nextTick(() => { this.resetEditor();
this.hackResetWxReplySelect = true//
})
this.showRightFlag = true; // this.showRightFlag = true; //
this.tempObj = subItem;// this.tempObj = subItem;//
this.tempSelfObj.grand = "2"; // this.tempSelfObj.grand = "2"; //
this.tempSelfObj.index = index; // this.tempSelfObj.index = index; //
this.tempSelfObj.secondIndex = k; // this.tempSelfObj.secondIndex = k; //
this.isSubMenuActive = index + "" + k; // this.nameMaxLength = 7
this.showConfigureContent = true;
//
this.isActive = -1; // this.isActive = -1; //
this.showConfigurContent = true; this.isSubMenuActive = index + "" + k; //
this.nameMaxlength = 7
}, },
// //
addMenu(){ addMenu(){
let menuKeyLength = this.menuKeyLength const menuKeyLength = this.menuList.length;
let addButton = { const addButton = {
name: "菜单名称", name: "菜单名称",
sub_button: [] children: []
} }
this.$set(this.menu.button,menuKeyLength,addButton) this.$set(this.menuList, menuKeyLength, addButton)
this.menuClick(this.menuKeyLength - 1, addButton) this.menuClick(this.menuKeyLength - 1, addButton)
}, },
// // item
addSubMenu(i, item) { addSubMenu(i, item) {
if(!item.sub_button||item.sub_button.length<=0){ if (!item.children || item.children.length <= 0){
this.$set( item, 'sub_button',[]) this.$set( item, 'children',[])
// TODO
this.$delete( item, 'type') this.$delete( item, 'type')
this.$delete( item, 'pagepath') this.$delete( item, 'pagepath')
this.$delete( item, 'url') this.$delete( item, 'url')
this.$delete( item, 'key') this.$delete( item, 'key')
this.$delete( item, 'article_id') this.$delete( item, 'article_id')
this.$delete( item, 'textContent') this.$delete( item, 'textContent')
this.showConfigurContent = false this.showConfigureContent = false
} }
let subMenuKeyLength = item.sub_button.length;//key
let subMenuKeyLength = item.children.length; // key
let addButton = { let addButton = {
name: "子菜单名称" name: "子菜单名称"
} }
this.$set(item.sub_button,subMenuKeyLength,addButton); this.$set(item.children, subMenuKeyLength, addButton);
this.subMenuClick(item.sub_button[subMenuKeyLength], i, subMenuKeyLength) this.subMenuClick(item.children[subMenuKeyLength], i, subMenuKeyLength)
}, },
// //
deleteMenu(obj){ deleteMenu(item) {
let _this = this; this.$modal.confirm('确定要删除吗?').then(() => {
this.$confirm('确定要删除吗?', '提示', { //
if (this.tempSelfObj.grand === "1") { //
this.menuList.splice(this.tempSelfObj.index, 1);
} else if (this.tempSelfObj.grand === "2") { //
this.menuList[this.tempSelfObj.index].children.splice(this.tempSelfObj.secondIndex, 1);
}
//
this.$modal.msgSuccess("删除成功");
//
this.tempObj = {};
this.showRightFlag = false;
this.isActive = -1;
this.isSubMenuActive = -1;
}).catch(() => {});
},
// ======================== ========================
handleSaveAndReleaseFun(){
this.$confirm('确定要保证并发布该菜单吗?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
_this.deleteData();// this.loading = true
_this.tempObj = {}; saveAndRelease({
_this.showRightFlag = false; strWxMenu:this.menu
this.isActive = -1; }).then(response => {
this.isSubMenuActive = -1; this.loading = false
if(response.code == 200){
this.$message({
showClose: true,
message: '发布成功',
type: 'success'
})
}else{
this.$message.error(response.data.msg)
}
}).catch(() => {
this.loading = false
})
}).catch(() => { }).catch(() => {
}); })
}, },
// // Editor
deleteData(){ resetEditor() {
// this.hackResetEditor = false //
if(this.tempSelfObj.grand == "1"){ this.$nextTick(() => {
this.menu.button.splice(this.tempSelfObj.index,1); this.hackResetEditor = true //
} })
// },
if(this.tempSelfObj.grand == "2"){
this.menu.button[this.tempSelfObj.index].sub_button.splice(this.tempSelfObj.secondIndex, 1); // TODO
}
this.$message({ deleteTempObj(){
type: 'success', this.$delete(this.tempObj,'repName')
message: '删除成功!' this.$delete(this.tempObj,'repUrl')
}); this.$delete(this.tempObj,'content')
},
openMaterial(){
this.dialogNewsVisible = true
},
selectMaterial(item){
if(item.content.articles.length>1){
this.$alert('您选择的是多图文,将默认跳转第一篇', '提示', {
confirmButtonText: '确定'
})
} }
this.dialogNewsVisible = false
this.tempObj.article_id = item.articleId
this.tempObj.mediaName = item.name
this.tempObj.url = item.url
item.mediaType = this.tempObj.mediaType
item.content.articles = item.content.articles.slice(0,1)
this.tempObj.content = item.content
},
}, },
} }
</script> </script>

Loading…
Cancel
Save