feat(公司tab): 店铺管理与数据权限分组按成员集筛, 凭据按 id 补读闸门
Task 11: ShopManageController.page / listGroups 接 DataReadScope.readScope, 把 company_id 算出的成员集当参数传给 service(controller 层收口, service 手上 只有 operatorId+布尔); ShopManageGroupService.list 增加 companyMemberIds 腿。 凭据 getCredentialById 的闸门用与 page() 同形的尺子(created_by_id IN creators OR group_id IN groups),不是账号集合 —— 后者表达不了分组那一腿, 会把列表看得见 的行读凭据时 403 掉, 那是把正当访问静默删掉。 新增 testutil/SourceScan 供源码扫描式护栏取文(找不到方法必须抛, 不许返回空串恒绿)。 前端两页接 tab: companyId 取 companyTab.requestCompanyId, 并 watch activeId 重载; G1 登记表给 admin_shop_manage 钉两条发送点(白名单 builder 故意不收 companyId)。 写侧入口一律不收 company_id, 由 ShopManageServiceTest 逐方法反向钉住。
This commit is contained in:
@@ -2,9 +2,10 @@
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
/** 分组管理页 · 像素复刻旧版 admin.html panel-group-manage(自绘:顶部数据权限分组摘要 chips + 分组列表表格 + 新建分组;全量无分页同旧版)。
|
||||
* script 逻辑沿用现有 Vue 实现;编辑器保留现有组件。 */
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
||||
import { deleteShopGroup, fetchShopGroups } from './shop-group-api'
|
||||
import type { ShopGroupItem } from './shop-group-model'
|
||||
@@ -12,6 +13,7 @@ import GroupEditorDialog from './GroupEditorDialog.vue'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
|
||||
const session = useAdminSessionStore()
|
||||
const companyTab = useCompanyTabStore()
|
||||
const loading = ref(false)
|
||||
const rows = ref<ShopGroupItem[]>([])
|
||||
const editorVisible = ref(false)
|
||||
@@ -46,7 +48,7 @@ function canEditOf(group: ShopGroupItem): boolean {
|
||||
async function loadGroups() {
|
||||
loading.value = true
|
||||
try {
|
||||
rows.value = await fetchShopGroups()
|
||||
rows.value = await fetchShopGroups(companyTab.requestCompanyId)
|
||||
} catch (error) {
|
||||
ElMessage.error(error instanceof Error ? error.message : '数据权限分组加载失败')
|
||||
} finally {
|
||||
@@ -54,6 +56,9 @@ async function loadGroups() {
|
||||
}
|
||||
}
|
||||
|
||||
// 切公司 = 重新取数(G1 的 pageFiles 断言盯着这一条)。
|
||||
watch(() => companyTab.activeId, () => void loadGroups())
|
||||
|
||||
function openCreate() {
|
||||
editingGroup.value = null
|
||||
editorVisible.value = true
|
||||
|
||||
@@ -11,8 +11,8 @@ import {
|
||||
|
||||
export const SHOP_GROUPS_ENDPOINT = '/api/admin/shop-manages/groups'
|
||||
|
||||
export async function fetchShopGroups(): Promise<ShopGroupItem[]> {
|
||||
const { data } = await http.get<unknown>(SHOP_GROUPS_ENDPOINT)
|
||||
export async function fetchShopGroups(companyId?: number | null): Promise<ShopGroupItem[]> {
|
||||
const { data } = await http.get<unknown>(SHOP_GROUPS_ENDPOINT, { params: { company_id: companyId } })
|
||||
return parseShopGroupList(data)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
/** 店铺管理页 · 像素复刻旧版 admin.html panel-shop-manage(自绘:面板头+新增店铺、筛选、密码列 ******+眼睛实时读明文、旧式表格/分页、原生 confirm 删除)。
|
||||
* script 逻辑沿用现有 Vue 实现(凭证明文 dialog/编辑弹窗/分组筛选)。 */
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import {
|
||||
deleteShopManage,
|
||||
fetchShopCredential,
|
||||
@@ -18,6 +19,7 @@ import type { ShopCredential, ShopGroupOption, ShopSummary } from './shop-dto.ts
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
|
||||
const session = useAdminSessionStore()
|
||||
const companyTab = useCompanyTabStore()
|
||||
/** 仅超管需要分组维度:非超管数据由后端裁剪到本人分组,分组筛选/列一律不展示。 */
|
||||
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
||||
const loading = ref(false)
|
||||
@@ -75,7 +77,7 @@ async function togglePassword(row: ShopSummary) {
|
||||
|
||||
async function loadGroups() {
|
||||
try {
|
||||
groups.value = await fetchShopManageGroups()
|
||||
groups.value = await fetchShopManageGroups(companyTab.requestCompanyId)
|
||||
} catch (error) {
|
||||
ElMessage.error(error instanceof Error ? error.message : '分组加载失败')
|
||||
}
|
||||
@@ -89,6 +91,7 @@ async function load() {
|
||||
pageSize: pageSize.value,
|
||||
groupId: filter.groupId,
|
||||
shopName: filter.shopName.trim() || undefined,
|
||||
companyId: companyTab.requestCompanyId,
|
||||
})
|
||||
rows.value = result.items
|
||||
total.value = result.total
|
||||
@@ -100,6 +103,9 @@ async function load() {
|
||||
}
|
||||
}
|
||||
|
||||
// 切公司 = 重新取数:列表与分组下拉共用这一个 watch(少一个 = 那半边的 tab 是装饰品)。
|
||||
watch(() => companyTab.activeId, () => { void loadGroups(); void load() })
|
||||
|
||||
function apply() {
|
||||
page.value = 1
|
||||
load()
|
||||
|
||||
@@ -93,6 +93,8 @@ export interface ShopManageListParams {
|
||||
pageSize: number
|
||||
groupId?: number | null
|
||||
shopName?: string
|
||||
/** 公司 tab 的值;normalizeShopListParams 不点名它,只有 api 层能从原始 params 读到。 */
|
||||
companyId?: number | null
|
||||
}
|
||||
|
||||
export interface ShopKeyPageQuery {
|
||||
@@ -105,6 +107,8 @@ export interface ShopManagePageQuery {
|
||||
pageSize: number
|
||||
groupId?: number
|
||||
shopName?: string
|
||||
/** 下划线形:与后端 @RequestParam(name = "company_id") 逐字对齐。 */
|
||||
company_id?: number
|
||||
}
|
||||
|
||||
function finiteInt(value: unknown): number | null {
|
||||
|
||||
@@ -24,15 +24,21 @@ export const SHOP_MANAGE_ENDPOINT = '/api/admin/shop-manages'
|
||||
|
||||
export async function fetchShopManageList(params: Partial<ShopManageListParams> = {}): Promise<ShopPageResult> {
|
||||
const normalized = normalizeShopListParams(params)
|
||||
const { data } = await http.get<unknown>(SHOP_MANAGE_ENDPOINT, { params: toShopManagePageQuery(normalized) })
|
||||
// normalizeShopListParams 与 toShopManagePageQuery 都是白名单构造(不点名 companyId),
|
||||
// 所以公司值只能从原始 params 读:写成 normalized.companyId 是 TS 绿、运行时恒 undefined。
|
||||
const query = toShopManagePageQuery(normalized)
|
||||
if (params.companyId != null) query.company_id = params.companyId
|
||||
const { data } = await http.get<unknown>(SHOP_MANAGE_ENDPOINT, { params: query })
|
||||
return parseShopManagePage(data)
|
||||
}
|
||||
|
||||
export const SHOP_MANAGE_GROUPS_ENDPOINT = '/api/admin/shop-manages/groups'
|
||||
|
||||
/** 加载店铺分组下拉选项(超级管理员取全部,普通管理员由后端限定可访问分组)。 */
|
||||
export async function fetchShopManageGroups(): Promise<ShopGroupOption[]> {
|
||||
const { data } = await http.get<unknown>(SHOP_MANAGE_GROUPS_ENDPOINT)
|
||||
/** 分组下拉:打的是与分组管理页同一个 GET /groups,所以它也必须跟着公司 tab 收窄,
|
||||
* 否则店铺列表窄了、下拉里还选得到别家的组。 */
|
||||
export async function fetchShopManageGroups(companyId?: number | null): Promise<ShopGroupOption[]> {
|
||||
const { data } = await http.get<unknown>(SHOP_MANAGE_GROUPS_ENDPOINT, { params: { company_id: companyId } })
|
||||
return parseShopManageGroups(data)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user