CRM:完善商机的新增、修改逻辑

This commit is contained in:
YunaiV 2024-02-21 21:49:55 +08:00
parent 6baeadc87a
commit 29605800b5
4 changed files with 53 additions and 30 deletions

View File

@ -11,6 +11,27 @@ export interface BusinessStatusTypeVO {
} }
} }
export const DEFAULT_STATUSES = [
{
endStatus: 1,
key: '结束',
name: '赢单',
percent: 100
},
{
endStatus: 2,
key: '结束',
name: '输单',
percent: 0
},
{
endStatus: 3,
key: '结束',
name: '无效',
percent: 0
}
]
// 查询商机状态组列表 // 查询商机状态组列表
export const getBusinessStatusPage = async (params: any) => { export const getBusinessStatusPage = async (params: any) => {
return await request.get({ url: `/crm/business-status/page`, params }) return await request.get({ url: `/crm/business-status/page`, params })
@ -31,6 +52,11 @@ export const getBusinessStatus = async (id: number) => {
return await request.get({ url: `/crm/business-status/get?id=` + id }) return await request.get({ url: `/crm/business-status/get?id=` + id })
} }
// 删除商机状态
export const deleteBusinessStatus = async (id: number) => {
return await request.delete({ url: `/crm/business-status/delete?id=` + id })
}
// 获得商机状态组列表 // 获得商机状态组列表
export const getBusinessStatusTypeSimpleList = async () => { export const getBusinessStatusTypeSimpleList = async () => {
return await request.get({ url: `/crm/business-status/type-simple-list` }) return await request.get({ url: `/crm/business-status/type-simple-list` })

View File

@ -50,6 +50,7 @@
placeholder="请选择商机状态组" placeholder="请选择商机状态组"
clearable clearable
class="w-1/1" class="w-1/1"
:disabled="formType !== 'create'"
> >
<el-option <el-option
v-for="item in statusTypeList" v-for="item in statusTypeList"

View File

@ -25,20 +25,27 @@
/> />
</el-form-item> </el-form-item>
<el-form-item label="阶段设置" prop="statuses"> <el-form-item label="阶段设置" prop="statuses">
<el-table border style="width: 100%" :data="formData.statuses"> <el-table
border
style="width: 100%"
:data="formData.statuses.concat(BusinessStatusApi.DEFAULT_STATUSES)"
>
<el-table-column align="center" label="阶段" width="70"> <el-table-column align="center" label="阶段" width="70">
<template #default="scope"> <template #default="scope">
<el-text>阶段 {{ scope.$index + 1 }}</el-text> <el-text v-if="!scope.row.defaultStatus">阶段 {{ scope.$index + 1 }}</el-text>
<el-text v-else>结束</el-text>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="阶段名称" width="160" prop="name"> <el-table-column align="center" label="阶段名称" width="160" prop="name">
<template #default="{ row }"> <template #default="{ row }">
<el-input v-model="row.name" placeholder="请输入状态名称" /> <el-input v-if="!row.endStatus" v-model="row.name" placeholder="请输入状态名称" />
<el-text v-else>{{ row.name }}</el-text>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="140" align="center" label="赢单率" prop="percent"> <el-table-column width="140" align="center" label="赢单率%" prop="percent">
<template #default="{ row }"> <template #default="{ row }">
<el-input-number <el-input-number
v-if="!row.endStatus"
v-model="row.percent" v-model="row.percent"
placeholder="请输入赢单率" placeholder="请输入赢单率"
controls-position="right" controls-position="right"
@ -47,12 +54,21 @@
:precision="2" :precision="2"
class="!w-1/1" class="!w-1/1"
/> />
<el-text v-else>{{ row.percent }}</el-text>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" width="110" align="center"> <el-table-column label="操作" width="110" align="center">
<template #default="scope"> <template #default="scope">
<el-button link type="primary" @click="addStatusArea(scope.$index)"> 添加 </el-button>
<el-button <el-button
v-if="!scope.row.endStatus"
link
type="primary"
@click="addStatus(scope.$index)"
>
添加
</el-button>
<el-button
v-if="!scope.row.endStatus"
link link
type="danger" type="danger"
@click="deleteStatusArea(scope.$index)" @click="deleteStatusArea(scope.$index)"
@ -110,13 +126,13 @@ const open = async (type: string, id?: number) => {
formData.value = await BusinessStatusApi.getBusinessStatus(id) formData.value = await BusinessStatusApi.getBusinessStatus(id)
treeRef.value.setCheckedKeys(formData.value.deptIds) treeRef.value.setCheckedKeys(formData.value.deptIds)
if (formData.value.statuses.length == 0) { if (formData.value.statuses.length == 0) {
addStatusArea(0) addStatus()
} }
} finally { } finally {
formLoading.value = false formLoading.value = false
} }
} else { } else {
addStatusArea(0) addStatus()
} }
// //
deptList.value = handleTree(await DeptApi.getSimpleDeptList()) deptList.value = handleTree(await DeptApi.getSimpleDeptList())
@ -162,7 +178,7 @@ const resetForm = () => {
} }
/** 添加状态 */ /** 添加状态 */
const addStatusArea = () => { const addStatus = () => {
const data = formData.value const data = formData.value
data.statuses.push({ data.statuses.push({
name: '', name: '',

View File

@ -80,6 +80,7 @@ import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download' import download from '@/utils/download'
import * as BusinessStatusApi from '@/api/crm/business/status' import * as BusinessStatusApi from '@/api/crm/business/status'
import BusinessStatusForm from './BusinessStatusForm.vue' import BusinessStatusForm from './BusinessStatusForm.vue'
import { deleteBusinessStatus } from '@/api/crm/business/status'
defineOptions({ name: 'CrmBusinessStatus' }) defineOptions({ name: 'CrmBusinessStatus' })
@ -126,40 +127,19 @@ const openForm = (type: string, id?: number) => {
formRef.value.open(type, id) formRef.value.open(type, id)
} }
/** 选择客户操作 */
const formCustomerRef = ref()
const openCustomerForm = (id?: number) => {
formCustomerRef.value.open(id)
}
/** 删除按钮操作 */ /** 删除按钮操作 */
const handleDelete = async (id: number) => { const handleDelete = async (id: number) => {
try { try {
// //
await message.delConfirm() await message.delConfirm()
// //
await BusinessStatusTypeApi.deleteBusinessStatusType(id) await BusinessStatusApi.deleteBusinessStatus(id)
message.success(t('common.delSuccess')) message.success(t('common.delSuccess'))
// //
await getList() await getList()
} catch {} } catch {}
} }
/** 导出按钮操作 */
const handleExport = async () => {
try {
//
await message.exportConfirm()
//
exportLoading.value = true
const data = await BusinessStatusTypeApi.exportBusinessStatusType(queryParams)
download.excel(data, '商机状态组.xls')
} catch {
} finally {
exportLoading.value = false
}
}
/** 初始化 **/ /** 初始化 **/
onMounted(() => { onMounted(() => {
getList() getList()