Files
FreeERP.Applet/miniprogram/pages/manage/groupDetail/groupDetail.ts

106 lines
2.3 KiB
TypeScript
Raw Normal View History

2026-02-06 15:30:07 +08:00
import { loginStatusPage, post } from '@/utils/https';
2026-02-02 16:58:37 +08:00
import { getAuthInfo, toArray } from '@/utils/util';
Page({
/**
*
*/
data: {
list: [] as any[],
group_id: '',
},
handleLogin(e: any) {
this.setData({ isLogin: e.detail });
if (e.detail) {
this.init();
}
},
init() {
this.setData({ authInfo: getAuthInfo() });
this.getList();
},
getList() {
post('Groups/getGrpRights', { group_id: this.data.group_id }).then((res: any) => {
const list = toArray(res.right_tree);
const rights = `${res.rights || ''}`.split(',');
this.data.list.length = 0;
toArray(list).forEach((menu) => {
const arr: any[] = [];
toArray(menu.children).forEach((menu2) => {
let flag = false;
toArray(menu2.children).forEach((fun) => {
fun.web_checked = rights.includes(`${fun.function_id}`);
if (fun.web_checked) {
flag = true;
}
});
if (flag) {
arr.push({
menu_ch_name: menu2.menu_ch_name,
menu_id: menu2.menu_id,
functions: toArray(menu2.children),
});
}
});
if (arr.length) {
this.data.list.push({
menu_ch_name: menu.menu_ch_name,
menu_id: menu.menu_id,
children: arr,
});
}
});
// console.log(this.data.list);
this.setData({ list: this.data.list });
});
},
/**
* --
*/
onLoad(options) {
this.data.group_id = `${options.group_id}`;
wx.setNavigationBarTitle({ title: `${decodeURIComponent(`${options.name}`)} 权限` });
2026-02-06 15:30:07 +08:00
loginStatusPage(this);
2026-02-02 16:58:37 +08:00
},
/**
* --
*/
onReady() {},
/**
* --
*/
onShow() {},
/**
* --
*/
onHide() {},
/**
* --
*/
onUnload() {},
/**
* --
*/
onPullDownRefresh() {},
/**
*
*/
onReachBottom() {},
/**
*
*/
onShareAppMessage() {},
});