迁移合作订单完整能力,并统一 AppRoleCode 角色权限与首页菜单展示。
新增 CooperationOrder 模块(双 Tab 列表、获客员绑定、主 Tab 扫码)、订单来源/带客单绑定及配套 API 测试;同步引入 roleCode 权限匹配与相关单元测试。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -27,23 +27,18 @@ struct HomeView: View {
|
||||
|
||||
private let commonMenuStore = HomeCommonMenuStore()
|
||||
private let timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect()
|
||||
private let minimalTopRoleIds: Set<Int> = [46, 47, 52, 53, 54]
|
||||
|
||||
private var contentMaxWidth: CGFloat {
|
||||
horizontalSizeClass == .regular ? 760 : .infinity
|
||||
}
|
||||
|
||||
private var currentRoleId: Int? {
|
||||
permissionContext.currentRole?.id
|
||||
}
|
||||
|
||||
private var isStoreManager: Bool {
|
||||
currentRoleId == 46
|
||||
permissionContext.currentAppRole?.isStoreAdmin == true
|
||||
}
|
||||
|
||||
private var shouldShowWorkStatus: Bool {
|
||||
guard let currentRoleId else { return true }
|
||||
return !minimalTopRoleIds.contains(currentRoleId)
|
||||
guard let role = permissionContext.currentAppRole else { return true }
|
||||
return !AppRoleCode.homeMinimalTopRoles.contains(role)
|
||||
}
|
||||
|
||||
private var currentScenicName: String {
|
||||
@ -66,9 +61,8 @@ struct HomeView: View {
|
||||
}
|
||||
|
||||
private var displayMenuItems: [HomeMenuItem] {
|
||||
let selected = commonUris.compactMap(menuItemForHomeEntry(uri:))
|
||||
let fallback = selected.isEmpty ? Array(viewModel.menuItems.prefix(3)) : selected
|
||||
return fallback + [HomeMenuItem(title: "更多功能", uri: "more_functions", iconSrc: nil)]
|
||||
let items = commonUris.compactMap(menuItemForHomeEntry(uri:))
|
||||
return items + [HomeMenuItem(title: "更多功能", uri: "more_functions", iconSrc: nil)]
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@ -113,7 +107,7 @@ struct HomeView: View {
|
||||
guard isOnline, secondsUntilReport > 0 else { return }
|
||||
secondsUntilReport -= 1
|
||||
}
|
||||
.onChange(of: permissionContext.currentRole?.id) { _ in
|
||||
.onChange(of: permissionContext.currentRole?.roleCode) { _ in
|
||||
rebuildMenusFromCurrentContext()
|
||||
}
|
||||
.onChange(of: permissionContext.rolePermissions.count) { _ in
|
||||
@ -412,11 +406,18 @@ struct HomeView: View {
|
||||
}
|
||||
|
||||
private func rebuildMenusFromCurrentContext() {
|
||||
let roleCode = permissionContext.currentAppRole?.rawValue
|
||||
let legacyRoleId = permissionContext.currentRole?.id
|
||||
viewModel.buildMenus(
|
||||
from: permissionContext.rolePermissions,
|
||||
currentRoleId: permissionContext.currentRole?.id
|
||||
currentRoleCode: roleCode
|
||||
)
|
||||
commonUris = commonMenuStore.load(
|
||||
menuItems: viewModel.menuItems,
|
||||
roleCode: roleCode,
|
||||
legacyRoleId: legacyRoleId,
|
||||
topLevelPermissionURIs: permissionContext.topLevelPermissionURIs(for: roleCode)
|
||||
)
|
||||
commonUris = commonMenuStore.load(menuItems: viewModel.menuItems)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user