完善智能气阀新建归属选择

新建页面明确说明当前归属四选一,选择新归属时自动清空其他归属;字段改用业务名称并补充选择提示,同时扩展专项检查和中文文档。
This commit is contained in:
czl231
2026-08-13 21:50:57 +08:00
parent f8e91fb00a
commit e5289e8f8a
6 changed files with 141 additions and 8 deletions

View File

@@ -116,6 +116,14 @@
<div class="form-shell">基本信息</div>
</template>
<div class="form-shell form-content">
<a-alert
v-if="mode === 'create' && definition.name === 'product_info'"
class="workflow-alert"
type="warning"
show-icon
>
当前归属只能选择库房气站配送点或用户中的一个选择新归属时会自动清空其他归属
</a-alert>
<a-form :model="form" layout="vertical">
<ResourceFieldForm
v-model="form"
@@ -126,7 +134,7 @@
:relation-loading="relations.loading"
:role-options="roleOptions"
:contract-attachment="contractAttachmentState"
@change-relation="relationLinkage.change"
@change-relation="changeRelation"
@search-relation="relationLinkage.search"
@select-attachment="contractAttachment.select"
@remove-attachment="confirmRemoveContractAttachment"
@@ -188,7 +196,11 @@ import {
recordStatusColor,
recordStatusLabel,
} from '@/api/resource-display';
import { getResource, type DetailAction } from '@/api/resources';
import {
getResource,
type DetailAction,
type ResourceField,
} from '@/api/resources';
import { useUserStore } from '@/store';
import ResourceAccountSummary from './ResourceAccountSummary.vue';
import ResourceActionDialog from './ResourceActionDialog.vue';
@@ -246,6 +258,12 @@ const staffOwnerGuard = useStaffCredentialOwnerGuard({
const resolvedStaffType = staffOwnerGuard.resolvedStaffType;
const relations = staffOwnerGuard.relations;
const relationLinkage = useResourceRelationLinkage(form, relations);
const productOwnershipKeys = [
'warehouse_identity',
'gas_basic_identity',
'delivery_basic_identity',
'user_account_identity',
];
const actionVisible = ref(false);
const activeAction = ref<DetailAction>();
const avatar = useResourceAvatar();
@@ -262,6 +280,22 @@ const contractAttachmentState = computed(() => ({
removed: contractAttachment.removed.value,
}));
/** 新建智能气阀选择归属时清空其他互斥归属,再执行字段原有联动。 */
async function changeRelation(field: ResourceField, value: unknown) {
if (
mode.value === 'create' &&
definition.value.name === 'product_info' &&
productOwnershipKeys.includes(field.key) &&
value != null &&
String(value).trim() !== ''
) {
for (const key of productOwnershipKeys) {
if (key !== field.key) form[key] = undefined;
}
}
await relationLinkage.change(field, value);
}
const accountSummary = computed(() => usesAccountSummary(definition.value));
const accountSummaryVisible = computed(
() =>