浏览代码

ETA1.0.4 接口联调

cxmo 1 年之前
父节点
当前提交
6d50baa42a

+ 1 - 1
src/api/modules/etaMenuApi.js

@@ -30,7 +30,7 @@ export const menuConfigInterface = {
      * @param {Number} MenuId 菜单ID 其他参数同上
      * @returns 
      */
-    exitMenu:params=>{
+    editMenu:params=>{
         return http.post('/eta_business/menu/edit',params)
     },
     /**

+ 25 - 6
src/views/system_manage/etaMenu_manage/components/ModifyMenuDialog.vue

@@ -11,7 +11,7 @@
             center
         >
             <div class="dialog-container-wrap">
-                <el-form :model="form" :rules="rules" label-width="80px" ref="menuForm">
+                <el-form :model="form" :rules="rules" label-width="80px" :hide-required-asterisk="true" ref="menuForm">
                     <el-form-item label="菜单类型" prop="MenuType">
                         <el-radio-group v-model="form.MenuType" :disabled="form.MenuId">
                             <el-radio :label="0" :disabled="isMenuDisabled">菜单</el-radio>
@@ -31,7 +31,7 @@
                         <el-input v-model="form.Name"></el-input>
                     </el-form-item>
                     <template v-if="form.MenuType===0">
-                        <el-form-item label="菜单图标" prop="Name">
+                        <el-form-item label="菜单图标" prop="Name" v-if="form.treeLevel===0">
                             <div class="icon-wrap">
                                 <img :src="form.IconPath" v-if="form.IconPath">
                                 <el-button @click="isShowIconDialog = true">选择图标</el-button>
@@ -44,11 +44,11 @@
                             <el-input v-model="form.Component"></el-input>
                         </el-form-item>
                     </template>
-                    <el-form-item label="按钮ID" prop="ButtonCode">
+                    <el-form-item label="按钮ID" prop="ButtonCode" v-if="form.MenuType!==0">
                         <el-input v-model="form.ButtonCode"></el-input>
                     </el-form-item>
                     <el-form-item label="显示排序" prop="Sort">
-                        <el-input v-model="form.Sort"></el-input>
+                        <el-input v-model="form.Sort" type="number" :min="0"></el-input>
                     </el-form-item>
                     <el-form-item label="是否隐藏" prop="Hidden">
                         <el-radio-group v-model="form.Hidden">
@@ -107,7 +107,15 @@ export default {
                 ButtonCode: '',
                 treeLevel: 0
             },
-            rules: {},
+            rules: {
+                ParentId:[{required:true,message:'请选择上级菜单'}],
+                Name:[{required:true,message:'请输入菜单标题'}],
+                IconPath:[{required:true,message:'请选择菜单图标'}],
+                Path:[{required:true,message:'请输入路由地址'}],
+                Component:[{required:true,message:'请输入组件地址'}],
+                Sort:[{required:true,message:'请输入显示排序'}],
+                ButtonCode:[{required:true,message:'请输入按钮ID'}]
+            },
             menuList: [{
                     MenuId: -1,
                     Name: '无'
@@ -128,6 +136,9 @@ export default {
                 this.form = this.$options.data().form;
                 this.menuList = this.$options.data().menuList;
                 this.initForm();
+                this.$nextTick(()=>{
+                    this.$refs.menuForm&&this.$refs.menuForm.clearValidate();
+                })
             }
         },
         'form.MenuType': {
@@ -160,10 +171,18 @@ export default {
             if (this.form.treeLevel > 1 && this.openType !== 'edit') {
                 this.form.MenuType = 1;
             }
+            if(this.form.treeLevel===0 && this.openType !== 'add'){
+                this.form.ParentId = -1
+            }
         },
         saveMenu() {
             //检验表单
-            this.$emit(this.form.MenuId ? 'edit' : 'add', this.form);
+            this.$refs.menuForm.validate((valid)=>{
+                if(valid){
+                    this.$emit(this.form.MenuId ? 'edit' : 'add', this.form);
+                }
+            })
+            
         },
         changeListLevel(level) {
             if (level === 0) {

+ 55 - 6
src/views/system_manage/etaMenu_manage/etaMenuConfig.vue

@@ -1,7 +1,7 @@
 <template>
     <div class="eta-menu-config-wrap">
         <div class="menu-top">
-            <el-button type="primary" @click="modifyMenu('add',{})">添加菜单</el-button>
+            <el-button type="primary" @click="handleModifyMenu('add',{})">添加菜单</el-button>
             <el-input placeholder="请输入菜单名称" prefix-icon="el-icon-search" clearable
                 v-model="Keyword" @input="getMenuData"></el-input>
         </div>
@@ -37,8 +37,8 @@
                 </el-table-column>
                 <el-table-column align="center" prop="操作">
                     <template slot-scope="{row}">
-                        <el-button type="text" @click="modifyMenu('addNext',row)">添加子项</el-button>
-                        <el-button type="text" @click="modifyMenu('edit',row)">编辑</el-button>
+                        <el-button type="text" @click="handleModifyMenu('addNext',row)">添加子项</el-button>
+                        <el-button type="text" @click="handleModifyMenu('edit',row)">编辑</el-button>
                         <el-button type="text" style="color:#FF0000;" @click="deleteMenu(row)">删除</el-button>
                     </template>
                 </el-table-column>
@@ -49,6 +49,8 @@
             :formData="formData"
             :etaMenu="tableData"
             :openType="openType"
+            @add="(params)=>{modifyMenu(params,'addMenu')}"
+            @edit="(params)=>{modifyMenu(params,'editMenu')}"
             @close="()=>{formData = {};isShowMenuDialog = false;}"
         />
     </div>
@@ -103,7 +105,7 @@ export default {
             }
             return data
         },
-        modifyMenu(type, data) {
+        handleModifyMenu(type, data) {
             if (type === 'addNext') {
                 this.formData.ParentId = data.MenuId;
                 this.formData.treeLevel = data.treeLevel+1
@@ -118,8 +120,55 @@ export default {
             this.isShowMenuDialog = true;
         },
         deleteMenu(data){
-            console.log('scope',data)
-        }
+            this.$confirm(`删除后不可恢复,确认删除该${data.MenuType===0?'菜单及子菜单吗':'按钮吗'}?`,'提示',{
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+                type: 'warning'
+            }).then(()=>{
+                menuConfigInterface.removeMenu({MenuId:data.MenuId}).then(res=>{
+                    if(res.Ret!==200) return 
+                    this.$message.success('删除成功')
+                    this.getMenuData()
+                })
+            }).catch(()=>{})
+            
+        },
+        modifyMenu(params,type){
+            let InterfaceParams = {}
+            if(params.MenuType===0){
+                const {ParentId,MenuType,Name,IconPath,Sort,Path,Component,Hidden} = params
+                InterfaceParams = {
+                    ParentId:ParentId===-1?0:ParentId,
+                    MenuType,
+                    Name,
+                    IconPath,
+                    Sort,
+                    Path,
+                    Component,
+                    Hidden
+                }
+            }else{
+                const {ParentId,MenuType,Name,Sort,Hidden,ButtonCode} = params
+                InterfaceParams = {
+                    ParentId:ParentId===-1?0:ParentId,
+                    MenuType,
+                    Name,
+                    Sort,
+                    Hidden,
+                    ButtonCode
+                }
+            }
+            if(type==='editMenu'){
+                InterfaceParams = {...{MenuId:params.MenuId},...InterfaceParams}
+            }
+            menuConfigInterface[type](InterfaceParams).then(res=>{
+                    if(res.Ret!==200) return 
+                    this.$message.success(`${type==='addMenu'?'添加':'编辑'}成功`)
+                    this.getMenuData()
+                    this.isShowMenuDialog = false
+                })
+        },
+        editMenu(params){}
     },
     mounted() {
         this.getMenuData();