完善合同气瓶绑定引导
This commit is contained in:
@@ -95,6 +95,8 @@ export type ResourceField = {
|
||||
relationAutoSelectKey?: string;
|
||||
/** 关联候选为空时展示的业务引导。 */
|
||||
relationEmptyText?: string;
|
||||
/** 关联候选为空时提供的站内处理入口。 */
|
||||
relationEmptyAction?: { label: string; routeName: string };
|
||||
/** 该关联字段每次加载与搜索都必须携带的精确筛选参数。 */
|
||||
relationFilters?: Record<string, string>;
|
||||
/** 筛选结果中不存在当前值时立即清空,禁止通过详情补载绕过候选范围。 */
|
||||
@@ -541,7 +543,10 @@ export const resources: ResourceUiDefinition[] = [
|
||||
relationInvalidMessage: '所选合同已不是草稿状态,已清空,请重新选择',
|
||||
relationEmptyText: '暂无可绑定气瓶的草稿合同,请先新建配送合同',
|
||||
}), relation('product_info_identity', '/product_info', true, {
|
||||
label: '智能气阀',
|
||||
placeholder: '请先选择合同,再选择该合同用户可绑定的气瓶',
|
||||
relationEmptyText: '该合同用户暂无可绑定的智能气阀。请先到“智能气阀管理”将设备归属变更为该用户,并确认设备已启用、未报废。',
|
||||
relationEmptyAction: { label: '前往智能气阀管理', routeName: 'product-info' },
|
||||
relationLinkage: {
|
||||
parentKey: 'gasorder_contract_identity', optionParentKey: '',
|
||||
filterKey: 'contract_identity', filterOnly: true,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<!--
|
||||
功能:渲染标准资源的新建、编辑和业务动作字段控件。
|
||||
版本:v1.3.0
|
||||
版本:v1.4.0
|
||||
-->
|
||||
<template>
|
||||
<div class="field-grid">
|
||||
@@ -114,7 +114,17 @@
|
||||
}}
|
||||
</a-option>
|
||||
<template #empty>
|
||||
<div class="relation-empty">{{ relationEmptyText(field) }}</div>
|
||||
<div class="relation-empty">
|
||||
<span>{{ relationEmptyText(field) }}</span>
|
||||
<a-button
|
||||
v-if="field.relationEmptyAction && !relationRequiresParent(field)"
|
||||
type="text"
|
||||
size="mini"
|
||||
@click.stop="navigateRelationEmptyAction(field)"
|
||||
>
|
||||
{{ field.relationEmptyAction.label }}
|
||||
</a-button>
|
||||
</div>
|
||||
</template>
|
||||
</a-select>
|
||||
<div
|
||||
@@ -137,6 +147,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { relationOptionLabel } from '@/api/resource-display';
|
||||
import { dynamicRelationResource, type ResourceField } from '@/api/resources';
|
||||
import type { ResourceRow } from '@/api/resource-page-rules';
|
||||
@@ -181,6 +192,7 @@ const emit = defineEmits<{
|
||||
'preview-attachment': [];
|
||||
}>();
|
||||
const model = defineModel<Record<string, any>>({ required: true });
|
||||
const router = useRouter();
|
||||
const disabledSet = computed(() => new Set(props.disabledKeys));
|
||||
|
||||
function isWide(field: ResourceField) {
|
||||
@@ -267,6 +279,12 @@ function relationEmptyText(field: ResourceField) {
|
||||
return field.relationEmptyText ?? '暂无数据';
|
||||
}
|
||||
|
||||
/** 从空候选引导直接进入对应管理页面,避免管理员只能猜测前置操作。 */
|
||||
function navigateRelationEmptyAction(field: ResourceField) {
|
||||
if (!field.relationEmptyAction) return;
|
||||
void router.push({ name: field.relationEmptyAction.routeName });
|
||||
}
|
||||
|
||||
/** 为历史未知编码补充只读选项,避免下拉框退回显示原始值。 */
|
||||
function selectOptions(field: ResourceField) {
|
||||
const options = [...(field.options ?? [])];
|
||||
@@ -309,6 +327,15 @@ function selectOptions(field: ResourceField) {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
}
|
||||
.relation-empty {
|
||||
display: grid;
|
||||
justify-items: center;
|
||||
gap: 4px;
|
||||
padding: 8px 12px;
|
||||
color: var(--color-text-3);
|
||||
text-align: center;
|
||||
white-space: normal;
|
||||
}
|
||||
.relation-identity {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
|
||||
Reference in New Issue
Block a user