From 0f6717078ff79a0f503ec27d83627a9e24ef5343 Mon Sep 17 00:00:00 2001 From: z <2199297992@qq.com> Date: Thu, 18 Jul 2024 17:32:24 +0800 Subject: [PATCH] feat: 客户管理模块开发 --- src/pages/Client/Components/ClientDrawer.tsx | 66 ++++++++++++++++++++++++++++++++++++++++++++++-------------------- src/pages/Client/Components/CommunicationHistoryModal.tsx | 3 ++- src/pages/Client/index.tsx | 31 ++++++++++++++++++++++++++++--- src/services/definition.ts | 14 ++++++++++---- src/services/request.ts | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 157 insertions(+), 28 deletions(-) diff --git a/src/pages/Client/Components/ClientDrawer.tsx b/src/pages/Client/Components/ClientDrawer.tsx index 4d70d7b..a668b2d 100644 --- a/src/pages/Client/Components/ClientDrawer.tsx +++ b/src/pages/Client/Components/ClientDrawer.tsx @@ -1,6 +1,7 @@ import { RESPONSE_CODE } from '@/constants/enum'; import { postAdminClientAddAdminClient, + postAdminClientModifyClientInfo, postDistrictSelectByLevel, postDistrictSelectByNameAndLevel, postDistrictSelOrderProvince, @@ -17,15 +18,53 @@ import { import { Button, Form, message } from 'antd'; import { useState } from 'react'; -export default ({ record }) => { +export default ({ optType, record }) => { const [form] = Form.useForm<{ name: string; company: string }>(); //省市区 const [province, setProvince] = useState(''); const [city, setCity] = useState(''); const [setDistrict] = useState(''); + const optTypeEnum = { + add: { + text: '新增', + button: <Button type="primary">新增</Button>, + readonly: false, + onFinish: async (values) => { + const res = await postAdminClientAddAdminClient({ + data: values, + }); + if (res.result === RESPONSE_CODE.SUCCESS) { + message.success('新增成功'); + // 不返回不会关闭弹框 + return true; + } + }, + }, + edit: { + text: '编辑', + button: <a type="primary">编辑</a>, + readonly: false, + onFinish: async (values) => { + const res = await postAdminClientModifyClientInfo({ + data: values, + }); + if (res.result === RESPONSE_CODE.SUCCESS) { + message.success('编辑成功'); + // 不返回不会关闭弹框 + return true; + } + }, + }, + detail: { + text: '详情', + button: <a type="primary">详情</a>, + readonly: true, + }, + }; + return ( <DrawerForm - title={record ? '详情' : '编辑'} + title={optTypeEnum[optType].text} resize={{ onResize() { console.log('resize!'); @@ -35,31 +74,18 @@ export default ({ record }) => { }} initialValues={record} form={form} - trigger={ - record ? ( - <a type="primary">详情</a> - ) : ( - <Button type="primary">新增</Button> - ) - } + trigger={optTypeEnum[optType].button} autoFocusFirstInput drawerProps={{ destroyOnClose: true, }} submitTimeout={2000} width={500} - readonly={!!record} - onFinish={async (values) => { - const res = await postAdminClientAddAdminClient({ - data: values, - }); - if (res.result === RESPONSE_CODE.SUCCESS) { - message.success('新增成功'); - // 不返回不会关闭弹框 - return true; - } - }} + readonly={optTypeEnum[optType].readonly} + onFinish={optTypeEnum[optType].onFinish} > + <ProFormText name="id" label="id" hidden={true} /> + <ProFormText name="name" label="客户名称" diff --git a/src/pages/Client/Components/CommunicationHistoryModal.tsx b/src/pages/Client/Components/CommunicationHistoryModal.tsx index b2bbe33..053e72d 100644 --- a/src/pages/Client/Components/CommunicationHistoryModal.tsx +++ b/src/pages/Client/Components/CommunicationHistoryModal.tsx @@ -33,7 +33,8 @@ export default ({ clientId }) => { }, { title: '内容', - width: 50, + width: 100, + valueType: 'textarea', rules: [{ required: true, message: '请输入内容' }], dataIndex: 'content', }, diff --git a/src/pages/Client/index.tsx b/src/pages/Client/index.tsx index a91d8bd..d624e9c 100644 --- a/src/pages/Client/index.tsx +++ b/src/pages/Client/index.tsx @@ -22,63 +22,75 @@ const columns = [ { title: '客户名称', dataIndex: 'name', + width: 100, hideInSearch: true, }, { title: '单位名称', + width: 150, dataIndex: 'companyName', hideInSearch: true, }, { title: '单位地址', + width: 250, dataIndex: 'companyName', hideInSearch: true, }, { title: '联系电话', + width: 150, dataIndex: 'phoneNumber', hideInSearch: true, }, { title: '客户来源', + width: 150, dataIndex: 'source', hideInSearch: true, }, { title: '推荐人', dataIndex: 'referrers', + width: 150, hideInSearch: true, }, { title: '客户需求', dataIndex: 'requirements', + width: 150, hideInSearch: true, }, { title: '是否已报方案', + width: 150, dataIndex: 'hasSchemeText', hideInSearch: true, }, { title: '报价时间', key: 'since', + width: 150, dataIndex: 'quoteDatetime', valueType: 'dateTime', hideInSearch: true, }, { title: '跟进状态', + width: 150, dataIndex: 'tradeStatusText', hideInSearch: true, }, { title: '客户等级', + width: 150, dataIndex: 'levelText', hideInSearch: true, }, { title: '创建时间', key: 'since', + width: 150, dataIndex: 'createTime', valueType: 'dateTime', hideInSearch: true, @@ -86,6 +98,7 @@ const columns = [ { title: '最新跟进时间', key: 'since', + width: 150, dataIndex: 'latestCommunicationTime', valueType: 'dateTime', hideInSearch: true, @@ -147,7 +160,6 @@ const columns = [ { title: '创建时间', valueType: 'dateRange', - width: 200, hideInTable: true, search: { transform: (value) => { @@ -164,6 +176,7 @@ const columns = [ title: '操作', valueType: 'option', key: 'option', + width: 150, render: (text, record) => { console.log(JSON.stringify(record)); return [ @@ -171,7 +184,16 @@ const columns = [ key={'communicationHistory'} clientId={record.id} />, - <ClientDrawer key={'detail'} record={record}></ClientDrawer>, + <ClientDrawer + key={'detail'} + record={record} + optType={'detail'} + ></ClientDrawer>, + <ClientDrawer + key={'edit'} + record={record} + optType={'edit'} + ></ClientDrawer>, ]; }, }, @@ -223,6 +245,9 @@ export default () => { </Button>, ], }} + scroll={{ + x: 1400, + }} editable={{ type: 'multiple', }} @@ -261,7 +286,7 @@ export default () => { dateFormatter="string" headerTitle="高级表格" toolBarRender={() => [ - <ClientDrawer key="button"></ClientDrawer>, + <ClientDrawer optType={'add'} key="button"></ClientDrawer>, <ClientImportModal key="import" />, ]} /> diff --git a/src/services/definition.ts b/src/services/definition.ts index 6fe30a1..0bdaec4 100644 --- a/src/services/definition.ts +++ b/src/services/definition.ts @@ -117,6 +117,8 @@ export interface AdminClientDto { */ hasScheme?: boolean; hasSchemeText?: string; + /** @format int64 */ + id?: number; /** @format date-time */ latestCommunicationTime?: string; /** @@ -1940,7 +1942,8 @@ export interface QueryClientDto { } export interface QueryCommunicationInfoDto { - clientId?: string; + /** @format int64 */ + clientId?: number; content?: string; /** @format int32 */ current?: number; @@ -1948,7 +1951,8 @@ export interface QueryCommunicationInfoDto { datetime?: string; /** @format int32 */ end?: number; - id?: string; + /** @format int64 */ + id?: number; /** @format int32 */ pageSize?: number; /** @format int32 */ @@ -2728,7 +2732,8 @@ export interface ApiOrderConfirmReceiveRequest { } export interface ClientCommunicationInfo { - clientId?: string; + /** @format int64 */ + clientId?: number; /** * @description * 内容 @@ -2743,7 +2748,8 @@ export interface ClientCommunicationInfo { * @format date-time */ datetime?: string; - id?: string; + /** @format int64 */ + id?: number; logicDelete?: boolean; updateByName?: string; /** @format date-time */ diff --git a/src/services/request.ts b/src/services/request.ts index ea422c8..20b9978 100644 --- a/src/services/request.ts +++ b/src/services/request.ts @@ -609,6 +609,77 @@ export const postAdminClientModifyClientComunicationInfo = return request; })(); +/** @description request parameter type for postAdminClientModifyClientInfo */ +export interface PostAdminClientModifyClientInfoOption { + /** + * @description + * dto + */ + body: { + /** + @description + dto */ + dto: AdminClientDto; + }; +} + +/** @description response type for postAdminClientModifyClientInfo */ +export interface PostAdminClientModifyClientInfoResponse { + /** + * @description + * OK + */ + 200: ServerResult; + /** + * @description + * Created + */ + 201: any; + /** + * @description + * Unauthorized + */ + 401: any; + /** + * @description + * Forbidden + */ + 403: any; + /** + * @description + * Not Found + */ + 404: any; +} + +export type PostAdminClientModifyClientInfoResponseSuccess = + PostAdminClientModifyClientInfoResponse[200]; +/** + * @description + * 修改跟进信息 + * @tags 客户管理 + * @produces * + * @consumes application/json + */ +export const postAdminClientModifyClientInfo = /* #__PURE__ */ (() => { + const method = 'post'; + const url = '/admin/client/modifyClientInfo'; + function request( + option: PostAdminClientModifyClientInfoOption, + ): Promise<PostAdminClientModifyClientInfoResponseSuccess> { + return requester(request.url, { + method: request.method, + ...option, + }) as unknown as Promise<PostAdminClientModifyClientInfoResponseSuccess>; + } + + /** http method */ + request.method = method; + /** request url */ + request.url = url; + return request; +})(); + /** @description request parameter type for postAdminClientQueryClientComunicationInfo */ export interface PostAdminClientQueryClientComunicationInfoOption { /** -- libgit2 0.23.3