refactor: 统一处理null数据为'未知'

This commit is contained in:
dhb52 2024-04-09 18:47:31 +08:00
parent 0e15d6c9d2
commit 5358863fc6
2 changed files with 22 additions and 22 deletions

View File

@ -11,13 +11,7 @@
<el-card shadow="never" class="mt-16px"> <el-card shadow="never" class="mt-16px">
<el-table v-loading="loading" :data="list"> <el-table v-loading="loading" :data="list">
<el-table-column label="序号" align="center" type="index" width="80" /> <el-table-column label="序号" align="center" type="index" width="80" />
<el-table-column <el-table-column label="区域" align="center" prop="areaName" min-width="200" />
label="区域"
align="center"
prop="areaName"
min-width="200"
:formatter="(_, __, val: any) => val ?? '未知'"
/>
<el-table-column <el-table-column
label="成交周期(天)" label="成交周期(天)"
align="center" align="center"
@ -112,13 +106,19 @@ const echartsOption = reactive<EChartsOption>({
/** 获取数据并填充图表 */ /** 获取数据并填充图表 */
const fetchAndFill = async () => { const fetchAndFill = async () => {
// 1. // 1.
const customerDealCycleByArea = await StatisticsCustomerApi.getCustomerDealCycleByArea( const customerDealCycleByArea = (
props.queryParams await StatisticsCustomerApi.getCustomerDealCycleByArea(props.queryParams)
) ).map((s: CrmStatisticsCustomerDealCycleByAreaRespVO) => {
return {
areaName: s.areaName,
customerDealCycle: s.customerDealCycle,
customerDealCount: s.customerDealCount
}
})
// 2.1 Echarts // 2.1 Echarts
if (echartsOption.xAxis && echartsOption.xAxis['data']) { if (echartsOption.xAxis && echartsOption.xAxis['data']) {
echartsOption.xAxis['data'] = customerDealCycleByArea.map( echartsOption.xAxis['data'] = customerDealCycleByArea.map(
(s: CrmStatisticsCustomerDealCycleByAreaRespVO) => s.areaName ?? '未知' (s: CrmStatisticsCustomerDealCycleByAreaRespVO) => s.areaName
) )
} }
if (echartsOption.series && echartsOption.series[0] && echartsOption.series[0]['data']) { if (echartsOption.series && echartsOption.series[0] && echartsOption.series[0]['data']) {

View File

@ -11,13 +11,7 @@
<el-card shadow="never" class="mt-16px"> <el-card shadow="never" class="mt-16px">
<el-table v-loading="loading" :data="list"> <el-table v-loading="loading" :data="list">
<el-table-column label="序号" align="center" type="index" width="80" /> <el-table-column label="序号" align="center" type="index" width="80" />
<el-table-column <el-table-column label="产品名称" align="center" prop="productName" min-width="200" />
label="产品名称"
align="center"
prop="productName"
min-width="200"
:formatter="(_, __, val: any) => val ?? '未知'"
/>
<el-table-column <el-table-column
label="成交周期(天)" label="成交周期(天)"
align="center" align="center"
@ -112,13 +106,19 @@ const echartsOption = reactive<EChartsOption>({
/** 获取数据并填充图表 */ /** 获取数据并填充图表 */
const fetchAndFill = async () => { const fetchAndFill = async () => {
// 1. // 1.
const customerDealCycleByProduct = await StatisticsCustomerApi.getCustomerDealCycleByProduct( const customerDealCycleByProduct = (
props.queryParams await StatisticsCustomerApi.getCustomerDealCycleByProduct(props.queryParams)
) ).map((s: CrmStatisticsCustomerDealCycleByProductRespVO) => {
return {
productName: s.productName ?? '未知',
customerDealCycle: s.customerDealCount,
customerDealCount: s.customerDealCount
}
})
// 2.1 Echarts // 2.1 Echarts
if (echartsOption.xAxis && echartsOption.xAxis['data']) { if (echartsOption.xAxis && echartsOption.xAxis['data']) {
echartsOption.xAxis['data'] = customerDealCycleByProduct.map( echartsOption.xAxis['data'] = customerDealCycleByProduct.map(
(s: CrmStatisticsCustomerDealCycleByProductRespVO) => s.productName ?? '未知' (s: CrmStatisticsCustomerDealCycleByProductRespVO) => s.productName
) )
} }
if (echartsOption.series && echartsOption.series[0] && echartsOption.series[0]['data']) { if (echartsOption.series && echartsOption.series[0] && echartsOption.series[0]['data']) {