Commit ca02506c37268f2d456a2555d00fe3d1cefd474f

Authored by PurelzMgnead
1 parent ffece678

feat: 添加关联销售

src/pages/Client/Client/Components/ClientDrawer.tsx
... ... @@ -8,6 +8,7 @@ import {
8 8 postResearchGroupsNameSet,
9 9 postServiceConstClientLevels,
10 10 postServiceConstClientSource,
  11 + postServiceOrderQuerySalesCode,
11 12 } from '@/services';
12 13  
13 14 import { enumToSelect } from '@/utils';
... ... @@ -18,7 +19,7 @@ import {
18 19 } from '@ant-design/pro-components';
19 20 import { Button, Form, message } from 'antd';
20 21 // import { options } from 'node_modules/axios/index.cjs';
21   -import { useState } from 'react';
  22 +import { useEffect, useState } from 'react';
22 23  
23 24 export default ({ optType, record, onFinish }) => {
24 25 const [form] = Form.useForm();
... ... @@ -26,6 +27,24 @@ export default ({ optType, record, onFinish }) => {
26 27 const [province, setProvince] = useState('');
27 28 const [city, setCity] = useState('');
28 29 const [showReferrers, setShowReferrers] = useState(false); // 控制显示的状态,初始为false
  30 + const [affiliateSalesOptions, setAffiliateSalesOptions] = useState([]);
  31 +
  32 + useEffect(() => {
  33 + const fetchAffiliateSalesOptions = async () => {
  34 + try {
  35 + const res = await postServiceOrderQuerySalesCode();
  36 + const options = res.data?.map((item) => ({
  37 + label: item.userName,
  38 + value: item.userName,
  39 + }));
  40 + setAffiliateSalesOptions(options || []);
  41 + } catch (error) {
  42 + console.error('Failed to fetch assign people options:', error);
  43 + }
  44 + };
  45 + fetchAffiliateSalesOptions();
  46 + }, []);
  47 +
29 48 const optTypeEnum = {
30 49 add: {
31 50 text: '新增',
... ... @@ -152,8 +171,6 @@ export default ({ optType, record, onFinish }) => {
152 171 console.log(value);
153 172  
154 173 if (value !== undefined || value !== null) {
155   - console.log('setProvince');
156   -
157 174 setProvince(value);
158 175 }
159 176 }}
... ... @@ -350,6 +367,15 @@ export default ({ optType, record, onFinish }) => {
350 367 label="课题组名称"
351 368 placeholder="请输入名称"
352 369 />
  370 + <Form.Item label="关联销售" name="affiliateSales">
  371 + <ProFormSelect
  372 + name="affiliateSales"
  373 + options={affiliateSalesOptions}
  374 + placeholder="请选择指派人员"
  375 + rules={[{ required: true, message: '请选择关联销售' }]}
  376 + mode="multiple"
  377 + />
  378 + </Form.Item>
353 379 <ProFormText
354 380 name="department"
355 381 label="部门"
... ...
src/pages/Client/Client/Components/CommunicationHistoryModal.tsx
... ... @@ -137,6 +137,7 @@ export default ({ record }) =&gt; {
137 137 const [createByName, setCreateByName] = useState(''); // 创建人
138 138 const [latestObject, setLatestObject] = useState(); // 最新跟进时间
139 139 const [recordSave, setRecordSave] = useState(); //新增跟进
  140 + const [affiliateSales, setAffiliateSales] = useState([]);
140 141 useEffect(() => {
141 142 const request = async () => {
142 143 const resShow = await postAdminClientQueryClientComunicationInfo({
... ... @@ -174,6 +175,7 @@ export default ({ record }) =&gt; {
174 175 setAddress(record.address);
175 176 setNotes(record.notes);
176 177 setCreateByName(record.createByName);
  178 + setAffiliateSales(record.affiliateSales.join(','));
177 179 };
178 180 request();
179 181 }, []);
... ... @@ -248,6 +250,11 @@ export default ({ record }) =&gt; {
248 250 label: '最新跟进时间',
249 251 children: latestObject, // 最新跟进时间
250 252 },
  253 + {
  254 + key: '16',
  255 + label: '关联销售',
  256 + children: affiliateSales, // 创建人
  257 + },
251 258 ];
252 259 return (
253 260 <ModalForm
... ...
src/pages/Client/Client/index.tsx
... ... @@ -105,6 +105,12 @@ const columns = [
105 105 },
106 106 },
107 107 {
  108 + title: '关联销售',
  109 + hideInSearch: true,
  110 + hideInTable: true,
  111 + dataIndex: 'affiliateSales',
  112 + },
  113 + {
108 114 title: '部门',
109 115 width: 150,
110 116 ellipsis: true,
... ... @@ -295,48 +301,50 @@ const columns = [
295 301 action.reload(); // 刷新表格
296 302 }
297 303 };
298   - return [
299   - <CommunicationHistoryModal
300   - key={'communicationHistory'}
301   - record={record}
302   - />,
303   - <ClientDrawer
304   - key={'detail'}
305   - record={record}
306   - optType={'detail'}
307   - onFinish={() => {
308   - action.reload();
309   - }}
310   - ></ClientDrawer>,
311   - <ClientModal
312   - key={'add'}
313   - data={record}
314   - reloadTable={() => {
315   - action?.reload();
316   - }}
317   - type={'add'}
318   - />,
319   - <ClientDrawer
320   - key={'edit'}
321   - record={record}
322   - optType={'edit'}
323   - onFinish={() => {
324   - action.reload();
325   - }}
326   - ></ClientDrawer>,
327   - // <a key={'delete'} onClick={handleDelete}>
328   - // 删除
329   - // </a>,
330   - <ButtonConfirm
331   - key="delete"
332   - className="p-0"
333   - title={'删除该客户,客户下的跟进记录会一并删除'}
334   - text="删除"
335   - onConfirm={async () => {
336   - handleDelete();
337   - }}
338   - />,
339   - ];
  304 + if (record?.paths?.includes('DETAIL')) {
  305 + return [
  306 + <CommunicationHistoryModal
  307 + key={'communicationHistory'}
  308 + record={record}
  309 + />,
  310 + <ClientDrawer
  311 + key={'detail'}
  312 + record={record}
  313 + optType={'detail'}
  314 + onFinish={() => {
  315 + action.reload();
  316 + }}
  317 + ></ClientDrawer>,
  318 + <ClientModal
  319 + key={'add'}
  320 + data={record}
  321 + reloadTable={() => {
  322 + action?.reload();
  323 + }}
  324 + type={'add'}
  325 + />,
  326 + <ClientDrawer
  327 + key={'edit'}
  328 + record={record}
  329 + optType={'edit'}
  330 + onFinish={() => {
  331 + action.reload();
  332 + }}
  333 + ></ClientDrawer>,
  334 + // <a key={'delete'} onClick={handleDelete}>
  335 + // 删除
  336 + // </a>,
  337 + <ButtonConfirm
  338 + key="delete"
  339 + className="p-0"
  340 + title={'删除该客户,客户下的跟进记录会一并删除'}
  341 + text="删除"
  342 + onConfirm={async () => {
  343 + handleDelete();
  344 + }}
  345 + />,
  346 + ];
  347 + }
340 348 },
341 349 },
342 350 ];
... ...