修复智能气阀归属互斥选择

选择任一新归属时自动清空其他归属,保留提交防御校验和审计接口,并补充专项检查、中文操作日志及项目文档。
This commit is contained in:
czl231
2026-08-13 20:14:56 +08:00
parent 8c5e0468c2
commit 81920d43e8
5 changed files with 115 additions and 1 deletions

View File

@@ -22,6 +22,7 @@
"staff-organization:check": "node scripts/check-staff-organization-linkage.mjs",
"staff-relations:check": "node scripts/check-staff-relation-policy.mjs",
"user-address-display:check": "node scripts/check-user-address-relation-display.mjs",
"product-ownership:check": "node scripts/check-product-ownership-action.mjs",
"resource-search:check": "node scripts/check-resource-search.mjs",
"audit:platform": "node scripts/check-backend-contract.mjs",
"lint": "biome lint .",

View File

@@ -0,0 +1,27 @@
/**
* 功能:检查智能气阀归属弹窗保留互斥选择和提交防御。
* 版本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 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}`);
}
}
console.log('智能气阀归属互斥检查通过:选择时自动清空,提交时保留防御校验。');

View File

@@ -16,7 +16,7 @@
这是高风险操作可能改变业务状态且无法直接撤销请确认目标记录和填写内容准确
</a-alert>
<a-alert v-if="isOwnershipAction" class="action-alert" type="warning" show-icon>
智能气阀只能有一个当前归属选择新归属前请清空原归属操作会写入审计记录
智能气阀只能有一个当前归属选择新归属后会自动清空其他归属操作会写入审计记录
</a-alert>
<a-form :model="form" layout="vertical">
<ResourceFieldForm
@@ -25,6 +25,7 @@
:required-keys="requiredKeys"
:relation-options="relations.options"
:relation-loading="relations.loading"
@change-relation="changeRelation"
@search-relation="searchRelation"
/>
</a-form>
@@ -75,6 +76,21 @@ function searchRelation(field: ResourceField, keyword: string) {
relations.searchField(field, keyword);
}
/** 选择智能气阀的新归属时清空其余互斥归属,避免提交非法多重归属。 */
function changeRelation(field: ResourceField, value: unknown) {
if (
!isOwnershipAction.value ||
!ownershipKeys.includes(field.key) ||
value == null ||
String(value).trim() === ''
) {
return;
}
for (const key of ownershipKeys) {
if (key !== field.key) form[key] = undefined;
}
}
watch(
() => [props.visible, props.action?.name] as const,
async ([visible]) => {