Commit 8472f9bc by chenwq

优化搜索表单组件,增加日期选择器的禁用日期功能,并完善输入框的占位符提示

1 parent 4fccd7b5
Pipeline #586 for 8472f9bc failed in 0 seconds
import { useMemo, useState } from 'react';
import { useQuery } from '@tanstack/react-query';
import type { Dayjs } from 'dayjs';
import dayjs, { type Dayjs } from 'dayjs';
import { UAlert, UButton, UCard, UResult, UTag, UTabs, tabLabel } from '@uj/ui';
import {
DataTable,
......@@ -41,7 +41,17 @@ const STATUS_TABS = [
{ key: '4', label: '成功收车', countKey: 'successCount' },
] as const;
const LEVELS = ['O', 'H', 'A', 'B', 'C', 'D'].map((value) => ({ value, label: `${value}级` }));
const LEVELS = [
{ value: 'O', label: 'O级:新车已定,旧车已签合同(客情回复,确认交车时间)' },
{ value: 'H', label: 'H级:新车已定,旧车已评估报价,客户正在对比价格(1日内跟进)' },
{ value: 'A', label: 'A级:客户新车基本看好,一周内会购车,旧车已评估报价(2日内跟进)' },
{
value: 'B',
label: 'B级:新车车型基本看好,预计一个月内会购车,旧车还未确定是否置换(5天内跟进)',
},
{ value: 'C', label: 'C级:客户新车还未确定车型,旧车未确定置换(10天内跟进)' },
{ value: 'D', label: 'D级:新车未看具体车型,短期内不打算换车,旧车大概看看(20天跟进)' },
];
const FOLLOW_STATUS = [
{ value: '1', label: '临期' },
{ value: '2', label: '已超期' },
......@@ -173,23 +183,26 @@ export default function Leads() {
name: 'cluesNo',
label: '线索 ID',
type: 'input',
placeholder: '请输入线索ID',
essential: true,
},
{
name: 'carOwnerName',
label: '车主姓名',
type: 'input',
placeholder: '请输入车主姓名',
essential: true,
},
{
name: 'carOwnerPhone',
label: '车主电话',
type: 'input',
placeholder: '请输入车主电话',
essential: true,
},
{
name: 'sellerMerchantIdList',
label: '线索门店',
label: '线索门店名称',
type: 'selectMultiple',
options: (merchants.data?.records ?? []).map((item) => ({
value: item.sellerMerchantId,
......@@ -197,22 +210,42 @@ export default function Leads() {
})),
essential: true,
},
{ name: 'sellerName', label: '销售顾问', type: 'input' },
{
name: 'sellerName',
label: '推荐销售顾问',
type: 'input',
placeholder: '请输入推荐销售顾问',
},
{
name: 'customerIntentLevelList',
label: '意向等级',
label: '客户意向等级',
type: 'selectMultiple',
options: LEVELS,
},
{
name: 'followTimeStatusList',
label: '跟进提示',
label: '跟进状态提示',
type: 'selectMultiple',
options: FOLLOW_STATUS,
},
{ name: 'createTimeRange', label: '创建时间', type: 'dateRange' },
{ name: 'lastFollowUpTimeRange', label: '最后跟进时间', type: 'dateRange' },
{ name: 'conversionName', label: '评估师', type: 'input' },
{
name: 'createTimeRange',
label: '创建时间',
type: 'dateRange',
disabledDate: (date) => date.isAfter(dayjs(), 'day'),
},
{
name: 'lastFollowUpTimeRange',
label: '最后跟进时间',
type: 'dateRange',
disabledDate: (date) => date.isAfter(dayjs(), 'day'),
},
{
name: 'conversionName',
label: '评估师姓名',
type: 'input',
placeholder: '请输入评估师姓名',
},
{
name: 'enterType',
label: '录线索人员',
......@@ -226,6 +259,7 @@ export default function Leads() {
name: 'carModel',
label: '评估品牌车型',
type: 'input',
placeholder: '请输入品牌车型关键词',
},
],
[merchants.data?.records],
......@@ -420,7 +454,6 @@ export default function Leads() {
rowActions={rowActions}
actions={actions}
actionColumnWidth={100}
toolbarTitle={`共 ${list.data?.total ?? 0} 条线索`}
pagination={{
current: page.current,
pageSize: page.size,
......
......@@ -259,7 +259,11 @@ export function SearchForm<T extends Record<string, unknown>>({
disabled: typeof field.disabled === 'boolean' ? field.disabled : false,
placeholder:
field.placeholder ??
(isTextInput ? `请输入${selectorLabel ?? (label || '内容')}` : undefined),
(isTextInput
? `请输入${selectorLabel ?? (label || '内容')}`
: field.type === 'select' || field.type === 'selectMultiple'
? `请选择${label || '内容'}`
: undefined),
};
const width = field.width ?? '100%';
if (field.type === 'select' || field.type === 'selectMultiple') {
......@@ -269,6 +273,8 @@ export function SearchForm<T extends Record<string, unknown>>({
<USelect
{...common}
allowClear={false}
showSearch
optionFilterProp="label"
style={{ width }}
options={
field.type === 'select' && !hasAllOption
......@@ -282,9 +288,16 @@ export function SearchForm<T extends Record<string, unknown>>({
}
if (field.type === 'cascader')
return <UCascader {...common} style={{ width }} options={field.options} allowClear={false} />;
if (field.type === 'date') return <UDatePicker {...common} style={{ width }} />;
if (field.type === 'date')
return <UDatePicker {...common} disabledDate={field.disabledDate} style={{ width }} />;
if (field.type === 'dateRange') {
const picker = <UDatePicker.RangePicker disabled={common.disabled} style={{ width }} />;
const picker = (
<UDatePicker.RangePicker
disabled={common.disabled}
disabledDate={field.disabledDate}
style={{ width }}
/>
);
if (!field.selector) return picker;
return (
<div style={{ display: 'flex', width, minWidth: 0 }}>
......
import type { CSSProperties, ReactNode } from 'react';
import type { ButtonProps, CascaderProps, FormItemProps, InputProps, SelectProps } from 'antd';
import type {
ButtonProps,
CascaderProps,
DatePickerProps,
FormItemProps,
InputProps,
SelectProps,
} from 'antd';
import type { TextAreaProps } from 'antd/es/input';
import type { Rule } from 'antd/es/form';
......@@ -60,6 +67,8 @@ export interface FieldSchema<T extends Record<string, unknown> = Record<string,
textareaProps?: TextAreaProps;
/** select 类型的扩展属性。 */
selectProps?: SelectProps;
/** 日期控件中不可选的日期;日期与日期范围控件共用。 */
disabledDate?: DatePickerProps['disabledDate'];
/** cascader 类型的扩展属性,选项统一由 options 提供。 */
cascaderProps?: Omit<CascaderProps, 'options' | 'multiple'>;
/** 表单值标准化处理,例如手机号仅保留数字。 */
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!