Skip to content

Commit a1fd3af

Browse files
committed
crm联系人商机修改
1 parent df1c565 commit a1fd3af

File tree

9 files changed

+75
-107
lines changed

9 files changed

+75
-107
lines changed

src/api/crm/business/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/*
2+
* @Author: zyna
3+
* @Date: 2023-12-02 13:08:56
4+
* @LastEditTime: 2023-12-17 16:28:20
5+
* @FilePath: \yudao-ui-admin-vue3\src\api\crm\business\index.ts
6+
* @Description:
7+
*/
18
import request from '@/config/axios'
29

310
export interface BusinessVO {
@@ -55,3 +62,8 @@ export const deleteBusiness = async (id: number) => {
5562
export const exportBusiness = async (params) => {
5663
return await request.download({ url: `/crm/business/export-excel`, params })
5764
}
65+
66+
//联系人关联商机列表
67+
export const getBusinessPageByContact = async (params) => {
68+
return await request.get({ url: `/crm/business/page-by-contact`, params })
69+
}

src/api/crm/contact/index.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ export interface ContactVO {
2525
areaName: string
2626
ownerUserName: string
2727
}
28-
28+
export interface ContactBusinessLinkVO {
29+
id: number
30+
contactId: number
31+
businessId: number
32+
}
2933
// 查询 CRM 联系人列表
3034
export const getContactPage = async (params) => {
3135
return await request.get({ url: `/crm/contact/page`, params })
@@ -65,3 +69,13 @@ export const exportContact = async (params) => {
6569
export const getSimpleContactList = async () => {
6670
return await request.get({ url: `/crm/contact/simple-all-list` })
6771
}
72+
73+
//批量新增联系人商机关联
74+
export const createContactBusinessLinkBatch = async (data: ContactBusinessLinkVO[]) => {
75+
return await request.post({ url: `/crm/contact/create-batch-business`, data })
76+
}
77+
78+
//解除联系人商机关联
79+
export const deleteContactBusinessLink = async (data: ContactBusinessLinkVO) => {
80+
return await request.delete({ url: `/crm/contact/delete-batch-business`, data })
81+
}

src/api/crm/contactbusinesslink/index.ts

Lines changed: 0 additions & 47 deletions
This file was deleted.

src/views/crm/business/BusinessForm.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ const queryParams = reactive({
242242
mobile: null,
243243
industryId: null,
244244
level: null,
245-
source: null
245+
source: null,
246+
pool:false
246247
})
247248
// 选择客户
248249
const showCustomer = ref(false)

src/views/crm/contactBusinessLink/components/BusinessLinkContactList.vue renamed to src/views/crm/business/components/BusinessForContactLink.vue

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
</ContentWrap>
3030

3131
<!-- 列表 -->
32-
<!-- TODO @zyna:字段按照他们对齐下 -->
3332
<ContentWrap class="mt-10px">
3433
<el-table
3534
v-loading="loading"
@@ -75,12 +74,14 @@
7574
</template>
7675
<script setup lang="ts">
7776
import * as BusinessApi from '@/api/crm/business'
78-
import BusinessForm from '../../business/BusinessForm.vue'
77+
import BusinessForm from '../BusinessForm.vue'
7978
import { fenToYuanFormat } from '@/utils/formatter'
80-
// TODO @zyna:下面这个拼接,要注意大小写哈
81-
import * as ContactbusinesslinkApi from '@/api/crm/contactbusinesslink'
82-
const message = useMessage() // 消息弹窗
79+
import * as ContactApi from '@/api/crm/contact'
8380
81+
const message = useMessage() // 消息弹窗
82+
const props = defineProps<{
83+
customerId: number
84+
}>()
8485
defineOptions({ name: 'CrmBusinessLinkContactList' })
8586
8687
const dialogVisible = ref(false) // 弹窗的是否展示
@@ -93,25 +94,25 @@ const formLoading = ref(false) // 表单的加载中:1)修改时的数据加
9394
const queryParams = reactive({
9495
pageNo: 1,
9596
pageSize: 10,
96-
// TODO @zyna:是不是要根据 customerId 筛选?
97-
name: undefined
97+
name: undefined,
98+
customerId: props.customerId
9899
})
99100
const contactIdProp = ref(0) // 联系人编号
100101
101102
/** 打开弹窗 */
102103
const open = async (contactId: number) => {
103104
dialogVisible.value = true
104105
contactIdProp.value = contactId
105-
// TODO @zyna:下面要 await 下;一般 idea 如果有黄色警告,最好都看看哈
106-
getList()
106+
await getList()
107107
}
108108
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
109109
110110
/** 查询列表 */
111111
const getList = async () => {
112112
loading.value = true
113113
try {
114-
const data = await BusinessApi.getBusinessPage(queryParams)
114+
console.log(queryParams)
115+
const data = await BusinessApi.getBusinessPageByCustomer(queryParams)
115116
list.value = data.list
116117
total.value = data.total
117118
} finally {
@@ -141,25 +142,19 @@ const openForm = () => {
141142
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
142143
const businessRef = ref()
143144
const submitForm = async () => {
144-
// TODO @zyna:可以 if return,这样括号层级简单一点
145145
if (businessRef.value.getSelectionRows().length === 0) {
146-
message.success('未选择商机')
147-
} else {
148-
// TODO @zyna:这里 postData 应该不用 ref,搞个 数组就好了?
149-
const postData = ref<ContactbusinesslinkApi.ContactBusinessLinkVO[]>([])
150-
businessRef.value.getSelectionRows().forEach((element) => {
151-
// TODO @zyna:可以直接 push,不用声明 data
152-
let data = {
153-
id: undefined,
154-
businessId: element.id,
155-
contactId: contactIdProp.value
156-
}
157-
postData.value.push(data)
158-
})
159-
await ContactbusinesslinkApi.createContactBusinessLinkBatch(postData.value)
160-
dialogVisible.value = false
161-
emit('success')
146+
return message.success('未选择商机')
162147
}
148+
const postData = []
149+
businessRef.value.getSelectionRows().forEach((element) => {
150+
postData.push({
151+
businessId: element.id,
152+
contactId: contactIdProp.value
153+
})
154+
})
155+
await ContactApi.createContactBusinessLinkBatch(postData)
156+
dialogVisible.value = false
157+
emit('success')
163158
}
164159
165160
/** 打开联系人详情 */

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import * as BusinessApi from '@/api/crm/business'
3939
import BusinessForm from './../BusinessForm.vue'
4040
import { BizTypeEnum } from '@/api/crm/permission'
4141
import { fenToYuanFormat } from '@/utils/formatter'
42+
import * as ContactApi from '@/api/crm/contact'
4243
4344
defineOptions({ name: 'CrmBusinessList' })
4445
const props = defineProps<{
@@ -67,12 +68,15 @@ const getList = async () => {
6768
case BizTypeEnum.CRM_CUSTOMER:
6869
queryParams.customerId = props.bizId
6970
data = await BusinessApi.getBusinessPageByCustomer(queryParams)
71+
72+
console.log(data)
7073
break
7174
default:
7275
return
7376
}
7477
list.value = data.list
7578
total.value = data.total
79+
console.log(list.value)
7680
} finally {
7781
loading.value = false
7882
}

src/views/crm/contactBusinessLink/components/BusinessListByContact.vue renamed to src/views/crm/business/components/BusinessListByContact.vue

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<Icon class="mr-5px" icon="ep:opportunity" />
66
创建商机
77
</el-button>
8-
<el-button @click="openBusinessLink"> 关联 </el-button>
9-
<el-button @click="deleteBusinessLink"> 解除关联 </el-button>
8+
<el-button @click="openBusinessLink"> <Icon class="mr-5px" icon="ep:remove" />关联 </el-button>
9+
<el-button @click="deleteBusinessLink"> <Icon class="mr-5px" icon="ep:circle-plus" />解除关联 </el-button>
1010
</el-row>
1111

1212
<!-- 列表 -->
@@ -41,22 +41,25 @@
4141
</ContentWrap>
4242

4343
<!-- 表单弹窗:添加 -->
44-
<BusinessForm ref="formRef" @success="getList" />
45-
<!---->
46-
<BusinessLink ref="businessLinkRef" @success="getList" />
44+
<BusinessForm ref="formRef" @success="getList"/>
45+
<!--关联商机选择弹框-->
46+
<BusinessLink ref="businessLinkRef" @success="getList" :customer-id="props.customerId"/>
4747
</template>
4848
<script setup lang="ts">
49-
import * as ContactBusinessLinkApi from '@/api/crm/contactbusinesslink'
50-
import BusinessForm from '../../business/BusinessForm.vue'
49+
import * as BusinessApi from '@/api/crm/business'
50+
import BusinessForm from '../BusinessForm.vue'
5151
import { BizTypeEnum } from '@/api/crm/permission'
5252
import { fenToYuanFormat } from '@/utils/formatter'
53-
import BusinessLink from './BusinessLinkContactList.vue'
53+
import BusinessLink from './BusinessForContactLink.vue'
54+
import * as ContactApi from '@/api/crm/contact'
55+
import { el } from 'element-plus/es/locale'
56+
5457
const message = useMessage() // 消息弹窗
55-
// TODO @zyna:这个组件,可以服用 BusinessList,然后根据传入的编号类型,做一些判断?
5658
defineOptions({ name: 'CrmBusinessContactList' })
5759
const props = defineProps<{
5860
bizType: number // 业务类型
5961
bizId: number // 业务编号
62+
customerId: number
6063
}>()
6164
6265
const loading = ref(true) // 列表的加载中
@@ -72,14 +75,15 @@ const queryParams = reactive({
7275
const getList = async () => {
7376
loading.value = true
7477
try {
78+
console.log(props.customerId)
7579
// 置空参数
7680
queryParams.contactId = undefined
7781
// 执行查询
7882
let data = { list: [], total: 0 }
7983
switch (props.bizType) {
8084
case BizTypeEnum.CRM_CONTACT:
8185
queryParams.contactId = props.bizId
82-
data = await ContactBusinessLinkApi.getBusinessByContactPage(queryParams)
86+
data = await BusinessApi.getBusinessPageByContact(queryParams)
8387
break
8488
default:
8589
return
@@ -113,16 +117,11 @@ const deleteBusinessLink = async () => {
113117
if (businessRef.value.getSelectionRows().length === 0) {
114118
message.success('未选择商机')
115119
} else {
116-
const postData = ref<ContactBusinessLinkApi.ContactBusinessLinkVO[]>([])
120+
const postData = []
117121
businessRef.value.getSelectionRows().forEach((element) => {
118-
let data = {
119-
id: undefined,
120-
businessId: element.id,
121-
contactId: props.bizId
122-
}
123-
postData.value.push(data)
122+
postData.push(element.businessContactId)
124123
})
125-
await ContactBusinessLinkApi.deleteContactBusinessLink(postData.value)
124+
await ContactApi.deleteContactBusinessLink(postData)
126125
handleQuery()
127126
}
128127
}

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1-
<!--
2-
* @Author: zyna
3-
* @Date: 2023-12-02 13:08:57
4-
* @LastEditTime: 2023-12-03 13:47:16
5-
* @FilePath: \yudao-ui-admin-vue3\src\views\crm\contact\detail\ContactDetailsHeader.vue
6-
* @Description:
7-
-->
8-
<!-- TODO @zyna:上面这个不加哈 -->
91
<template>
10-
<!-- TODO @zyna:loading 缺了 -->
11-
<div v-loading="loading">
2+
<div>
123
<div class="flex items-start justify-between">
134
<div>
145
<el-col>
@@ -48,7 +39,6 @@
4839
import * as ContactApi from '@/api/crm/contact'
4940
import ContactForm from '@/views/crm/contact/ContactForm.vue'
5041
import { formatDate } from '@/utils/formatTime'
51-
5242
//操作修改
5343
const formRef = ref()
5444
const openForm = (type: string, id?: number) => {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<PermissionList :biz-id="contact.id!" :biz-type="BizTypeEnum.CRM_CONTACT" />
1111
</el-tab-pane>
1212
<el-tab-pane label="商机" lazy>
13-
<BusinessList :biz-id="contact.id!" :biz-type="BizTypeEnum.CRM_CONTACT" />
13+
<BusinessList :biz-id="contact.id!" :biz-type="BizTypeEnum.CRM_CONTACT" :customer-id="contact.customerId" />
1414
</el-tab-pane>
1515
</el-tabs>
1616
</el-col>
@@ -21,7 +21,7 @@ import { useTagsViewStore } from '@/store/modules/tagsView'
2121
import * as ContactApi from '@/api/crm/contact'
2222
import ContactDetailsHeader from '@/views/crm/contact/detail/ContactDetailsHeader.vue'
2323
import ContactDetailsInfo from '@/views/crm/contact/detail/ContactDetailsInfo.vue'
24-
import BusinessList from '@/views/crm/contactBusinessLink/components/BusinessListByContact.vue' // 商机列表
24+
import BusinessList from '@/views/crm/business/components/BusinessListByContact.vue' // 商机列表
2525
import PermissionList from '@/views/crm/permission/components/PermissionList.vue' // 团队成员列表(权限)
2626
import { BizTypeEnum } from '@/api/crm/permission'
2727

0 commit comments

Comments
 (0)