添加页面

This commit is contained in:
zhengw
2026-02-02 16:58:37 +08:00
parent bdee04ad67
commit 1c0e0b265d
38 changed files with 1575 additions and 10 deletions

View File

@@ -0,0 +1,4 @@
{
"usingComponents": { },
"navigationBarTitleText": "我的权限"
}

View File

@@ -0,0 +1,110 @@
import { loginStatus, post } from '@/utils/https';
import { getAuthInfo, toArray } from '@/utils/util';
Page({
/**
* 页面的初始数据
*/
data: {
list: [] as any[],
},
handleLogin(e: any) {
this.setData({ isLogin: e.detail });
if (e.detail) {
this.init();
}
},
init() {
this.setData({ authInfo: getAuthInfo() });
this.getList();
},
getList() {
post('Groups/myAuth').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.setData({ loading: true });
loginStatus()
.then(() => {
this.setData({ isLogin: true, loading: false });
this.init();
})
.catch((err) => {
this.setData({ isLogin: false, loading: false });
console.log('调用登录状态请求失败', err);
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow() {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {},
});

View File

@@ -0,0 +1,25 @@
<page-plugin isAuth="{{authInfo['SF_ERP_GROUP_VIEW']}}" loading="{{loading}}" is-login="{{isLogin}}"
bind:handleLogin="handleLogin" customStyle="padding-top: 0">
<empty-plugin wx:if="{{list.length == 0}}" />
<view wx:if="{{list.length}}" class="top">
<view class="header">
<view class="name">菜单名称</view>
<view class="name2">目录名称</view>
<view class="functions">权限点</view>
</view>
</view>
<view wx:for="{{list}}" wx:key="menu_id" class="content">
<view class="name">{{item.menu_ch_name}}</view>
<view style="display: flex;flex-direction: column;flex: 1;">
<view wx:for="{{item.children}}" wx:key="menu_id" wx:for-item="item2"
style="display: flex;flex: 1;">
<view class="name2" style="flex-shrink: 0;">{{item2.menu_ch_name}}</view>
<view style="display: flex;" class="functions">
<block wx:for="{{item2.functions}}" wx:key="function_id">
<view wx:if="{{item.web_checked}}">{{item.function_ch_name}}</view>
</block>
</view>
</view>
</view>
</view>
</page-plugin>

View File

@@ -0,0 +1,55 @@
.header,
.content {
display: flex;
font-size: 14px;
border-left: 1rpx solid #ddd;
border-right: 1rpx solid #ddd;
box-sizing: border-box;
}
.header {
border-top: 1rpx solid #ddd;
background: #f5f5f5;
font-weight: bold;
}
.top {
position: sticky;
top: 0;
z-index: 1;
padding-top: 24rpx;
background: #fff;
}
.content {
/* flex-direction: column; */
align-items: stretch;
}
.name,
.name2 {
width: 5.5em;
flex-shrink: 0;
border-bottom: 1rpx solid #ddd;
border-right: 1rpx solid #ddd;
min-width: 0;
display: flex;
align-items: center;
padding: 12rpx 0.5em;
word-break: break-all;
box-sizing: border-box;
}
.name2 {
width: 6.5em;
}
.functions {
border-bottom: 1rpx solid #ddd;
flex: 1;
display: flex;
column-gap: 0.5em;
row-gap: 12rpx;
flex-wrap: wrap;
padding: 0.5em;
}