2026-08-13 20:14:56 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 功能:检查智能气阀归属弹窗保留互斥选择和提交防御。
|
|
|
|
|
|
* 版本: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');
|
2026-08-13 21:50:57 +08:00
|
|
|
|
const recordPageUrl = new URL(
|
|
|
|
|
|
'../src/views/resource/ResourceRecordPage.vue',
|
|
|
|
|
|
import.meta.url,
|
|
|
|
|
|
);
|
|
|
|
|
|
const recordPageSource = await readFile(fileURLToPath(recordPageUrl), 'utf8');
|
2026-08-13 20:14:56 +08:00
|
|
|
|
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}`);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-13 21:50:57 +08:00
|
|
|
|
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('智能气阀归属互斥检查通过:新建页与专用弹窗均自动清空,提交时保留防御校验。');
|