2023-12-03 19:56:46 +08:00
|
|
|
|
<template>
|
|
|
|
|
<!-- 操作栏 -->
|
|
|
|
|
<el-row justify="end">
|
|
|
|
|
<el-button @click="openForm">
|
|
|
|
|
<Icon class="mr-5px" icon="ep:opportunity" />
|
|
|
|
|
创建商机
|
|
|
|
|
</el-button>
|
2023-12-17 17:34:32 +08:00
|
|
|
|
<el-button @click="openBusinessLink"> <Icon class="mr-5px" icon="ep:remove" />关联 </el-button>
|
|
|
|
|
<el-button @click="deleteBusinessLink"> <Icon class="mr-5px" icon="ep:circle-plus" />解除关联 </el-button>
|
2023-12-03 19:56:46 +08:00
|
|
|
|
</el-row>
|
|
|
|
|
|
|
|
|
|
<!-- 列表 -->
|
|
|
|
|
<ContentWrap class="mt-10px">
|
2023-12-06 19:26:39 +08:00
|
|
|
|
<el-table
|
|
|
|
|
v-loading="loading"
|
|
|
|
|
ref="businessRef"
|
|
|
|
|
:data="list"
|
|
|
|
|
:stripe="true"
|
|
|
|
|
:show-overflow-tooltip="true"
|
|
|
|
|
>
|
2023-12-03 19:56:46 +08:00
|
|
|
|
<el-table-column type="selection" width="55" />
|
|
|
|
|
<el-table-column label="商机名称" fixed="left" align="center" prop="name">
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
<el-link type="primary" :underline="false" @click="openDetail(scope.row.id)">
|
|
|
|
|
{{ scope.row.name }}
|
|
|
|
|
</el-link>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column label="商机金额" align="center" prop="price" :formatter="fenToYuanFormat" />
|
|
|
|
|
<el-table-column label="客户名称" align="center" prop="customerName" />
|
|
|
|
|
<el-table-column label="商机组" align="center" prop="statusTypeName" />
|
|
|
|
|
<el-table-column label="商机阶段" align="center" prop="statusName" />
|
|
|
|
|
</el-table>
|
|
|
|
|
<!-- 分页 -->
|
|
|
|
|
<Pagination
|
|
|
|
|
:total="total"
|
|
|
|
|
v-model:page="queryParams.pageNo"
|
|
|
|
|
v-model:limit="queryParams.pageSize"
|
|
|
|
|
@pagination="getList"
|
|
|
|
|
/>
|
|
|
|
|
</ContentWrap>
|
|
|
|
|
|
|
|
|
|
<!-- 表单弹窗:添加 -->
|
2023-12-17 17:34:32 +08:00
|
|
|
|
<BusinessForm ref="formRef" @success="getList"/>
|
|
|
|
|
<!--关联商机选择弹框-->
|
|
|
|
|
<BusinessLink ref="businessLinkRef" @success="getList" :customer-id="props.customerId"/>
|
2023-12-03 19:56:46 +08:00
|
|
|
|
</template>
|
|
|
|
|
<script setup lang="ts">
|
2023-12-17 17:34:32 +08:00
|
|
|
|
import * as BusinessApi from '@/api/crm/business'
|
|
|
|
|
import BusinessForm from '../BusinessForm.vue'
|
2023-12-03 19:56:46 +08:00
|
|
|
|
import { BizTypeEnum } from '@/api/crm/permission'
|
|
|
|
|
import { fenToYuanFormat } from '@/utils/formatter'
|
2023-12-17 17:34:32 +08:00
|
|
|
|
import BusinessLink from './BusinessForContactLink.vue'
|
|
|
|
|
import * as ContactApi from '@/api/crm/contact'
|
|
|
|
|
import { el } from 'element-plus/es/locale'
|
|
|
|
|
|
2023-12-03 19:56:46 +08:00
|
|
|
|
const message = useMessage() // 消息弹窗
|
|
|
|
|
defineOptions({ name: 'CrmBusinessContactList' })
|
|
|
|
|
const props = defineProps<{
|
|
|
|
|
bizType: number // 业务类型
|
|
|
|
|
bizId: number // 业务编号
|
2023-12-17 17:34:32 +08:00
|
|
|
|
customerId: number
|
2023-12-03 19:56:46 +08:00
|
|
|
|
}>()
|
|
|
|
|
|
|
|
|
|
const loading = ref(true) // 列表的加载中
|
|
|
|
|
const total = ref(0) // 列表的总页数
|
|
|
|
|
const list = ref([]) // 列表的数据
|
|
|
|
|
const queryParams = reactive({
|
|
|
|
|
pageNo: 1,
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
contactId: undefined as unknown // 允许 undefined + number
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
/** 查询列表 */
|
|
|
|
|
const getList = async () => {
|
|
|
|
|
loading.value = true
|
|
|
|
|
try {
|
|
|
|
|
// 置空参数
|
|
|
|
|
queryParams.contactId = undefined
|
|
|
|
|
// 执行查询
|
|
|
|
|
let data = { list: [], total: 0 }
|
|
|
|
|
switch (props.bizType) {
|
|
|
|
|
case BizTypeEnum.CRM_CONTACT:
|
|
|
|
|
queryParams.contactId = props.bizId
|
2023-12-17 17:34:32 +08:00
|
|
|
|
data = await BusinessApi.getBusinessPageByContact(queryParams)
|
2023-12-03 19:56:46 +08:00
|
|
|
|
break
|
|
|
|
|
default:
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
list.value = data.list
|
|
|
|
|
total.value = data.total
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 搜索按钮操作 */
|
|
|
|
|
const handleQuery = () => {
|
|
|
|
|
queryParams.pageNo = 1
|
|
|
|
|
getList()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 添加操作 */
|
|
|
|
|
const formRef = ref()
|
|
|
|
|
const openForm = () => {
|
|
|
|
|
formRef.value.open('create')
|
|
|
|
|
}
|
|
|
|
|
/** 关联操作 */
|
|
|
|
|
const businessLinkRef = ref()
|
|
|
|
|
const openBusinessLink = () => {
|
|
|
|
|
businessLinkRef.value.open(props.bizId)
|
|
|
|
|
}
|
|
|
|
|
/**解除关联 */
|
|
|
|
|
const businessRef = ref()
|
|
|
|
|
const deleteBusinessLink = async () => {
|
2023-12-06 19:26:39 +08:00
|
|
|
|
if (businessRef.value.getSelectionRows().length === 0) {
|
2023-12-03 19:56:46 +08:00
|
|
|
|
message.success('未选择商机')
|
2023-12-06 19:26:39 +08:00
|
|
|
|
} else {
|
2023-12-17 17:34:32 +08:00
|
|
|
|
const postData = []
|
2023-12-06 19:26:39 +08:00
|
|
|
|
businessRef.value.getSelectionRows().forEach((element) => {
|
2023-12-17 17:34:32 +08:00
|
|
|
|
postData.push(element.businessContactId)
|
2023-12-06 19:26:39 +08:00
|
|
|
|
})
|
2023-12-17 17:34:32 +08:00
|
|
|
|
await ContactApi.deleteContactBusinessLink(postData)
|
2023-12-03 19:56:46 +08:00
|
|
|
|
handleQuery()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/** 打开联系人详情 */
|
|
|
|
|
const { push } = useRouter()
|
|
|
|
|
const openDetail = (id: number) => {
|
|
|
|
|
push({ name: 'CrmBusinessDetail', params: { id } })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 监听打开的 bizId + bizType,从而加载最新的列表 */
|
|
|
|
|
watch(
|
|
|
|
|
() => [props.bizId, props.bizType],
|
|
|
|
|
() => {
|
|
|
|
|
handleQuery()
|
|
|
|
|
},
|
|
|
|
|
{ immediate: true, deep: true }
|
|
|
|
|
)
|
|
|
|
|
</script>
|