菜单管理新增isOpen字段来控制左侧菜单是否可以使用新tab来打开外链

dev
smallchill 5 years ago
parent 6543d7d392
commit bbbe7cbb37
  1. 3
      src/page/index/sidebar/config.js
  2. 25
      src/page/index/sidebar/sidebarItem.vue
  3. 31
      src/views/system/menu.vue

@ -3,6 +3,7 @@ export default {
label: 'label', label: 'label',
path: 'path', path: 'path',
icon: 'icon', icon: 'icon',
children: 'children' children: 'children',
isOpen: 'isOpen'
} }
} }

@ -5,7 +5,7 @@
:index="item[pathKey]" :index="item[pathKey]"
@click="open(item)" @click="open(item)"
:key="item[labelKey]" :key="item[labelKey]"
:class="{'is-active':vaildAvtive(item)}"> :class="{'is-active':vaildActive(item)}">
<i :class="item[iconKey]"></i> <i :class="item[iconKey]"></i>
<span slot="title" <span slot="title"
:alt="item[pathKey]">{{generateTitle(item)}}</span> :alt="item[pathKey]">{{generateTitle(item)}}</span>
@ -21,7 +21,7 @@
<template v-for="(child,cindex) in item[childrenKey]"> <template v-for="(child,cindex) in item[childrenKey]">
<el-menu-item :index="child[pathKey],cindex" <el-menu-item :index="child[pathKey],cindex"
@click="open(child)" @click="open(child)"
:class="{'is-active':vaildAvtive(child)}" :class="{'is-active':vaildActive(child)}"
v-if="validatenull(child[childrenKey])" v-if="validatenull(child[childrenKey])"
:key="child[labelKey]"> :key="child[labelKey]">
<i :class="child[iconKey]"></i> <i :class="child[iconKey]"></i>
@ -40,7 +40,7 @@
</template> </template>
<script> <script>
import {mapGetters} from "vuex"; import {mapGetters} from "vuex";
import {validatenull} from "@/util/validate"; import {isURL, validatenull} from "@/util/validate";
import config from "./config.js"; import config from "./config.js";
export default { export default {
@ -89,6 +89,9 @@
childrenKey() { childrenKey() {
return this.props.children || this.config.propsDefault.children; return this.props.children || this.config.propsDefault.children;
}, },
isOpenKey() {
return this.props.isOpen || this.config.propsDefault.isOpen;
},
nowTagValue() { nowTagValue() {
return this.$router.$avueRouter.getValue(this.$route); return this.$router.$avueRouter.getValue(this.$route);
} }
@ -100,7 +103,10 @@
(item.meta || {}).i18n (item.meta || {}).i18n
); );
}, },
vaildAvtive(item) { vaildActive(item) {
if (this.validIsOpen(item)) {
return false;
}
const groupFlag = (item["group"] || []).some(ele => const groupFlag = (item["group"] || []).some(ele =>
this.$route.path.includes(ele) this.$route.path.includes(ele)
); );
@ -113,8 +119,16 @@
validatenull(val) { validatenull(val) {
return validatenull(val); return validatenull(val);
}, },
open (item) { validIsOpen(item) {
if (item[this.isOpenKey] === 2 && isURL(item[this.pathKey])) {
return true;
}
},
open(item) {
if (this.screen <= 1) this.$store.commit("SET_COLLAPSE"); if (this.screen <= 1) this.$store.commit("SET_COLLAPSE");
if (this.validIsOpen(item)) {
window.open(item[this.pathKey]);
} else {
this.$router.$avueRouter.group = item.group; this.$router.$avueRouter.group = item.group;
this.$router.$avueRouter.meta = item.meta; this.$router.$avueRouter.meta = item.meta;
this.$router.push({ this.$router.push({
@ -126,6 +140,7 @@
}); });
} }
} }
}
}; };
</script> </script>

@ -184,10 +184,36 @@
} }
] ]
}, },
{
label: "新窗口",
prop: "isOpen",
type: "radio",
disabled: false,
dicData: [
{
label: "否",
value: 1
},
{
label: "是",
value: 2
}
],
value: 1,
rules: [
{
required: true,
message: "请选择新窗口打开",
trigger: "blur"
}
]
},
{ {
label: "菜单排序", label: "菜单排序",
prop: "sort", prop: "sort",
type: "number", type: "number",
row: true,
span: 24,
rules: [ rules: [
{ {
required: true, required: true,
@ -216,8 +242,11 @@
if (item.prop === "path") { if (item.prop === "path") {
item.rules[0].required = category === 1; item.rules[0].required = category === 1;
} }
}); if (item.prop === 'isOpen') {
item.disabled = category === 2;
} }
});
},
}, },
computed: { computed: {
...mapGetters(["userInfo", "permission"]), ...mapGetters(["userInfo", "permission"]),

Loading…
Cancel
Save