Skip to content

Commit ce79dd6

Browse files
committed
📈 CRM:code review 联系人商机功能
1 parent d629138 commit ce79dd6

File tree

7 files changed

+82
-56
lines changed

7 files changed

+82
-56
lines changed

src/api/crm/contactbusinesslink/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { getBusiness } from './../business/index';
21
import request from '@/config/axios'
32

43
export interface ContactBusinessLinkVO {
@@ -29,7 +28,7 @@ export const updateContactBusinessLink = async (data: ContactBusinessLinkVO) =>
2928

3029
// 删除联系人商机关联
3130
export const deleteContactBusinessLink = async (data: ContactBusinessLinkVO) => {
32-
return await request.delete({ url: `/crm/contact-business-link/delete-batch` , data })
31+
return await request.delete({ url: `/crm/contact-business-link/delete-batch`, data })
3332
}
3433

3534
// 导出联系人商机关联 Excel
@@ -43,5 +42,6 @@ export const createContactBusinessLinkBatch = async (data: ContactBusinessLinkVO
4342
}
4443
// 查询联系人关联商机列表
4544
export const getBusinessByContactPage = async (params) => {
46-
return await request.get({ url: `/crm/contact-business-link/page-by-contact` , params })
47-
}
45+
return await request.get({ url: `/crm/contact-business-link/page-by-contact`, params })
46+
}
47+
// TODO @zyna:根据后端,调整下请求

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
* @Date: 2023-12-02 13:08:57
44
* @LastEditTime: 2023-12-03 13:47:16
55
* @FilePath: \yudao-ui-admin-vue3\src\views\crm\contact\detail\ContactDetailsHeader.vue
6-
* @Description:
6+
* @Description:
77
-->
8+
<!-- TODO @zyna:上面这个不加哈 -->
89
<template>
10+
<!-- TODO @zyna:loading 缺了 -->
911
<div v-loading="loading">
1012
<div class="flex items-start justify-between">
1113
<div>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@
6565
</el-collapse>
6666
</template>
6767
<script setup lang="ts">
68-
// TODO 芋艿:后面在 review 么?
6968
import * as ContactApi from '@/api/crm/contact'
7069
import { DICT_TYPE } from '@/utils/dict'
7170
import { formatDate } from '@/utils/formatTime'
72-
const { contact } = defineProps<{ contact: ContactApi.ContactVO }>()
71+
const { contact } = defineProps<{
72+
contact: ContactApi.ContactVO
73+
}>()
7374
7475
// 展示的折叠面板
7576
const activeNames = ref(['basicInfo', 'systemInfo'])
7677
</script>
77-
<style scoped lang="scss"></style>

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

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@
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" />
1414
</el-tab-pane>
1515
</el-tabs>
1616
</el-col>
1717
</template>
18-
1918
<script setup lang="ts">
2019
import { ElMessage } from 'element-plus'
2120
import { useTagsViewStore } from '@/store/modules/tagsView'
@@ -27,18 +26,13 @@ import PermissionList from '@/views/crm/permission/components/PermissionList.vue
2726
import { BizTypeEnum } from '@/api/crm/permission'
2827
2928
defineOptions({ name: 'CrmContactDetail' })
30-
const { delView } = useTagsViewStore() // 视图操作
29+
3130
const route = useRoute()
32-
const { currentRoute } = useRouter() // 路由
33-
const id = Number(route.params.id)
31+
const id = Number(route.params.id) // 联系人编号
3432
const loading = ref(true) // 加载中
35-
// 联系人详情
36-
const contact = ref<ContactApi.ContactVO>({} as ContactApi.ContactVO)
37-
/**
38-
* 获取详情
39-
*
40-
* @param id
41-
*/
33+
const contact = ref<ContactApi.ContactVO>({} as ContactApi.ContactVO) // 联系人详情
34+
35+
/** 获取详情 */
4236
const getContactData = async (id: number) => {
4337
loading.value = true
4438
try {
@@ -47,9 +41,10 @@ const getContactData = async (id: number) => {
4741
loading.value = false
4842
}
4943
}
50-
/**
51-
* 初始化
52-
*/
44+
45+
/** 初始化 */
46+
const { delView } = useTagsViewStore() // 视图操作
47+
const { currentRoute } = useRouter() // 路由
5348
onMounted(async () => {
5449
if (!id) {
5550
ElMessage.warning('参数错误,联系人不能为空!')

src/views/crm/contactBusinessLink/components/BusinessLinkContactList.vue

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<Dialog :title="dialogTitle" v-model="dialogVisible">
3+
<!-- 搜索工作栏 -->
34
<ContentWrap>
4-
<!-- 搜索工作栏 -->
55
<el-form
66
class="-mb-15px"
77
:model="queryParams"
@@ -27,9 +27,17 @@
2727
</el-form-item>
2828
</el-form>
2929
</ContentWrap>
30+
3031
<!-- 列表 -->
32+
<!-- TODO @zyna:字段按照他们对齐下 -->
3133
<ContentWrap class="mt-10px">
32-
<el-table v-loading="loading" ref="businessRef" :data="list" :stripe="true" :show-overflow-tooltip="true">
34+
<el-table
35+
v-loading="loading"
36+
ref="businessRef"
37+
:data="list"
38+
:stripe="true"
39+
:show-overflow-tooltip="true"
40+
>
3341
<el-table-column type="selection" width="55" />
3442
<el-table-column label="商机名称" fixed="left" align="center" prop="name">
3543
<template #default="scope">
@@ -38,7 +46,12 @@
3846
</el-link>
3947
</template>
4048
</el-table-column>
41-
<el-table-column label="商机金额" align="center" prop="price" :formatter="fenToYuanFormat" />
49+
<el-table-column
50+
label="商机金额"
51+
align="center"
52+
prop="price"
53+
:formatter="fenToYuanFormat"
54+
/>
4255
<el-table-column label="客户名称" align="center" prop="customerName" />
4356
<el-table-column label="商机组" align="center" prop="statusTypeName" />
4457
<el-table-column label="商机阶段" align="center" prop="statusName" />
@@ -55,38 +68,45 @@
5568
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
5669
<el-button @click="dialogVisible = false">取 消</el-button>
5770
</template>
71+
5872
<!-- 表单弹窗:添加 -->
5973
<BusinessForm ref="formRef" @success="getList" />
6074
</Dialog>
6175
</template>
6276
<script setup lang="ts">
6377
import * as BusinessApi from '@/api/crm/business'
6478
import BusinessForm from '../../business/BusinessForm.vue'
65-
import { BizTypeEnum } from '@/api/crm/permission'
6679
import { fenToYuanFormat } from '@/utils/formatter'
80+
// TODO @zyna:下面这个拼接,要注意大小写哈
6781
import * as ContactbusinesslinkApi from '@/api/crm/contactbusinesslink'
6882
const message = useMessage() // 消息弹窗
83+
6984
defineOptions({ name: 'CrmBusinessLinkContactList' })
85+
7086
const dialogVisible = ref(false) // 弹窗的是否展示
71-
const dialogTitle = ref('') // 弹窗的标题
87+
const dialogTitle = ref('') // 弹窗的标题 TODO @zyna:是不是搞个标题?
7288
const loading = ref(true) // 列表的加载中
7389
const total = ref(0) // 列表的总页数
7490
const list = ref([]) // 列表的数据
7591
const queryFormRef = ref() // 搜索的表单
7692
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
77-
const contactIdProp = ref(undefined)
7893
const queryParams = reactive({
7994
pageNo: 1,
8095
pageSize: 10,
81-
name: undefined as unknown, // 允许 undefined + number
96+
// TODO @zyna:是不是要根据 customerId 筛选?
97+
name: undefined
8298
})
99+
const contactIdProp = ref(0) // 联系人编号
100+
83101
/** 打开弹窗 */
84-
const open = async (contactId?: number) => {
102+
const open = async (contactId: number) => {
85103
dialogVisible.value = true
86104
contactIdProp.value = contactId
105+
// TODO @zyna:下面要 await 下;一般 idea 如果有黄色警告,最好都看看哈
87106
getList()
88107
}
89108
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
109+
90110
/** 查询列表 */
91111
const getList = async () => {
92112
loading.value = true
@@ -104,32 +124,38 @@ const handleQuery = () => {
104124
queryParams.pageNo = 1
105125
getList()
106126
}
127+
107128
/** 重置按钮操作 */
108129
const resetQuery = () => {
109130
queryFormRef.value.resetFields()
110131
handleQuery()
111132
}
133+
112134
/** 添加操作 */
113135
const formRef = ref()
114136
const openForm = () => {
115137
formRef.value.open('create')
116138
}
117-
/**关联商机提交 */
139+
140+
/** 关联商机提交 */
118141
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
119142
const businessRef = ref()
120-
const submitForm = async () =>{
121-
if(businessRef.value.getSelectionRows().length === 0){
143+
const submitForm = async () => {
144+
// TODO @zyna:可以 if return,这样括号层级简单一点
145+
if (businessRef.value.getSelectionRows().length === 0) {
122146
message.success('未选择商机')
123-
}else{
147+
} else {
148+
// TODO @zyna:这里 postData 应该不用 ref,搞个 数组就好了?
124149
const postData = ref<ContactbusinesslinkApi.ContactBusinessLinkVO[]>([])
125-
businessRef.value.getSelectionRows().forEach(element => {
150+
businessRef.value.getSelectionRows().forEach((element) => {
151+
// TODO @zyna:可以直接 push,不用声明 data
126152
let data = {
127-
id:undefined,
128-
businessId : element.id,
129-
contactId : contactIdProp.value
153+
id: undefined,
154+
businessId: element.id,
155+
contactId: contactIdProp.value
130156
}
131157
postData.value.push(data)
132-
});
158+
})
133159
await ContactbusinesslinkApi.createContactBusinessLinkBatch(postData.value)
134160
dialogVisible.value = false
135161
emit('success')

src/views/crm/contactBusinessLink/components/BusinessListByContact.vue

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@
55
<Icon class="mr-5px" icon="ep:opportunity" />
66
创建商机
77
</el-button>
8-
<el-button @click="openBusinessLink">
9-
关联
10-
</el-button>
11-
<el-button @click="deleteBusinessLink">
12-
解除关联
13-
</el-button>
8+
<el-button @click="openBusinessLink"> 关联 </el-button>
9+
<el-button @click="deleteBusinessLink"> 解除关联 </el-button>
1410
</el-row>
1511

1612
<!-- 列表 -->
1713
<ContentWrap class="mt-10px">
18-
<el-table v-loading="loading" ref="businessRef" :data="list" :stripe="true" :show-overflow-tooltip="true">
14+
<el-table
15+
v-loading="loading"
16+
ref="businessRef"
17+
:data="list"
18+
:stripe="true"
19+
:show-overflow-tooltip="true"
20+
>
1921
<el-table-column type="selection" width="55" />
2022
<el-table-column label="商机名称" fixed="left" align="center" prop="name">
2123
<template #default="scope">
@@ -39,9 +41,9 @@
3941
</ContentWrap>
4042

4143
<!-- 表单弹窗:添加 -->
42-
<BusinessForm ref="formRef" @success="getList"/>
44+
<BusinessForm ref="formRef" @success="getList" />
4345
<!---->
44-
<BusinessLink ref="businessLinkRef" @success="getList"/>
46+
<BusinessLink ref="businessLinkRef" @success="getList" />
4547
</template>
4648
<script setup lang="ts">
4749
import * as ContactBusinessLinkApi from '@/api/crm/contactbusinesslink'
@@ -50,6 +52,7 @@ import { BizTypeEnum } from '@/api/crm/permission'
5052
import { fenToYuanFormat } from '@/utils/formatter'
5153
import BusinessLink from './BusinessLinkContactList.vue'
5254
const message = useMessage() // 消息弹窗
55+
// TODO @zyna:这个组件,可以服用 BusinessList,然后根据传入的编号类型,做一些判断?
5356
defineOptions({ name: 'CrmBusinessContactList' })
5457
const props = defineProps<{
5558
bizType: number // 业务类型
@@ -107,18 +110,18 @@ const openBusinessLink = () => {
107110
/**解除关联 */
108111
const businessRef = ref()
109112
const deleteBusinessLink = async () => {
110-
if(businessRef.value.getSelectionRows().length === 0){
113+
if (businessRef.value.getSelectionRows().length === 0) {
111114
message.success('未选择商机')
112-
}else{
115+
} else {
113116
const postData = ref<ContactBusinessLinkApi.ContactBusinessLinkVO[]>([])
114-
businessRef.value.getSelectionRows().forEach(element => {
117+
businessRef.value.getSelectionRows().forEach((element) => {
115118
let data = {
116-
id:undefined,
117-
businessId : element.id,
118-
contactId : props.bizId
119+
id: undefined,
120+
businessId: element.id,
121+
contactId: props.bizId
119122
}
120123
postData.value.push(data)
121-
});
124+
})
122125
await ContactBusinessLinkApi.deleteContactBusinessLink(postData.value)
123126
handleQuery()
124127
}

src/views/crm/contactBusinessLink/index.vue

Whitespace-only changes.

0 commit comments

Comments
 (0)