为基础资料维护页面增加导入导出

This commit is contained in:
2026-10-09 21:13:43 +08:00
parent a62803ccf0
commit a8af1f542b
20 changed files with 2134 additions and 15 deletions
@@ -442,6 +442,20 @@ const expectedButtonPermissions = [
'master:pallet:add',
'master:pallet:edit',
'master:pallet:print',
'master:strain:import',
'master:strain:export',
'master:customer:import',
'master:customer:export',
'master:site:import',
'master:site:export',
'master:line:import',
'master:line:export',
'master:warehouse:import',
'master:warehouse:export',
'master:pallet:import',
'master:pallet:export',
'master:tunnel:import',
'master:tunnel:export',
'business:inbound:query',
'business:inbound:add',
'business:inbound:edit',
@@ -1221,8 +1235,8 @@ test('窄屏模式控件仍保留正式退出与测试批次切换入口', async
test('17 个页面的真实权限门禁逐项匹配独立硬编码契约', async () => {
assert.equal(expectedPagePermissions.length, 17)
assert.equal(expectedButtonPermissions.length, 38)
assert.equal(new Set(expectedPermissions).size, 55)
assert.equal(expectedButtonPermissions.length, 52)
assert.equal(new Set(expectedPermissions).size, 69)
const relativePaths = [
...Object.values(masterPageContracts),
...Object.values(businessPageContracts),
@@ -1231,7 +1245,7 @@ test('17 个页面的真实权限门禁逐项匹配独立硬编码契约', async
assert.equal(relativePaths.length, 17)
const actualPermissions = []
for (const relativePath of relativePaths) {
for (const relativePath of [...relativePaths, 'src/components/MasterExcelActions/index.vue']) {
const source = await readFile(path.join(frontendRoot, relativePath), 'utf8')
const guarded = extractGuardedVuePermissions(source)
assert.ok(guarded.length > 0, `${relativePath} 缺少真实权限门禁`)
@@ -1840,6 +1854,16 @@ test('六个基础资料页面逐页满足 API、权限、分页和安全删除
assert.doesNotMatch(source, /\.catch\(\(\) => \{\}\)/, `${resource} 页面禁止空 catch`)
assert.doesNotMatch(source, />\s*(?:导入|导出)\s*<\/el-button>/)
assert.doesNotMatch(source, /\bhandle(?:Import|Export)\b|proxy\.download\(/)
assert.match(
masterToolbar,
new RegExp(`<master-excel-actions resource="${resource}" :allow-import="isMasterWriteAllowed" :query-params="queryParams" @imported="getList"\\s*/>`),
`${resource} 必须复用基础资料导入导出组件`
)
assert.match(
masterToolbar,
/<\/template>\s*<master-excel-actions\b[\s\S]*?\/>\s*<right-toolbar\b/,
`${resource} 导入导出应放在写操作之后、刷新工具栏之前`
)
assert.match(source, /let listGeneration = 0;/)
assert.match(source, /function isCurrentListRequest\(listContext\)\s*{\s*return listContext\.generation === listGeneration;?\s*}/)
@@ -1950,6 +1974,18 @@ test('六个基础资料页面逐页满足 API、权限、分页和安全删除
}
})
test('隧道资料页复用基础资料导入导出组件', async () => {
const source = await readFile(path.join(frontendRoot, 'src/views/master/tunnel/index.vue'), 'utf8')
const masterToolbar = source.match(/<el-row\b[^>]*class="[^"]*\bmaster-toolbar\b[^"]*"[^>]*>[\s\S]*?<\/el-row>/)?.[0] || ''
assert.match(
masterToolbar,
/<master-excel-actions resource="tunnel" :allow-import="isMasterWriteAllowed" :query-params="queryParams" @imported="getList"\s*\/>/
)
assert.match(masterToolbar, /<\/template>\s*<master-excel-actions\b[\s\S]*?\/>\s*<right-toolbar\b/)
assert.doesNotMatch(source, />\s*(?:导入|导出)\s*<\/el-button>/)
assert.doesNotMatch(source, /\bhandle(?:Import|Export)\b|proxy\.download\(/)
})
test('五个业务页面逐页满足 API、精确权限、列表和交互基础契约', async (t) => {
for (const [resource, contract] of Object.entries(businessPageContracts)) {
await t.test(contract.relativePath, async () => {