Commit 0cb7fa74 by liimin

Merge branch 'v1.0.0' of http://192.168.3.233:8090/ujia/uj-admin into v1.0.0

2 parents fd4903ae fceeff5b
Pipeline #493 for 0cb7fa74 failed in 0 seconds
......@@ -19,6 +19,7 @@ import Operation from './pages/Operation';
import ContractDetail from './pages/Operation/ContractDetail';
import ContractEdit from './pages/Operation/ContractEdit';
import Vehicles from './pages/Vehicles';
import VehicleDetail from './pages/Vehicles/VehicleDetail';
import Delivery from './pages/Delivery';
import Ledger from './pages/Ledger';
import Handover from './pages/Handover';
......@@ -45,6 +46,8 @@ const ROUTES: RouteDef[] = [
{ path: 'operation/contract/:id', Page: ContractDetail },
{ path: 'operation/contract-edit/:id/:contractNo', Page: ContractEdit },
{ path: 'vehicles', Page: Vehicles },
{ path: 'vehicles/:id', Page: VehicleDetail },
{ path: 'vehicles/:id/:mode', Page: VehicleDetail },
{ path: 'delivery', Page: Delivery },
{ path: 'ledger', Page: Ledger },
{ path: 'handover', Page: Handover },
......
import { useEffect, useMemo, useState } from 'react';
import { useQuery } from '@tanstack/react-query';
import dayjs, { type Dayjs } from 'dayjs';
import { UAlert, UButton, UCard, UDatePicker, UForm, UModal, UResult, useUMessage } from '@uj/ui';
import { CombiForm, PageShell, type FieldSchema } from '@/components';
import { useAccess } from '@/access';
import { carManagementApi } from '@/api';
import { UC } from '@/permissions/codes';
import type { PageParams } from '@/routes';
import { goTo } from '../Leads/navigate';
import { errorDetail } from '@/utils/error';
import './vehicles.css';
type VehicleDetail = Record<string, unknown> & {
id: string | number;
carStatus?: string | number;
evalOrderNo?: string;
sellingTime?: string;
};
type Values = Record<string, unknown>;
const STATUS = [
{ value: '0', label: '库存中' },
{ value: '2', label: '待售' },
{ value: '3', label: '已预定' },
{ value: '5', label: '待拍卖' },
{ value: '8', label: '预展中' },
{ value: '6', label: '拍卖中' },
{ value: '1', label: '已售出' },
{ value: '4', label: '已交付' },
{ value: '7', label: '已退库' },
];
const LEVEL: Record<string, number> = {
'0': 1,
'2': 2,
'3': 3,
'5': 4,
'8': 5,
'6': 6,
'1': 7,
'4': 8,
'7': 9,
};
const display = (value: unknown) =>
value === undefined || value === null || value === '' ? '-' : String(value);
const displayMoney = (value: unknown) => (display(value) === '-' ? '-' : `${display(value)} 元`);
const readFields = (names: Array<[string, string]>) =>
names.map(([name, label]) => ({
name,
label,
type: 'input' as const,
render: (value: unknown) =>
['purchasePrice', 'sellingPrice', 'msrp'].includes(name)
? displayMoney(value)
: display(value),
}));
const statusLabel = (value: unknown) =>
STATUS.find((item) => item.value === String(value))?.label ?? display(value);
function previewUrl(value: unknown): string {
if (typeof value === 'string') return value;
if (Array.isArray(value)) return previewUrl(value[0]);
if (value && typeof value === 'object')
return String((value as Record<string, unknown>).fileUrl ?? '');
return '';
}
function FilePreview({ value }: { value: unknown }) {
const url = previewUrl(value);
if (!url) return '-';
const name = url.split('?')[0].split('/').at(-1) || '附件文件';
return (
<div className="uc-vehicle-file">
<span className="uc-vehicle-file__name" title={name}>
{name}
</span>
<UButton
type="link"
size="small"
onClick={() => window.open(url, '_blank', 'noopener,noreferrer')}
>
预览
</UButton>
</div>
);
}
export default function VehicleDetail({ params }: { params: PageParams }) {
const editing = params.mode === 'edit';
const { canPoint } = useAccess();
const allowed = canPoint(UC.VEHICLE_VIEW) && (!editing || canPoint(UC.VEHICLE_STATUS));
const message = useUMessage();
const id = params.id;
const [form] = UForm.useForm<Values>();
const formValues = UForm.useWatch([], form) as Values | undefined;
const [confirmOpen, setConfirmOpen] = useState(false);
const [saving, setSaving] = useState(false);
const detail = useQuery({
queryKey: ['usedcar', 'vehicle', id],
queryFn: () => carManagementApi.getCarManagementDetail<VehicleDetail>({ id }),
enabled: allowed && Boolean(id),
});
const data = detail.data ?? ({ id: id ?? '' } as VehicleDetail);
const currentStatus = String(data.carStatus ?? '');
const statusOptions = useMemo(
() => STATUS.filter((item) => LEVEL[item.value] >= (LEVEL[currentStatus] ?? 0)),
[currentStatus],
);
useEffect(() => {
if (!detail.data) return;
form.setFieldsValue({
...detail.data,
carStatus:
detail.data.carStatus === undefined || detail.data.carStatus === null
? undefined
: String(detail.data.carStatus),
sellingTime: detail.data.sellingTime ? dayjs(String(detail.data.sellingTime)) : undefined,
});
}, [detail.data, form]);
if (!allowed)
return (
<UResult
status="403"
title={editing ? '无变更车辆状态的权限' : '无查看车辆详情的权限'}
subTitle="请联系管理员开通对应权限。"
/>
);
if (!id) return <UResult status="404" title="未找到车辆" subTitle="详情地址缺少车辆编号。" />;
const sold = String(formValues?.carStatus ?? currentStatus) === '1';
const editFields: FieldSchema<Values>[] = [
{
name: 'carStatus',
label: '车辆状态',
type: 'select',
section: '车辆状态与保管信息',
options: statusOptions,
rules: [{ required: true, message: '请选择车辆状态' }],
},
{
name: 'storageLocation',
label: '保管地',
type: 'input',
section: '车辆状态与保管信息',
inputProps: { maxLength: 50 },
},
{
name: 'sellingPrice',
label: '卖出价(元)',
type: 'input',
section: '车辆采购与卖出信息',
disabled: !sold,
inputProps: { inputMode: 'decimal', maxLength: 15 },
rules: sold
? [
{ required: true, message: '请输入卖出价' },
{ pattern: /^\d+(\.\d{1,2})?$/, message: '请输入有效卖出价' },
]
: [],
},
{
name: 'sellingTime',
label: '卖出时间',
type: 'date',
section: '车辆采购与卖出信息',
disabled: !sold,
rules: sold ? [{ required: true, message: '请选择卖出时间' }] : [],
},
{
name: 'seller',
label: '卖出方',
type: 'input',
section: '车辆采购与卖出信息',
disabled: !sold,
inputProps: { maxLength: 200 },
rules: sold ? [{ required: true, message: '请输入卖出方' }] : [],
},
{
name: 'sellingNotes',
label: '车辆卖出备注',
type: 'textarea',
section: '车辆采购与卖出信息',
itemStyle: { gridColumn: 'span 2' },
textareaProps: { maxLength: 200, rows: 3, showCount: true },
},
{
name: 'vehicleNotes',
label: '车辆备注',
type: 'textarea',
section: '车辆信息',
itemStyle: { gridColumn: 'span 2' },
textareaProps: { maxLength: 200, rows: 3, showCount: true },
},
];
const submit = async (values: Values) => {
const isSold = String(values.carStatus) === '1';
if (isSold && !values.sellingTime) {
message.error('请选择卖出时间');
return;
}
setSaving(true);
try {
const response = await carManagementApi.editCarStatus<unknown>({
id,
evalOrderNo: data.evalOrderNo,
carStatus: values.carStatus,
storageLocation: values.storageLocation,
sellingNotes: values.sellingNotes,
vehicleNotes: values.vehicleNotes,
...(isSold
? {
sellingPrice: values.sellingPrice,
seller: values.seller,
sellingTime: dayjs(values.sellingTime as Dayjs).format('YYYY-MM-DD 00:00:00'),
}
: {}),
});
if (response !== true) {
message.error('操作失败');
return;
}
message.success('操作成功');
goTo('vehicles');
} catch (error) {
message.error(errorDetail(error));
} finally {
setSaving(false);
setConfirmOpen(false);
}
};
return (
<PageShell title={editing ? '编辑车辆' : '车辆详情'}>
{detail.isError ? (
<UAlert
type="error"
showIcon
title="车辆详情加载失败"
description={errorDetail(detail.error)}
/>
) : null}
<div className="uc-vehicle-detail">
{editing ? (
<UCard>
<CombiForm
mode="form"
form={form}
fields={editFields}
initialValues={{}}
layout="horizontal"
labelWidth={128}
sectionContentStyle={{
display: 'grid',
gridTemplateColumns: 'repeat(2, minmax(0, 1fr))',
columnGap: 24,
}}
renderSectionTitle={(title) => (
<h3 className="uc-vehicle-detail__section-title">{title}</h3>
)}
renderControl={(field) =>
field.name === 'sellingTime' ? <UDatePicker disabled={!sold} /> : undefined
}
onSubmit={() => setConfirmOpen(true)}
/>
</UCard>
) : null}
{!editing ? (
<UCard title="车辆状态与保管信息">
<CombiForm
mode="detail"
detailColumns={2}
labelWidth={128}
fields={[
{ name: 'carStatus', label: '车辆状态', type: 'input', render: statusLabel },
{ name: 'carCreator', label: '车辆创建人', type: 'input', render: display },
{ name: 'storageLocation', label: '保管地', type: 'input', render: display },
{ name: 'custodian', label: '保管人', type: 'input', render: display },
{
name: 'custodyContract',
label: '代保管合同',
type: 'input',
render: (value) => <FilePreview value={value} />,
},
{
name: 'deliveryConfirmation',
label: '交车确认书',
type: 'input',
render: (value) => <FilePreview value={value} />,
},
{
name: 'supplementaryAgreement',
label: '补充协议',
type: 'input',
render: (value) => <FilePreview value={value} />,
},
]}
initialValues={data}
/>
</UCard>
) : null}
<UCard title="车辆采购与卖出信息">
<CombiForm
mode="detail"
detailColumns={2}
labelWidth={128}
fields={readFields([
['purchasePrice', '收车价'],
['purchaseTime', '收车时间'],
['sellingPrice', '卖出价'],
['sellingTime', '卖出时间'],
['seller', '卖出方'],
['sellingNotes', '车辆卖出备注'],
])}
initialValues={data}
/>
</UCard>
<UCard title="车辆信息">
<CombiForm
mode="detail"
detailColumns={2}
labelWidth={128}
fields={readFields([
['licensePlate', '车牌号'],
['vin', '车架号'],
['sourceNo', '车源号'],
['carTypeName', '车型'],
['listingDate', '上牌时间'],
['listingCity', '上牌城市'],
['mileage', '表显里程'],
['usageType', '使用性质'],
['ownerType', '所有人性质'],
['hasAccident', '是否事故'],
['sunroof', '天窗'],
['sourceStoreName', '车辆来源门店'],
['createTime', '车辆创建时间'],
['originalOwner', '原车主姓名'],
['ownerContact', '原车主联系方式'],
['insuranceExpiry', '交强险到期日'],
['inspectionExpiry', '年审到期日'],
['msrp', '新车指导价'],
['productionDate', '车辆生产日期'],
['source', '车辆来源'],
['vehicleNotes', '车辆备注'],
])}
initialValues={data}
/>
</UCard>
<UCard title="牌证信息">
<CombiForm
mode="detail"
detailColumns={2}
labelWidth={128}
fields={readFields([
['keyCode', '钥匙编码'],
['keyCount', '钥匙数'],
['transfersNumber', '过户次数'],
])}
initialValues={data}
/>
</UCard>
</div>
{editing ? (
<div className="uc-vehicle-detail-actions">
<UButton type="primary" loading={saving} onClick={() => form.submit()}>
保存
</UButton>
<UButton onClick={() => goTo('vehicles')}>关闭</UButton>
</div>
) : (
<div className="uc-vehicle-detail-actions">
<UButton onClick={() => goTo('vehicles')}>返回</UButton>
</div>
)}
<UModal
open={confirmOpen}
title="提示"
confirmLoading={saving}
onCancel={() => setConfirmOpen(false)}
onOk={() => void form.validateFields().then(submit)}
>
请确认是否要执行当前操作?
</UModal>
</PageShell>
);
}
import { RoutePlaceholder } from '@/features/shared/RoutePlaceholder';
import { useMemo, useState } from 'react';
import { useQuery } from '@tanstack/react-query';
import type { Dayjs } from 'dayjs';
import { UAlert, UButton, UCard, UResult, UTag } from '@uj/ui';
import { downloadCenter } from '@uj/platform-sdk';
import {
DataTable,
PageShell,
SearchForm,
type ActionSchema,
type FieldSchema,
type RowActionSchema,
} from '@/components';
import { useAccess } from '@/access';
import { carManagementApi } from '@/api';
import { UC } from '@/permissions/codes';
import { goTo } from '../Leads/navigate';
import { errorDetail } from '@/utils/error';
import './vehicles.css';
type Filters = {
licensePlate?: string;
vin?: string;
sourceNo?: string;
carTypeName?: string;
registerTime?: [Dayjs, Dayjs];
listingCity?: string;
usageType?: string;
ownerType?: string;
hasAccident?: string;
carCreator?: string;
carStatus?: string;
originalOwner?: string;
ownerContact?: string;
custodian?: string;
carCreateTime?: [Dayjs, Dayjs];
source?: string;
};
type Vehicle = Record<string, unknown> & { id: string | number; carPhoto?: string };
type PageResult = { records: Vehicle[]; total: number };
const OPTIONS = {
usageType: [
{ value: '1', label: '非营运' },
{ value: '2', label: '营运' },
{ value: '3', label: '营转非' },
],
ownerType: [
{ value: '1', label: '个人' },
{ value: '2', label: '单位' },
],
hasAccident: [
{ value: '0', label: '否' },
{ value: '1', label: '是' },
],
source: [
{ value: '1', label: '系统生成' },
{ value: '2', label: '人工导入' },
],
carStatus: [
{ value: '0', label: '库存中' },
{ value: '2', label: '待售' },
{ value: '3', label: '已预定' },
{ value: '5', label: '待拍卖' },
{ value: '8', label: '预展中' },
{ value: '6', label: '拍卖中' },
{ value: '1', label: '已售出' },
{ value: '4', label: '已交付' },
{ value: '7', label: '已退库' },
],
} as const;
const text = (value: unknown) =>
value === undefined || value === null || value === '' ? '-' : String(value);
const labelOf = (options: readonly { value: string; label: string }[], value: unknown) =>
options.find((item) => item.value === String(value))?.label ?? '-';
function toParams(filters: Filters) {
const { registerTime, carCreateTime, ...rest } = filters;
return Object.fromEntries(
Object.entries({
...rest,
...(registerTime
? {
listingStartDate: `${registerTime[0].format('YYYY-MM-DD')} 00:00:00`,
listingEndDate: `${registerTime[1].format('YYYY-MM-DD')} 23:59:59`,
}
: {}),
...(carCreateTime
? {
createdStartDate: carCreateTime[0].format('YYYY-MM-DD HH:mm:ss'),
createdEndDate: carCreateTime[1].format('YYYY-MM-DD HH:mm:ss'),
}
: {}),
}).filter(([, value]) => value !== '' && value !== undefined),
);
}
/** menu_code 1002605 · 车辆管理 · usedcar:vehicle:view */
export default function Vehicles() {
return <RoutePlaceholder title="车辆管理" route="/usedcar/vehicles" />;
const { canPoint } = useAccess();
const allowed = canPoint(UC.VEHICLE_VIEW);
const [filters, setFilters] = useState<Filters>({});
const [page, setPage] = useState({ current: 1, size: 10 });
const [selectedKeys, setSelectedKeys] = useState<React.Key[]>([]);
const params = useMemo(() => toParams(filters), [filters]);
const list = useQuery({
queryKey: ['usedcar', 'vehicles', params, page],
queryFn: () =>
carManagementApi.getCarManagementPage<PageResult>({
currentPage: page.current,
pageSize: page.size,
t: params,
}),
enabled: allowed,
});
const fields: FieldSchema<Filters>[] = [
{ name: 'licensePlate', label: '车牌号', type: 'input', essential: true },
{ name: 'vin', label: '车架号', type: 'input', essential: true },
{
name: 'sourceNo',
label: '车源号',
type: 'input',
essential: true,
inputProps: { maxLength: 20 },
normalize: (value) =>
String(value ?? '')
.replace(/[^\x20-\x7E]/g, '')
.slice(0, 20),
},
{ name: 'carTypeName', label: '车型', type: 'input', essential: true },
{ name: 'registerTime', label: '上牌时间', type: 'dateRange' },
{ name: 'listingCity', label: '上牌城市', type: 'input' },
{ name: 'usageType', label: '使用性质', type: 'select', options: [...OPTIONS.usageType] },
{ name: 'ownerType', label: '所有人性质', type: 'select', options: [...OPTIONS.ownerType] },
{ name: 'hasAccident', label: '是否事故', type: 'select', options: [...OPTIONS.hasAccident] },
{ name: 'carCreator', label: '车辆创建人', type: 'input' },
{ name: 'carStatus', label: '车辆状态', type: 'select', options: [...OPTIONS.carStatus] },
{ name: 'originalOwner', label: '原车主姓名', type: 'input' },
{ name: 'ownerContact', label: '原车主联系方式', type: 'input' },
{ name: 'custodian', label: '车辆保管人', type: 'input' },
{ name: 'carCreateTime', label: '车辆创建时间', type: 'dateRange' },
{ name: 'source', label: '车辆来源', type: 'select', options: [...OPTIONS.source] },
];
const columns = [
{
title: '车辆照片',
dataIndex: 'carPhoto',
width: 112,
render: (url: unknown) =>
typeof url === 'string' ? <img className="uc-vehicle-cover" src={url} alt="车辆" /> : '-',
},
{ title: '车牌号', dataIndex: 'licensePlate', width: 110, render: text },
{ title: '车架号', dataIndex: 'vin', width: 170, render: text },
{ title: '车源号', dataIndex: 'sourceNo', width: 140, render: text },
{
title: '车型',
key: 'model',
width: 190,
render: (_: unknown, row: Vehicle) =>
[row.carBrand, row.carSeriesName, row.carTypeName].filter(Boolean).join(' ') || '-',
},
{ title: '上牌时间', dataIndex: 'listingDate', width: 130, render: text },
{ title: '上牌城市', dataIndex: 'listingCity', width: 120, render: text },
{
title: '使用性质',
dataIndex: 'usageType',
width: 110,
render: (value: unknown) => labelOf(OPTIONS.usageType, value),
},
{
title: '所有人性质',
dataIndex: 'ownerType',
width: 110,
render: (value: unknown) => labelOf(OPTIONS.ownerType, value),
},
{
title: '是否事故',
dataIndex: 'hasAccident',
width: 100,
render: (value: unknown) => labelOf(OPTIONS.hasAccident, value),
},
{ title: '车辆创建人', dataIndex: 'carCreator', width: 120, render: text },
{
title: '车辆状态',
dataIndex: 'carStatus',
width: 115,
render: (value: unknown) => <UTag>{labelOf(OPTIONS.carStatus, value)}</UTag>,
},
{ title: '原车主姓名', dataIndex: 'originalOwner', width: 120, render: text },
{ title: '原车主联系方式', dataIndex: 'ownerContact', width: 140, render: text },
{ title: '车辆保管人', dataIndex: 'custodian', width: 120, render: text },
{ title: '车辆创建时间', dataIndex: 'createTime', width: 170, render: text },
{
title: '车辆来源',
dataIndex: 'source',
width: 110,
render: (value: unknown) => labelOf(OPTIONS.source, value),
},
];
const rowActions: RowActionSchema<Vehicle>[] = [
{
label: '详情',
permission: UC.VEHICLE_DETAIL,
onClick: (row) => goTo(`vehicles/${encodeURIComponent(String(row.id))}`),
},
{
label: '状态变更',
permission: UC.VEHICLE_STATUS,
onClick: (row) => goTo(`vehicles/${encodeURIComponent(String(row.id))}/edit`),
},
{
label: '图片下载',
permission: UC.VEHICLE_IMAGE_DOWNLOAD,
onClick: (row) =>
downloadCenter.asyncExport({
source: 'usedcar',
sourceLabel: '二手车管理 / 车辆管理 / 车辆图片下载',
label: '车辆管理车辆图片',
method: '/carManagement/exportCarManageInfoImageZipAsync',
params: { id: row.id },
dedupeKey: `vehicle-images-${String(row.id)}`,
}),
},
];
const actions: ActionSchema[] = canPoint(UC.VEHICLE_EXPORT)
? [
{
label: '导出',
tone: 'export',
onClick: () =>
downloadCenter.asyncExport({
source: 'usedcar',
sourceLabel: '二手车管理 / 车辆管理 / 车辆列表导出',
label: '车辆管理',
method: '/carManagement/exportCarManageInfoAsync',
params: { ...params, idsStr: selectedKeys.join(',') },
dedupeKey: 'vehicle-export',
}),
},
]
: [];
if (!allowed)
return (
<UResult status="403" title="无访问车辆管理的权限" subTitle="请联系管理员开通访问权限。" />
);
return (
<PageShell fill title="车辆管理">
<UCard className="uj-filter-card" size="small">
<SearchForm
fields={fields}
initialValues={{}}
onSearch={(values) => {
setFilters(values);
setPage((old) => ({ ...old, current: 1 }));
}}
onReset={() => {
setFilters({});
setPage((old) => ({ ...old, current: 1 }));
}}
/>
</UCard>
{list.isError ? (
<UAlert
type="error"
showIcon
title="车辆列表加载失败"
description={errorDetail(list.error)}
action={
<UButton type="link" onClick={() => void list.refetch()}>
重试
</UButton>
}
/>
) : null}
<UCard size="small" fill>
<DataTable<Vehicle>
rowKey="id"
fillHeight
columns={columns}
dataSource={list.data?.records ?? []}
loading={list.isPending || list.isFetching}
rowSelection={{ selectedRowKeys: selectedKeys, onChange: setSelectedKeys }}
rowActions={rowActions}
actions={actions}
actionColumnWidth={240}
pagination={{
current: page.current,
pageSize: page.size,
total: list.data?.total ?? 0,
onChange: (current, size) =>
setPage({ current: size === page.size ? current : 1, size }),
}}
/>
</UCard>
</PageShell>
);
}
.uc-vehicle-cover {
display: block;
width: 88px;
height: 64px;
object-fit: contain;
border-radius: 4px;
background: var(--ant-color-fill-quaternary);
}
.uc-vehicle-detail {
display: grid;
gap: 16px;
}
.uc-vehicle-detail .ant-descriptions-view > table {
width: 100%;
table-layout: fixed;
}
.uc-vehicle-detail .ant-descriptions-item-label {
width: 128px;
min-width: 128px;
white-space: nowrap;
}
.uc-vehicle-detail-actions {
display: flex;
justify-content: center;
gap: 12px;
margin-top: 16px;
}
.uc-vehicle-detail__section-title {
margin: 0 0 16px;
padding-bottom: 12px;
border-bottom: 1px solid var(--ant-color-border-secondary);
font-size: 16px;
}
.uc-vehicle-file {
display: flex;
align-items: center;
width: 240px;
min-width: 0;
}
.uc-vehicle-file__name {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.uc-vehicle-file .ant-btn-link {
flex: 0 0 auto;
padding-inline: 6px 0;
}
......@@ -13,6 +13,12 @@ export interface CombiFormProps<T extends Record<string, unknown>> {
formStyle?: CSSProperties;
sectionContentStyle?: CSSProperties;
renderSectionTitle?: (title: string) => ReactNode;
/** 详情信息每行列数,默认单列。 */
detailColumns?: number;
/** 标签固定宽度,表单和详情均右对齐。 */
labelWidth?: number;
/** 标签对齐方式,默认右对齐。 */
labelAlign?: 'left' | 'right';
renderControl?: (
field: FieldSchema<T>,
form: FormInstance<T>,
......@@ -30,18 +36,27 @@ export function CombiForm<T extends Record<string, unknown>>({
sectionContentStyle,
renderSectionTitle,
renderControl,
detailColumns = 1,
labelWidth,
labelAlign = 'right',
}: CombiFormProps<T>) {
const [innerForm] = UForm.useForm<T>();
const form = externalForm ?? innerForm;
const values = UForm.useWatch([], form) as T | undefined;
const data = (values ?? initialValues ?? {}) as T;
// 详情模式只展示调用方传入的数据;空的内部表单状态不能覆盖接口返回的详情值。
const data = (mode === 'detail' ? initialValues : (values ?? initialValues ?? {})) as T;
const visible = fields.filter(
(field) => !(typeof field.hidden === 'function' ? field.hidden(data) : field.hidden),
);
if (mode === 'detail')
return (
<UDescriptions
column={1}
column={detailColumns}
styles={
labelWidth === undefined
? undefined
: { label: { width: labelWidth, justifyContent: labelAlign, whiteSpace: 'nowrap' } }
}
items={visible.map((field) => ({
key: field.name,
label: field.label,
......@@ -103,6 +118,9 @@ export function CombiForm<T extends Record<string, unknown>>({
form={form}
initialValues={initialValues}
layout={layout}
labelAlign={labelAlign}
labelCol={labelWidth === undefined ? undefined : { flex: `${labelWidth}px` }}
wrapperCol={labelWidth === undefined ? undefined : { flex: 'auto' }}
style={formStyle}
onFinish={(next) => onSubmit?.(next as T)}
>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!