Commit 52c3306f by chenwq

优化合同和阳光激励页面,增加字段选项和逻辑,添加选中行功能

1 parent 7823eb54
import { useState } from 'react'; import { useState } from 'react';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import dayjs from 'dayjs';
import { UAlert, UCard, useUMessage } from '@uj/ui'; import { UAlert, UCard, useUMessage } from '@uj/ui';
import { DataTable, SearchForm, type FieldSchema, type RowActionSchema } from '@/components'; import { DataTable, SearchForm, type FieldSchema, type RowActionSchema } from '@/components';
import { useAccess } from '@/access'; import { useAccess } from '@/access';
...@@ -10,12 +11,26 @@ import { errorDetail } from '@/utils/error'; ...@@ -10,12 +11,26 @@ import { errorDetail } from '@/utils/error';
import { CONTRACT_COLUMNS } from './tableConfig'; import { CONTRACT_COLUMNS } from './tableConfig';
import { goTo } from '../../Leads/navigate'; import { goTo } from '../../Leads/navigate';
import ImportContractModal from './ImportContractModal'; import ImportContractModal from './ImportContractModal';
import {
CONTRACT_FLOW_STATUSES,
CONTRACT_ORGS,
CONTRACT_SOURCES,
CONTRACT_TEMPLATES,
CONTRACT_TYPES,
OA_FLOW_STATUSES,
OA_PAYMENT_STATUSES,
PAYMENT_METHODS,
PAYMENT_STATUSES,
SIGNER_TYPES,
YES_NO_OPTIONS,
} from './operationOptions';
export default function ContractTab() { export default function ContractTab() {
const { canPoint } = useAccess(), const { canPoint } = useAccess(),
msg = useUMessage(), msg = useUMessage(),
qc = useQueryClient(); qc = useQueryClient();
const [p, setP] = useState({ current: 1, size: 10 }); const [p, setP] = useState({ current: 1, size: 10 });
const [f, setF] = useState<Record<string, unknown>>({}); const [f, setF] = useState<Record<string, unknown>>({});
const [selectedKeys, setSelectedKeys] = useState<React.Key[]>([]);
const [importOpen, setImportOpen] = useState(false); const [importOpen, setImportOpen] = useState(false);
const q = useQuery({ const q = useQuery({
queryKey: ['op', 'contracts', p, f], queryKey: ['op', 'contracts', p, f],
...@@ -40,26 +55,54 @@ export default function ContractTab() { ...@@ -40,26 +55,54 @@ export default function ContractTab() {
onError: (error) => msg.error(errorDetail(error)), onError: (error) => msg.error(errorDetail(error)),
}); });
// 查询项对齐源 contract/index.vue searchForm(21 项里的高频字段;金额区间按源拆起止)。
const fields: FieldSchema<Record<string, unknown>>[] = [ const fields: FieldSchema<Record<string, unknown>>[] = [
{ name: 'licensePlate', label: '车牌号', type: 'input', essential: true }, { name: 'licensePlate', label: '车牌号', type: 'input', essential: true },
{ name: 'vin', label: '车架号', type: 'input', essential: true }, { name: 'vin', label: '车架号', type: 'input', essential: true },
{ name: 'contractNo', label: '合同编号', type: 'input', essential: true }, { name: 'carTypeName', label: '车型', type: 'input', essential: true },
{ name: 'evalOrderNo', label: '评估单编号', type: 'input' }, {
{ name: 'signTime', label: '签约时间', type: 'dateRange' }, name: 'signTime',
{ name: 'electronicContractType', label: '合同类型', type: 'input' }, label: '签约时间',
{ name: 'docTemplateType', label: '合同模版', type: 'input' }, type: 'dateRange',
{ name: 'electronicContractStatus', label: '流转状态', type: 'input' }, disabledDate: (date) => date.isAfter(dayjs(), 'day'),
},
{ name: 'electronicContractType', label: '合同类型', type: 'select', options: CONTRACT_TYPES },
{ name: 'docTemplateType', label: '合同模版', type: 'select', options: CONTRACT_TEMPLATES },
{
name: 'electronicContractStatus',
label: '合同流转状态',
type: 'select',
options: CONTRACT_FLOW_STATUSES,
},
{ name: 'createdBy', label: '驻店人员', type: 'input' }, { name: 'createdBy', label: '驻店人员', type: 'input' },
{ name: 'oaFlowPaymentStatus', label: '支付状态', type: 'input' }, {
{ name: 'paymentType', label: '支付方式', type: 'input' }, name: 'oaFlowPaymentStatus',
label: '支付状态',
type: 'select',
options: OA_PAYMENT_STATUSES,
},
{ name: 'paymentType', label: '支付方式', type: 'select', options: PAYMENT_STATUSES },
{ name: 'lastOaFlowCode', label: '企微审批单号', type: 'input' }, { name: 'lastOaFlowCode', label: '企微审批单号', type: 'input' },
{ name: 'oaFlowStatus', label: '企微审批状态', type: 'input' },
{ name: 'previousOwnerName', label: '车主姓名', type: 'input' }, { name: 'previousOwnerName', label: '车主姓名', type: 'input' },
{ name: 'previousOwnerPhone', label: '车主电话', type: 'input' }, { name: 'previousOwnerPhone', label: '车主联系方式', type: 'input' },
{ name: 'source', label: '合同来源', type: 'input' }, { name: 'oaFlowStatus', label: '企微审批状态', type: 'select', options: OA_FLOW_STATUSES },
{ name: 'signerType', label: '签署人类型', type: 'input' }, { name: 'splitPay', label: '是否拆分支付', type: 'select', options: YES_NO_OPTIONS },
{ name: 'contractOrg', label: '内部主体', type: 'input' }, {
name: 'minContractPrice',
label: '合同金额(最小)',
type: 'input',
inputProps: { inputMode: 'decimal' },
},
{
name: 'maxContractPrice',
label: '合同金额(最大)',
type: 'input',
inputProps: { inputMode: 'decimal' },
},
{ name: 'evalOrderNo', label: '评估单编号', type: 'input' },
{ name: 'source', label: '合同来源', type: 'select', options: CONTRACT_SOURCES },
{ name: 'paymentMethod', label: '付款方式', type: 'select', options: PAYMENT_METHODS },
{ name: 'signerType', label: '签署人类型', type: 'select', options: SIGNER_TYPES },
{ name: 'contractOrg', label: '内部主体', type: 'select', options: CONTRACT_ORGS },
]; ];
const actions: RowActionSchema<Contract>[] = [ const actions: RowActionSchema<Contract>[] = [
{ {
...@@ -98,7 +141,8 @@ export default function ContractTab() { ...@@ -98,7 +141,8 @@ export default function ContractTab() {
onSearch={(v) => { onSearch={(v) => {
// 签约时间是范围控件,按源拆成起止两个参数再传给列表/导出。 // 签约时间是范围控件,按源拆成起止两个参数再传给列表/导出。
const { signTime, ...rest } = v; const { signTime, ...rest } = v;
const range = signTime as unknown as Array<{ format: (f: string) => string }> | undefined; const range = signTime as unknown as
Array<{ format: (f: string) => string }> | undefined;
setF({ setF({
...rest, ...rest,
...(range?.length === 2 ...(range?.length === 2
...@@ -109,8 +153,12 @@ export default function ContractTab() { ...@@ -109,8 +153,12 @@ export default function ContractTab() {
: {}), : {}),
}); });
setP((x) => ({ ...x, current: 1 })); setP((x) => ({ ...x, current: 1 }));
setSelectedKeys([]);
}}
onReset={() => {
setF({});
setSelectedKeys([]);
}} }}
onReset={() => setF({})}
/> />
</UCard> </UCard>
{q.isError ? <UAlert type="error" showIcon title="合同列表加载失败" /> : null} {q.isError ? <UAlert type="error" showIcon title="合同列表加载失败" /> : null}
...@@ -121,6 +169,11 @@ export default function ContractTab() { ...@@ -121,6 +169,11 @@ export default function ContractTab() {
columns={CONTRACT_COLUMNS} columns={CONTRACT_COLUMNS}
dataSource={q.data?.records ?? []} dataSource={q.data?.records ?? []}
loading={q.isLoading} loading={q.isLoading}
rowSelection={{
selectedRowKeys: selectedKeys,
onChange: setSelectedKeys,
preserveSelectedRowKeys: true,
}}
rowActions={actions} rowActions={actions}
actions={[ actions={[
...(canPoint(UC.CONTRACT_IMPORT) ...(canPoint(UC.CONTRACT_IMPORT)
...@@ -131,7 +184,7 @@ export default function ContractTab() { ...@@ -131,7 +184,7 @@ export default function ContractTab() {
{ {
label: '导出', label: '导出',
tone: 'export' as const, tone: 'export' as const,
onClick: () => onClick: () => {
downloadCenter.asyncExport({ downloadCenter.asyncExport({
source: 'usedcar', source: 'usedcar',
sourceLabel: '运营管理 / 合同管理', sourceLabel: '运营管理 / 合同管理',
...@@ -139,10 +192,13 @@ export default function ContractTab() { ...@@ -139,10 +192,13 @@ export default function ContractTab() {
method: '/evalElectronicContract/exportElectronicContractAsync', method: '/evalElectronicContract/exportElectronicContractAsync',
params: { params: {
...f, ...f,
idsStr: selectedKeys.join(','),
currentPage: 1, currentPage: 1,
}, },
dedupeKey: 'operation-contract-export', dedupeKey: 'operation-contract-export',
}), });
setSelectedKeys([]);
},
}, },
] ]
: []), : []),
......
import { useState } from 'react'; import { useState } from 'react';
import { useQuery, useQueryClient } from '@tanstack/react-query'; import { useQuery, useQueryClient } from '@tanstack/react-query';
import dayjs from 'dayjs';
import { UCard, useUMessage } from '@uj/ui'; import { UCard, useUMessage } from '@uj/ui';
import { import {
DataTable, DataTable,
...@@ -31,6 +32,7 @@ export default function SunshineTab() { ...@@ -31,6 +32,7 @@ export default function SunshineTab() {
qc = useQueryClient(); qc = useQueryClient();
const [p, setP] = useState({ current: 1, size: 10 }); const [p, setP] = useState({ current: 1, size: 10 });
const [f, setF] = useState<SunshineFilters>({}); const [f, setF] = useState<SunshineFilters>({});
const [selectedKeys, setSelectedKeys] = useState<React.Key[]>([]);
const [edit, setEdit] = useState<Sunshine | null>(null); const [edit, setEdit] = useState<Sunshine | null>(null);
const [detail, setDetail] = useState<Sunshine | null>(null); const [detail, setDetail] = useState<Sunshine | null>(null);
const [pendingDelete, setPendingDelete] = useState<Sunshine | null>(null); const [pendingDelete, setPendingDelete] = useState<Sunshine | null>(null);
...@@ -41,15 +43,9 @@ export default function SunshineTab() { ...@@ -41,15 +43,9 @@ export default function SunshineTab() {
queryFn: () => dashboardApi.getServiceStore({ scene: 7 }), queryFn: () => dashboardApi.getServiceStore({ scene: 7 }),
}); });
const toParams = (filters: SunshineFilters) => ({
...filters,
currentPage: p.current,
pageSize: p.size,
});
const q = useQuery({ const q = useQuery({
queryKey: ['op', 'sun', p, f], queryKey: ['op', 'sun', p, f],
queryFn: () => operationApi.sunshine(toParams(f)), queryFn: () => operationApi.sunshine({ currentPage: p.current, pageSize: p.size, t: f }),
}); });
const reload = () => qc.invalidateQueries({ queryKey: ['op', 'sun'] }); const reload = () => qc.invalidateQueries({ queryKey: ['op', 'sun'] });
...@@ -76,17 +72,22 @@ export default function SunshineTab() { ...@@ -76,17 +72,22 @@ export default function SunshineTab() {
{ name: 'carType', label: '车辆类型', type: 'select', options: CAR_TYPES }, { name: 'carType', label: '车辆类型', type: 'select', options: CAR_TYPES },
{ {
name: 'sunlightInspiresPriceBegin', name: 'sunlightInspiresPriceBegin',
label: '激励价格起', label: '激励价格(最小)',
type: 'input', type: 'input',
inputProps: { inputMode: 'decimal' }, inputProps: { inputMode: 'decimal' },
}, },
{ {
name: 'sunlightInspiresPriceEnd', name: 'sunlightInspiresPriceEnd',
label: '激励价格止', label: '激励价格(最大)',
type: 'input', type: 'input',
inputProps: { inputMode: 'decimal' }, inputProps: { inputMode: 'decimal' },
}, },
{ name: 'createdDate', label: '录入时间', type: 'dateRange' }, {
name: 'createdDate',
label: '录入时间',
type: 'dateRange',
disabledDate: (date) => date.isAfter(dayjs(), 'day'),
},
]; ];
const doDelete = async () => { const doDelete = async () => {
...@@ -107,10 +108,44 @@ export default function SunshineTab() { ...@@ -107,10 +108,44 @@ export default function SunshineTab() {
<SearchForm <SearchForm
fields={fields} fields={fields}
onSearch={(v) => { onSearch={(v) => {
setF(v); const { createdDate, sunlightInspiresPriceBegin, sunlightInspiresPriceEnd, ...rest } =
v;
const dateRange = createdDate as
Array<{ format: (pattern: string) => string }> | undefined;
const minPrice = sunlightInspiresPriceBegin;
const maxPrice = sunlightInspiresPriceEnd;
if (
minPrice !== '' &&
minPrice !== undefined &&
maxPrice !== '' &&
maxPrice !== undefined &&
Number(minPrice) > Number(maxPrice)
) {
msg.error('最小价格不能大于最大价格');
return;
}
setF({
...rest,
...(dateRange?.length === 2
? {
createdDateBegin: dateRange[0].format('YYYY-MM-DD HH:mm:ss'),
createdDateEnd: dateRange[1].format('YYYY-MM-DD HH:mm:ss'),
}
: {}),
...(minPrice !== '' && minPrice !== undefined
? { sunlightInspiresPriceBegin: minPrice }
: {}),
...(maxPrice !== '' && maxPrice !== undefined
? { sunlightInspiresPriceEnd: maxPrice }
: {}),
});
setP((x) => ({ ...x, current: 1 })); setP((x) => ({ ...x, current: 1 }));
setSelectedKeys([]);
}}
onReset={() => {
setF({});
setSelectedKeys([]);
}} }}
onReset={() => setF({})}
/> />
</UCard> </UCard>
<UCard size="small" fill> <UCard size="small" fill>
...@@ -120,6 +155,11 @@ export default function SunshineTab() { ...@@ -120,6 +155,11 @@ export default function SunshineTab() {
columns={SUNSHINE_COLUMNS} columns={SUNSHINE_COLUMNS}
dataSource={q.data?.records ?? []} dataSource={q.data?.records ?? []}
loading={q.isLoading} loading={q.isLoading}
rowSelection={{
selectedRowKeys: selectedKeys,
onChange: setSelectedKeys,
preserveSelectedRowKeys: true,
}}
rowActions={actions} rowActions={actions}
actions={[ actions={[
...(canPoint(UC.INCENTIVE_CREATE) ...(canPoint(UC.INCENTIVE_CREATE)
...@@ -130,7 +170,7 @@ export default function SunshineTab() { ...@@ -130,7 +170,7 @@ export default function SunshineTab() {
{ {
label: '导出', label: '导出',
tone: 'export' as const, tone: 'export' as const,
onClick: () => onClick: () => {
downloadCenter.asyncExport({ downloadCenter.asyncExport({
source: 'usedcar', source: 'usedcar',
sourceLabel: '运营管理 / 阳光激励', sourceLabel: '运营管理 / 阳光激励',
...@@ -138,10 +178,13 @@ export default function SunshineTab() { ...@@ -138,10 +178,13 @@ export default function SunshineTab() {
method: '/sunlightInspiresConfig/export', method: '/sunlightInspiresConfig/export',
params: { params: {
...f, ...f,
ids: selectedKeys,
currentPage: 1, currentPage: 1,
}, },
dedupeKey: 'operation-sunshine-export', dedupeKey: 'operation-sunshine-export',
}), });
setSelectedKeys([]);
},
}, },
] ]
: []), : []),
......
export type OperationOption = { value: string | number; label: string };
export const CONTRACT_TYPES: OperationOption[] = [
{ value: '1', label: '二手车转让协议' },
{ value: '3', label: '二手车补充协议' },
{ value: '2', label: '车辆代保管协议' },
{ value: '4', label: '车辆交接确认单' },
];
export const CONTRACT_TEMPLATES: OperationOption[] = [
{ value: '1', label: '二手车转让协议' },
{ value: '2', label: '车辆代保管协议' },
{ value: '3', label: '二手车补充协议' },
{ value: '4', label: '车辆交接确认单' },
{ value: '5', label: '小鹏旧机动车收购合同' },
{ value: '6', label: '优加二手车委托销售合同(经纪模式)' },
];
export const CONTRACT_FLOW_STATUSES: OperationOption[] = [
{ value: '1', label: '合同签署中' },
{ value: '2', label: '合同签署完成' },
];
export const PAYMENT_STATUSES: OperationOption[] = [
{ value: '1', label: '定金' },
{ value: '2', label: '尾款' },
{ value: '3', label: '全款' },
];
export const OA_FLOW_STATUSES: OperationOption[] = [
{ value: '1', label: '审批中' },
{ value: '2', label: '已通过' },
{ value: '3', label: '已驳回' },
{ value: '4', label: '已撤销' },
];
export const OA_PAYMENT_STATUSES: OperationOption[] = [
{ value: '2', label: '支付成功' },
{ value: '3', label: '支付失败' },
{ value: '1', label: '支付中' },
{ value: '4', label: '支付取消' },
];
export const YES_NO_OPTIONS: OperationOption[] = [
{ value: '1', label: '是' },
{ value: '0', label: '否' },
];
export const CONTRACT_SOURCES: OperationOption[] = [
{ value: '1', label: '系统生成' },
{ value: '2', label: '人工导入' },
];
export const PAYMENT_METHODS: OperationOption[] = [
{ value: '1', label: '银行转账' },
{ value: '2', label: '冲账' },
];
export const SIGNER_TYPES: OperationOption[] = [
{ value: 0, label: '个人' },
{ value: 1, label: '企业委托' },
{ value: 2, label: '企业' },
];
export const CONTRACT_ORGS: OperationOption[] = [
{ value: 'hzglsk', label: '惠州广联' },
{ value: 'szyjzh', label: '优加' },
];
export const optionLabel = (options: OperationOption[], value: unknown): string =>
options.find((option) => String(option.value) === String(value))?.label ?? '-';
import type { DataTableColumnsType } from '@/components'; import type { DataTableColumnsType } from '@/components';
import type { Contract, Sunshine } from '@/api'; import type { Contract, Sunshine } from '@/api';
import { UImage } from '@uj/ui';
import {
CONTRACT_FLOW_STATUSES,
CONTRACT_ORGS,
CONTRACT_SOURCES,
CONTRACT_TYPES,
OA_FLOW_STATUSES,
OA_PAYMENT_STATUSES,
optionLabel,
PAYMENT_METHODS,
PAYMENT_STATUSES,
SIGNER_TYPES,
YES_NO_OPTIONS,
} from './operationOptions';
/** 运营管理表格列的唯一配置位置;页面只负责数据和操作。 */ /** 运营管理表格列的唯一配置位置;页面只负责数据和操作。 */
const cell = (v: unknown) => (v === undefined || v === null || v === '' ? '-' : String(v)); const cell = (v: unknown) => (v === undefined || v === null || v === '' ? '-' : String(v));
...@@ -12,6 +26,17 @@ const cell = (v: unknown) => (v === undefined || v === null || v === '' ? '-' : ...@@ -12,6 +26,17 @@ const cell = (v: unknown) => (v === undefined || v === null || v === '' ? '-' :
* 车型是 render 拼接串、无 dataIndex,tip 取 render 结果本身,完整可见。 * 车型是 render 拼接串、无 dataIndex,tip 取 render 结果本身,完整可见。
*/ */
export const CONTRACT_COLUMNS: DataTableColumnsType<Contract> = [ export const CONTRACT_COLUMNS: DataTableColumnsType<Contract> = [
{
title: '车辆照片',
dataIndex: 'vehicleImgUrl',
width: 138,
render: (value) =>
typeof value === 'string' && value ? (
<UImage src={value} width={96} height={54} alt="车辆" />
) : (
'-'
),
},
{ title: '车牌号', dataIndex: 'licensePlate', render: cell }, { title: '车牌号', dataIndex: 'licensePlate', render: cell },
{ title: '车架号', dataIndex: 'vin', width: 200, render: cell }, { title: '车架号', dataIndex: 'vin', width: 200, render: cell },
{ {
...@@ -20,22 +45,63 @@ export const CONTRACT_COLUMNS: DataTableColumnsType<Contract> = [ ...@@ -20,22 +45,63 @@ export const CONTRACT_COLUMNS: DataTableColumnsType<Contract> = [
render: (_, row) => render: (_, row) =>
[row.carBrand, row.carSeriesName, row.carTypeName].filter(Boolean).join(' ') || '-', [row.carBrand, row.carSeriesName, row.carTypeName].filter(Boolean).join(' ') || '-',
}, },
{ title: '合同编号', dataIndex: 'contractNo', width: 200, render: cell }, { title: '签约时间', dataIndex: 'signTime', render: cell },
{ title: '评估单编号', dataIndex: 'evalOrderNo', width: 200, render: cell }, { title: '评估单编号', dataIndex: 'evalOrderNo', width: 200, render: cell },
{ {
title: '合同类型', title: '合同类型',
dataIndex: 'electronicContractType', dataIndex: 'electronicContractType',
render: cell, render: (value) => optionLabel(CONTRACT_TYPES, value),
}, },
{ title: '合同模版', dataIndex: 'docTemplateName', width: 200, render: cell }, { title: '合同模版', dataIndex: 'docTemplateName', width: 200, render: cell },
{ title: '签约时间', dataIndex: 'signTime', render: cell }, {
title: '合同流转状态',
dataIndex: 'electronicContractStatus',
render: (value) => optionLabel(CONTRACT_FLOW_STATUSES, value),
},
{ title: '驻店人员', dataIndex: 'createdBy', render: cell }, { title: '驻店人员', dataIndex: 'createdBy', render: cell },
{ title: '车主姓名', dataIndex: 'previousOwnerName', render: cell }, {
{ title: '车主电话', dataIndex: 'previousOwnerPhone', render: cell }, title: '支付方式',
{ title: '支付状态', dataIndex: 'oaFlowPaymentStatus', render: cell }, dataIndex: 'paymentType',
render: (value) => optionLabel(PAYMENT_STATUSES, value),
},
{
title: '支付状态',
dataIndex: 'oaFlowPaymentStatus',
render: (value) => optionLabel(OA_PAYMENT_STATUSES, value),
},
{ title: '企微审批单号', dataIndex: 'lastOaFlowCode', render: cell }, { title: '企微审批单号', dataIndex: 'lastOaFlowCode', render: cell },
{ title: '合同金额', dataIndex: 'contractPrice', render: cell }, {
{ title: '合同状态', dataIndex: 'electronicContractStatus', render: cell }, title: '企微审批状态',
dataIndex: 'oaFlowStatus',
render: (value) => optionLabel(OA_FLOW_STATUSES, value),
},
{ title: '车主姓名', dataIndex: 'previousOwnerName', render: cell },
{ title: '车主联系方式', dataIndex: 'previousOwnerPhone', render: cell },
{
title: '是否拆分付款',
dataIndex: 'splitPay',
render: (value) => optionLabel(YES_NO_OPTIONS, value),
},
{
title: '合同来源',
dataIndex: 'source',
render: (value) => optionLabel(CONTRACT_SOURCES, value),
},
{
title: '付款方式',
dataIndex: 'paymentMethod',
render: (value) => optionLabel(PAYMENT_METHODS, value),
},
{
title: '签署人类型',
dataIndex: 'signerType',
render: (value) => optionLabel(SIGNER_TYPES, value),
},
{
title: '内部主体',
dataIndex: 'contractOrg',
render: (value) => optionLabel(CONTRACT_ORGS, value),
},
]; ];
/** 源 constants.js vehicleCategoryOpt:carType 存 confId,列表按字典翻译。 */ /** 源 constants.js vehicleCategoryOpt:carType 存 confId,列表按字典翻译。 */
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!