Skip to content

Commit 8512fe6

Browse files
committed
✨ CRM:完善商机和联系人之间的关联
1 parent 01684aa commit 8512fe6

File tree

8 files changed

+86
-37
lines changed

8 files changed

+86
-37
lines changed

src/api/crm/contact/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ export const getContactPageByCustomer = async (params: any) => {
4747
return await request.get({ url: `/crm/contact/page-by-customer`, params })
4848
}
4949

50+
// 查询 CRM 联系人列表,基于指定商机
51+
export const getContactPageByBusiness = async (params: any) => {
52+
return await request.get({ url: `/crm/contact/page-by-business`, params })
53+
}
54+
5055
// 查询 CRM 联系人详情
5156
export const getContact = async (id: number) => {
5257
return await request.get({ url: `/crm/contact/get?id=` + id })

src/views/crm/business/BusinessForm.vue

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@
3131
</el-col>
3232
<el-col :span="8">
3333
<el-form-item label="客户名称" prop="customerId">
34-
<el-select v-model="formData.customerId" placeholder="请选择客户" class="w-1/1">
34+
<el-select
35+
:disabled="formData.customerDefault"
36+
v-model="formData.customerId"
37+
placeholder="请选择客户"
38+
class="w-1/1"
39+
>
3540
<el-option
3641
v-for="item in customerList"
3742
:key="item.id"
@@ -158,7 +163,9 @@ const formData = ref({
158163
totalProductPrice: undefined,
159164
totalPrice: undefined,
160165
remark: undefined,
161-
products: []
166+
products: [],
167+
contactId: undefined,
168+
customerDefault: false
162169
})
163170
const formRules = reactive({
164171
name: [{ required: true, message: '商机名称不能为空', trigger: 'blur' }],
@@ -197,7 +204,7 @@ watch(
197204
)
198205
199206
/** 打开弹窗 */
200-
const open = async (type: string, id?: number) => {
207+
const open = async (type: string, id?: number, customerId?: number, contactId?: number) => {
201208
dialogVisible.value = true
202209
dialogTitle.value = t('action.' + type)
203210
formType.value = type
@@ -210,7 +217,17 @@ const open = async (type: string, id?: number) => {
210217
} finally {
211218
formLoading.value = false
212219
}
220+
} else {
221+
if (customerId) {
222+
formData.value.customerId = customerId
223+
formData.value.customerDefault = true // 默认客户的选择,不允许变
224+
}
225+
// 自动关联 contactId 联系人编号
226+
if (contactId) {
227+
formData.value.contactId = contactId
228+
}
213229
}
230+
// 获得客户列表
214231
customerList.value = await CustomerApi.getCustomerSimpleList()
215232
// 加载商机状态类型列表
216233
statusTypeList.value = await BusinessStatusApi.getBusinessStatusTypeSimpleList()
@@ -264,7 +281,9 @@ const resetForm = () => {
264281
totalProductPrice: undefined,
265282
totalPrice: undefined,
266283
remark: undefined,
267-
products: []
284+
products: [],
285+
contactId: undefined,
286+
customerDefault: false
268287
}
269288
formRef.value?.resetFields()
270289
}

src/views/crm/business/components/BusinessList.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ const props = defineProps<{
7676
bizType: number // 业务类型
7777
bizId: number // 业务编号
7878
customerId?: number // 关联联系人与商机时,需要传入 customerId 进行筛选
79+
contactId?: number // 特殊:联系人编号;在【联系人】详情中,可以传递联系人编号,默认新建的商机关联到该联系人
7980
}>()
8081
8182
const loading = ref(true) // 列表的加载中
@@ -125,7 +126,7 @@ const handleQuery = () => {
125126
/** 添加操作 */
126127
const formRef = ref()
127128
const openForm = () => {
128-
formRef.value.open('create')
129+
formRef.value.open('create', null, props.customerId, props.contactId)
129130
}
130131
131132
/** 打开联系人详情 */

src/views/crm/business/detail/index.vue

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
<el-tab-pane label="详细资料">
1616
<BusinessDetailsInfo :business="business" />
1717
</el-tab-pane>
18+
<el-tab-pane label="联系人" lazy>
19+
<ContactList
20+
:biz-id="business.id!"
21+
:biz-type="BizTypeEnum.CRM_BUSINESS"
22+
:business-id="business.id"
23+
:customer-id="business.customerId"
24+
/>
25+
</el-tab-pane>
1826
<el-tab-pane label="操作日志">
1927
<OperateLogV2 :log-list="logList" />
2028
</el-tab-pane>
@@ -27,13 +35,6 @@
2735
@quit-team="close"
2836
/>
2937
</el-tab-pane>
30-
<el-tab-pane label="商机" lazy>
31-
<BusinessList
32-
:biz-id="business.id!"
33-
:biz-type="BizTypeEnum.CRM_CONTACT"
34-
:customer-id="business.customerId"
35-
/>
36-
</el-tab-pane>
3738
</el-tabs>
3839
</el-col>
3940
<!-- 表单弹窗:添加/修改 -->
@@ -46,14 +47,14 @@ import * as ContactApi from '@/api/crm/contact'
4647
import * as BusinessApi from '@/api/crm/business'
4748
import BusinessDetailsHeader from './BusinessDetailsHeader.vue'
4849
import BusinessDetailsInfo from './BusinessDetailsInfo.vue'
49-
import BusinessList from '@/views/crm/business/components/BusinessList.vue' // 商机列表
5050
import PermissionList from '@/views/crm/permission/components/PermissionList.vue' // 团队成员列表(权限)
5151
import { BizTypeEnum } from '@/api/crm/permission'
5252
import { OperateLogV2VO } from '@/api/system/operatelog'
5353
import { getOperateLogPage } from '@/api/crm/operateLog'
5454
import ContactForm from '@/views/crm/contact/ContactForm.vue'
5555
import CrmTransferForm from '@/views/crm/permission/components/TransferForm.vue'
5656
import FollowUpList from '@/views/crm/followup/index.vue'
57+
import ContactList from '@/views/crm/contact/components/ContactList.vue'
5758
5859
defineOptions({ name: 'CrmBusinessDetail' })
5960

src/views/crm/business/index.vue

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838

3939
<!-- 列表 -->
4040
<ContentWrap>
41+
<el-tabs v-model="activeName" @tab-click="handleTabClick">
42+
<el-tab-pane label="我负责的" name="1" />
43+
<el-tab-pane label="我参与的" name="2" />
44+
<el-tab-pane label="下属负责的" name="3" />
45+
</el-tabs>
4146
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
4247
<el-table-column align="center" label="商机名称" fixed="left" prop="name" width="160">
4348
<template #default="scope">
@@ -157,6 +162,7 @@ import download from '@/utils/download'
157162
import * as BusinessApi from '@/api/crm/business'
158163
import BusinessForm from './BusinessForm.vue'
159164
import { erpPriceTableColumnFormatter } from '@/utils'
165+
import { TabsPaneContext } from 'element-plus'
160166
161167
defineOptions({ name: 'CrmBusiness' })
162168
@@ -169,27 +175,12 @@ const list = ref([]) // 列表的数据
169175
const queryParams = reactive({
170176
pageNo: 1,
171177
pageSize: 10,
172-
name: null,
173-
statusTypeId: null,
174-
statusId: null,
175-
contactNextTime: [],
176-
customerId: null,
177-
dealTime: [],
178-
price: null,
179-
discountPercent: null,
180-
productPrice: null,
181-
remark: null,
182-
ownerUserId: null,
183-
createTime: [],
184-
roUserIds: null,
185-
rwUserIds: null,
186-
endStatus: null,
187-
endRemark: null,
188-
contactLastTime: [],
189-
followUpStatus: null
178+
sceneType: '1', // 默认和 activeName 相等
179+
name: null
190180
})
191181
const queryFormRef = ref() // 搜索的表单
192182
const exportLoading = ref(false) // 导出的加载中
183+
const activeName = ref('1') // 列表 tab
193184
194185
/** 查询列表 */
195186
const getList = async () => {
@@ -215,6 +206,12 @@ const resetQuery = () => {
215206
handleQuery()
216207
}
217208
209+
/** tab 切换 */
210+
const handleTabClick = (tab: TabsPaneContext) => {
211+
queryParams.sceneType = tab.paneName
212+
handleQuery()
213+
}
214+
218215
/** 打开客户详情 */
219216
const { currentRoute, push } = useRouter()
220217
const openDetail = (id: number) => {

src/views/crm/contact/ContactForm.vue

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@
3333
<el-row>
3434
<el-col :span="12">
3535
<el-form-item label="客户名称" prop="customerId">
36-
<el-select v-model="formData.customerId" placeholder="请选择客户" class="w-1/1">
36+
<el-select
37+
:disabled="formData.customerDefault"
38+
v-model="formData.customerId"
39+
placeholder="请选择客户"
40+
class="w-1/1"
41+
>
3742
<el-option
3843
v-for="item in customerList"
3944
:key="item.id"
@@ -198,7 +203,9 @@ const formData = ref({
198203
master: false,
199204
post: undefined,
200205
parentId: undefined,
201-
remark: undefined
206+
remark: undefined,
207+
businessId: undefined,
208+
customerDefault: false
202209
})
203210
const formRules = reactive({
204211
name: [{ required: true, message: '姓名不能为空', trigger: 'blur' }],
@@ -212,7 +219,7 @@ const customerList = ref<CustomerApi.CustomerVO[]>([]) // 客户列表
212219
const contactList = ref<ContactApi.ContactVO[]>([]) // 联系人列表
213220
214221
/** 打开弹窗 */
215-
const open = async (type: string, id?: number) => {
222+
const open = async (type: string, id?: number, customerId?: number, businessId?: number) => {
216223
dialogVisible.value = true
217224
dialogTitle.value = t('action.' + type)
218225
formType.value = type
@@ -225,8 +232,19 @@ const open = async (type: string, id?: number) => {
225232
} finally {
226233
formLoading.value = false
227234
}
235+
} else {
236+
if (customerId) {
237+
formData.value.customerId = customerId
238+
formData.value.customerDefault = true // 默认客户的选择,不允许变
239+
}
240+
// 自动关联 businessId 商机编号
241+
if (businessId) {
242+
formData.value.businessId = businessId
243+
}
228244
}
245+
// 获得联系人列表
229246
contactList.value = await ContactApi.getSimpleContactList()
247+
// 获得客户列表
230248
customerList.value = await CustomerApi.getCustomerSimpleList()
231249
// 获得地区列表
232250
areaList.value = await AreaApi.getAreaTree()
@@ -284,7 +302,9 @@ const resetForm = () => {
284302
master: false,
285303
post: undefined,
286304
parentId: undefined,
287-
remark: undefined
305+
remark: undefined,
306+
businessId: undefined,
307+
customerDefault: false
288308
}
289309
formRef.value?.resetFields()
290310
}

src/views/crm/contact/components/ContactList.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.master" />
2626
</template>
2727
</el-table-column>
28-
<!-- TODO 芋艿:【操作:设为首要联系人】 -->
2928
</el-table>
3029
<!-- 分页 -->
3130
<Pagination
@@ -49,6 +48,8 @@ defineOptions({ name: 'CrmContactList' })
4948
const props = defineProps<{
5049
bizType: number // 业务类型
5150
bizId: number // 业务编号
51+
customerId: number // 特殊:客户编号;在【商机】详情中,可以传递客户编号,默认新建的联系人关联到该客户
52+
businessId: number // 特殊:商机编号;在【商机】详情中,可以传递商机编号,默认新建的联系人关联到该商机
5253
}>()
5354
5455
const loading = ref(true) // 列表的加载中
@@ -73,6 +74,10 @@ const getList = async () => {
7374
queryParams.customerId = props.bizId
7475
data = await ContactApi.getContactPageByCustomer(queryParams)
7576
break
77+
case BizTypeEnum.CRM_BUSINESS:
78+
queryParams.businessId = props.bizId
79+
data = await ContactApi.getContactPageByBusiness(queryParams)
80+
break
7681
default:
7782
return
7883
}
@@ -92,7 +97,7 @@ const handleQuery = () => {
9297
/** 添加操作 */
9398
const formRef = ref()
9499
const openForm = () => {
95-
formRef.value.open('create')
100+
formRef.value.open('create', undefined, props.customerId, props.businessId)
96101
}
97102
98103
/** 打开联系人详情 */

src/views/crm/contact/detail/index.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
:biz-id="contact.id!"
3333
:biz-type="BizTypeEnum.CRM_CONTACT"
3434
:customer-id="contact.customerId"
35+
:contact-id="contact.id"
3536
/>
3637
</el-tab-pane>
3738
</el-tabs>

0 commit comments

Comments
 (0)