商机、商机状态类型

This commit is contained in:
ljlleo 2023-11-24 14:21:21 +08:00 committed by YunaiV
parent 661dc2ff67
commit 50430bb9cd
6 changed files with 932 additions and 0 deletions

View File

@ -0,0 +1,52 @@
import request from '@/config/axios'
export interface BusinessVO {
id: number
name: string
statusTypeId: number
statusId: number
contactNextTime: Date
customerId: number
dealTime: Date
price: number
discountPercent: number
productPrice: number
remark: string
ownerUserId: number
roUserIds: string
rwUserIds: string
endStatus: number
endRemark: string
contactLastTime: Date
followUpStatus: number
}
// 查询商机列表
export const getBusinessPage = async (params) => {
return await request.get({ url: `/crm/business/page`, params })
}
// 查询商机详情
export const getBusiness = async (id: number) => {
return await request.get({ url: `/crm/business/get?id=` + id })
}
// 新增商机
export const createBusiness = async (data: BusinessVO) => {
return await request.post({ url: `/crm/business/create`, data })
}
// 修改商机
export const updateBusiness = async (data: BusinessVO) => {
return await request.put({ url: `/crm/business/update`, data })
}
// 删除商机
export const deleteBusiness = async (id: number) => {
return await request.delete({ url: `/crm/business/delete?id=` + id })
}
// 导出商机 Excel
export const exportBusiness = async (params) => {
return await request.download({ url: `/crm/business/export-excel`, params })
}

View File

@ -0,0 +1,48 @@
import request from '@/config/axios'
export interface BusinessStatusTypeVO {
id: number
name: string
deptIds: number[]
status: boolean
}
// 查询商机状态类型列表
export const getBusinessStatusTypePage = async (params) => {
return await request.get({ url: `/crm/business-status-type/page`, params })
}
// 查询商机状态类型详情
export const getBusinessStatusType = async (id: number) => {
return await request.get({ url: `/crm/business-status-type/get?id=` + id })
}
// 新增商机状态类型
export const createBusinessStatusType = async (data: BusinessStatusTypeVO) => {
return await request.post({ url: `/crm/business-status-type/create`, data })
}
// 修改商机状态类型
export const updateBusinessStatusType = async (data: BusinessStatusTypeVO) => {
return await request.put({ url: `/crm/business-status-type/update`, data })
}
// 删除商机状态类型
export const deleteBusinessStatusType = async (id: number) => {
return await request.delete({ url: `/crm/business-status-type/delete?id=` + id })
}
// 导出商机状态类型 Excel
export const exportBusinessStatusType = async (params) => {
return await request.download({ url: `/crm/business-status-type/export-excel`, params })
}
// 获取商机状态类型信息列表
export const getBusinessStatusTypeList = async () => {
return await request.get({ url: `/crm/business-status-type/get-simple-list` })
}
// 根据类型ID获取商机状态信息列表
export const getBusinessStatusListByTypeId = async (typeId: number) => {
return await request.get({ url: `/crm/business-status-type/get-status-list?typeId=` + typeId })
}

View File

@ -0,0 +1,281 @@
<template>
<Dialog :title="dialogTitle" v-model="dialogVisible">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="100px"
v-loading="formLoading"
>
<el-form-item label="商机名称" prop="name">
<el-input v-model="formData.name" placeholder="请输入商机名称" />
</el-form-item>
<el-form-item label="客户名称" prop="customerName">
<el-popover
placement="bottom"
:width="600"
trigger="click"
:teleported="false"
:visible="showCustomer"
:offset="10"
>
<template #reference>
<el-input
placeholder="请选择客户"
@click="openCustomerSelect"
v-model="formData.customerName"
/>
</template>
<el-table :data="customerList" ref="multipleTableRef" @select="handleSelectionChange">
<el-table-column width="55" label="选择" type="selection" />
<el-table-column width="100" label="编号" property="id" />
<el-table-column width="150" label="客户名称" property="name" />
<el-table-column width="100" label="客户来源" prop="source" align="center">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_CUSTOMER_SOURCE" :value="scope.row.source" />
</template>
</el-table-column>
<el-table-column label="客户等级" align="center" prop="level" width="120">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_CUSTOMER_LEVEL" :value="scope.row.level" />
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<el-row :gutter="20">
<el-col>
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getCustomerList"
layout="sizes, prev, pager, next"
/>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="10" :offset="13">
<el-button @click="selectCustomer">确认</el-button>
<el-button @click="showCustomer = false">取消</el-button>
</el-col>
</el-row>
</el-popover>
</el-form-item>
<el-form-item label="商机状态类型" prop="statusTypeId">
<el-select
v-model="formData.statusTypeId"
placeholder="请选择商机状态类型"
clearable
size="small"
@change="changeBusinessStatusType"
>
<el-option
v-for="item in businessStatusTypeList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="商机状态" prop="statusId">
<el-select
v-model="formData.statusId"
placeholder="请选择商机状态"
clearable
size="small"
>
<el-option
v-for="item in businessStatusList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="预计成交日期" prop="dealTime">
<el-date-picker
v-model="formData.dealTime"
type="date"
value-format="x"
placeholder="选择预计成交日期"
/>
</el-form-item>
<el-form-item label="商机金额" prop="price">
<el-input v-model="formData.price" placeholder="请输入商机金额" />
</el-form-item>
<el-form-item label="整单折扣" prop="discountPercent">
<el-input v-model="formData.discountPercent" placeholder="请输入整单折扣" />
</el-form-item>
<el-form-item label="产品总金额" prop="productPrice">
<el-input v-model="formData.productPrice" placeholder="请输入产品总金额" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="formData.remark" placeholder="请输入备注" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script setup lang="ts">
import * as BusinessApi from '@/api/crm/business'
import * as BusinessStatusTypeApi from '@/api/crm/businessStatusType'
import * as CustomerApi from "@/api/crm/customer";
import { DICT_TYPE } from '@/utils/dict'
import {ElTable} from "element-plus";
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const formData = ref({
id: undefined,
name: undefined,
statusTypeId: undefined,
statusId: undefined,
contactNextTime: undefined,
customerId: undefined,
dealTime: undefined,
price: undefined,
discountPercent: undefined,
productPrice: undefined,
remark: undefined,
ownerUserId: undefined,
roUserIds: undefined,
rwUserIds: undefined,
endStatus: undefined,
endRemark: undefined,
contactLastTime: undefined,
followUpStatus: undefined
})
const formRules = reactive({
name: [{ required: true, message: '商机名称不能为空', trigger: 'blur' }]
})
const formRef = ref() // Ref
const businessStatusList = ref([]) //
const businessStatusTypeList = ref([]) //
const loading = ref(true) //
const total = ref(0) //
const customerList = ref([]) //
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
resetForm()
//
if (id) {
formLoading.value = true
try {
formData.value = await BusinessApi.getBusiness(id)
} finally {
formLoading.value = false
}
}
//
businessStatusTypeList.value = await BusinessStatusTypeApi.getBusinessStatusTypeList()
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
if (!formRef) return
const valid = await formRef.value.validate()
if (!valid) return
//
formLoading.value = true
try {
const data = formData.value as unknown as BusinessApi.BusinessVO
if (formType.value === 'create') {
await BusinessApi.createBusiness(data)
message.success(t('common.createSuccess'))
} else {
await BusinessApi.updateBusiness(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
id: undefined,
name: undefined,
statusTypeId: undefined,
statusId: undefined,
contactNextTime: undefined,
customerId: undefined,
dealTime: undefined,
price: undefined,
discountPercent: undefined,
productPrice: undefined,
remark: undefined,
ownerUserId: undefined,
roUserIds: undefined,
rwUserIds: undefined,
endStatus: undefined,
endRemark: undefined,
contactLastTime: undefined,
followUpStatus: undefined
}
formRef.value?.resetFields()
}
const changeBusinessStatusType = async (id) => {
//
businessStatusList.value = await BusinessStatusTypeApi.getBusinessStatusListByTypeId(id)
}
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
name: null,
mobile: null,
industryId: null,
level: null,
source: null
})
//
const showCustomer = ref(false)
const openCustomerSelect = () => {
showCustomer.value = !showCustomer.value
queryParams.pageNo = 1
getCustomerList()
}
/** 查询客户列表 */
const getCustomerList = async () => {
loading.value = true
try {
const data = await CustomerApi.getCustomerPage(queryParams)
console.log(JSON.stringify(data))
customerList.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
const multipleTableRef = ref<InstanceType<typeof ElTable>>()
const multipleSelection = ref()
const handleSelectionChange = ({}, row) => {
multipleSelection.value = row
multipleTableRef.value!.clearSelection()
multipleTableRef.value!.toggleRowSelection(row, undefined)
}
const selectCustomer = () => {
formData.value.customerId = multipleSelection.value.id
formData.value.customerName = multipleSelection.value.name
showCustomer.value = !showCustomer.value
}
</script>

View File

@ -0,0 +1,207 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item label="商机名称" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入商机名称"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
<el-button type="primary" @click="openForm('create')" v-hasPermi="['crm:business:create']">
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
<el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['crm:business:export']"
>
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="商机名称" align="center" prop="name" />
<el-table-column label="客户名称" align="center" prop="customerName" />
<el-table-column label="商机金额" align="center" prop="price" />
<el-table-column
label="预计成交日期"
align="center"
prop="dealTime"
:formatter="dateFormatter"
width="180px"
/>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="商机状态类型" align="center" prop="statusTypeName" />
<el-table-column label="商机状态" align="center" prop="statusName" />
<el-table-column
label="更新时间"
align="center"
prop="updateTime"
:formatter="dateFormatter"
width="180px"
/>
<el-table-column
label="创建时间"
align="center"
prop="createTime"
:formatter="dateFormatter"
width="180px"
/>
<el-table-column label="负责人" align="center" prop="ownerUserId" />
<el-table-column label="创建人" align="center" prop="creator" />
<el-table-column label="跟进状态" align="center" prop="followUpStatus" />
<el-table-column label="操作" align="center" fixed="right" width="130px">
<template #default="scope">
<el-button
link
type="primary"
@click="openForm('update', scope.row.id)"
v-hasPermi="['crm:business:update']"
>
编辑
</el-button>
<el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['crm:business:delete']"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<BusinessForm ref="formRef" @success="getList" />
</template>
<script setup lang="ts">
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import * as BusinessApi from '@/api/crm/business'
import BusinessForm from './BusinessForm.vue'
defineOptions({ name: 'CrmBusiness' })
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) //
const total = ref(0) //
const list = ref([]) //
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
name: null,
statusTypeId: null,
statusId: null,
contactNextTime: [],
customerId: null,
dealTime: [],
price: null,
discountPercent: null,
productPrice: null,
remark: null,
ownerUserId: null,
createTime: [],
roUserIds: null,
rwUserIds: null,
endStatus: null,
endRemark: null,
contactLastTime: [],
followUpStatus: null
})
const queryFormRef = ref() //
const exportLoading = ref(false) //
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await BusinessApi.getBusinessPage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await BusinessApi.deleteBusiness(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
/** 导出按钮操作 */
const handleExport = async () => {
try {
//
await message.exportConfirm()
//
exportLoading.value = true
const data = await BusinessApi.exportBusiness(queryParams)
download.excel(data, '商机.xls')
} catch {
} finally {
exportLoading.value = false
}
}
/** 初始化 **/
onMounted(() => {
getList()
})
</script>

View File

@ -0,0 +1,173 @@
<template>
<Dialog :title="dialogTitle" v-model="dialogVisible">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="100px"
v-loading="formLoading"
>
<el-form-item label="状态类型名" prop="name">
<el-input v-model="formData.name" placeholder="请输入状态类型名" />
</el-form-item>
<el-form-item label="应用部门" prop="deptIds">
<el-tree
ref="treeRef"
:data="deptList"
:props="defaultProps"
:check-strictly="!checkStrictly"
node-key="id"
placeholder="请选择归属部门"
show-checkbox
/>
</el-form-item>
<el-form-item label="状态设置" prop="statusList">
<el-table border style="width: 100%" :data="formData.statusList">
<el-table-column
align="center"
label="状态"
width="120"
prop="star"
>
<template #default="scope">
<el-text>状态{{scope.$index+1}}</el-text>
</template>
</el-table-column>
<el-table-column
align="center"
label="状态名称"
width="120"
prop="name"
>
<template #default="{ row }">
<el-input v-model="row.name" placeholder="请输入状态名称" />
</template>
</el-table-column>
<el-table-column width="120" align="center" label="赢单率" prop="percent">
<template #default="{ row }">
<el-input v-model="row.percent" placeholder="请输入赢单率" />
</template>
</el-table-column>
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button link type="primary" @click="addStatusArea(scope.$index)">
添加
</el-button>
<el-button link type="danger" @click="deleteStatusArea(scope.$index)" v-show="scope.$index>0">
删除
</el-button>
</template>
</el-table-column>
</el-table>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script setup lang="ts">
import * as BusinessStatusTypeApi from '@/api/crm/businessStatusType'
import {defaultProps, handleTree} from "@/utils/tree";
import * as DeptApi from "@/api/system/dept";
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const formData = ref({
id: 0,
name: '',
deptIds: [],
statusList: []
})
const formRules = reactive({
name: [{ required: true, message: '状态类型名不能为空', trigger: 'blur' }],
})
const formRef = ref() // Ref
const deptList = ref<Tree[]>([]) //
const treeRef = ref() // Ref
const checkStrictly = ref(true) //
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
resetForm()
//
if (id) {
formLoading.value = true
try {
formData.value = await BusinessStatusTypeApi.getBusinessStatusType(id)
treeRef.value.setCheckedKeys(formData.value.deptIds)
if(formData.value.statusList.length == 0) {
addStatusArea(0)
}
} finally {
formLoading.value = false
}
} else {
addStatusArea(0)
}
//
deptList.value = handleTree(await DeptApi.getSimpleDeptList())
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
await formRef.value.validate()
//
formLoading.value = true
try {
const data = formData.value as unknown as BusinessStatusTypeApi.BusinessStatusTypeVO
data.deptIds = treeRef.value.getCheckedKeys(false)
if (formType.value === 'create') {
await BusinessStatusTypeApi.createBusinessStatusType(data)
message.success(t('common.createSuccess'))
} else {
await BusinessStatusTypeApi.updateBusinessStatusType(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
checkStrictly.value = true
formData.value = {
id: 0,
name: '',
deptIds: [],
statusList: []
}
treeRef.value?.setCheckedNodes([])
formRef.value?.resetFields()
}
/** 添加状态 */
const addStatusArea = (index) => {
const data = formData.value
data.statusList.push({
name: '',
percent: ''
})
}
/** 删除状态 */
const deleteStatusArea = (index) => {
const data = formData.value
data.statusList.splice(index, 1)
}
</script>

View File

@ -0,0 +1,171 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
<el-button
type="primary"
plain
@click="openForm('create')"
v-hasPermi="['crm:business-status-type:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
<el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['crm:business-status-type:export']"
>
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="状态类型名" align="center" prop="name" />
<el-table-column label="使用的部门" align="center" prop="deptNames" />
<el-table-column label="创建人" align="center" prop="creator" />
<el-table-column
label="创建时间"
align="center"
prop="createTime"
:formatter="dateFormatter"
width="180px"
/>
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button
link
type="primary"
@click="openForm('update', scope.row.id)"
v-hasPermi="['crm:business-status-type:update']"
>
编辑
</el-button>
<el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['crm:business-status-type:delete']"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<BusinessStatusTypeForm ref="formRef" @success="getList" />
</template>
<script setup lang="ts">
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import * as BusinessStatusTypeApi from '@/api/crm/businessStatusType'
import BusinessStatusTypeForm from './BusinessStatusTypeForm.vue'
defineOptions({ name: 'BusinessStatusType' })
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) //
const list = ref([]) //
const total = ref(0) //
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
})
const queryFormRef = ref() //
const exportLoading = ref(false) //
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await BusinessStatusTypeApi.getBusinessStatusTypePage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 选择客户操作 */
const formCustomerRef = ref()
const openCustomerForm = (id?: number) => {
formCustomerRef.value.open(id)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await BusinessStatusTypeApi.deleteBusinessStatusType(id)
message.success(t('common.delSuccess'))
//
await getList()
} 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(() => {
getList()
})
</script>