莳松crm管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ss-crm-manage-web/src/views/Home/Comp/DialogSalerReportDetail.vue

402 lines
11 KiB

6 months ago
<template>
6 months ago
<Dialog :title="dialogTitle" v-model="dialogVisible" width="1000px">
6 months ago
<el-form :model="searchForm" label-width="0" inline>
<el-form-item>
<el-date-picker
6 months ago
v-model="searchForm.consultTime"
6 months ago
type="daterange"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
start-placeholder="选择日期"
end-placeholder="选择日期"
6 months ago
:clearable="false"
6 months ago
/>
</el-form-item>
<el-form-item>
<el-tree-select
v-model="searchForm.sourceId"
:data="props.sourceOptions"
:props="defaultProps"
check-strictly
6 months ago
clearable
6 months ago
node-key="sourceId"
placeholder="请选择渠道"
6 months ago
@change="sourceChange"
6 months ago
/>
</el-form-item>
6 months ago
<el-form-item v-if="appStore.getAppInfo?.instanceType == 1">
6 months ago
<el-select
v-model="searchForm.licenseTypeList"
placeholder="选择驾照类型"
clearable
multiple
>
6 months ago
<el-option
6 months ago
v-for="item in props.licenseTypeOptions"
:key="item.label"
6 months ago
:label="item.label"
6 months ago
:value="item.label"
6 months ago
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button @click="handleSearch">查询</el-button>
<el-button @click="handleReset">重置</el-button>
</el-form-item>
</el-form>
<el-tabs v-model="showPane" class="pb-10px">
<el-tab-pane label="详细数据" :name="1">
<el-table v-loading="loading" :data="tableList" border stripe>
<el-table-column prop="sourceName" label="渠道名称" width="100" fixed="left" />
6 months ago
<el-table-column prop="newClueNumber" label="新线索数" sortable min-width="100" />
<el-table-column prop="signNumber" label="成交数" sortable min-width="100" />
6 months ago
<el-table-column
prop="signRate"
label="成交率"
sortable
min-width="100"
:formatter="(row) => row.signRate + '%'"
/>
6 months ago
<el-table-column prop="averageSignPeriod" label="成交周期" sortable min-width="100" />
<el-table-column
prop="grossProfitOfSingleSign"
label="毛利/单"
sortable
min-width="100"
/>
<el-table-column prop="payPriceOfSingleSign" label="支出/单" sortable min-width="100" />
<el-table-column prop="costOfSingleClue" label="线索成本/条" sortable min-width="100" />
<el-table-column
prop="netProfitOfSingleSign"
label="净利润/单"
sortable
min-width="100"
/>
6 months ago
<el-table-column label="总线索成本" prop="clueCostTotal" sortable min-width="100" />
<el-table-column label="总支出" prop="payPriceTotal" sortable min-width="100" />
<el-table-column label="总利润" prop="profitTotal" sortable min-width="100" />
6 months ago
</el-table>
</el-tab-pane>
<el-tab-pane label="图表展示" :name="2" lazy>
<el-row :gutter="20">
<el-col :span="24" :offset="0">
<el-checkbox-group v-model="showChannel" @change="setReportData">
<el-checkbox v-for="(item, index) in channelArr" :key="index" :label="item" />
</el-checkbox-group>
</el-col>
<el-col :span="12" :offset="0">
<el-skeleton :loading="loading" animated>
<Echart :options="echart1Option" width="100%" :height="400" />
</el-skeleton>
</el-col>
6 months ago
<el-col :span="12" :offset="0" v-if="appStore.getAppInfo?.instanceType == 1">
6 months ago
<Echart :options="echart2Option" width="100%" :height="400" />
</el-col>
<el-col :span="24" :offset="0">
<Echart :options="echart3Option" width="100%" :height="400" />
</el-col>
</el-row>
</el-tab-pane>
</el-tabs>
</Dialog>
</template>
<script setup name="DialogSalerReportDetail">
import { set } from 'lodash-es'
6 months ago
import * as reportApi from '@/api/home/reportSaler'
import { getIntDictOptions } from '@/utils/dict'
6 months ago
import { removeNullField } from '@/utils'
6 months ago
import { useAppStore } from '@/store/modules/app'
6 months ago
import { formatDate } from '@/utils/formatTime'
6 months ago
const appStore = useAppStore()
6 months ago
const props = defineProps({
6 months ago
licenseTypeOptions: {
6 months ago
type: Array,
default: () => []
},
sourceOptions: {
type: Array,
default: () => []
}
})
const defaultProps = {
children: 'children',
label: 'sourceName',
value: 'sourceId',
isLeaf: 'leaf'
}
6 months ago
const showChannel = ref([])
const intentionOptions = getIntDictOptions('intention_state')
const channelArr = computed(() => {
if (searchForm.value.sourceId) {
let arr =
props.sourceOptions.find((it) => it.sourceId == searchForm.value.sourceId)?.children || []
return arr.map((it) => it.sourceName)
} else {
return props.sourceOptions.map((it) => it.sourceName)
}
})
6 months ago
const dialogVisible = ref(false) // 弹窗的是否展示
const dialogTitle = ref('') // 弹窗的标题
const loading = ref(false)
const searchForm = ref({})
const showPane = ref(1)
function handleReset() {
searchForm.value = {
nickname: undefined,
6 months ago
consultTime: [`${year}-${month}-01`, formatDate(new Date())],
licenseTypeList: [],
sourceId: undefined
6 months ago
}
}
/** 打开弹窗 */
const open = async (info, queryInfo) => {
showPane.value = 1
dialogVisible.value = true
6 months ago
dialogTitle.value = info.nickname
searchForm.value = { ...queryInfo }
searchForm.value.userId = info.userId
6 months ago
6 months ago
sourceChange()
6 months ago
}
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
const tableList = ref([])
async function handleSearch() {
loading.value = true
try {
6 months ago
const params = { ...searchForm.value }
const data = await reportApi.getInfo(removeNullField(params))
tableList.value = data.sourceDetailVOList
setReportData(data)
6 months ago
} finally {
loading.value = false
}
}
6 months ago
function sourceChange() {
handleSearch()
showChannel.value = channelArr.value
}
6 months ago
const echart1Option = ref({
title: {
text: '线索分布图'
},
radiusAxis: {},
angleAxis: {},
tooltip: {
show: true,
formatter: '{b0}-{a}: {c}'
},
polar: {},
legend: {
6 months ago
show: true,
type: 'scroll',
left: 100
6 months ago
}
})
const echart2Option = ref({
title: {
text: '成交分布图'
},
radiusAxis: {},
angleAxis: {},
tooltip: {
show: true,
formatter: '{b0}-{a}: {c}'
},
polar: {},
legend: {
6 months ago
show: true,
type: 'scroll',
left: 100
6 months ago
}
})
const echart3Option = ref({
title: {
text: '销售雷达图'
},
radar: {
indicator: [
{ name: '成交周期' },
{ name: '毛利/单' },
{ name: '支出/单' },
{ name: '线索成本/条' },
{ name: '净利润/单' },
6 months ago
{ name: '成交率' }
// { name: '线索总成本' },
// { name: '总支出' },
// { name: '总利润' }
6 months ago
]
},
legend: {
6 months ago
show: true,
right: '10px',
orient: 'vertical'
6 months ago
}
})
6 months ago
const setReportData = async (data) => {
6 months ago
// const data = await HomeApi.getClueSignSignRate()
6 months ago
const channelClueArr = showChannel.value.sort((pre, cur) => {
const preArr = tableList.value.find((it) => it.sourceName == pre).clueIntentionNumVOList || []
const curArr = tableList.value.find((it) => it.sourceName == cur).clueIntentionNumVOList || []
const preCount = preArr.reduce((preVal, curVal) => preVal + curVal.intentionNum, 0)
const curCount = curArr.reduce((preVal, curVal) => preVal + curVal.intentionNum, 0)
return preCount - curCount
})
6 months ago
const arr1 = intentionOptions.map((intention) => {
const list = []
6 months ago
channelClueArr.map((item) => {
const row = tableList.value.find((it) => item == it.sourceName)
if (row) {
6 months ago
list.push(
6 months ago
row.clueIntentionNumVOList.find((it) => it.intentionState == intention.value).intentionNum
6 months ago
)
6 months ago
}
6 months ago
})
return {
6 months ago
type: 'bar',
6 months ago
data: list,
6 months ago
coordinateSystem: 'polar',
6 months ago
name: intention.label,
6 months ago
stack: 'a',
emphasis: {
focus: 'series'
},
label: {
show: true,
position: 'middle'
}
6 months ago
}
})
6 months ago
const channelSignArr = showChannel.value.sort((pre, cur) => {
const preArr = tableList.value.find((it) => it.sourceName == pre).signLicenseTypeNumVOList || []
const curArr = tableList.value.find((it) => it.sourceName == cur).signLicenseTypeNumVOList || []
const preCount = preArr.reduce((preVal, curVal) => preVal + curVal.licenseTypeNum, 0)
const curCount = curArr.reduce((preVal, curVal) => preVal + curVal.licenseTypeNum, 0)
return preCount - curCount
})
6 months ago
const arr2 = props.licenseTypeOptions.map((cartype) => {
const list = []
6 months ago
channelClueArr.map((item) => {
const row = tableList.value.find((it) => item == it.sourceName)
if (row) {
6 months ago
list.push(
6 months ago
row.signLicenseTypeNumVOList.find((it) => it.licenseType == cartype.label).licenseTypeNum
6 months ago
)
}
})
return {
6 months ago
type: 'bar',
6 months ago
data: list,
6 months ago
coordinateSystem: 'polar',
6 months ago
name: cartype.label,
6 months ago
stack: 'a',
emphasis: {
focus: 'series'
},
label: {
show: true,
position: 'middle'
}
}
6 months ago
})
6 months ago
6 months ago
set(echart1Option.value, 'radiusAxis', {
6 months ago
type: 'category',
6 months ago
data: channelClueArr,
6 months ago
axisLabel: {
margin: 5,
fontSize: 10,
interval: 0
}
})
6 months ago
set(echart1Option.value, 'series', arr1)
set(echart2Option.value, 'radiusAxis', {
type: 'category',
6 months ago
data: channelSignArr,
6 months ago
axisLabel: {
margin: 5,
fontSize: 10,
interval: 0
6 months ago
}
6 months ago
})
set(echart2Option.value, 'series', arr2)
const { personDetail, averageDetail } = data
6 months ago
set(echart3Option.value, 'series', [
{
type: 'radar',
data: [
{
6 months ago
value: [
averageDetail.averageSignPeriod,
averageDetail.grossProfitOfSingleSign,
averageDetail.payPriceOfSingleSign,
averageDetail.costOfSingleClue,
averageDetail.netProfitOfSingleSign,
averageDetail.signRate
// averageDetail.clueCostTotal,
// averageDetail.payPriceTotal,
// averageDetail.profitTotal
],
name: '平均水平',
lineStyle: {
type: 'dashed'
},
areaStyle: {
color: 'rgba(0, 191, 255, 0.6)'
},
6 months ago
label: {
show: true
}
},
{
6 months ago
value: [
personDetail.averageSignPeriod,
personDetail.grossProfitOfSingleSign,
personDetail.payPriceOfSingleSign,
personDetail.costOfSingleClue,
personDetail.netProfitOfSingleSign,
6 months ago
personDetail.signRate
6 months ago
// personDetail.clueCostTotal,
// personDetail.payPriceTotal,
// personDetail.profitTotal
],
name: dialogTitle.value,
areaStyle: {
color: 'rgba(255, 145, 124, 0.4)'
},
6 months ago
label: {
show: true
}
}
]
}
])
}
</script>
<style lang="scss" scoped></style>