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

115 lines
2.7 KiB
TypeScript
Raw Normal View History

import { onPageLoadInitAuth, 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: '',
isLogin: false,
2026-02-02 16:58:37 +08:00
},
handleLogin(e: any) {
this.setData({ isLogin: e.detail });
if (e.detail) {
this.init();
this.getList();
2026-02-02 16:58:37 +08:00
}
},
init() {
this.setData({ authInfo: getAuthInfo() });
},
getList() {
return new Promise<void>((resolve, reject) => {
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;
2026-02-02 16:58:37 +08:00
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;
}
});
2026-02-02 16:58:37 +08:00
if (flag) {
arr.push({
menu_ch_name: menu2.menu_ch_name,
menu_id: menu2.menu_id,
functions: toArray(menu2.children),
});
}
2026-02-02 16:58:37 +08:00
});
if (arr.length) {
this.data.list.push({
menu_ch_name: menu.menu_ch_name,
menu_id: menu.menu_id,
children: arr,
});
}
2026-02-02 16:58:37 +08:00
});
// console.log(this.data.list);
this.setData({ list: this.data.list, isLogin: true });
resolve(res);
})
.catch((res) => {
this.setData({ isLogin: false });
reject(res);
});
2026-02-02 16:58:37 +08:00
});
},
/**
* --
*/
onLoad(options) {
this.data.group_id = `${options.group_id}`;
wx.setNavigationBarTitle({ title: `${decodeURIComponent(`${options.name}`)} 权限` });
onPageLoadInitAuth(this, () => this.getList());
2026-02-02 16:58:37 +08:00
},
/**
* --
*/
onReady() {},
/**
* --
*/
onShow() {},
/**
* --
*/
onHide() {},
/**
* --
*/
onUnload() {},
/**
* --
*/
onPullDownRefresh() {},
/**
*
*/
onReachBottom() {},
/**
*
*/
onShareAppMessage() {},
});