构建版本修改
This commit is contained in:
		
							
								
								
									
										35
									
								
								packages/core/AppMenuManager/AppMenuManager.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								packages/core/AppMenuManager/AppMenuManager.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,35 @@ | ||||
| <template> | ||||
|   <section class="AppMenuManager"> | ||||
|     <component :is="currentPage" v-bind="$props"/> | ||||
|   </section> | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
| import List from "./list"; | ||||
| import IntroPage from "./introPage"; | ||||
|  | ||||
| export default { | ||||
|   name: "AppMenuManager", | ||||
|   components: {IntroPage, List}, | ||||
|   label: "菜单管理", | ||||
|   props: { | ||||
|     instance: Function, | ||||
|     dict: {default: () => ({})} | ||||
|   }, | ||||
|   computed: { | ||||
|     currentPage() { | ||||
|       const {hash} = this.$route | ||||
|       return hash == "#intro" ? IntroPage : List | ||||
|     } | ||||
|   }, | ||||
|   created() { | ||||
|     this.dict.load("menuType", "yesOrNo") | ||||
|   } | ||||
| } | ||||
| </script> | ||||
|  | ||||
| <style lang="scss" scoped> | ||||
| .AppMenuManager { | ||||
|   height: 100%; | ||||
| } | ||||
| </style> | ||||
							
								
								
									
										96
									
								
								packages/core/AppMenuManager/introPage.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										96
									
								
								packages/core/AppMenuManager/introPage.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,96 @@ | ||||
| <template> | ||||
|   <section class="introPage"> | ||||
|     <ai-detail :list="!edit"> | ||||
|       <ai-title slot="title" title="引导页配置" isShowBottomBorder isShowBack @onBackClick="$router.push({})"> | ||||
|         <template #rightBtn> | ||||
|           <ai-edit-btn @edit="edit=true,getConfigs()" @cancel="edit=false" @submit="submit"/> | ||||
|         </template> | ||||
|       </ai-title> | ||||
|       <template #content> | ||||
|         <el-form v-if="edit" :model="form" ref="IntroForm" size="small" :rules="rules" label-width="120px"> | ||||
|           <ai-card title="基本信息"> | ||||
|             <template #content> | ||||
|               <el-form-item label="副标题" prop="subtitle"> | ||||
|                 <el-input v-model="form.subtitle" clearable placeholder="请输入"/> | ||||
|               </el-form-item> | ||||
|               <el-form-item label="操作示例链接" prop="operationExamples"> | ||||
|                 <el-input v-model="form.operationExamples" clearable placeholder="请输入"/> | ||||
|               </el-form-item> | ||||
|             </template> | ||||
|           </ai-card> | ||||
|           <ai-card title="引导内容"> | ||||
|             <template #content> | ||||
|               <el-form-item label-width="0" prop="guideContent"> | ||||
|                 <ai-editor :instance="instance" v-model="form.guideContent" placeholder="请输入" action="/oms/api/file/add" :params="{withoutToken:true}"/> | ||||
|               </el-form-item> | ||||
|             </template> | ||||
|           </ai-card> | ||||
|         </el-form> | ||||
|         <ai-intro v-else :id="$route.query.id" v-bind="$props"/> | ||||
|       </template> | ||||
|     </ai-detail> | ||||
|   </section> | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
|  | ||||
| import AiEditBtn from "../../../components/AiEditBtn"; | ||||
| export default { | ||||
|   name: "introPage", | ||||
|   components: {AiEditBtn}, | ||||
|   props: { | ||||
|     instance: Function, | ||||
|     dict: {default: () => ({})} | ||||
|   }, | ||||
|   data() { | ||||
|     return { | ||||
|       form: {}, | ||||
|       rules: { | ||||
|         subtitle: {required: true, message: "请输入副标题"}, | ||||
|         guideContent: {required: true, message: "请输入引导内容"}, | ||||
|       }, | ||||
|       edit: false | ||||
|     } | ||||
|   }, | ||||
|   methods: { | ||||
|     getConfigs() { | ||||
|       const {id} = this.$route.query | ||||
|       this.instance.post("/admin/sysappguideconfig/queryDetailById", null, { | ||||
|         params: {id} | ||||
|       }).then(res => { | ||||
|         if (res?.data) { | ||||
|           this.form = res.data | ||||
|         } | ||||
|       }) | ||||
|     }, | ||||
|     submit(cb) { | ||||
|       this.$refs.IntroForm.validate(v => { | ||||
|         if (v) { | ||||
|           const {form, $route: {query: {id}}} = this | ||||
|           this.instance.post("/admin/sysappguideconfig/addOrUpdate", {...form, id}).then(res => { | ||||
|             if (res?.code == 0) { | ||||
|               this.$message.success("提交成功!") | ||||
|               cb() | ||||
|               this.edit = false | ||||
|             } | ||||
|           }) | ||||
|         } | ||||
|       }) | ||||
|     } | ||||
|   } | ||||
| } | ||||
| </script> | ||||
|  | ||||
| <style lang="scss" scoped> | ||||
| .introPage { | ||||
|   height: 100%; | ||||
|  | ||||
|   ::v-deep.ai-detail__content--wrapper { | ||||
|     min-height: 100%; | ||||
|  | ||||
|     &.list { | ||||
|       padding-top: 0; | ||||
|     } | ||||
|   } | ||||
| } | ||||
| </style> | ||||
							
								
								
									
										268
									
								
								packages/core/AppMenuManager/list.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										268
									
								
								packages/core/AppMenuManager/list.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,268 @@ | ||||
| <template> | ||||
|   <section class="list"> | ||||
|     <ai-list> | ||||
|       <ai-title slot="title" title="菜单配置" isShowBottomBorder/> | ||||
|       <template #content> | ||||
|         <ai-search-bar> | ||||
|           <template #left> | ||||
|             <el-button type="primary" icon="el-icon-circle-plus" @click="addRootMenu">添加一级目录</el-button> | ||||
|           </template> | ||||
|           <template #right> | ||||
|             <el-input size="small" v-model="search" clearable @change="$refs.MenuTree.filter(search)" | ||||
|                       placeholder="菜单名称"/> | ||||
|             <el-button icon="iconfont iconResetting" @click="getData">刷新</el-button> | ||||
|           </template> | ||||
|         </ai-search-bar> | ||||
|         <el-row type="flex" class="headerRow"> | ||||
|           <div class="menuName" v-text="`菜单名称`"/> | ||||
|           <el-row type="flex" align="middle" class="info"> | ||||
|             <div class="style" v-text="`图标`"/> | ||||
|             <div class="type" v-text="`菜单类型`"/> | ||||
|             <div class="component" v-text="`应用模块`"/> | ||||
|             <div class="status" v-text="`是否显示`"/> | ||||
|             <div class="showIndex" v-text="`排序`"/> | ||||
|           </el-row> | ||||
|           <div class="operation" v-text="`操作`"/> | ||||
|         </el-row> | ||||
|         <el-scrollbar> | ||||
|           <el-tree ref="MenuTree" :data="treeData" :props="{children:'subSet'}" highlight-current node-key="id" | ||||
|                    :filter-node-method="handleSearch"> | ||||
|             <el-row type="flex" align="middle" slot-scope="{node,data}" class="menuItem"> | ||||
|               <div class="menuName" v-text="data.name"/> | ||||
|               <el-row type="flex" align="middle" class="info"> | ||||
|                 <div class="style" :class="data.style"/> | ||||
|                 <div class="type" v-text="dict.getLabel('menuType',data.type)"/> | ||||
|                 <div class="component" v-text="data.component"/> | ||||
|                 <div class="status" v-text="dict.getLabel('yesOrNo',data.status)"/> | ||||
|                 <div class="showIndex" v-text="data.showIndex"/> | ||||
|               </el-row> | ||||
|               <el-row type="flex" align="middle" class="operation"> | ||||
|                 <div v-if="node.isLeaf" class="opBtn del" v-text="`删除`" @click="handleDelete(data)"/> | ||||
|                 <div v-if="data.component&&data.type==1" class="opBtn" v-text="`引导页`" @click="$router.push({hash:'#intro',query:{id:data.id}})"/> | ||||
|                 <div v-if="data.type<2" class="opBtn" v-text="`添加下级`" @click="addMenu(data)"/> | ||||
|                 <div class="opBtn" v-text="`编辑`" @click="handleEdit(data)"/> | ||||
|               </el-row> | ||||
|             </el-row> | ||||
|           </el-tree> | ||||
|         </el-scrollbar> | ||||
|       </template> | ||||
|     </ai-list> | ||||
|     <ai-dialog :visible.sync="dialog" title="菜单设置" width="500px" @onConfirm="handleSubmit" | ||||
|                @closed="form={},selected={}"> | ||||
|       <el-form ref="MenuForm" :model="form" size="small" label-width="100px" :rules="rules"> | ||||
|         <el-form-item label="菜单名称" prop="name"> | ||||
|           <el-input v-model="form.name" placeholder="请输入" clearable/> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="菜单类型" prop="type"> | ||||
|           <ai-select v-model="form.type" clearable :selectList="dict.getDict('menuType')"/> | ||||
|         </el-form-item> | ||||
|         <template v-if="form.type==0"> | ||||
|           <el-form-item label="菜单图标" prop="style"> | ||||
|             <el-input v-model="form.style" placeholder="请输入" clearable/> | ||||
|           </el-form-item> | ||||
|         </template> | ||||
|         <template v-if="form.type==1"> | ||||
|           <el-form-item label="路由名" prop="route"> | ||||
|             <span v-text="form.route||'提交保存后会自动生成'"/> | ||||
|           </el-form-item> | ||||
|           <el-form-item label="菜单应用" prop="component"> | ||||
|             <el-input v-model="form.component" placeholder="请输入" clearable/> | ||||
|           </el-form-item> | ||||
|           <el-form-item label="路径(path)" prop="path"> | ||||
|             <el-input v-model="form.path" placeholder="请输入" clearable/> | ||||
|           </el-form-item> | ||||
|         </template> | ||||
|         <template v-if="form.type==2"> | ||||
|           <el-form-item label="权限码" prop="permission"> | ||||
|             <el-input v-model="form.permission" placeholder="请输入" clearable/> | ||||
|           </el-form-item> | ||||
|         </template> | ||||
|         <el-form-item label="显示菜单" prop="status"> | ||||
|           <ai-select v-model="form.status" clearable :selectList="dict.getDict('yesOrNo')"/> | ||||
|         </el-form-item> | ||||
|         <el-form-item v-if="form.type<2" label="排序" prop="showIndex"> | ||||
|           <el-input v-model="form.showIndex" placeholder="请输入" clearable/> | ||||
|         </el-form-item> | ||||
|       </el-form> | ||||
|     </ai-dialog> | ||||
|  | ||||
|   </section> | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
| export default { | ||||
|   name: "list", | ||||
|   props: { | ||||
|     instance: Function, | ||||
|     dict: {default: () => ({})} | ||||
|   }, | ||||
|   data() { | ||||
|     return { | ||||
|       treeData: [], | ||||
|       dialog: false, | ||||
|       form: {}, | ||||
|       selected: {}, | ||||
|       rules: { | ||||
|         name: [{required: true, message: "请输入 菜单名称"}], | ||||
|         type: [{required: true, message: "请选择 菜单类型"}], | ||||
|         status: [{required: true, message: "请选择 显示菜单"}], | ||||
|         showIndex: [{required: true, message: "请输入 排序"}], | ||||
|         permission: [{required: true, message: "请输入 权限码"}], | ||||
|       }, | ||||
|       search: "" | ||||
|     } | ||||
|   }, | ||||
|   methods: { | ||||
|     getData() { | ||||
|       return this.instance.post("/admin/menu/menuTree").then(res => { | ||||
|         if (res?.data) { | ||||
|           this.treeData = res.data | ||||
|         } | ||||
|       }) | ||||
|     }, | ||||
|     handleSubmit() { | ||||
|       this.$refs.MenuForm.validate(v => { | ||||
|         if (v) { | ||||
|           this.instance.post("/admin/menu/addOrUpdate", this.form).then(res => { | ||||
|             if (res?.code == 0) { | ||||
|               this.$message.success("提交成功!") | ||||
|               this.dialog = false | ||||
|               if (!!this.form.id) { | ||||
|                 let node = this.$refs.MenuTree.getNode(this.form) | ||||
|                 node.data = this.form | ||||
|               } else if (!!this.form.parentId) { | ||||
|                 this.$refs.MenuTree.append(this.form, this.selected) | ||||
|               } else this.getData() | ||||
|             } | ||||
|           }) | ||||
|         } | ||||
|       }) | ||||
|     }, | ||||
|     handleDelete(data) { | ||||
|       let {id} = data | ||||
|       this.$confirm("是否要删除该菜单").then(() => { | ||||
|         this.instance.post("/admin/menu/delete", null, { | ||||
|           params: {id} | ||||
|         }).then(res => { | ||||
|           if (res?.code == 0) { | ||||
|             this.$message.success("删除成功!") | ||||
|             this.dialog = false | ||||
|             this.$refs.MenuTree.remove(data) | ||||
|           } | ||||
|         }) | ||||
|       }).catch(() => 0) | ||||
|     }, | ||||
|     addRootMenu(row) { | ||||
|       this.dialog = true | ||||
|       this.selected = row | ||||
|     }, | ||||
|     addMenu(row) { | ||||
|       this.dialog = true | ||||
|       this.form = {parentId: row.id} | ||||
|       this.selected = row | ||||
|     }, | ||||
|     handleEdit(row) { | ||||
|       this.dialog = true | ||||
|       this.form = JSON.parse(JSON.stringify(row)) | ||||
|       this.selected = row | ||||
|     }, | ||||
|     handleSearch(value, data) { | ||||
|       if (!value) return true; | ||||
|       return data.name.indexOf(value) !== -1; | ||||
|     } | ||||
|   }, | ||||
|   created() { | ||||
|     this.getData() | ||||
|   } | ||||
| } | ||||
| </script> | ||||
|  | ||||
| <style lang="scss" scoped> | ||||
| .list { | ||||
|   height: 100%; | ||||
|  | ||||
|   ::v-deep .ai-list__content--right-wrapper { | ||||
|     height: calc(100% - 10px); | ||||
|     display: flex; | ||||
|     flex-direction: column; | ||||
|  | ||||
|     .el-tree { | ||||
|       width: 100%; | ||||
|       height: 100%; | ||||
|       font-size: 14px; | ||||
|  | ||||
|       .menuItem { | ||||
|         flex: 1; | ||||
|         min-width: 0; | ||||
|       } | ||||
|  | ||||
|       .el-tree-node:nth-of-type(2n) { | ||||
|         background: rgba(#26f, .05); | ||||
|       } | ||||
|  | ||||
|       .el-tree-node__content { | ||||
|         border-bottom: 1px solid #d0d4dc; | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     .el-scrollbar { | ||||
|       flex: 1; | ||||
|       min-height: 0; | ||||
|  | ||||
|       .el-scrollbar__wrap { | ||||
|         overflow-x: auto; | ||||
|       } | ||||
|     } | ||||
|  | ||||
|  | ||||
|     .headerRow { | ||||
|       background: #f3f4f5; | ||||
|       color: #666; | ||||
|       font-weight: bold; | ||||
|       align-items: center; | ||||
|       height: 40px; | ||||
|  | ||||
|       .menuName { | ||||
|         padding-left: 16px; | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     .info { | ||||
|       gap: 16px; | ||||
|       text-align: center; | ||||
|  | ||||
|       .showIndex, .status, .type, .style { | ||||
|         width: 80px; | ||||
|       } | ||||
|  | ||||
|       .component { | ||||
|         width: 300px; | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     .operation { | ||||
|       width: 300px; | ||||
|       flex-shrink: 0; | ||||
|       justify-content: flex-end; | ||||
|       text-align: center; | ||||
|  | ||||
|       .opBtn { | ||||
|         cursor: pointer; | ||||
|         width: 60px; | ||||
|  | ||||
|         font-size: 14px; | ||||
|         color: #26f; | ||||
|  | ||||
|         &.del { | ||||
|           color: #f46; | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     .menuName { | ||||
|       flex: 1; | ||||
|       min-width: 0; | ||||
|     } | ||||
|   } | ||||
| } | ||||
| </style> | ||||
		Reference in New Issue
	
	Block a user