fix: 接诊UI

This commit is contained in:
李琦
2026-08-07 20:24:49 +08:00
parent 33dcd3f5d8
commit 7a504433da
32 changed files with 2638 additions and 297 deletions

View File

@@ -1,6 +1,6 @@
/**
* VIP 权限判断工具(前端口子)
* 当前从登录态 userInfo.vip 读取;后续可扩展为按 storeId 请求接口
* 默认从登录态 userInfo.vip 读取;在线复诊等场景可传入挂号履约诊所的 vip
*/
import { useUserStore } from '@vben/stores';
@@ -23,11 +23,24 @@ export function getCurrentVip(): StoreVipInfo | null {
return ((userStore.userInfo as any)?.vip as StoreVipInfo) || null;
}
/** 是否拥有指定权限码 */
export function hasVipPermission(code: string): boolean {
/**
* 是否拥有指定权限码
* @param code 权限码
* @param vipOrPermissions 可选:挂号侧 vip 对象,或 permissions 字符串数组;不传则用登录态
*/
export function hasVipPermission(
code: string,
vipOrPermissions?: StoreVipInfo | string[] | null,
): boolean {
if (!code) return false;
const vip = getCurrentVip();
const list = vip?.permissions;
let list: string[] | undefined;
if (Array.isArray(vipOrPermissions)) {
list = vipOrPermissions;
} else if (vipOrPermissions && typeof vipOrPermissions === 'object') {
list = vipOrPermissions.permissions;
} else {
list = getCurrentVip()?.permissions;
}
return Array.isArray(list) && list.includes(code);
}
@@ -35,12 +48,11 @@ export function hasVipPermission(code: string): boolean {
* 等级是否不低于目标(按 level_weight若无 weight 则仅精确匹配编码时返回 true
* 简化:仅当当前 level_code 与 minCode 相同,或 weight 足够时通过
*/
export function levelAtLeast(minCode: string): boolean {
const vip = getCurrentVip();
if (!vip?.level_code) return false;
if (vip.level_code === minCode) return true;
// 无完整等级表时,仅做字符串相等判断;业务侧应以后端 Gate 为准
const weight = Number(vip.level_weight ?? 0);
export function levelAtLeast(minCode: string, vip?: StoreVipInfo | null): boolean {
const current = vip ?? getCurrentVip();
if (!current?.level_code) return false;
if (current.level_code === minCode) return true;
const weight = Number(current.level_weight ?? 0);
const minWeight = parseLevelWeight(minCode);
if (minWeight >= 0) {
return weight >= minWeight;