feat(菜单权限): 每家公司一套菜单树(V149)+ 公司 tab 只在注册表页渲染
本批两件事,加上随本批一起入仓的并行会话在制品: 一、菜单权限按公司隔离(批次 6) - V149 给 columns 加 company_id:先可空加列(末位、ALGORITHM=INSTANT)→ 回填公司 1 → MODIFY 收紧 NOT NULL;三段式缺一即撞 1048。同时建 (company_id, column_key) 复合键、 把公司 2 的 16 笔授权按 column_key 改指向它自己的副本,三类 menu_type 全复制, admin_companies 作为角色内生闸门行不复制(D3)。 - 第三道归属门 PermissionMenuService.resolveScopeCompanyId:站点超管可带 company_id 读写任意公司,非超管锁本公司、越界 403。它注册进 CompanyIdParamGoesThroughReadScopeTest 的 SCOPE_DOORS,四条判据与 readScope / readCompanyIdOrOwn 共用——护栏在代码出口,不靠清单。 - 旁路种子 PermissionMenuSchemaInitializer 只种公司 1:31 段种子逐条钉公司, 按 column_key 点查的 14 段全部带 company_id,否则摘了 DEFAULT 就是跨公司串写。 - CompanyService.create 同一次写入里给新公司复制模板树(D4)。 二、公司 tab 收口(批次 b) tab 条挂在壳层,对 22 页全画;改为按正列表 companyTabAppliesTo(menuKey) 判定, 只有注册表页渲染。护栏钉在用户看见的那个出口。 三、并行会话在制品(控制方「全部提交」,未单独拆分——见下) - V150 店铺密钥 biz_shop_key 按公司(readCompanyIdOrOwn + writeCompanyId 两道门) - V151 品牌库/商品类目推翻为全平台共享:只退唯一键、company_id DEFAULT 保留为 NOT NULL 承重约束(摘了每条 1364);删掉 ProductCategoryControllerCompanyScopeTest 那支"按公司隔离"的旧护栏,readCompanyId 方法一并移除 - invalidasin 字段与外观专利合批的连带改动 为什么不拆笔:后端 3891 例 / 0 红、前端 1731 例 / 0 红这两个读数是"合起来的树"的读数, 拆成多笔会让每一笔落到从未一起验过的组合上,而这一版要直接上两台。 回滚脚本在 backend-java/docs/rollback-V149/V150/V151-*.sql,不放进 Flyway 扫描路径。 设计记录:docs/ops/menu-company-tree-design-2026-10-06.md
This commit is contained in:
@@ -155,7 +155,7 @@ async function create(): Promise<void> {
|
||||
</el-form-item>
|
||||
<el-form-item label="菜单权限(勾选上级菜单会继承全部子菜单)">
|
||||
<div class="auth-tree-box">
|
||||
<UserMenuAuthTree v-model:checked="form.columnIds" />
|
||||
<UserMenuAuthTree v-model:checked="form.columnIds" :company-id="form.companyId" />
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
@@ -9,7 +9,9 @@ import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { actionableErrorText } from '@/components/admin-feedback'
|
||||
import UserMenuAuthTree from './UserMenuAuthTree.vue'
|
||||
|
||||
const props = defineProps<{ modelValue: boolean; user: AdminUser | null; operatorSuper?: boolean }>()
|
||||
/** companyId 由 UsersPage 把 companyTab.requestCompanyId 透传进来(本页的用户列表本来就由它筛 ⇒ 目标账号的公司
|
||||
* 就是 tab 选中的那家);弹窗自己不读 store,公司 tab 的取值口只留在页面组件那一处。 */
|
||||
const props = defineProps<{ modelValue: boolean; user: AdminUser | null; operatorSuper?: boolean; companyId?: number | null }>()
|
||||
const emit = defineEmits<{ (e: 'update:modelValue', v: boolean): void; (e: 'updated'): void }>()
|
||||
|
||||
const form = reactive<EditUserForm>({ uid: 0, username: '', password: '', role: 'normal', columnIds: [], originalRole: '', expiresAt: '' })
|
||||
@@ -48,7 +50,7 @@ async function refreshAuth(): Promise<void> {
|
||||
if (!props.user) return
|
||||
loadingAuth.value = true
|
||||
try {
|
||||
const { checkedIds } = await loadUserMenuAuth(props.user.id)
|
||||
const { checkedIds } = await loadUserMenuAuth(props.user.id, props.companyId)
|
||||
form.columnIds = checkedIds
|
||||
authReady.value = true
|
||||
} catch (error) {
|
||||
@@ -133,7 +135,7 @@ async function save(): Promise<void> {
|
||||
</el-form-item>
|
||||
<el-form-item label="菜单权限(勾选上级菜单会继承全部子菜单)">
|
||||
<div class="auth-tree-box">
|
||||
<UserMenuAuthTree v-model:checked="form.columnIds" />
|
||||
<UserMenuAuthTree v-model:checked="form.columnIds" :company-id="props.companyId" />
|
||||
<div v-if="loadingAuth" class="auth-loading">菜单权限加载中…</div>
|
||||
<div v-else-if="!authReady" class="auth-loading auth-loading-error">
|
||||
菜单权限加载失败,保存已禁用;请关闭后重试
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
/** 菜单权限配置页 · 像素复刻旧版 admin.html panel-columns(自绘:面板头+新增菜单、拖拽手柄 ⠿、树形缩进+└、旧式表格、全量无分页同旧版)。
|
||||
* script 逻辑沿用现有 Vue 实现(拖拽分组/落点/重排保存、弹窗表单)。 */
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import { createMenu, deleteMenu, loadMenuManageTree, reorderMenus, updateMenu } from './menu-manage-api'
|
||||
import {
|
||||
MENU_TYPE_OPTIONS,
|
||||
@@ -28,6 +29,7 @@ interface MenuRow extends MenuManageNode {
|
||||
depth: number
|
||||
}
|
||||
|
||||
const companyTab = useCompanyTabStore()
|
||||
const loading = ref(false)
|
||||
const rows = ref<MenuManageNode[]>([])
|
||||
/** 筛选:菜单名称/类型(用户要求账户域子菜单补筛选条件)。 */
|
||||
@@ -84,7 +86,7 @@ function parentNameOf(node: MenuManageNode): string {
|
||||
async function loadMenus() {
|
||||
loading.value = true
|
||||
try {
|
||||
rows.value = await loadMenuManageTree()
|
||||
rows.value = await loadMenuManageTree(companyTab.requestCompanyId)
|
||||
} catch (error) {
|
||||
ElMessage.error(error instanceof Error ? error.message : '菜单列表加载失败')
|
||||
} finally {
|
||||
@@ -175,7 +177,7 @@ async function saveMenu() {
|
||||
await updateMenu(editingNode.value.id, menuForm)
|
||||
ElMessage.success('保存成功')
|
||||
} else {
|
||||
await createMenu(menuForm)
|
||||
await createMenu(menuForm, companyTab.requestCompanyId)
|
||||
ElMessage.success('创建成功')
|
||||
}
|
||||
createVisible.value = false
|
||||
@@ -204,6 +206,11 @@ async function removeMenu(node: MenuManageNode) {
|
||||
}
|
||||
}
|
||||
|
||||
/** 切公司:菜单名称/类型是客户端筛选(在 filteredMenuRows 上筛,不进请求),留着上一家填的值
|
||||
* 就是拿别家的字符串去筛新一家那一套树 ⇒ 首屏「暂无匹配菜单」而输入框里还显示着它;页码回 1
|
||||
* 是因为新一家的行数不同。末尾的 void loadMenus() 才是本页唯一的数据出口。 */
|
||||
watch(() => companyTab.activeId, () => { filterName.value = ''; filterType.value = ''; page.value = 1; void loadMenus() })
|
||||
|
||||
onMounted(loadMenus)
|
||||
</script>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { MenuOptionNode } from './user-menu-auth'
|
||||
import { compactDirectGrantIds } from './user-menu-auth'
|
||||
import { fetchGrantableMenus } from './user-menu-auth-api'
|
||||
|
||||
const props = defineProps<{ checked?: number[] }>()
|
||||
const props = defineProps<{ checked?: number[]; companyId?: number | null }>()
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:checked', ids: number[]): void
|
||||
(e: 'load', ok: boolean): void
|
||||
@@ -42,7 +42,7 @@ function onCheck(): void {
|
||||
|
||||
async function load(): Promise<void> {
|
||||
try {
|
||||
data.value = await fetchGrantableMenus()
|
||||
data.value = await fetchGrantableMenus(props.companyId)
|
||||
loaded.value = true
|
||||
emit('load', true)
|
||||
// el-tree 的 store 通过异步 watch 同步 props.data,setCheckedKeys 必须等树
|
||||
@@ -62,6 +62,12 @@ watch(
|
||||
if (loaded.value) applyChecked()
|
||||
},
|
||||
)
|
||||
/** 公司换了要整棵重取:勾选集里存的是 column id,别家同名菜单是另一份 id(V149 每公司一套树),
|
||||
* 拿别家的树勾出来的 id 提交会被后端判「无效的菜单权限项」,而已授权项也因为 id 不在这棵树上勾不上。 */
|
||||
watch(
|
||||
() => props.companyId,
|
||||
() => { void load() },
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -260,7 +260,7 @@ onMounted(() => {
|
||||
:company-options="companyOptions"
|
||||
@created="loadUsers"
|
||||
/>
|
||||
<EditUserDialog v-model="editVisible" :user="editUser" :operator-super="isSuperAdmin" @updated="loadUsers" />
|
||||
<EditUserDialog v-model="editVisible" :user="editUser" :operator-super="isSuperAdmin" :company-id="companyTab.requestCompanyId" @updated="loadUsers" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -14,20 +14,27 @@ import {
|
||||
export const MENUS_ENDPOINT = '/api/admin/permission-menus'
|
||||
export const REORDER_ENDPOINT = '/api/admin/column/reorder'
|
||||
|
||||
/** 拉取扁平可编辑菜单节点(全量类型,对齐 admin.js loadColumns 的 /api/admin/columns 语义)。 */
|
||||
export async function fetchMenuManageNodes(): Promise<MenuManageNode[]> {
|
||||
const { data } = await http.get<unknown>(MENUS_ENDPOINT)
|
||||
/** 拉取扁平可编辑菜单节点(全量类型,对齐 admin.js loadColumns 的 /api/admin/columns 语义)。
|
||||
* 公司 tab 的值由调用方(MenusPage)传 companyTab.requestCompanyId:菜单字典 2026-10-06 起每家公司一套树,
|
||||
* 不带 company_id 时非超管恒锁本公司、超管拿到的是全部公司的行(两排同名菜单)。 */
|
||||
export async function fetchMenuManageNodes(companyId?: number | null): Promise<MenuManageNode[]> {
|
||||
const query: Record<string, string | number> = {}
|
||||
if (companyId != null) query.company_id = companyId
|
||||
const { data } = await http.get<unknown>(MENUS_ENDPOINT, { params: query })
|
||||
return parseMenuManageList(data)
|
||||
}
|
||||
|
||||
/** 拉取并按 parentId 组装成展示树。 */
|
||||
export async function loadMenuManageTree(): Promise<MenuManageNode[]> {
|
||||
return buildMenuManageTree(await fetchMenuManageNodes())
|
||||
export async function loadMenuManageTree(companyId?: number | null): Promise<MenuManageNode[]> {
|
||||
return buildMenuManageTree(await fetchMenuManageNodes(companyId))
|
||||
}
|
||||
|
||||
/** 新建菜单:POST /api/admin/permission-menus,返回后端落库节点。 */
|
||||
export async function createMenu(form: MenuManageForm): Promise<MenuManageNode> {
|
||||
const { data } = await http.post<unknown>(MENUS_ENDPOINT, toMenuCreateRequest(form))
|
||||
/** 新建菜单:POST /api/admin/permission-menus,返回后端落库节点。
|
||||
* 归属由端点的 company_id 决定(缺省=操作者本公司),前端不靠从树里猜。 */
|
||||
export async function createMenu(form: MenuManageForm, companyId?: number | null): Promise<MenuManageNode> {
|
||||
const query: Record<string, string | number> = {}
|
||||
if (companyId != null) query.company_id = companyId
|
||||
const { data } = await http.post<unknown>(MENUS_ENDPOINT, toMenuCreateRequest(form), { params: query })
|
||||
const created = parseMenuManageItem(unwrap<unknown>(data))
|
||||
if (!created) throw new Error('创建菜单响应异常:缺少菜单数据')
|
||||
return created
|
||||
|
||||
@@ -18,11 +18,18 @@ export const USER_PERMISSION_COLUMNS_ENDPOINT = '/api/admin/permission-users'
|
||||
/**
|
||||
* 拉取可授权菜单树(后台 admin + 前端客户端 app 两类合并,按 sort 排序)。
|
||||
* grantableOnly:非超管只拿到自己已持有的菜单,范围外的项后端不再下发。
|
||||
* <p>companyId 传 companyTab.requestCompanyId:2026-10-06 起每家公司一套菜单树,同一 column_key 在
|
||||
* 别家有一份**不同 id** 的副本。这一页的授权载荷提交的是 column id,树取错公司就等于
|
||||
* 把别家的 id 授给本公司账号(后端按「id 必须在被授权账号自己的树里」拒 ⇒ 保存必然失败,
|
||||
* 而已授权项因为 id 对不上树根本勾不上,看上去像"这个人一条权限都没有")。
|
||||
* null(非超管、或建号时没指定公司)由后端锁到操作者本公司。
|
||||
*/
|
||||
export async function fetchGrantableMenus(): Promise<MenuOptionNode[]> {
|
||||
export async function fetchGrantableMenus(companyId?: number | null): Promise<MenuOptionNode[]> {
|
||||
const query: Record<string, string | number> = {}
|
||||
if (companyId != null) query.company_id = companyId
|
||||
const [adminRes, appRes] = await Promise.all([
|
||||
http.get<unknown>(GRANT_MENUS_ENDPOINT, { params: { menuType: ADMIN_MENU_TYPE, grantableOnly: true } }),
|
||||
http.get<unknown>(GRANT_MENUS_ENDPOINT, { params: { menuType: APP_MENU_TYPE, grantableOnly: true } }),
|
||||
http.get<unknown>(GRANT_MENUS_ENDPOINT, { params: { ...query, menuType: ADMIN_MENU_TYPE, grantableOnly: true } }),
|
||||
http.get<unknown>(GRANT_MENUS_ENDPOINT, { params: { ...query, menuType: APP_MENU_TYPE, grantableOnly: true } }),
|
||||
])
|
||||
const nodes = [
|
||||
...parseMenuOptionList(adminRes.data, ADMIN_MENU_TYPE),
|
||||
@@ -53,8 +60,8 @@ export interface UserMenuAuthData {
|
||||
checkedIds: number[]
|
||||
}
|
||||
|
||||
export async function loadUserMenuAuth(userId: number): Promise<UserMenuAuthData> {
|
||||
const [tree, checkedIds] = await Promise.all([fetchGrantableMenus(), fetchUserGrantedColumnIds(userId)])
|
||||
export async function loadUserMenuAuth(userId: number, companyId?: number | null): Promise<UserMenuAuthData> {
|
||||
const [tree, checkedIds] = await Promise.all([fetchGrantableMenus(companyId), fetchUserGrantedColumnIds(userId)])
|
||||
return { tree, checkedIds }
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import { formatDateTime } from '@/utils/datetime'
|
||||
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 { createInvalidAsin, deleteInvalidAsin, fetchInvalidAsinPage, updateInvalidAsin } from '../invalidasin/invalid-asin-api.ts'
|
||||
import type { InvalidAsinItem } from '../invalidasin/invalid-asin-model.ts'
|
||||
import { invalidAsinDeleteText, invalidAsinLockedGroupId, recordSourceLabel } from '../invalidasin/invalid-asin-model.ts'
|
||||
@@ -15,7 +14,6 @@ import type { ShopGroupOption } from '../shop/shop-dto.ts'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
|
||||
const session = useAdminSessionStore()
|
||||
const companyTab = useCompanyTabStore()
|
||||
const loading = ref(false)
|
||||
const rows = ref<InvalidAsinItem[]>([])
|
||||
const total = ref(0)
|
||||
@@ -46,7 +44,7 @@ const groupOptions = computed<ShopGroupOption[]>(() => {
|
||||
|
||||
async function loadGroups() {
|
||||
try {
|
||||
groups.value = await fetchShopManageGroups(companyTab.requestCompanyId)
|
||||
groups.value = await fetchShopManageGroups()
|
||||
} catch {
|
||||
groups.value = []
|
||||
}
|
||||
@@ -65,7 +63,6 @@ async function load() {
|
||||
dataValue: filter.dataValue.trim() || undefined,
|
||||
brand: filter.brand.trim() || undefined,
|
||||
groupId: filter.groupId,
|
||||
companyId: companyTab.requestCompanyId,
|
||||
})
|
||||
rows.value = result.items
|
||||
total.value = result.total
|
||||
@@ -163,10 +160,6 @@ watch(isSuperAdmin, () => {
|
||||
if (isSuperAdmin.value) filter.groupId = null
|
||||
})
|
||||
|
||||
// 切公司 = 重新取数:列表与分组下拉共用这一个 watch(少一个 = 那半边的 tab 是装饰品)。
|
||||
// groupId 必须一起清掉:上一家选中的分组在新一家根本不存在,留着会把切 tab 后的首屏筛成空列表。
|
||||
watch(() => companyTab.activeId, () => { filter.groupId = null; void loadGroups(); void load() })
|
||||
|
||||
onMounted(() => {
|
||||
loadGroups()
|
||||
load()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
/** 商品类目 · 像素复刻旧版 admin.html panel-product-categories(自绘:面板头搜索框组+新增类目 同行、原生树表格[+/−]折叠+懒加载「加载更多 已加载 x/y」、搜索态旧式分页)。
|
||||
* script 逻辑沿用现有 Vue 实现(懒加载树/编辑删除/导出/弹窗)。 */
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { fetchProductCategoryChildren, searchProductCategories } from './product-category-api.ts'
|
||||
import { createProductCategory, deleteProductCategory, updateProductCategory } from './product-category-editor-api.ts'
|
||||
@@ -17,9 +17,7 @@ import { categoryDraftError, createProductCategoryDraft, toCategorySaveRequest,
|
||||
import { buildProductCategoryExportUrl } from './product-category-export.ts'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
|
||||
const companyTab = useCompanyTabStore()
|
||||
const loading = ref(false)
|
||||
const tree = ref<ProductCategoryNode[]>([])
|
||||
const keyword = ref('')
|
||||
@@ -70,7 +68,7 @@ const rootTotal = ref(0)
|
||||
async function loadTree(): Promise<void> {
|
||||
loading.value = true
|
||||
try {
|
||||
const result = await fetchProductCategoryChildren(null, rootPage.value, rootPageSize.value, companyTab.requestCompanyId)
|
||||
const result = await fetchProductCategoryChildren(null, rootPage.value, rootPageSize.value)
|
||||
const state = { page: result.page, total: result.total, hasMore: result.hasMore, loading: false }
|
||||
childrenState.set(ROOT_KEY, state)
|
||||
// 顶层当前页直接作为树根(不含合成「加载更多」节点,翻页由 OldPagination 承担)。
|
||||
@@ -146,7 +144,7 @@ async function loadChildrenPage(parent: ProductCategoryNode | null, page: number
|
||||
if (state?.loading) return
|
||||
childrenState.set(key, { page: state?.page ?? 0, total: state?.total ?? 0, hasMore: state?.hasMore ?? false, loading: true })
|
||||
try {
|
||||
const result = await fetchProductCategoryChildren(parent?.id ?? null, page, PRODUCT_CATEGORY_DEFAULT_PAGE_SIZE, companyTab.requestCompanyId)
|
||||
const result = await fetchProductCategoryChildren(parent?.id ?? null, page, PRODUCT_CATEGORY_DEFAULT_PAGE_SIZE)
|
||||
const loaded = append ? (state?.page ?? 0) + result.items.length : result.items.length
|
||||
const nextState = { page: result.page, total: result.total, hasMore: result.hasMore, loading: false }
|
||||
childrenState.set(key, nextState)
|
||||
@@ -197,7 +195,7 @@ function changeSearchSize(size: number) {
|
||||
async function runSearch(page: number): Promise<void> {
|
||||
searchLoading.value = true
|
||||
try {
|
||||
const result = await searchProductCategories(keyword.value, page, searchPageSize.value, companyTab.requestCompanyId)
|
||||
const result = await searchProductCategories(keyword.value, page, searchPageSize.value)
|
||||
searchRows.value = result.items
|
||||
searchTotal.value = result.total
|
||||
searchPage.value = result.page
|
||||
@@ -299,17 +297,13 @@ async function submit(): Promise<void> {
|
||||
|
||||
function exportCategories(): void {
|
||||
const anchor = document.createElement('a')
|
||||
anchor.href = buildProductCategoryExportUrl(keyword.value, companyTab.requestCompanyId)
|
||||
anchor.href = buildProductCategoryExportUrl(keyword.value)
|
||||
document.body.appendChild(anchor)
|
||||
anchor.click()
|
||||
anchor.remove()
|
||||
ElMessage.success('类目导出已开始下载')
|
||||
}
|
||||
|
||||
// 切公司 = 重新取数。childrenState/expandedIds 必须一起清:这两份是**上一家**的懒加载分页缓存与展开集,
|
||||
// 留着会把别家的子级行画进新一家的树里(同一个父级 id 在两家的子集不同),而请求本身是对的。
|
||||
watch(() => companyTab.activeId, () => { childrenState.clear(); expandedIds.value = new Set(); selected.value = null; rootPage.value = 1; void (searching.value ? runSearch(1) : loadTree()) })
|
||||
|
||||
onMounted(loadTree)
|
||||
</script>
|
||||
|
||||
@@ -332,14 +326,14 @@ onMounted(loadTree)
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 34%">类目</th>
|
||||
<th>层级路径</th>
|
||||
<th style="width: 90px">排序</th>
|
||||
<th style="width: 120px">来源</th>
|
||||
<th>备注</th>
|
||||
<th style="width: 170px">创建时间</th>
|
||||
<th style="width: 170px">更新时间</th>
|
||||
<th style="width: 150px">操作</th>
|
||||
<th style="width: 220px">类目</th>
|
||||
<th style="width: 230px">层级路径</th>
|
||||
<th style="width: 66px">排序</th>
|
||||
<th style="width: 82px">来源</th>
|
||||
<th style="width: 170px">备注</th>
|
||||
<th style="width: 154px">创建时间</th>
|
||||
<th style="width: 154px">更新时间</th>
|
||||
<th style="width: 148px">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody v-if="!searching">
|
||||
@@ -598,7 +592,10 @@ h3 {
|
||||
table-layout: fixed;
|
||||
}
|
||||
.category-table-scroll > table {
|
||||
min-width: 860px;
|
||||
/* table-layout:fixed 下,没写宽度的列在容器变窄时第一个被压到 0(10-06 截图:层级路径只剩一个字、
|
||||
备注只剩破折号)。承重的是 thead 里 8 列全部显式 px 定宽;这个下限与它们成对维护,
|
||||
数值由 tests/align-product-category.test.ts 从 markup 现算比对,改列宽要同时改这里。 */
|
||||
min-width: 1224px;
|
||||
}
|
||||
.table-scroll th,
|
||||
.table-scroll td {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/** 商品类目树/搜索适配(任务 78):GET /api/admin/product-categories(+keyword) 与 /product-categories/search。 */
|
||||
/** 商品类目树/搜索适配(任务 78):GET /api/admin/product-categories(+keyword) 与 /product-categories/search。
|
||||
* 2026-10-06 起这一页全平台共享:三个取数口都不带 company_id。 */
|
||||
import { http } from '@/api/http'
|
||||
import {
|
||||
parseProductCategoryList,
|
||||
@@ -11,10 +12,9 @@ import {
|
||||
export const PRODUCT_CATEGORY_ENDPOINT = '/api/admin/product-categories'
|
||||
|
||||
/** 拉取类目树(keyword 非空时由服务端过滤并保留父路径)。 */
|
||||
export async function fetchProductCategoryTree(keyword = '', companyId?: number | null): Promise<ProductCategoryListResult> {
|
||||
export async function fetchProductCategoryTree(keyword = ''): Promise<ProductCategoryListResult> {
|
||||
const trimmed = keyword.trim()
|
||||
const params: Record<string, string | number> = trimmed ? { keyword: trimmed } : {}
|
||||
if (companyId != null) params.company_id = companyId
|
||||
const { data } = await http.get<unknown>(PRODUCT_CATEGORY_ENDPOINT, { params })
|
||||
return parseProductCategoryList(data)
|
||||
}
|
||||
@@ -24,12 +24,10 @@ export async function searchProductCategories(
|
||||
keyword: string,
|
||||
page: number,
|
||||
pageSize: number,
|
||||
companyId?: number | null,
|
||||
): Promise<ProductCategorySearchPage> {
|
||||
const params: Record<string, string | number> = { page, page_size: pageSize }
|
||||
const trimmed = keyword.trim()
|
||||
if (trimmed) params.keyword = trimmed
|
||||
if (companyId != null) params.company_id = companyId
|
||||
const { data } = await http.get<unknown>(`${PRODUCT_CATEGORY_ENDPOINT}/search`, { params })
|
||||
return parseProductCategorySearchPage(data)
|
||||
}
|
||||
@@ -47,11 +45,9 @@ export async function fetchProductCategoryChildren(
|
||||
parentId: number | null,
|
||||
page: number,
|
||||
pageSize: number,
|
||||
companyId?: number | null,
|
||||
): Promise<ProductCategoryChildrenPage> {
|
||||
const params: Record<string, string | number> = { page, page_size: pageSize }
|
||||
if (parentId != null) params.parent_id = parentId
|
||||
if (companyId != null) params.company_id = companyId
|
||||
const { data } = await http.get<unknown>(`${PRODUCT_CATEGORY_ENDPOINT}/children`, { params })
|
||||
const parsed = parseProductCategorySearchPage(data)
|
||||
return { items: parsed.items, total: parsed.total, page: parsed.page, hasMore: parsed.hasMore }
|
||||
|
||||
@@ -3,11 +3,10 @@
|
||||
export const PRODUCT_CATEGORY_EXPORT_ENDPOINT = '/api/admin/product-categories/export'
|
||||
|
||||
/** 导出下载地址:浏览器直接访问该 URL 触发流式下载。
|
||||
* company_id 与列表同源:导出走的是同一个服务口径,不带它就是把别家类目写进同一份 XLSX。 */
|
||||
export function buildProductCategoryExportUrl(keyword: string, companyId?: number | null): string {
|
||||
* 与列表同源:导出走的是同一个服务口径。这一页 2026-10-06 起全平台共享,不带 company_id。 */
|
||||
export function buildProductCategoryExportUrl(keyword: string): string {
|
||||
const params: string[] = []
|
||||
const trimmed = (keyword || '').trim()
|
||||
if (trimmed) params.push(`keyword=${encodeURIComponent(trimmed)}`)
|
||||
if (companyId != null) params.push(`company_id=${companyId}`)
|
||||
return params.length ? `${PRODUCT_CATEGORY_EXPORT_ENDPOINT}?${params.join('&')}` : PRODUCT_CATEGORY_EXPORT_ENDPOINT
|
||||
}
|
||||
|
||||
@@ -12,8 +12,6 @@ export interface InvalidAsinQuery {
|
||||
dataValue?: string
|
||||
brand?: string
|
||||
groupId?: number | null
|
||||
/** 公司 tab 的值;toQuery 是白名单构造、不点名它,所以由发送口从原始 query 读。 */
|
||||
companyId?: number | null
|
||||
}
|
||||
|
||||
function trimOrUndefined(value: unknown): string | undefined {
|
||||
@@ -31,11 +29,8 @@ function toQuery(query: InvalidAsinQuery): Record<string, string | number> {
|
||||
}
|
||||
|
||||
export async function fetchInvalidAsinPage(query: InvalidAsinQuery): Promise<InvalidAsinPageResult> {
|
||||
// 公司值落在 toQuery 之后、发请求之前的唯一一处:toQuery 是白名单构造(只点名 page/data_value/brand/group_id),
|
||||
// 所以这里必须从原始 query 读 companyId——从 toQuery 的结果里读是 undefined,请求照发、参数没有。
|
||||
const params = toQuery(query)
|
||||
if (query.companyId != null) params.company_id = query.companyId
|
||||
const { data } = await http.get<unknown>(INVALID_ASIN_ENDPOINT, { params })
|
||||
// 这一页 2026-10-06 起全平台共享:请求里不许出现 company_id(后端唯一键退回全局见 V151)。
|
||||
const { data } = await http.get<unknown>(INVALID_ASIN_ENDPOINT, { params: toQuery(query) })
|
||||
return parseInvalidAsinPage(data)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,16 @@
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
/** 店铺密钥管理页 · 像素复刻旧版 admin.html panel-shop-keys(自绘:面板头+新增店铺密钥、序号列、令牌掩码、白名单状态药丸+悬停详情、旧式分页)。
|
||||
* script 逻辑沿用现有 Vue 实现(编辑留空令牌=沿用);弹窗保留现有组件。 */
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import { fetchShopKeyList, submitCreateShopKey, updateShopKey, deleteShopKey, checkShopKeyWhitelist } from './shop-key-api.ts'
|
||||
import { emptyShopKeyForm, normalizeZiniaoToken, validateProxyUrl } from './shop-key-form-model.ts'
|
||||
import type { ShopKeyItem } from './shop-dto.ts'
|
||||
import { whitelistStatusMeta } from './shop-key-model.ts'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
|
||||
const companyTab = useCompanyTabStore()
|
||||
const loading = ref(false)
|
||||
const rows = ref<ShopKeyItem[]>([])
|
||||
const total = ref(0)
|
||||
@@ -56,7 +58,11 @@ function whitelistTooltip(row: ShopKeyItem): string {
|
||||
async function load() {
|
||||
loading.value = true
|
||||
try {
|
||||
const result = await fetchShopKeyList({ page: page.value, pageSize: pageSize.value })
|
||||
const result = await fetchShopKeyList({
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
companyId: companyTab.requestCompanyId,
|
||||
})
|
||||
rows.value = result.items
|
||||
total.value = result.total
|
||||
page.value = result.page
|
||||
@@ -172,6 +178,8 @@ function goJump() {
|
||||
changePage(Math.min(Math.max(n, 1), totalPages.value))
|
||||
}
|
||||
|
||||
watch(() => companyTab.activeId, () => { filterKeyword.value = ''; page.value = 1; void load() })
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
|
||||
|
||||
@@ -81,10 +81,12 @@ export interface ShopGroupOption {
|
||||
leaderUsername?: string
|
||||
}
|
||||
|
||||
/** 店铺密钥列表分页参数(该接口只支持分页)。 */
|
||||
/** 店铺密钥列表分页参数(分页 + 公司 tab;归一是白名单构造,不点名 companyId)。 */
|
||||
export interface ShopKeyListParams {
|
||||
page: number
|
||||
pageSize: number
|
||||
/** 公司 tab 的值;normalizeKeyListParams 不点名它,只有 api 层能从原始 params 读到。 */
|
||||
companyId?: number | null
|
||||
}
|
||||
|
||||
/** 店铺列表分页/筛选参数。 */
|
||||
@@ -100,6 +102,8 @@ export interface ShopManageListParams {
|
||||
export interface ShopKeyPageQuery {
|
||||
page: number
|
||||
pageSize: number
|
||||
/** 下划线形:与后端 @RequestParam(name = "company_id") 逐字对齐。 */
|
||||
company_id?: number
|
||||
}
|
||||
|
||||
export interface ShopManagePageQuery {
|
||||
|
||||
@@ -19,7 +19,11 @@ export const SHOP_KEYS_ENDPOINT = '/api/admin/shop-keys'
|
||||
|
||||
export async function fetchShopKeyList(params: Partial<ShopKeyListParams> = {}): Promise<ShopKeyPageResult> {
|
||||
const normalized = normalizeKeyListParams(params)
|
||||
const { data } = await http.get<unknown>(SHOP_KEYS_ENDPOINT, { params: toKeyPageQuery(normalized) })
|
||||
// normalizeKeyListParams 与 toKeyPageQuery 都是白名单构造(不点名 companyId),
|
||||
// 所以公司值只能从原始 params 读:写成 normalized.companyId 是 TS 绿、运行时恒 undefined。
|
||||
const query = toKeyPageQuery(normalized)
|
||||
if (params.companyId != null) query.company_id = params.companyId
|
||||
const { data } = await http.get<unknown>(SHOP_KEYS_ENDPOINT, { params: query })
|
||||
return parseShopKeyPage(data)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user