From bb1324a70ae25bac00eadbd4d14bb0c1faf5d2df Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期二, 26 五月 2020 14:33:45 +0800
Subject: [PATCH] 支持一级菜单(和主页同级)在main区域显示
---
ruoyi-ui/src/views/system/menu/index.vue | 90 +++++++++++++++++++++++++++++++++------------
1 files changed, 66 insertions(+), 24 deletions(-)
diff --git a/ruoyi-ui/src/views/system/menu/index.vue b/ruoyi-ui/src/views/system/menu/index.vue
index 090a232..74b4378 100644
--- a/ruoyi-ui/src/views/system/menu/index.vue
+++ b/ruoyi-ui/src/views/system/menu/index.vue
@@ -11,9 +11,9 @@
/>
</el-form-item>
<el-form-item label="鐘舵��">
- <el-select v-model="queryParams.visible" placeholder="鑿滃崟鐘舵��" clearable size="small">
+ <el-select v-model="queryParams.status" placeholder="鑿滃崟鐘舵��" clearable size="small">
<el-option
- v-for="dict in visibleOptions"
+ v-for="dict in statusOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
@@ -32,22 +32,22 @@
row-key="menuId"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
- <el-table-column prop="menuName" label="鑿滃崟鍚嶇О" :show-overflow-tooltip="true" width="130px"></el-table-column>
- <el-table-column prop="icon" label="鍥炬爣" align="center" width="100px">
+ <el-table-column prop="menuName" label="鑿滃崟鍚嶇О" :show-overflow-tooltip="true" width="160"></el-table-column>
+ <el-table-column prop="icon" label="鍥炬爣" align="center" width="100">
<template slot-scope="scope">
<svg-icon :icon-class="scope.row.icon" />
</template>
</el-table-column>
- <el-table-column prop="orderNum" label="鎺掑簭" width="60px"></el-table-column>
- <el-table-column prop="perms" label="鏉冮檺鏍囪瘑" width="130px" :show-overflow-tooltip="true"></el-table-column>
- <el-table-column prop="component" label="缁勪欢璺緞" width="180px" :show-overflow-tooltip="true"></el-table-column>
- <el-table-column prop="visible" label=" 鍙" :formatter="visibleFormat" width="80px"></el-table-column>
- <el-table-column label="鍒涘缓鏃堕棿" align="center" prop="createTime" width="180">
+ <el-table-column prop="orderNum" label="鎺掑簭" width="60"></el-table-column>
+ <el-table-column prop="perms" label="鏉冮檺鏍囪瘑" :show-overflow-tooltip="true"></el-table-column>
+ <el-table-column prop="component" label="缁勪欢璺緞" :show-overflow-tooltip="true"></el-table-column>
+ <el-table-column prop="status" label="鐘舵��" :formatter="statusFormat" width="80"></el-table-column>
+ <el-table-column label="鍒涘缓鏃堕棿" align="center" prop="createTime">
<template slot-scope="scope">
- <span>{{ dateFormat(scope.row.createTime) }}</span>
+ <span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
- <el-table-column label="鎿嶄綔" align="center" width="180" class-name="small-padding fixed-width">
+ <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini"
type="text"
@@ -63,7 +63,6 @@
v-hasPermi="['system:menu:add']"
>鏂板</el-button>
<el-button
- v-if="scope.row.parentId != 0"
size="mini"
type="text"
icon="el-icon-delete"
@@ -75,14 +74,15 @@
</el-table>
<!-- 娣诲姞鎴栦慨鏀硅彍鍗曞璇濇 -->
- <el-dialog :title="title" :visible.sync="open" width="600px">
+ <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-row>
- <el-col :span="24" v-if="form.parentId !== 0">
+ <el-col :span="24">
<el-form-item label="涓婄骇鑿滃崟">
<treeselect
v-model="form.parentId"
:options="menuOptions"
+ :normalizer="normalizer"
:show-count="true"
placeholder="閫夋嫨涓婄骇鑿滃崟"
/>
@@ -152,11 +152,22 @@
<el-input v-model="form.perms" placeholder="璇锋潈闄愭爣璇�" maxlength="50" />
</el-form-item>
</el-col>
- <el-col :span="24">
- <el-form-item v-if="form.menuType != 'F'" label="鑿滃崟鐘舵��">
+ <el-col :span="12">
+ <el-form-item v-if="form.menuType != 'F'" label="鏄剧ず鐘舵��">
<el-radio-group v-model="form.visible">
<el-radio
v-for="dict in visibleOptions"
+ :key="dict.dictValue"
+ :label="dict.dictValue"
+ >{{dict.dictLabel}}</el-radio>
+ </el-radio-group>
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item v-if="form.menuType != 'F'" label="鑿滃崟鐘舵��">
+ <el-radio-group v-model="form.status">
+ <el-radio
+ v-for="dict in statusOptions"
:key="dict.dictValue"
:label="dict.dictValue"
>{{dict.dictLabel}}</el-radio>
@@ -174,12 +185,13 @@
</template>
<script>
-import { listMenu, getMenu, treeselect, delMenu, addMenu, updateMenu } from "@/api/system/menu";
+import { listMenu, getMenu, delMenu, addMenu, updateMenu } from "@/api/system/menu";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import IconSelect from "@/components/IconSelect";
export default {
+ name: "Menu",
components: { Treeselect, IconSelect },
data() {
return {
@@ -188,13 +200,15 @@
// 鑿滃崟琛ㄦ牸鏍戞暟鎹�
menuList: [],
// 鑿滃崟鏍戦�夐」
- menuOptions: undefined,
+ menuOptions: [],
// 寮瑰嚭灞傛爣棰�
title: "",
// 鏄惁鏄剧ず寮瑰嚭灞�
open: false,
- // 鑿滃崟鐘舵�佹暟鎹瓧鍏�
+ // 鏄剧ず鐘舵�佹暟鎹瓧鍏�
visibleOptions: [],
+ // 鑿滃崟鐘舵�佹暟鎹瓧鍏�
+ statusOptions: [],
// 鏌ヨ鍙傛暟
queryParams: {
menuName: undefined,
@@ -209,6 +223,9 @@
],
orderNum: [
{ required: true, message: "鑿滃崟椤哄簭涓嶈兘涓虹┖", trigger: "blur" }
+ ],
+ path: [
+ { required: true, message: "璺敱鍦板潃涓嶈兘涓虹┖", trigger: "blur" }
]
}
};
@@ -217,6 +234,9 @@
this.getList();
this.getDicts("sys_show_hide").then(response => {
this.visibleOptions = response.data;
+ });
+ this.getDicts("sys_normal_disable").then(response => {
+ this.statusOptions = response.data;
});
},
methods: {
@@ -228,22 +248,43 @@
getList() {
this.loading = true;
listMenu(this.queryParams).then(response => {
- this.menuList = response.data;
+ this.menuList = this.handleTree(response.data, "menuId");
this.loading = false;
});
},
+ /** 杞崲鑿滃崟鏁版嵁缁撴瀯 */
+ normalizer(node) {
+ if (node.children && !node.children.length) {
+ delete node.children;
+ }
+ return {
+ id: node.menuId,
+ label: node.menuName,
+ children: node.children
+ };
+ },
/** 鏌ヨ鑿滃崟涓嬫媺鏍戠粨鏋� */
getTreeselect() {
- treeselect().then(response => {
- this.menuOptions = response.data;
+ listMenu().then(response => {
+ this.menuOptions = [];
+ const menu = { menuId: 0, menuName: '涓荤被鐩�', children: [] };
+ menu.children = this.handleTree(response.data, "menuId");
+ this.menuOptions.push(menu);
});
},
- // 鑿滃崟鏄剧ず鐘舵�佸瓧鍏哥炕璇�
+ // 鏄剧ず鐘舵�佸瓧鍏哥炕璇�
visibleFormat(row, column) {
if (row.menuType == "F") {
return "";
}
return this.selectDictLabel(this.visibleOptions, row.visible);
+ },
+ // 鑿滃崟鐘舵�佸瓧鍏哥炕璇�
+ statusFormat(row, column) {
+ if (row.menuType == "F") {
+ return "";
+ }
+ return this.selectDictLabel(this.statusOptions, row.status);
},
// 鍙栨秷鎸夐挳
cancel() {
@@ -260,7 +301,8 @@
menuType: "M",
orderNum: undefined,
isFrame: "1",
- visible: "0"
+ visible: "0",
+ status: "0"
};
this.resetForm("form");
},
--
Gitblit v1.9.3