update 菜单完善
This commit is contained in:
@@ -115,11 +115,11 @@ namespace Ewide.Core
|
|||||||
[Comment("备注")]
|
[Comment("备注")]
|
||||||
public string Remark { get; set; }
|
public string Remark { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 不关联上级菜单显示 0标识关联 1表示不需要关联菜单 仅按钮有效
|
/// 关联上级菜单显示 0表示不需要关联菜单 1表示关联 仅按钮有效
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Comment("不关联菜单显示")]
|
[Comment("关联菜单显示")]
|
||||||
[Column("UnbindParent", TypeName = "bit")]
|
[Column("VisibleParent", TypeName = "bit")]
|
||||||
public bool UnbindParent { get; set; }
|
public bool VisibleParent { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 状态(字典 0正常 1停用 2删除)
|
/// 状态(字典 0正常 1停用 2删除)
|
||||||
|
|||||||
@@ -88,9 +88,9 @@ namespace Ewide.Core.Service
|
|||||||
public string Remark { get; set; }
|
public string Remark { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 不绑定上级菜单
|
/// 绑定上级菜单显示
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int UnbindParent { get; set; }
|
public bool VisibleParent { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AddMenuInput : MenuInput
|
public class AddMenuInput : MenuInput
|
||||||
|
|||||||
@@ -28,10 +28,20 @@ namespace Ewide.Core.Service
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Value { get; set; }
|
public string Value { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 菜单类型
|
||||||
|
/// </summary>
|
||||||
|
public int Type { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 关联显示父级
|
||||||
|
/// </summary>
|
||||||
|
public bool VisibleParent { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 排序,越小优先级越高
|
/// 排序,越小优先级越高
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Weight { get; set; }
|
public int Sort { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 子节点
|
/// 子节点
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ namespace Ewide.Core.Service
|
|||||||
var router = input.Router;
|
var router = input.Router;
|
||||||
var permission = input.Permission;
|
var permission = input.Permission;
|
||||||
var openType = input.OpenType;
|
var openType = input.OpenType;
|
||||||
var isUnbindParent = input.UnbindParent==1;
|
var isVisibleParent = input.VisibleParent;
|
||||||
|
|
||||||
if (type.Equals((int)MenuType.DIR))
|
if (type.Equals((int)MenuType.DIR))
|
||||||
{
|
{
|
||||||
@@ -208,8 +208,8 @@ namespace Ewide.Core.Service
|
|||||||
//if (!urlSet.Contains(permission.Replace(":","/")))
|
//if (!urlSet.Contains(permission.Replace(":","/")))
|
||||||
// throw Oops.Oh(ErrorCode.meu1005);
|
// throw Oops.Oh(ErrorCode.meu1005);
|
||||||
}
|
}
|
||||||
//按钮可以设置未不绑定菜单
|
//按钮可以设置绑定菜单
|
||||||
if(isUnbindParent && type.Equals((int)MenuType.BTN))
|
if(!isVisibleParent && type.Equals((int)MenuType.BTN))
|
||||||
{
|
{
|
||||||
throw Oops.Oh(ErrorCode.D4004);
|
throw Oops.Oh(ErrorCode.D4004);
|
||||||
}
|
}
|
||||||
@@ -382,7 +382,9 @@ namespace Ewide.Core.Service
|
|||||||
ParentId = u.Pid,
|
ParentId = u.Pid,
|
||||||
Value = u.Id.ToString(),
|
Value = u.Id.ToString(),
|
||||||
Title = u.Name,
|
Title = u.Name,
|
||||||
Weight = u.Sort
|
Type = u.Type,
|
||||||
|
VisibleParent = u.VisibleParent,
|
||||||
|
Sort = u.Sort
|
||||||
}).ToListAsync();
|
}).ToListAsync();
|
||||||
return new TreeBuildUtil<MenuTreeOutput>().DoTreeBuild(menus);
|
return new TreeBuildUtil<MenuTreeOutput>().DoTreeBuild(menus);
|
||||||
}
|
}
|
||||||
@@ -413,7 +415,9 @@ namespace Ewide.Core.Service
|
|||||||
ParentId = u.Pid,
|
ParentId = u.Pid,
|
||||||
Value = u.Id.ToString(),
|
Value = u.Id.ToString(),
|
||||||
Title = u.Name,
|
Title = u.Name,
|
||||||
Weight = u.Sort
|
Type = u.Type,
|
||||||
|
VisibleParent = u.VisibleParent,
|
||||||
|
Sort = u.Sort
|
||||||
}).ToListAsync();
|
}).ToListAsync();
|
||||||
return new TreeBuildUtil<MenuTreeOutput>().DoTreeBuild(menus);
|
return new TreeBuildUtil<MenuTreeOutput>().DoTreeBuild(menus);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { api } from '@/common/api'
|
import { api } from '@/common/api'
|
||||||
import { token } from '@/common/token'
|
import { token } from '@/common/token'
|
||||||
import { GLOBAL_INFO_KEY, APP_MENU_KEY } from '@/common/storage'
|
import { GLOBAL_INFO_KEY, ACTIVE_APP_KEY } from '@/common/storage'
|
||||||
import { encryptByDES, decryptByDES } from '@/util/des'
|
import { encryptByDES, decryptByDES } from '@/util/des'
|
||||||
import app from '@/main'
|
import app from '@/main'
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ const doLogout = () => {
|
|||||||
if (success) {
|
if (success) {
|
||||||
removeGlobal()
|
removeGlobal()
|
||||||
token.value = ''
|
token.value = ''
|
||||||
window.localStorage.removeItem(APP_MENU_KEY)
|
window.localStorage.removeItem(ACTIVE_APP_KEY)
|
||||||
if (app.$route.path === '/') {
|
if (app.$route.path === '/') {
|
||||||
app.$router.replace('/login')
|
app.$router.replace('/login')
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
const SESSION_KEY = '__SESSION'
|
const SESSION_KEY = '__SESSION'
|
||||||
const SETTING_KEY = '__SETTINGS'
|
const SETTING_KEY = '__SETTINGS'
|
||||||
const GLOBAL_INFO_KEY = '__GLOBAL_INFO'
|
const GLOBAL_INFO_KEY = '__GLOBAL_INFO'
|
||||||
const APP_MENU_KEY = '__APP_MENU'
|
const ACTIVE_APP_KEY = '__ACTIVE_APP'
|
||||||
|
|
||||||
export {
|
export {
|
||||||
SESSION_KEY,
|
SESSION_KEY,
|
||||||
SETTING_KEY,
|
SETTING_KEY,
|
||||||
GLOBAL_INFO_KEY,
|
GLOBAL_INFO_KEY,
|
||||||
APP_MENU_KEY
|
ACTIVE_APP_KEY
|
||||||
}
|
}
|
||||||
@@ -59,11 +59,18 @@ export default {
|
|||||||
renderCheckbox(data) {
|
renderCheckbox(data) {
|
||||||
return (
|
return (
|
||||||
<div class="yo-authority-view--checkbox">
|
<div class="yo-authority-view--checkbox">
|
||||||
|
{data.visibleParent && data.type == 2 &&
|
||||||
|
<a-tooltip placement="top" title="选中此项才会显示父节点">
|
||||||
|
<a-icon type="eye" style={{ color: '#1890ff' }} class="mr-xxs" />
|
||||||
|
</a-tooltip>
|
||||||
|
}
|
||||||
<a-checkbox
|
<a-checkbox
|
||||||
value={data.id}
|
value={data.id}
|
||||||
checked={data.checked}
|
checked={data.checked}
|
||||||
onChange={(e) => this.onChange(e, data)}
|
onChange={(e) => this.onChange(e, data)}
|
||||||
>{data.title}</a-checkbox>
|
>
|
||||||
|
{data.title}
|
||||||
|
</a-checkbox>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@@ -100,7 +107,16 @@ export default {
|
|||||||
|
|
||||||
this.onSelect(e.target.checked, item)
|
this.onSelect(e.target.checked, item)
|
||||||
|
|
||||||
this.$emit('select', this.list.filter(p => p.checked).map(p => p.id), this.list.filter(p => p.checked || p.indeterminate).map(p => p.id))
|
const visible = this.getVisible()
|
||||||
|
|
||||||
|
this.$emit('select',
|
||||||
|
// 返回所有选中
|
||||||
|
this.list.filter(p => p.checked).map(p => p.id),
|
||||||
|
// 返回所有选中和半选
|
||||||
|
this.list.filter(p => p.checked || p.indeterminate).map(p => p.id),
|
||||||
|
// 返回所有选中和半选,但是不返回没有子级选中visibleParent的半选
|
||||||
|
visible
|
||||||
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
onSelect(check, item) {
|
onSelect(check, item) {
|
||||||
@@ -167,6 +183,42 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getVisible() {
|
||||||
|
const checked = this.list.filter(p => p.checked)
|
||||||
|
const caseChildren = checked.filter(p => p.visibleParent || p.type != 2)
|
||||||
|
const visibleParents = []
|
||||||
|
// 递归寻找父级
|
||||||
|
const findVisibleParents = (children) => {
|
||||||
|
const parents = []
|
||||||
|
children.forEach(item => {
|
||||||
|
if (item.parentId) {
|
||||||
|
const parent = this.list.find(p => p.id === item.parentId)
|
||||||
|
if (parent) {
|
||||||
|
parents.push(parent)
|
||||||
|
visibleParents.push(parent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (parents.length) {
|
||||||
|
findVisibleParents(parents)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
findVisibleParents(caseChildren)
|
||||||
|
|
||||||
|
const checkedIds = checked.map(p => p.id)
|
||||||
|
const visibleParentsIds = visibleParents.map(p => p.id)
|
||||||
|
|
||||||
|
const result = checkedIds
|
||||||
|
visibleParentsIds.forEach(p => {
|
||||||
|
if (result.indexOf(p) === -1) {
|
||||||
|
result.push(p)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|||||||
@@ -94,8 +94,11 @@
|
|||||||
<a-form-model-item label="权限标识" prop="permission" v-if="form.type == 2">
|
<a-form-model-item label="权限标识" prop="permission" v-if="form.type == 2">
|
||||||
<a-input placeholder="请输入权限标识" v-model="form.permission" />
|
<a-input placeholder="请输入权限标识" v-model="form.permission" />
|
||||||
</a-form-model-item>
|
</a-form-model-item>
|
||||||
|
<a-form-model-item label="关联上级菜单显示" prop="visibleParent" v-if="form.type == 2">
|
||||||
|
<a-switch v-model="form.visibleParent" />
|
||||||
|
</a-form-model-item>
|
||||||
<a-form-model-item label="可见性">
|
<a-form-model-item label="可见性">
|
||||||
<a-switch checked-children="可见" un-checked-children="隐藏" v-model="form.visible" />
|
<a-switch v-model="form.visible" />
|
||||||
</a-form-model-item>
|
</a-form-model-item>
|
||||||
<!-- 图标只有[按钮]不可用 -->
|
<!-- 图标只有[按钮]不可用 -->
|
||||||
<a-form-model-item label="图标" v-if="form.type != 2">
|
<a-form-model-item label="图标" v-if="form.type != 2">
|
||||||
@@ -132,6 +135,7 @@ const defaultValue = {
|
|||||||
type: '1',
|
type: '1',
|
||||||
openType: '1',
|
openType: '1',
|
||||||
weight: '1',
|
weight: '1',
|
||||||
|
visibleParent: false,
|
||||||
visible: true,
|
visible: true,
|
||||||
sort: 100,
|
sort: 100,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -69,8 +69,8 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onSelect(a1, a2) {
|
onSelect(a1, a2, a3) {
|
||||||
this.selectedKeys = a2;
|
this.selectedKeys = a3;
|
||||||
},
|
},
|
||||||
|
|
||||||
onOk() {
|
onOk() {
|
||||||
|
|||||||
@@ -37,10 +37,6 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
|
||||||
console.log(this.apps);
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onChangeApp(app) {
|
onChangeApp(app) {
|
||||||
this.$emit('change-app', app);
|
this.$emit('change-app', app);
|
||||||
|
|||||||
@@ -82,6 +82,9 @@ export default {
|
|||||||
mounted() {
|
mounted() {
|
||||||
// swiper不能使用vue版本的组件.效果相当差
|
// swiper不能使用vue版本的组件.效果相当差
|
||||||
swiper = new Swiper('#layout--swiper-container', siderSwiperOptions);
|
swiper = new Swiper('#layout--swiper-container', siderSwiperOptions);
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.onUpdateSwiper();
|
||||||
|
});
|
||||||
|
|
||||||
window.addEventListener('resize', () => {
|
window.addEventListener('resize', () => {
|
||||||
if (this.$root.global.settings.layout === 'left-menu' || this.$root.global.settings.layout === 'right-menu') {
|
if (this.$root.global.settings.layout === 'left-menu' || this.$root.global.settings.layout === 'right-menu') {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ import Content from './_layout/content';
|
|||||||
import Setting from './setting';
|
import Setting from './setting';
|
||||||
|
|
||||||
import { setGlobal } from '@/common/login';
|
import { setGlobal } from '@/common/login';
|
||||||
import { APP_MENU_KEY } from '@/common/storage';
|
import { ACTIVE_APP_KEY } from '@/common/storage';
|
||||||
|
|
||||||
import { EMPTY_ID } from '@/util/global';
|
import { EMPTY_ID } from '@/util/global';
|
||||||
|
|
||||||
@@ -210,13 +210,7 @@ export default {
|
|||||||
this.nav.loading = true;
|
this.nav.loading = true;
|
||||||
this.$api.sysMenuChange({ application: app.code }).then(({ data }) => {
|
this.$api.sysMenuChange({ application: app.code }).then(({ data }) => {
|
||||||
this.nav.apps.map((p) => (p.active = p.code === app.code));
|
this.nav.apps.map((p) => (p.active = p.code === app.code));
|
||||||
window.localStorage.setItem(
|
window.localStorage.removeItem(ACTIVE_APP_KEY);
|
||||||
APP_MENU_KEY,
|
|
||||||
JSON.stringify({
|
|
||||||
...this.nav.apps.find((p) => p.active),
|
|
||||||
menus: data,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
this.onSetNav({
|
this.onSetNav({
|
||||||
apps: this.nav.apps,
|
apps: this.nav.apps,
|
||||||
menus: data,
|
menus: data,
|
||||||
@@ -229,20 +223,19 @@ export default {
|
|||||||
onSetNav(nav) {
|
onSetNav(nav) {
|
||||||
// 从本地存储获取当前选中的应用及菜单
|
// 从本地存储获取当前选中的应用及菜单
|
||||||
this.nav.apps = nav.apps;
|
this.nav.apps = nav.apps;
|
||||||
const storage = JSON.parse(window.localStorage.getItem(APP_MENU_KEY));
|
const code = window.localStorage.getItem(ACTIVE_APP_KEY);
|
||||||
if (storage) {
|
if (code) {
|
||||||
this.nav.apps.map((p) => (p.active = p.code === storage.code));
|
this.nav.apps.map((p) => (p.active = p.code === code.code));
|
||||||
this.serializeMenu(storage.menus);
|
this.onChangeApp({
|
||||||
|
code,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
// 将默认选中菜单存储
|
// 将默认选中菜单存储
|
||||||
window.localStorage.setItem(
|
const app = nav.apps.find((p) => p.active);
|
||||||
APP_MENU_KEY,
|
if (app) {
|
||||||
JSON.stringify({
|
window.localStorage.setItem(ACTIVE_APP_KEY, app.code);
|
||||||
...nav.apps.find((p) => p.active),
|
this.serializeMenu(nav.menus);
|
||||||
menus: nav.menus,
|
}
|
||||||
})
|
|
||||||
);
|
|
||||||
this.serializeMenu(nav.menus);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user