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 4da57903
authored
Nov 23, 2026
by
chenwq
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化搜索表单,清空条件时同时清除选择器字段,调整控件布局
1 parent
0a0a7047
Pipeline
#604
for
4da57903
failed
in 0 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
17 deletions
apps/web/subapps/usedcar/src/pages/Delivery/index.tsx
packages/biz/src/components/SearchForm/index.tsx
apps/web/subapps/usedcar/src/pages/Delivery/index.tsx
View file @
4da5790
import { useMemo, useState } from 'react';
import { useMemo, useState } from 'react';
import { useQuery } from '@tanstack/react-query';
import { useQuery } from '@tanstack/react-query';
import
type {
Dayjs } from 'dayjs';
import
dayjs, { type
Dayjs } from 'dayjs';
import { UAlert, UButton, UCard, UResult, UTag } from '@uj/ui';
import { UAlert, UButton, UCard, UResult, UTag } from '@uj/ui';
import { downloadCenter } from '@uj/platform-sdk';
import { downloadCenter } from '@uj/platform-sdk';
import {
import {
...
@@ -37,14 +37,14 @@ type Filters = Record<string, unknown> & {
...
@@ -37,14 +37,14 @@ type Filters = Record<string, unknown> & {
type Row = Record<string, unknown> & { id: string | number; deliveryOrderId?: string };
type Row = Record<string, unknown> & { id: string | number; deliveryOrderId?: string };
type Result = { records: Row[]; total: number };
type Result = { records: Row[]; total: number };
const status = [
const status = [
{ value: '-1', label: '已取消' },
{ value: '-1', label: '已取消'
, color: 'red'
},
{ value: '0', label: '待交付' },
{ value: '0', label: '待交付'
, color: 'orange'
},
{ value: '1', label: '交付中' },
{ value: '1', label: '交付中'
, color: 'blue'
},
{ value: '2', label: '交付完成' },
{ value: '2', label: '交付完成'
, color: 'green'
},
];
];
const payment = [
const payment = [
{ value: '0', label: '待支付' },
{ value: '0', label: '待支付'
, color: 'orange'
},
{ value: '1', label: '已结清' },
{ value: '1', label: '已结清'
, color: 'green'
},
];
];
const delivery = [
const delivery = [
{ value: '0', label: '客户自提' },
{ value: '0', label: '客户自提' },
...
@@ -53,6 +53,8 @@ const delivery = [
...
@@ -53,6 +53,8 @@ const delivery = [
const txt = (v: unknown) => (v === undefined || v === null || v === '' ? '-' : String(v));
const txt = (v: unknown) => (v === undefined || v === null || v === '' ? '-' : String(v));
const label = (o: readonly { value: string; label: string }[], v: unknown) =>
const label = (o: readonly { value: string; label: string }[], v: unknown) =>
o.find((x) => x.value === String(v))?.label ?? '-';
o.find((x) => x.value === String(v))?.label ?? '-';
const colorOf = (o: readonly { value: string; color: string }[], v: unknown) =>
o.find((x) => x.value === String(v))?.color;
function paramsOf(f: Filters) {
function paramsOf(f: Filters) {
const { dateRange, dateType, personKeyword, personType, phoneKeyword, phoneType, ...rest } = f;
const { dateRange, dateType, personKeyword, personType, phoneKeyword, phoneType, ...rest } = f;
const r = (v: [Dayjs, Dayjs] | undefined, s: string, e: string) =>
const r = (v: [Dayjs, Dayjs] | undefined, s: string, e: string) =>
...
@@ -115,9 +117,8 @@ export default function Delivery() {
...
@@ -115,9 +117,8 @@ export default function Delivery() {
// 控件较宽,统一收进「更多筛选」,避免收起时换行、展开时与另一个同形控件看起来重复。
// 控件较宽,统一收进「更多筛选」,避免收起时换行、展开时与另一个同形控件看起来重复。
fields.splice(4, 0, {
fields.splice(4, 0, {
name: 'personKeyword',
name: 'personKeyword',
label: '
姓名
',
label: '',
type: 'input',
type: 'input',
placeholder: '请输入交付专员姓名',
selector: {
selector: {
name: 'personType',
name: 'personType',
options: [
options: [
...
@@ -130,9 +131,8 @@ export default function Delivery() {
...
@@ -130,9 +131,8 @@ export default function Delivery() {
});
});
fields.splice(5, 0, {
fields.splice(5, 0, {
name: 'phoneKeyword',
name: 'phoneKeyword',
label: '
电话
',
label: '',
type: 'input',
type: 'input',
placeholder: '请输入交付专员电话',
selector: {
selector: {
name: 'phoneType',
name: 'phoneType',
options: [
options: [
...
@@ -162,6 +162,7 @@ export default function Delivery() {
...
@@ -162,6 +162,7 @@ export default function Delivery() {
],
],
},
},
filterGroup: 'date',
filterGroup: 'date',
disabledDate: (date) => date.isAfter(dayjs(), 'day'),
},
},
);
);
const columns = [
const columns = [
...
@@ -193,13 +194,13 @@ export default function Delivery() {
...
@@ -193,13 +194,13 @@ export default function Delivery() {
title: '交付状态',
title: '交付状态',
dataIndex: 'orderStatus',
dataIndex: 'orderStatus',
width: 120,
width: 120,
render: (v: unknown) => <UTag>{label(status, v)}</UTag>,
render: (v: unknown) => <UTag
color={colorOf(status, v)}
>{label(status, v)}</UTag>,
},
},
{
{
title: '付款状态',
title: '付款状态',
dataIndex: 'paymentStatus',
dataIndex: 'paymentStatus',
width: 120,
width: 120,
render: (v: unknown) => <UTag>{label(payment, v)}</UTag>,
render: (v: unknown) => <UTag
color={colorOf(payment, v)}
>{label(payment, v)}</UTag>,
},
},
{
{
title: '交付方式',
title: '交付方式',
...
...
packages/biz/src/components/SearchForm/index.tsx
View file @
4da5790
...
@@ -170,7 +170,9 @@ export function SearchForm<T extends Record<string, unknown>>({
...
@@ -170,7 +170,9 @@ export function SearchForm<T extends Record<string, unknown>>({
/** 全部清空走 onReset:页面侧把列表过滤条件一起清掉并回到第 1 页。 */
/** 全部清空走 onReset:页面侧把列表过滤条件一起清掉并回到第 1 页。 */
const clearAllConditions = () => {
const clearAllConditions = () => {
clearFields(fields.map((field) => field.name));
clearFields(
fields.flatMap((field) => [field.name, ...(field.selector ? [field.selector.name] : [])]),
);
setActivePopoverOpen(false);
setActivePopoverOpen(false);
onReset?.(formInitialValues, { ...searchPagination, current: 1 });
onReset?.(formInitialValues, { ...searchPagination, current: 1 });
};
};
...
@@ -308,7 +310,9 @@ export function SearchForm<T extends Record<string, unknown>>({
...
@@ -308,7 +310,9 @@ export function SearchForm<T extends Record<string, unknown>>({
options={field.selector.options}
options={field.selector.options}
/>
/>
</UFormItem>
</UFormItem>
<div style={{ minWidth: 0, flex: 1 }}>{picker}</div>
<UFormItem name={field.name as string} noStyle>
{picker}
</UFormItem>
</div>
</div>
);
);
}
}
...
@@ -329,7 +333,9 @@ export function SearchForm<T extends Record<string, unknown>>({
...
@@ -329,7 +333,9 @@ export function SearchForm<T extends Record<string, unknown>>({
options={field.selector.options}
options={field.selector.options}
/>
/>
</UFormItem>
</UFormItem>
<div style={{ minWidth: 0, flex: 1 }}>{input}</div>
<UFormItem name={field.name as string} noStyle>
{input}
</UFormItem>
</div>
</div>
);
);
};
};
...
@@ -343,8 +349,17 @@ export function SearchForm<T extends Record<string, unknown>>({
...
@@ -343,8 +349,17 @@ export function SearchForm<T extends Record<string, unknown>>({
const span = field.span ?? 1;
const span = field.span ?? 1;
const style: React.CSSProperties = { marginBottom: 0, minWidth: 0 };
const style: React.CSSProperties = { marginBottom: 0, minWidth: 0 };
if (span > 1) style.gridColumn = `span ${span}`;
if (span > 1) style.gridColumn = `span ${span}`;
const nestedName = Boolean(
field.selector &&
(field.type === 'input' || field.type === 'textarea' || field.type === 'dateRange'),
);
return (
return (
<UFormItem key={field.name} name={field.name as string} label={field.label} style={style}>
<UFormItem
key={field.name}
name={nestedName ? undefined : (field.name as string)}
label={field.label}
style={style}
>
{control(field)}
{control(field)}
</UFormItem>
</UFormItem>
);
);
...
...
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