统一合同气阀候选与绑定入口

This commit is contained in:
czl231
2026-08-31 22:04:22 +08:00
parent 9a23ab2f5a
commit 0f2475098f
23 changed files with 352 additions and 47 deletions

View File

@@ -22,7 +22,7 @@ const contracts: Record<string, ResourceDetailContract> = {
'contract_status',
'title',
'user_account_identity',
'user_service_active',
'user_delivery_service_active',
'gas_basic_identity',
'delivery_basic_identity',
'default_delivery_fee',

View File

@@ -1,6 +1,6 @@
/**
* 功能描述:统一配送点资源独立页面的字段名称和值展示。
* 版本v1.1.0。
* 版本v1.2.0。
*/
import dayjs from 'dayjs';
import type { ResourceRow } from './resource-record-form';
@@ -26,6 +26,7 @@ const aliases: Record<string, string> = {
contract: '合同',
order: '订单',
user_service_active: '签约用户仍属合同气站',
user_delivery_service_active: '签约用户仍属当前配送点',
user_account_display_name: '用户账户',
gas_basic_display_name: '气站',
delivery_basic_display_name: '配送点',

View File

@@ -421,7 +421,7 @@ const platformResources: ResourceUiDefinition[] = [
{ name: '续签合同', resource: '/gasorder_contract/:identity/renew', fields: [f('effective_at', { required: true }), f('expired_at'), ...reason], visibleFor: { field: 'contract_status', values: [11, 12, 13] } },
{ name: '终止合同', resource: '/gasorder_contract/:identity/terminate', danger: true, fields: reason, visibleFor: { field: 'contract_status', values: [11] } },
], { canCreate: true, canEdit: true }),
define('gasorder_contract_product', '合同气瓶', 'append_only', [relation('gasorder_contract_identity', '/gasorder_contract', true), relation('product_info_identity', '/product_info', true), f('unit_price')], 'list', [
define('gasorder_contract_product', '合同气瓶', 'append_only', [relation('gasorder_contract_identity', '/gasorder_contract', true), relation('product_info_identity', '/product_info', true, { label: '智能气阀', placeholder: '请选择该合同用户可绑定的智能气阀', relationEmptyText: '该合同用户暂无可绑定的智能气阀,请先由平台总后台将设备归属变更为该用户', relationLinkage: { parentKey: 'gasorder_contract_identity', filterKey: 'contract_identity', requiresParent: true, parentChangeMessage: '配送合同已变更,请重新选择该合同用户的智能气阀' } }), f('unit_price')], 'list', [
{ name: '解绑气瓶', resource: '/gasorder_contract_product/:identity/unbind', danger: true, fields: reason },
]),
define('gasorder_contract_revision', '合同修订记录', 'readonly', []),
@@ -514,7 +514,7 @@ const gasOverrides: ResourceUiDefinition[] = [
{ name: '续签合同', resource: '/gasorder_contract/:identity/renew', fields: [f('effective_at', { required: true }), f('expired_at'), ...reason], visibleFor: { field: 'contract_status', values: [11, 12, 13] } },
{ name: '终止合同', resource: '/gasorder_contract/:identity/terminate', danger: true, fields: reason, visibleFor: { field: 'contract_status', values: [11] } },
], { canCreate: true, canEdit: true }),
define('gasorder_contract_product', '合同气瓶', 'append_only', [relation('gasorder_contract_identity', '/gasorder_contract', true), relation('product_info_identity', '/product_info', true), f('unit_price')], 'list', [
define('gasorder_contract_product', '合同气瓶', 'append_only', [relation('gasorder_contract_identity', '/gasorder_contract', true), relation('product_info_identity', '/product_info', true, { label: '智能气阀', placeholder: '请选择该合同用户可绑定的智能气阀', relationEmptyText: '该合同用户暂无可绑定的智能气阀,请先由平台总后台将设备归属变更为该用户', relationLinkage: { parentKey: 'gasorder_contract_identity', filterKey: 'contract_identity', requiresParent: true, parentChangeMessage: '配送合同已变更,请重新选择该合同用户的智能气阀' } }), f('unit_price')], 'list', [
{ name: '解绑气瓶', resource: '/gasorder_contract_product/:identity/unbind', danger: true, fields: reason },
]),
define('gasorder_contract_revision', '合同修订记录', 'readonly', []),
@@ -553,7 +553,7 @@ const deliveryOverrides: ResourceUiDefinition[] = [
{ name: '续签合同', resource: '/gasorder_contract/:identity/renew', fields: [f('effective_at', { required: true }), f('expired_at'), ...reason], visibleFor: { field: 'contract_status', values: [11, 12, 13] } },
{ name: '终止合同', resource: '/gasorder_contract/:identity/terminate', danger: true, fields: reason, visibleFor: { field: 'contract_status', values: [11] } },
], { canCreate: true, canEdit: true }),
define('gasorder_contract_product', '合同气瓶', 'append_only', [relation('gasorder_contract_identity', '/gasorder_contract', true), relation('product_info_identity', '/product_info', true), f('unit_price')], 'list', [
define('gasorder_contract_product', '合同气瓶', 'append_only', [relation('gasorder_contract_identity', '/gasorder_contract', true), relation('product_info_identity', '/product_info', true, { label: '智能气阀', placeholder: '请选择该合同用户可绑定的智能气阀', relationEmptyText: '该合同用户暂无可绑定的智能气阀,请先由平台总后台将设备归属变更为该用户', relationLinkage: { parentKey: 'gasorder_contract_identity', filterKey: 'contract_identity', requiresParent: true, parentChangeMessage: '配送合同已变更,请重新选择该合同用户的智能气阀' } }), f('unit_price')], 'list', [
{ name: '解绑气瓶', resource: '/gasorder_contract_product/:identity/unbind', danger: true, fields: reason },
]),
define('gasorder_contract_revision', '合同修订记录', 'readonly', []),

View File

@@ -20,7 +20,7 @@
:color="contractStatusColor(Number(entry.rawValue))"
>{{ entry.value }}</a-tag>
<a-tag
v-else-if="entry.key === 'user_service_active'"
v-else-if="['user_service_active', 'user_delivery_service_active'].includes(entry.key)"
class="detail-status-tag"
:color="entry.rawValue === true ? 'green' : 'red'"
>{{ entry.value }}</a-tag>

View File

@@ -1,4 +1,4 @@
<!-- 功能描述承载配送点标准资源的新建详情和编辑独立页面版本v1.1.0 -->
<!-- 功能描述承载配送点标准资源的新建详情和编辑独立页面版本v1.2.0 -->
<template>
<div class="record-page">
<header class="page-header">
@@ -218,7 +218,16 @@ const summaryRecord = computed(() => (mode.value === 'detail' ? record.value : {
const formFields = computed(() =>
recordFormFields(definition.value.name, definition.value.fields, mode.value as 'create' | 'edit')
.filter((field) => field.key !== 'avatar')
.map((field) => (isCredentialResource.value && field.key === 'staff_account_identity' ? { ...field, readonly: true } : field)),
.map((field) => {
const lockedCredentialOwner = isCredentialResource.value && field.key === 'staff_account_identity';
const lockedContract =
mode.value === 'create' &&
definition.value.name === 'gasorder_contract_product' &&
field.key === 'gasorder_contract_identity' &&
route.query.relation_key === 'gasorder_contract_identity' &&
Boolean(route.query.owner_identity);
return lockedCredentialOwner || lockedContract ? { ...field, readonly: true } : field;
}),
);
const relationBusy = computed(() => relations.isLoading(formFields.value));
const relationUnavailableMessage = computed(() => relations.unavailableMessage(formFields.value));
@@ -226,7 +235,7 @@ const canEditRecord = computed(() => definition.value.canEdit && !recordEditReas
const visibleActions = computed(() =>
(definition.value.detailActions ?? []).filter(
(action) =>
!(definition.value.name === 'gasorder_contract' && record.value.user_service_active === false && action.name !== '终止合同') &&
!(definition.value.name === 'gasorder_contract' && record.value.user_delivery_service_active === false && action.name !== '终止合同') &&
(!action.visibleFor || action.visibleFor.values.includes(record.value[action.visibleFor.field] as string | number)),
),
);

View File

@@ -1,4 +1,4 @@
<!-- 功能描述展示配送点标准资源列表并导航到独立记录页版本v1.3.0 -->
<!-- 功能描述展示配送点标准资源列表并导航到独立记录页版本v1.4.0 -->
<template>
<a-card :title="listTitle" :bordered="false">
<template v-if="isCredentialList" #extra>
@@ -104,11 +104,17 @@
<a-table-column title="系统唯一标识" :width="170">
<template #cell="{ record }"><IdentityText :value="String(record.identity)" /></template>
</a-table-column>
<a-table-column title="操作" :width="220" fixed="right">
<a-table-column title="操作" :width="definition.name === 'gasorder_contract' ? 285 : 220" fixed="right">
<template #cell="{ record }">
<a-space>
<a-button v-if="definition.name === 'staff_account'" size="mini" @click="viewCredentials(record)">查看资质</a-button>
<a-button size="mini" @click="openRecord('detail', record)">详情</a-button>
<a-button
v-if="definition.name === 'gasorder_contract' && Number(record.contract_status) === 0 && record.user_delivery_service_active !== false"
size="mini"
type="primary"
@click="bindContractProduct(record)"
>绑定气瓶</a-button>
<a-tooltip v-if="definition.canEdit" :content="recordEditReason(definition, record) || '编辑记录'">
<span>
<a-button
@@ -361,6 +367,18 @@ function openRecord(mode: 'detail' | 'edit', row: ResourceRow) {
);
}
/** 从草稿合同列表进入合同气瓶新建页,并预填当前合同。 */
function bindContractProduct(row: ResourceRow) {
return router.push({
name: 'contract-products-create',
query: {
relation_key: 'gasorder_contract_identity',
owner_identity: String(row.identity ?? ''),
return_to: route.fullPath,
},
});
}
/** 进入当前配送人员的资质列表并保留来源。 */
function viewCredentials(row: ResourceRow) {
return router.push({