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 526ace97
authored
Nov 18, 2026
by
chenwq
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
重构4S店配置管理页面,新增配置弹窗及删除功能,优化数据展示和交互体验
1 parent
c1806a2a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
245 additions
and
10 deletions
apps/web/subapps/usedcar/src/pages/CustomerGroup/LiveCodesTab.tsx
apps/web/subapps/usedcar/src/pages/CustomerGroup/StoreConfigModal.tsx
apps/web/subapps/usedcar/src/pages/CustomerGroup/StoreConfigTab.tsx
apps/web/subapps/usedcar/src/pages/CustomerGroup/LiveCodesTab.tsx
View file @
526ace9
...
@@ -12,11 +12,24 @@ import { goTo } from '../Leads/navigate';
...
@@ -12,11 +12,24 @@ import { goTo } from '../Leads/navigate';
type Filters = { liveName?: string; remark?: string; createdBy?: string };
type Filters = { liveName?: string; remark?: string; createdBy?: string };
type Row = Record<string, unknown> & { id: string | number; defaultQrCodeUrl?: string };
type Row = Record<string, unknown> & { id: string | number; defaultQrCodeUrl?: string };
type Result = { records: Row[]; total: number };
type Result = { records: Row[]; total: number };
const text = (value: unknown) => (value === undefined || value === null || value === '' ? '-' : String(value));
const text = (value: unknown) =>
value === undefined || value === null || value === '' ? '-' : String(value);
const fields: FieldSchema<Filters>[] = [
const fields: FieldSchema<Filters>[] = [
{ name: 'liveName', label: '活码名称', type: 'input', essential: true, inputProps: { maxLength: 50 } },
{
name: 'liveName',
label: '活码名称',
type: 'input',
essential: true,
inputProps: { maxLength: 50 },
},
{ name: 'remark', label: '备注', type: 'input', essential: true, inputProps: { maxLength: 50 } },
{ name: 'remark', label: '备注', type: 'input', essential: true, inputProps: { maxLength: 50 } },
{ name: 'createdBy', label: '创建人', type: 'input', essential: true, inputProps: { maxLength: 50 } },
{
name: 'createdBy',
label: '创建人',
type: 'input',
essential: true,
inputProps: { maxLength: 50 },
},
];
];
export default function LiveCodesTab() {
export default function LiveCodesTab() {
...
@@ -25,15 +38,125 @@ export default function LiveCodesTab() {
...
@@ -25,15 +38,125 @@ export default function LiveCodesTab() {
const [filters, setFilters] = useState<Filters>({});
const [filters, setFilters] = useState<Filters>({});
const [page, setPage] = useState({ current: 1, size: 10 });
const [page, setPage] = useState({ current: 1, size: 10 });
const [selected, setSelected] = useState<React.Key[]>([]);
const [selected, setSelected] = useState<React.Key[]>([]);
const query = useQuery({ queryKey: ['live-code-page', filters, page], queryFn: () => liveCodeApi.getLiveCodePage<Result>({ currentPage: page.current, pageSize: page.size, t: filters }) });
const query = useQuery({
const remove = async (ids: React.Key[]) => { try { await liveCodeApi.deleteLiveCode({ ids }); message.success('删除成功'); setSelected((old) => old.filter((id) => !ids.includes(id))); void query.refetch(); } catch (error) { message.error(errorDetail(error)); } };
queryKey: ['live-code-page', filters, page],
queryFn: () =>
liveCodeApi.getLiveCodePage<Result>({
currentPage: page.current,
pageSize: page.size,
t: filters,
}),
});
const remove = async (ids: React.Key[]) => {
try {
await liveCodeApi.deleteLiveCode({ ids });
message.success('删除成功');
setSelected((old) => old.filter((id) => !ids.includes(id)));
void query.refetch();
} catch (error) {
message.error(errorDetail(error));
}
};
const rows: RowActionSchema<Row>[] = [
const rows: RowActionSchema<Row>[] = [
{ label: '下载', permission: UC.GROUP_DOWNLOAD, visible: (row) => Boolean(row.defaultQrCodeUrl), onClick: (row) => row.defaultQrCodeUrl && downloadCenter.url({ source: 'usedcar', sourceLabel: '二手车管理 / 一客一群', label: `${text(row.liveName)}二维码`, url: row.defaultQrCodeUrl, silent: true }) },
{
{ label: '修改', permission: UC.GROUP_UPDATE, onClick: (row) => goTo(`customer-group/live-code/edit/${row.id}`) },
label: '下载',
{ label: '删除', permission: UC.GROUP_DELETE, danger: true, onClick: (row) => { if (window.confirm('确认删除该群活码吗?')) void remove([row.id]); } },
permission: UC.GROUP_DOWNLOAD,
visible: (row) => Boolean(row.defaultQrCodeUrl),
onClick: (row) =>
row.defaultQrCodeUrl &&
downloadCenter.url({
source: 'usedcar',
sourceLabel: '二手车管理 / 一客一群',
label: `${text(row.liveName)}二维码`,
url: row.defaultQrCodeUrl,
silent: true,
}),
},
{
label: '修改',
permission: UC.GROUP_UPDATE,
onClick: (row) => goTo(`customer-group/live-code/edit/${row.id}`),
},
{
label: '删除',
permission: UC.GROUP_DELETE,
danger: true,
onClick: (row) => {
if (window.confirm('确认删除该群活码吗?')) void remove([row.id]);
},
},
];
];
const columns = [
const columns = [
{ title: '活码名称', dataIndex: 'liveName', width: 160, line: 1, render: text }, { title: '备注', dataIndex: 'remark', width: 180, line: 2, render: text }, { title: '群总数', dataIndex: 'groupCount', width: 100, render: text }, { title: '已占用群数', dataIndex: 'occupiedGroupCount', width: 120, render: text }, { title: '空闲群数', dataIndex: 'idleGroupCount', width: 120, render: text }, { title: '创建时间', dataIndex: 'createdDate', width: 170, line: 1, render: text }, { title: '创建人', dataIndex: 'createdBy', width: 130, line: 1, render: text },
{ title: '活码名称', dataIndex: 'liveName', width: 160, line: 1, render: text },
{ title: '备注', dataIndex: 'remark', width: 180, line: 2, render: text },
{ title: '群总数', dataIndex: 'groupCount', width: 100, render: text },
{ title: '已占用群数', dataIndex: 'occupiedGroupCount', width: 120, render: text },
{ title: '空闲群数', dataIndex: 'idleGroupCount', width: 120, render: text },
{ title: '创建时间', dataIndex: 'createdDate', width: 170, line: 1, render: text },
{ title: '创建人', dataIndex: 'createdBy', width: 130, line: 1, render: text },
];
];
return <><p className="uj-page-tip">可将多个群二维码组合生成一个活码,当客户扫码进群后即与该群产生绑定,不会再接待新的客户入群。</p><UCard className="uj-filter-card" size="small"><SearchForm fields={fields} onSearch={(value) => { setFilters(value); setPage((old) => ({ ...old, current: 1 })); }} onReset={() => setFilters({})} /></UCard>{query.isError ? <UAlert type="error" showIcon title="群列表加载失败" description={errorDetail(query.error)} action={<UButton type="link" onClick={() => void query.refetch()}>重试</UButton>} /> : null}<UCard size="small" fill><DataTable<Row> rowKey="id" fillHeight columns={columns} dataSource={query.data?.records ?? []} loading={query.isPending || query.isFetching} rowSelection={{ selectedRowKeys: selected, onChange: setSelected }} rowActions={rows} actions={[...(canPoint(UC.GROUP_CREATE) ? [{ label: '创建群活码', tone: 'primary' as const, onClick: () => goTo('customer-group/live-code/create') }] : []), ...(canPoint(UC.GROUP_BATCH_DELETE) ? [{ label: '批量删除', disabled: !selected.length, onClick: () => void remove(selected) }] : [])]} pagination={{ current: page.current, pageSize: page.size, total: query.data?.total ?? 0, onChange: (current, size) => setPage({ current, size }) }} /></UCard></>;
return (
<>
<UCard className="uj-filter-card" size="small">
<SearchForm
fields={fields}
onSearch={(value) => {
setFilters(value);
setPage((old) => ({ ...old, current: 1 }));
}}
onReset={() => setFilters({})}
/>
</UCard>
{query.isError ? (
<UAlert
type="error"
showIcon
title="群列表加载失败"
description={errorDetail(query.error)}
action={
<UButton type="link" onClick={() => void query.refetch()}>
重试
</UButton>
}
/>
) : null}
<UCard size="small" fill>
<DataTable<Row>
rowKey="id"
fillHeight
columns={columns}
dataSource={query.data?.records ?? []}
loading={query.isPending || query.isFetching}
rowSelection={{ selectedRowKeys: selected, onChange: setSelected }}
rowActions={rows}
actions={[
...(canPoint(UC.GROUP_CREATE)
? [
{
label: '创建群活码',
tone: 'primary' as const,
onClick: () => goTo('customer-group/live-code/create'),
},
]
: []),
...(canPoint(UC.GROUP_BATCH_DELETE)
? [
{
label: '批量删除',
disabled: !selected.length,
onClick: () => void remove(selected),
},
]
: []),
]}
pagination={{
current: page.current,
pageSize: page.size,
total: query.data?.total ?? 0,
onChange: (current, size) => setPage({ current, size }),
}}
/>
</UCard>
</>
);
}
}
apps/web/subapps/usedcar/src/pages/CustomerGroup/StoreConfigModal.tsx
0 → 100644
View file @
526ace9
import { useEffect, useMemo, useState } from 'react';
import { useQuery } from '@tanstack/react-query';
import { UForm, UModal, useUMessage } from '@uj/ui';
import { CombiForm, type FieldSchema } from '@/components';
import { liveCodeApi, storeConfigApi } from '@/api';
import { errorDetail } from '@/utils/error';
export type StoreConfigRow = Record<string, unknown> & { id?: string | number };
type FormValues = { storeId: string; pricingSpecialistId: string };
const text = (value: unknown) =>
value === undefined || value === null || value === '' ? '-' : String(value);
/** 新增/编辑4S店配置共用弹窗。字段、选项和保存逻辑集中维护。 */
export default function StoreConfigModal({
record,
onClose,
onSaved,
}: {
record: StoreConfigRow | null;
onClose: () => void;
onSaved: () => void;
}) {
const [form] = UForm.useForm<FormValues>();
const message = useUMessage();
const [saving, setSaving] = useState(false);
const stores = useQuery({
queryKey: ['live-code-car-dealers'],
queryFn: () => liveCodeApi.getCarDealerList<StoreConfigRow[]>(),
});
const staff = useQuery({
queryKey: ['live-code-pricing-staff'],
queryFn: () => storeConfigApi.getPricingStaffList<StoreConfigRow[]>(),
});
useEffect(() => {
if (record)
form.setFieldsValue({
storeId: text(record.storeId),
pricingSpecialistId: text(record.pricingSpecialistId),
});
else form.resetFields();
}, [form, record]);
const fields: FieldSchema<FormValues>[] = useMemo(
() => [
{
name: 'storeId',
label: '4S店',
type: 'select',
options: (stores.data ?? []).map((item) => ({
value: text(item.mainMerchantId),
label: text(item.mainMerchantName),
})),
selectProps: { showSearch: true, optionFilterProp: 'label', disabled: Boolean(record?.id) },
rules: [{ required: true, message: '请选择4S店' }],
},
{
name: 'pricingSpecialistId',
label: '总部定价师',
type: 'select',
options: (staff.data ?? []).map((item) => ({
value: text(item.staffId ?? item.id),
label: `${text(item.staffName)}(${text(item.staffPhone)})`,
})),
selectProps: { showSearch: true, optionFilterProp: 'label' },
rules: [{ required: true, message: '请选择总部定价师' }],
},
],
[record, staff.data, stores.data],
);
const save = async (values: FormValues) => {
const store = (stores.data ?? []).find((item) => text(item.mainMerchantId) === values.storeId);
const person = (staff.data ?? []).find(
(item) => text(item.staffId ?? item.id) === values.pricingSpecialistId,
);
setSaving(true);
try {
const payload = {
...values,
storeName: text(store?.mainMerchantName),
pricingSpecialistName: text(person?.staffName),
staffPhone: text(person?.staffPhone),
};
if (record?.id) await storeConfigApi.updateStoreConfig({ ...payload, id: record.id });
else await storeConfigApi.addStoreConfig(payload);
message.success('保存成功');
onSaved();
onClose();
} catch (error) {
message.error(errorDetail(error));
} finally {
setSaving(false);
}
};
return (
<UModal
open={Boolean(record)}
title={record?.id ? '修改配置' : '新增配置'}
confirmLoading={saving}
onCancel={onClose}
onOk={() => form.submit()}
>
<p className="uj-page-tip">此配置用于决定该4S店收取的线索默认分配给哪位总部定价师。</p>
<CombiForm
mode="form"
form={form}
layout="horizontal"
labelWidth={120}
fields={fields}
onSubmit={(values) => void save(values)}
/>
</UModal>
);
}
apps/web/subapps/usedcar/src/pages/CustomerGroup/StoreConfigTab.tsx
View file @
526ace9
This diff is collapsed.
Click to expand it.
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