dev-cl^2
qsh 1 week ago
parent cd22e26589
commit fe4270178f
  1. 12
      src/views/Home/Comp/DialogSalerReportDetail.vue
  2. 61
      src/views/Home/SalesReport.vue

@ -25,7 +25,12 @@
/> />
</el-form-item> </el-form-item>
<el-form-item v-if="appStore.getAppInfo?.instanceType == 1"> <el-form-item v-if="appStore.getAppInfo?.instanceType == 1">
<el-select v-model="searchForm.licenseType" placeholder="选择驾照类型" clearable> <el-select
v-model="searchForm.licenseTypeList"
placeholder="选择驾照类型"
clearable
multiple
>
<el-option <el-option
v-for="item in props.licenseTypeOptions" v-for="item in props.licenseTypeOptions"
:key="item.label" :key="item.label"
@ -105,6 +110,7 @@ import * as reportApi from '@/api/home/reportSaler'
import { getIntDictOptions } from '@/utils/dict' import { getIntDictOptions } from '@/utils/dict'
import { removeNullField } from '@/utils' import { removeNullField } from '@/utils'
import { useAppStore } from '@/store/modules/app' import { useAppStore } from '@/store/modules/app'
import { formatDate } from '@/utils/formatTime'
const appStore = useAppStore() const appStore = useAppStore()
@ -149,7 +155,9 @@ const showPane = ref(1)
function handleReset() { function handleReset() {
searchForm.value = { searchForm.value = {
nickname: undefined, nickname: undefined,
consultTime: [] consultTime: [`${year}-${month}-01`, formatDate(new Date())],
licenseTypeList: [],
sourceId: undefined
} }
} }

@ -27,7 +27,12 @@
/> />
</el-form-item> </el-form-item>
<el-form-item v-if="appStore.getAppInfo?.instanceType == 1"> <el-form-item v-if="appStore.getAppInfo?.instanceType == 1">
<el-select v-model="searchForm.licenseType" placeholder="选择驾照类型" clearable> <el-select
v-model="searchForm.licenseTypeList"
placeholder="选择驾照类型"
clearable
multiple
>
<el-option <el-option
v-for="item in licenseTypeOptions" v-for="item in licenseTypeOptions"
:key="item.label" :key="item.label"
@ -43,8 +48,15 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-table v-loading="loading" :data="tableList" border stripe> <el-table
<el-table-column type="index" width="50" fixed="left" /> v-loading="loading"
:data="tableList"
border
stripe
show-summary
:summary-method="getSummaries"
>
<el-table-column type="index" width="60" fixed="left" />
<el-table-column prop="nickname" label="姓名" width="80" fixed="left"> <el-table-column prop="nickname" label="姓名" width="80" fixed="left">
<template #default="{ row }"> <template #default="{ row }">
<el-button type="primary" style="padding: 0" text @click="handleDetail(row)">{{ <el-button type="primary" style="padding: 0" text @click="handleDetail(row)">{{
@ -164,22 +176,61 @@ function handleReset() {
const month = new Date().getMonth() + 1 const month = new Date().getMonth() + 1
searchForm.value = { searchForm.value = {
nickname: undefined, nickname: undefined,
consultTime: [`${year}-${month}-01`, formatDate(new Date())] consultTime: [`${year}-${month}-01`, formatDate(new Date())],
licenseTypeList: [],
sourceId: undefined
} }
} }
const loading = ref(false) const loading = ref(false)
const tableList = ref([]) const tableList = ref([])
const avgData = ref({})
async function handleSearch() { async function handleSearch() {
loading.value = true loading.value = true
try { try {
const data = await reportApi.getList(removeNullField(searchForm.value)) const data = await reportApi.getList(removeNullField(searchForm.value))
tableList.value = data tableList.value = data.personDataVOList
avgData.value = data.averageDataVO
} finally { } finally {
loading.value = false loading.value = false
} }
} }
function getSummaries({ columns, data }) {
const sums = []
columns.forEach((column, index) => {
if (index == 0) {
sums[index] = '统计'
return
}
const doubleSumsColumns = [
'newClueNumber',
'signNumber',
'clueCostTotal',
'payPriceTotal',
'profitTotal'
]
if (column.property in avgData.value) {
sums[index] = `均值: ${avgData.value[column.property]}`
} else if (doubleSumsColumns.includes(column.property)) {
const values = data.map((item) => Number(item[column.property]))
let sum = values.reduce((prev, curr) => prev + curr, 0)
let avg = sum / values.length
if (['newClueNumber', 'signNumber'].includes(column.property)) {
avg = Math.floor(avg)
} else {
sum = sum.toFixed(2)
avg = avg.toFixed(2)
}
sums[index] = h('div', {}, [h('div', {}, `合计:${sum}`), h('div', {}, `均值:${avg}`)])
} else {
sums[index] = ''
}
})
return sums
}
const SalerDetailDialog = ref() const SalerDetailDialog = ref()
function handleDetail(info) { function handleDetail(info) {
SalerDetailDialog.value.open(info, searchForm.value) SalerDetailDialog.value.open(info, searchForm.value)

Loading…
Cancel
Save