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:
@@ -32,3 +32,14 @@ test('align_menus_row_buttons_old_btn', () => {
|
||||
assert.doesNotMatch(s, /el-button[^>]*@click="openEdit/, '行内不再用 EP 按钮')
|
||||
assert.match(s, /openAdminConfirm\(\{ message: `确定删除菜单/, '删除确认走统一确认出口,文案对齐旧版')
|
||||
})
|
||||
|
||||
test('align_companies_row_buttons_old_btn', () => {
|
||||
const s = readSource('src/pages/account/CompaniesPage.vue')
|
||||
assert.match(s, /class="btn btn-sm"[^>]*@click="openEdit\(company\)"/, '编辑用旧版 btn-sm 实心小按钮')
|
||||
assert.match(s, /class="btn btn-sm btn-danger"[^>]*@click="removeCompany\(company\)"/, '删除用旧版 btn-sm btn-danger(2026-11-23 用户口径:公司管理加删除)')
|
||||
assert.doesNotMatch(s, /el-button[^>]*@click="openEdit/, '行内不再用 EP 按钮')
|
||||
assert.match(s, /openAdminConfirm\(\{ message: `确定删除公司/, '删除确认走统一确认出口')
|
||||
// 名下有账号的公司删不得:勾选框与删除按钮共用同一份理由(deleteBlockReasonOf)
|
||||
assert.match(s, /deleteBlockReasonOf\(company\)/, '删除按钮按理由置灰,悬停可见原因')
|
||||
assert.match(s, /该公司名下还有 \$\{userCount\} 个账号/, '置灰文案带账号数')
|
||||
})
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readSource } from './helpers.ts'
|
||||
|
||||
/**
|
||||
* 2026-11-23 用户口径「批量删除放上去,最大化利用空间」:BatchDeleteActions 不再独占一行,
|
||||
* 由各页并入筛选/工具行(组件 margin-left:auto 右对齐)。本钉防回归——有人把它挪回
|
||||
* 「LoadFailureBar 之后独占一行」的旧形状即红。
|
||||
*
|
||||
* 正向锚点 = 该页筛选行里紧挨着它的前一个控件;负向 = 旧形状「LoadFailureBar 后跟独立批量行」。
|
||||
*/
|
||||
const MOVED_PAGES: Array<{ file: string; rowMate: RegExp; note: string }> = [
|
||||
{ file: 'src/pages/account/UsersPage.vue', rowMate: /@click="search">查询<\/button>[\s\S]{0,300}?<BatchDeleteActions/, note: '查询按钮右侧' },
|
||||
{ file: 'src/pages/account/GroupsPage.vue', rowMate: /placeholder="输入组长用户名" \/>\s*<\/div>\s*<BatchDeleteActions/, note: '组长输入框右侧' },
|
||||
{ file: 'src/pages/account/MenusPage.vue', rowMate: /value="app" \/>\s*<\/el-select>\s*<\/div>\s*<BatchDeleteActions/, note: '菜单类型下拉右侧' },
|
||||
{ file: 'src/pages/account/UserSecretsPage.vue', rowMate: /<\/button>\s*<\/div>\s*<\/div>\s*<BatchDeleteActions/, note: '刷新余额那组按钮右侧' },
|
||||
{ file: 'src/pages/asin/QueryAsinPage.vue', rowMate: /导出 XLSX<\/button>\s*<BatchDeleteActions/, note: '导出按钮右侧' },
|
||||
{ file: 'src/pages/asin/AsinInvalidPage.vue', rowMate: /@click="apply">查询<\/button>\s*<BatchDeleteActions/, note: '查询按钮右侧' },
|
||||
{ file: 'src/pages/asin/SkipPricePage.vue', rowMate: /导出 XLSX<\/button>\s*<BatchDeleteActions/, note: '导出按钮右侧' },
|
||||
{ file: 'src/pages/asin/DedupeRegistryPage.vue', rowMate: /@click="apply">查询<\/button>\s*<\/div>\s*<BatchDeleteActions/, note: '查询按钮组右侧' },
|
||||
{ file: 'src/pages/asin/ProductCategoryPage.vue', rowMate: /@click="openCreate\(null\)">新增类目<\/button>\s*<BatchDeleteActions/, note: '新增类目按钮右侧' },
|
||||
{ file: 'src/pages/records/DeviceLogsPage.vue', rowMate: /<\/button>\s*<\/div>\s*<\/div>\s*<BatchDeleteActions/, note: '重置按钮组右侧' },
|
||||
{ file: 'src/pages/records/RecordsDigitalHumanVersionPage.vue', rowMate: /@click="uploadVisible = true">上传新版本<\/button>\s*<BatchDeleteActions/, note: '上传按钮右侧' },
|
||||
{ file: 'src/pages/shop/ShopManagePage.vue', rowMate: /@click="apply">查询<\/button>\s*<BatchDeleteActions/, note: '查询按钮右侧' },
|
||||
{ file: 'src/pages/shop/ShopKeysPage.vue', rowMate: /@click="apply">查询<\/button>\s*<BatchDeleteActions/, note: '查询按钮右侧' },
|
||||
{ file: 'src/pages/tasks/BrandGatingPanel.vue', rowMate: /@click="resetFilter">重置<\/button>\s*<BatchDeleteActions/, note: '重置按钮右侧' },
|
||||
]
|
||||
|
||||
for (const { file, rowMate, note } of MOVED_PAGES) {
|
||||
test(`align_batch_inline_${file.split('/').pop()}`, () => {
|
||||
const s = readSource(file)
|
||||
assert.doesNotMatch(s, /<LoadFailureBar[^>]*\/>\s*<BatchDeleteActions/, `旧形状(LoadFailureBar 后独占一行)不许回来`)
|
||||
assert.match(s, rowMate, `批量删除应并入筛选/工具行(${note}),紧跟行内前一个控件`)
|
||||
// 行内形状收口:组件是该行容器的最后一个孩子,紧跟该行的闭合 </div>
|
||||
assert.match(s, /<BatchDeleteActions :batch="batch" \/>\s*\n\s*<\/div>/, '组件应紧跟行容器闭合,而不是自己占一行再接表格')
|
||||
assert.equal((s.match(/<BatchDeleteActions/g) || []).length, 1, '每页只许一份批量删除入口')
|
||||
})
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"note": "readSource 钉子逐文件基线。两把尺子:pins=落在用例体内的读盘,reads=全文读点总数(含模块级夹具与 helper)。都只许减;pins 下降而 reads 没同步下降=把读盘挪出体内,不算改进。由 tests/source-pin-ratchet.test.ts 生成。",
|
||||
"totals": {
|
||||
"files": 264,
|
||||
"cases": 1857,
|
||||
"pins": 462,
|
||||
"reads": 663
|
||||
"files": 265,
|
||||
"cases": 1859,
|
||||
"pins": 463,
|
||||
"reads": 664
|
||||
},
|
||||
"files": {
|
||||
"admin-scaffold.test.ts": {
|
||||
@@ -22,6 +22,11 @@
|
||||
"pins": 7,
|
||||
"reads": 7
|
||||
},
|
||||
"align-batch-toolbar-inline.test.ts": {
|
||||
"cases": 1,
|
||||
"pins": 1,
|
||||
"reads": 1
|
||||
},
|
||||
"align-category-tree.test.ts": {
|
||||
"cases": 6,
|
||||
"pins": 5,
|
||||
@@ -208,7 +213,7 @@
|
||||
"reads": 3
|
||||
},
|
||||
"company-directory.test.ts": {
|
||||
"cases": 8,
|
||||
"cases": 9,
|
||||
"pins": 0,
|
||||
"reads": 0
|
||||
},
|
||||
|
||||
@@ -55,6 +55,24 @@ test('parseCompany 解析单条(新建/改名回包)', () => {
|
||||
assert.equal(parseCompany({ success: true, data: { company_name: '无 id' } }), null)
|
||||
})
|
||||
|
||||
test('user_count 仅列表解析进 userCount:非零即「名下有账号、删不得」(2026-11-23)', () => {
|
||||
const rows = parseCompanyList({ success: true, data: [
|
||||
{ id: 1, company_name: '厦门米椿花', status: 1, user_count: 3 },
|
||||
{ id: 2, company_name: '福州数富', status: 1, user_count: 0 },
|
||||
{ id: 3, company_name: '旧负载', status: 1 },
|
||||
{ id: 4, company_name: '脏值', status: 1, user_count: -1 },
|
||||
{ id: 5, company_name: '脏值2', status: 1, user_count: 'x' },
|
||||
] })
|
||||
assert.equal(rows[0].userCount, 3)
|
||||
assert.equal(rows[1].userCount, 0, '零账号=可删,字段照带')
|
||||
assert.ok(!('userCount' in rows[2]), '旧负载不带该键(按 0 读是消费方的事)')
|
||||
assert.ok(!('userCount' in rows[3]), '负数不是合法计数,丢弃')
|
||||
assert.ok(!('userCount' in rows[4]), '非数字丢弃')
|
||||
// 新建/改名回包不带 user_count:单条解析同样不凭空造键
|
||||
const saved = parseCompany({ success: true, data: { id: 6, company_name: '厦门米椿花', status: 1 } })
|
||||
assert.ok(saved && !('userCount' in saved))
|
||||
})
|
||||
|
||||
test('公司名必填、去空格后不得为空,且不超过列宽', () => {
|
||||
assert.equal(validateCompanyDraft({ companyName: ' ' }), '公司名称不能为空')
|
||||
assert.equal(validateCompanyDraft({ companyName: ' 厦门米椿花 ' }), '')
|
||||
|
||||
Reference in New Issue
Block a user