Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
ujia
/
uj-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit d62b975c
authored
Nov 24, 2026
by
chenwq
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化合同详情页面,重构字段展示方式,增加字段前后缀处理,调整样式以适应不同屏幕
1 parent
0be59775
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
51 deletions
apps/web/subapps/usedcar/src/pages/Operation/ContractDetail.tsx
apps/web/subapps/usedcar/src/pages/Operation/contractDetail.css
packages/biz/src/components/CombiForm/index.tsx
packages/biz/src/components/formSchema.ts
apps/web/subapps/usedcar/src/pages/Operation/ContractDetail.tsx
View file @
d62b975
import { useState, type ReactNode } from 'react';
import { useState, type ReactNode } from 'react';
import { useMutation, useQuery } from '@tanstack/react-query';
import { useMutation, useQuery } from '@tanstack/react-query';
import {
import { UAlert, UButton, UCard, UEmpty, UInput, UResult, UTable, UTag, useUMessage } from '@uj/ui';
UAlert,
import { CombiForm, PageShell, type FieldSchema } from '@/components';
UButton,
UCard,
UDescriptions,
UEmpty,
UInput,
UResult,
UTable,
UTag,
useUMessage,
} from '@uj/ui';
import { PageShell } from '@/components';
import { downloadCenter } from '@uj/platform-sdk';
import { downloadCenter } from '@uj/platform-sdk';
import { useAccess } from '@/access';
import { useAccess } from '@/access';
import { contractApi, type ContractDetail as Detail, type ContractOaAudit } from '@/api';
import { contractApi, type ContractDetail as Detail, type ContractOaAudit } from '@/api';
...
@@ -80,6 +69,22 @@ export default function ContractDetail({ params }: { params: PageParams }) {
...
@@ -80,6 +69,22 @@ export default function ContractDetail({ params }: { params: PageParams }) {
const oaAudits = Array.isArray(data.oaAudits) ? data.oaAudits : [];
const oaAudits = Array.isArray(data.oaAudits) ? data.oaAudits : [];
const fieldItems = Array.isArray(data.fieldItems) ? data.fieldItems : [];
const fieldItems = Array.isArray(data.fieldItems) ? data.fieldItems : [];
const logs = Array.isArray(data.logs) ? data.logs : [];
const logs = Array.isArray(data.logs) ? data.logs : [];
const contractInfoFields: FieldSchema<Detail>[] = [
{
name: 'electronicContractType',
label: '合同类型',
type: 'input',
render: (value) => dictValue(DICT.contractType, value),
},
{ name: 'carTypeName', label: '合同车型', type: 'input', render: () => contractModel(data) },
{ name: 'docTemplateName', label: '合同模板', type: 'input', render: display },
{
name: 'contractPrice',
label: '合同金额',
type: 'input',
detailPrefix: '¥',
},
];
const payColumns = [
const payColumns = [
{
{
...
@@ -96,10 +101,7 @@ export default function ContractDetail({ params }: { params: PageParams }) {
...
@@ -96,10 +101,7 @@ export default function ContractDetail({ params }: { params: PageParams }) {
},
},
{
{
title: '支付金额',
title: '支付金额',
render: (row: ContractOaAudit) =>
render: (row: ContractOaAudit) => displayAmount(row.paymentAmount),
row.paymentAmount === undefined || row.paymentAmount === ''
? '-'
: `¥${String(row.paymentAmount)}`,
},
},
{ title: '企微审批单号', dataIndex: 'oaFlowCode', render: display },
{ title: '企微审批单号', dataIndex: 'oaFlowCode', render: display },
{
{
...
@@ -157,11 +159,7 @@ export default function ContractDetail({ params }: { params: PageParams }) {
...
@@ -157,11 +159,7 @@ export default function ContractDetail({ params }: { params: PageParams }) {
<MetaItem label="付款方式">
<MetaItem label="付款方式">
{dictValue(DICT.paymentMethod, data.paymentMethod)}
{dictValue(DICT.paymentMethod, data.paymentMethod)}
</MetaItem>
</MetaItem>
<MetaItem label="合同金额">
<MetaItem label="合同金额">{displayAmount(data.contractPrice)}</MetaItem>
{data.contractPrice === undefined || data.contractPrice === ''
? '-'
: `¥${String(data.contractPrice)}`}
</MetaItem>
</div>
</div>
</div>
</div>
</UCard>
</UCard>
...
@@ -191,27 +189,12 @@ export default function ContractDetail({ params }: { params: PageParams }) {
...
@@ -191,27 +189,12 @@ export default function ContractDetail({ params }: { params: PageParams }) {
<UCard className="uc-detail-card" loading={detail.isPending}>
<UCard className="uc-detail-card" loading={detail.isPending}>
<CardHead title="合同信息" />
<CardHead title="合同信息" />
<div className="uc-detail-card__body">
<div className="uc-detail-card__body">
<UDescriptions
<CombiForm
className="uc-detail-descriptions"
mode="detail"
column={{ xs: 1, sm: 2 }}
fields={contractInfoFields}
styles={{ label: { width: 112, whiteSpace: 'nowrap' } }}
initialValues={data}
items={[
detailColumns={2}
{
labelWidth={112}
key: 'type',
label: '合同类型',
children: dictValue(DICT.contractType, data.electronicContractType),
},
{ key: 'model', label: '合同车型', children: contractModel(data) },
{ key: 'template', label: '合同模板', children: display(data.docTemplateName) },
{
key: 'price',
label: '合同金额',
children:
data.contractPrice === undefined || data.contractPrice === ''
? '-'
: `¥${String(data.contractPrice)}`,
},
]}
/>
/>
<div className="uc-contract-desc">
<div className="uc-contract-desc">
<span className="uc-contract-desc__label">合同描述</span>
<span className="uc-contract-desc__label">合同描述</span>
...
@@ -315,11 +298,12 @@ export default function ContractDetail({ params }: { params: PageParams }) {
...
@@ -315,11 +298,12 @@ export default function ContractDetail({ params }: { params: PageParams }) {
{side === 1 ? '甲方' : '乙方'}
{side === 1 ? '甲方' : '乙方'}
<span className="uc-contract-signer__type">{signerTypeName(data, side)}</span>
<span className="uc-contract-signer__type">{signerTypeName(data, side)}</span>
</div>
</div>
<UDescriptions
<CombiForm
className="uc-detail-descriptions"
mode="detail"
column={1}
detailColumns={1}
styles={{ label: { width: 110, whiteSpace: 'nowrap' } }}
labelWidth={110}
items={SIGNER_FIELDS.map((field) => {
initialValues={Object.fromEntries(
SIGNER_FIELDS.map((field) => {
let value: string;
let value: string;
if (field.kind === 'side') value = side === 1 ? '甲方' : '乙方';
if (field.kind === 'side') value = side === 1 ? '甲方' : '乙方';
else if (field.kind === 'type') value = signerTypeName(data, side);
else if (field.kind === 'type') value = signerTypeName(data, side);
...
@@ -328,8 +312,14 @@ export default function ContractDetail({ params }: { params: PageParams }) {
...
@@ -328,8 +312,14 @@ export default function ContractDetail({ params }: { params: PageParams }) {
const key = side === 1 ? field.keyA : field.keyB;
const key = side === 1 ? field.keyA : field.keyB;
value = display(key ? signers[key] : undefined);
value = display(key ? signers[key] : undefined);
}
}
return { key: field.title, label: field.title, children: value };
return [field.title, value];
})}
}),
)}
fields={SIGNER_FIELDS.map((field) => ({
name: field.title,
label: field.title,
type: 'input',
}))}
/>
/>
</div>
</div>
))}
))}
...
@@ -392,3 +382,7 @@ function MetaItem({ label, children }: { label: string; children: ReactNode }) {
...
@@ -392,3 +382,7 @@ function MetaItem({ label, children }: { label: string; children: ReactNode }) {
</div>
</div>
);
);
}
}
function displayAmount(value: unknown): string {
return value === undefined || value === null || value === '' ? '-' : `¥${String(value)}`;
}
apps/web/subapps/usedcar/src/pages/Operation/contractDetail.css
View file @
d62b975
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
}
}
.uc-contract-fields
{
.uc-contract-fields
{
display
:
grid
;
display
:
grid
;
grid-template-columns
:
repeat
(
2
,
minmax
(
0
,
1
fr
));
gap
:
12px
;
gap
:
12px
;
}
}
.uc-contract-field
{
.uc-contract-field
{
...
@@ -89,6 +90,9 @@
...
@@ -89,6 +90,9 @@
border-radius
:
var
(
--uj-radius-sm
);
border-radius
:
var
(
--uj-radius-sm
);
}
}
@media
(
max-width
:
900px
)
{
@media
(
max-width
:
900px
)
{
.uc-contract-fields
{
grid-template-columns
:
1
fr
;
}
.uc-contract-signers
{
.uc-contract-signers
{
grid-template-columns
:
1
fr
;
grid-template-columns
:
1
fr
;
}
}
...
...
packages/biz/src/components/CombiForm/index.tsx
View file @
d62b975
...
@@ -62,7 +62,12 @@ export function CombiForm<T extends Record<string, unknown>>({
...
@@ -62,7 +62,12 @@ export function CombiForm<T extends Record<string, unknown>>({
label: field.label,
label: field.label,
children: field.render
children: field.render
? field.render(data[field.name], data)
? field.render(data[field.name], data)
: String(data[field.name] ?? '—'),
: formatDetailValue(
data[field.name],
field.detailPrefix,
field.detailSuffix,
field.emptyValueAsDash,
),
}))}
}))}
/>
/>
);
);
...
@@ -147,6 +152,24 @@ export function CombiForm<T extends Record<string, unknown>>({
...
@@ -147,6 +152,24 @@ export function CombiForm<T extends Record<string, unknown>>({
);
);
}
}
function formatDetailValue(
value: unknown,
prefix?: ReactNode,
suffix?: ReactNode,
emptyValueAsDash = true,
): ReactNode {
if (value === undefined || value === null || value === '') {
return emptyValueAsDash ? '-' : String(value ?? '—');
}
return (
<>
{prefix}
{String(value)}
{suffix}
</>
);
}
function inputPlaceholder<T extends Record<string, unknown>>(field: FieldSchema<T>): string {
function inputPlaceholder<T extends Record<string, unknown>>(field: FieldSchema<T>): string {
if (field.placeholder) return field.placeholder;
if (field.placeholder) return field.placeholder;
return `请输入${typeof field.label === 'string' ? field.label : '内容'}`;
return `请输入${typeof field.label === 'string' ? field.label : '内容'}`;
...
...
packages/biz/src/components/formSchema.ts
View file @
d62b975
...
@@ -61,6 +61,11 @@ export interface FieldSchema<T extends Record<string, unknown> = Record<string,
...
@@ -61,6 +61,11 @@ export interface FieldSchema<T extends Record<string, unknown> = Record<string,
*/
*/
countsAsFilter
?:
boolean
;
countsAsFilter
?:
boolean
;
itemStyle
?:
CSSProperties
;
itemStyle
?:
CSSProperties
;
/** 详情模式值的前缀与后缀;值为空时统一显示“-”。 */
detailPrefix
?:
ReactNode
;
detailSuffix
?:
ReactNode
;
/** 空值是否显示“-”;默认开启,设为 false 时保留原来的空值展示。 */
emptyValueAsDash
?:
boolean
;
/** input 类型的扩展属性,如最大长度、数字键盘等。 */
/** input 类型的扩展属性,如最大长度、数字键盘等。 */
inputProps
?:
InputProps
;
inputProps
?:
InputProps
;
/** textarea 类型的扩展属性。 */
/** textarea 类型的扩展属性。 */
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment