Files
platforms/frontend/platform_admin/scripts/check-product-ownership-action.mjs
czl231 e5289e8f8a 完善智能气阀新建归属选择
新建页面明确说明当前归属四选一,选择新归属时自动清空其他归属;字段改用业务名称并补充选择提示,同时扩展专项检查和中文文档。
2026-08-13 21:50:57 +08:00

49 lines
1.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 功能:检查智能气阀归属弹窗保留互斥选择和提交防御。
* 版本v1.0.0
*/
import { readFile } from 'node:fs/promises';
import { fileURLToPath } from 'node:url';
const componentUrl = new URL(
'../src/views/resource/ResourceActionDialog.vue',
import.meta.url,
);
const source = await readFile(fileURLToPath(componentUrl), 'utf8');
const recordPageUrl = new URL(
'../src/views/resource/ResourceRecordPage.vue',
import.meta.url,
);
const recordPageSource = await readFile(fileURLToPath(recordPageUrl), 'utf8');
const requiredFragments = [
'@change-relation="changeRelation"',
'ownershipKeys.includes(field.key)',
'if (key !== field.key) form[key] = undefined',
"Message.warning('智能气阀只能选择一个当前归属')",
"payload[key] = String(form[key] ?? '')",
];
for (const fragment of requiredFragments) {
if (!source.includes(fragment)) {
throw new Error(`智能气阀归属互斥检查缺少实现:${fragment}`);
}
}
const createPageFragments = [
'@change-relation="changeRelation"',
"mode === 'create' && definition.name === 'product_info'",
'当前归属只能选择库房、气站、配送点或用户中的一个;选择新归属时会自动清空其他归属。',
"definition.value.name === 'product_info'",
'productOwnershipKeys.includes(field.key)',
'if (key !== field.key) form[key] = undefined',
'await relationLinkage.change(field, value)',
];
for (const fragment of createPageFragments) {
if (!recordPageSource.includes(fragment)) {
throw new Error(`智能气阀新建页归属互斥检查缺少实现:${fragment}`);
}
}
console.log('智能气阀归属互斥检查通过:新建页与专用弹窗均自动清空,提交时保留防御校验。');