feat(admin): 批量删除并入筛选行省一整行+公司管理加删除/批量删除(2026-11-23 用户口径)
- BatchDeleteActions margin-left:auto 右对齐、不再独占一行,14 页迁入各自筛选/工具行(Users/Groups/Menus/UserSecrets/QueryAsin/AsinInvalid/SkipPrice/DedupeRegistry/ProductCategory/DeviceLogs/DigitalHuman/ShopManage/ShopKeys/BrandGating);主按钮沿用全局 34px 同高,align-batch-toolbar-inline.test.ts 钉形状防回归
- 公司删除:DELETE /api/admin/companies/{id}(仅超管,名下有账号拒并带数量),只收公司行+columns 菜单树(PermissionMenuService.deleteTreeByCompany 与 copyTreeFromTemplate 对称),业务数据不级联;列表 VO 带 user_count 供前端置灰勾选/删除按钮;批量删除按用户管理同形走前端逐条循环
- CompaniesPage 加勾选列+行删除按钮(ops-cell 补 flex-wrap 过 ops-cell-must-wrap),删除后 refreshCompanyDirectory 同步 tab 条
- 测试:CompanyServiceDeleteTest 6+PermissionMenuServiceDeleteTreeTest 2+CompanyVoTest user_count 契约+CompanyControllerEndpointTest 翻转 exposesNoDeleteEndpoint→点名 DELETE 端点+CompanyReadPathMenuGateTest ensureSuperAdmin 3→4(delete 入册)+company-directory/row-buttons 补例;source-pin 基线重生成(265 文件/1859 例)
- 验证:admin-vue vue-tsc rc=0、node --test 1976 全绿、vitest mount 247 全绿;backend test-compile rc=0、Company*/PermissionMenu*/跨切守卫点名全绿(CatchSilenceRatchet 红因=另一路在飞件 JdPublishFillAiService 3 个 catch,归属京东窗不代抬)
This commit is contained in:
@@ -1,15 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
/** 公司管理(设计文档 §2.3):列表 + 新建 + 改名/启停。
|
||||
/** 公司管理(设计文档 §2.3):列表 + 新建 + 改名/启停 + 删除/批量删除(2026-11-23,名下有账号不能删)。
|
||||
* 可见范围由后端收窄(超管全部、公司内 admin 只自己公司);写操作仅超管,这里隐藏入口只是配合,
|
||||
* 真正的把关在 CompanyController,页面不得当作权限边界。 */
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
import { fetchCompanies } from '@/api/companies'
|
||||
import { useRowSelection } from '@/utils/use-row-selection'
|
||||
import { deleteCompany, fetchCompanies } from '@/api/companies'
|
||||
import { COMPANY_STATUS_ACTIVE, type CompanyItem } from '@/api/companies-dto'
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
import { refreshCompanyDirectory } from '@/stores/company-tab'
|
||||
import { usePlatformTabStore } from '@/stores/platform-tab'
|
||||
import BatchDeleteActions from '@/components/BatchDeleteActions.vue'
|
||||
import BatchDeleteCheckbox from '@/components/BatchDeleteCheckbox.vue'
|
||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import CompanyEditorDialog from './CompanyEditorDialog.vue'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
@@ -61,16 +66,58 @@ function openEdit(company: CompanyItem) {
|
||||
editorVisible.value = true
|
||||
}
|
||||
|
||||
/** 删除前置闸(勾选框置灰与删除按钮共用同一份理由;后端删除时还有权威校验兜底)。 */
|
||||
function deleteBlockReasonOf(company: CompanyItem): string | undefined {
|
||||
if (!canManage.value) return '只有超级管理员可以删除公司'
|
||||
const userCount = company.userCount ?? 0
|
||||
if (userCount > 0) return `该公司名下还有 ${userCount} 个账号,请先删除或转移后再删除公司`
|
||||
return undefined
|
||||
}
|
||||
|
||||
async function reloadCompaniesAndDirectory() {
|
||||
await loadCompanies()
|
||||
refreshCompanyDirectory().catch((error: unknown) => {
|
||||
console.warn('[company-tab] 公司变动后目录重拉失败', error)
|
||||
})
|
||||
}
|
||||
|
||||
const batch = useRowSelection({
|
||||
pageRows: () => pagedRows.value,
|
||||
rowId: (row) => row.id,
|
||||
rowLabel: (row) => row.companyName || `公司 ${row.id}`,
|
||||
deleteOne: (id) => deleteCompany(id),
|
||||
refresh: reloadCompaniesAndDirectory,
|
||||
blocked: () => loading.value || !!loadFailure.value,
|
||||
scope: () => [platformTab.active],
|
||||
precheck: (row) => deleteBlockReasonOf(row),
|
||||
})
|
||||
|
||||
async function removeCompany(company: CompanyItem) {
|
||||
if (batch.busy) return
|
||||
const reason = deleteBlockReasonOf(company)
|
||||
if (reason) {
|
||||
showAdminFeedback(reason, 'error')
|
||||
return
|
||||
}
|
||||
// 对齐分组管理:统一确认出口,删除不做级联(账号与业务数据留在各自页面处理)。
|
||||
if (!(await openAdminConfirm({ message: `确定删除公司“${company.companyName || company.id}”吗?删除后不可恢复。`, danger: true }))) return
|
||||
try {
|
||||
await deleteCompany(company.id)
|
||||
batch.removeFromSelection(company.id)
|
||||
ElMessage.success('删除成功')
|
||||
await reloadCompaniesAndDirectory()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
||||
}
|
||||
}
|
||||
|
||||
// 保存成功后:本页列表照常重拉,共享公司目录(tab 条)强制重拉一份。
|
||||
// 本页不参与公司隔离(控制方 2026-10-06「公司管理不要有 tab」)⇒ 走 store 的具名出口
|
||||
// refreshCompanyDirectory,而不是自己持一份 company-tab store(后者形状与「给这页上了 tab」
|
||||
// 分不开,company-config-entry-super-only 的 pageFiles 分母会当场红)。
|
||||
// 重拉失败不弹新提示(§12 第 5 条未批的界面暴露):tab 条保留旧名单,下一次切平台 tab / 重进页面会再试。
|
||||
async function onCompaniesSaved() {
|
||||
await loadCompanies()
|
||||
refreshCompanyDirectory().catch((error: unknown) => {
|
||||
console.warn('[company-tab] 公司保存后目录重拉失败', error)
|
||||
})
|
||||
await reloadCompaniesAndDirectory()
|
||||
}
|
||||
|
||||
// 切平台 tab(V206)= 重新取数:公司归属按平台分列,两 tab 各看各的公司。
|
||||
@@ -95,6 +142,7 @@ onMounted(loadCompanies)
|
||||
<label>公司名称</label>
|
||||
<input v-model="filterKeyword" type="text" placeholder="输入公司名称" />
|
||||
</div>
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
</div>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="loadCompanies" />
|
||||
@@ -102,18 +150,26 @@ onMounted(loadCompanies)
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="batch-delete-cell" scope="col">
|
||||
<BatchDeleteCheckbox label="全选当前页可删除公司" :checked="batch.pageAll" :partial="batch.pageSome"
|
||||
:disabled="batch.disabled || batch.pageEmpty" @change="batch.togglePage" />
|
||||
</th>
|
||||
<th style="width: 58px">序号</th>
|
||||
<th>公司名称</th>
|
||||
<th style="width: 90px">状态</th>
|
||||
<th style="width: 24%">备注</th>
|
||||
<th style="width: 160px">创建时间</th>
|
||||
<th style="width: 160px">修改时间</th>
|
||||
<th style="width: 90px">操作</th>
|
||||
<th style="width: 140px">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<template v-if="filteredRows.length">
|
||||
<tr v-for="(company, index) in pagedRows" :key="company.id">
|
||||
<tr v-for="(company, index) in pagedRows" :key="company.id" :class="{ 'batch-selected': batch.isSelected(company) }">
|
||||
<td class="batch-delete-cell">
|
||||
<BatchDeleteCheckbox :label="batch.reason(company) || `选择 ${batch.label(company)}`" :checked="batch.isSelected(company)"
|
||||
:disabled="batch.disabled || !!batch.reason(company)" @change="batch.toggle(company)" />
|
||||
</td>
|
||||
<td>{{ index + 1 }}</td>
|
||||
<td>{{ company.companyName || '-' }}</td>
|
||||
<td>
|
||||
@@ -125,16 +181,20 @@ onMounted(loadCompanies)
|
||||
<td>{{ formatDateTime(company.createdAt) }}</td>
|
||||
<td>{{ formatDateTime(company.updatedAt || company.createdAt) }}</td>
|
||||
<td class="ops-cell">
|
||||
<button v-if="canManage" class="btn btn-sm" type="button" @click="openEdit(company)">编辑</button>
|
||||
<template v-if="canManage">
|
||||
<button class="btn btn-sm" type="button" @click="openEdit(company)">编辑</button>
|
||||
<button class="btn btn-sm btn-danger" type="button" :disabled="batch.busy || !!deleteBlockReasonOf(company)"
|
||||
:title="deleteBlockReasonOf(company) || undefined" @click="removeCompany(company)">删除</button>
|
||||
</template>
|
||||
<span v-else class="cell-none">-</span>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
<tr v-else-if="loading">
|
||||
<td colspan="7" class="empty-tip">加载中...</td>
|
||||
<td colspan="8" class="empty-tip">加载中...</td>
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<td colspan="7" class="empty-tip">{{ filterKeyword.trim() ? '暂无匹配公司' : '暂无公司' }}</td>
|
||||
<td colspan="8" class="empty-tip">{{ filterKeyword.trim() ? '暂无匹配公司' : '暂无公司' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -283,6 +343,7 @@ h3 {
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
white-space: nowrap;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.cell-none {
|
||||
color: #8293a5;
|
||||
|
||||
@@ -139,10 +139,10 @@ onMounted(loadGroups)
|
||||
<label>组长</label>
|
||||
<input v-model="filterLeader" type="text" placeholder="输入组长用户名" />
|
||||
</div>
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
</div>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="loadGroups" />
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
<div class="table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
|
||||
@@ -283,10 +283,10 @@ onMounted(loadMenus)
|
||||
<el-option label="软件" value="app" />
|
||||
</el-select>
|
||||
</div>
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
</div>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="loadMenus" />
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
<div class="table-scroll columns-table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
|
||||
@@ -393,10 +393,10 @@ onMounted(load)
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
</div>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
<div class="secrets-table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
|
||||
@@ -257,6 +257,8 @@ onMounted(() => {
|
||||
</el-select>
|
||||
</div>
|
||||
<button class="btn" type="button" @click="search">查询</button>
|
||||
<!-- 批量删除并入筛选行(2026-11-23 用户口径),margin-left:auto 右对齐,不再独占一行。 -->
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
</div>
|
||||
|
||||
<div v-if="statePhase === 'error' && loadError" class="msg err">
|
||||
@@ -264,7 +266,6 @@ onMounted(() => {
|
||||
<button class="btn btn-sm btn-secondary" type="button" @click="retry">重试</button>
|
||||
</div>
|
||||
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
<div class="table-scroll user-table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
|
||||
@@ -186,10 +186,10 @@ onMounted(() => {
|
||||
</el-select>
|
||||
</div>
|
||||
<button class="btn" type="button" @click="apply">查询</button>
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
</div>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
<div class="table-scroll invalid-asin-table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
|
||||
@@ -410,6 +410,7 @@ onUnmounted(() => {
|
||||
<div class="dedupe-filter-actions">
|
||||
<button class="btn" type="button" @click="apply">查询</button>
|
||||
</div>
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
</div>
|
||||
|
||||
<div class="dedupe-filter-date-row">
|
||||
@@ -429,7 +430,6 @@ onUnmounted(() => {
|
||||
</div>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
<div class="table-scroll dedupe-table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
|
||||
@@ -343,11 +343,11 @@ onMounted(loadTree)
|
||||
<button class="btn btn-sm btn-secondary" type="button" @click="exportCategories">导出</button>
|
||||
<button v-if="selected && !searching" class="btn btn-sm" type="button" @click="openCreate(selected)">新增子类目</button>
|
||||
<button class="btn" type="button" @click="openCreate(null)">新增类目</button>
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="loadTree" />
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
<div class="table-scroll category-table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
|
||||
@@ -435,10 +435,10 @@ onMounted(() => {
|
||||
</div>
|
||||
<button class="btn" type="button" @click="apply">查询</button>
|
||||
<button class="btn btn-secondary" type="button" @click="doExport">导出 XLSX</button>
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
</div>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
<div class="table-scroll query-asin-table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
|
||||
@@ -477,10 +477,10 @@ onMounted(() => {
|
||||
</div>
|
||||
<button class="btn" type="button" @click="apply">查询</button>
|
||||
<button class="btn btn-secondary" type="button" @click="doExport">导出 XLSX</button>
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
</div>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
<div class="table-scroll skip-price-asin-table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
|
||||
@@ -352,10 +352,10 @@ onMounted(() => {
|
||||
<button class="btn btn-ghost" type="button" @click="reset">重置</button>
|
||||
</div>
|
||||
</div>
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
</div>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
<div class="logs-table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
|
||||
@@ -232,11 +232,11 @@ onMounted(load)
|
||||
<div class="dh-head-tools admin-header-controls">
|
||||
<input v-model="versionKeyword" type="text" placeholder="搜索版本号" class="dh-keyword" />
|
||||
<button class="btn" type="button" @click="uploadVisible = true">上传新版本</button>
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
<div class="table-scroll digital-human-version-table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
|
||||
@@ -244,10 +244,10 @@ onMounted(load)
|
||||
</el-select>
|
||||
</div>
|
||||
<button class="btn" type="button" @click="apply">查询</button>
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
</div>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
<div class="shop-key-table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
|
||||
@@ -267,10 +267,10 @@ onMounted(() => {
|
||||
<input v-model="filter.shopName" type="text" placeholder="请输入店铺名" @keyup.enter="apply" />
|
||||
</div>
|
||||
<button class="btn" type="button" @click="apply">查询</button>
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
</div>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
<div class="table-scroll shop-manage-table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
|
||||
@@ -339,11 +339,11 @@ onMounted(() => {
|
||||
</el-select>
|
||||
<button class="g-btn g-btn-primary" type="button" @click="query">查询</button>
|
||||
<button class="g-btn g-btn-ghost" type="button" @click="resetFilter">重置</button>
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
</div>
|
||||
|
||||
<LoadFailureBar v-if="loadError" :message="loadError" @retry="loadPage()" />
|
||||
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
<div class="g-table-wrap" v-loading="pageLoading">
|
||||
<table v-if="rows.length" class="g-table">
|
||||
<thead>
|
||||
|
||||
Reference in New Issue
Block a user