Merge branch 'feature/个险业绩排行优化' into dev

This commit is contained in:
mengxiaolong
2021-01-08 16:28:16 +08:00

View File

@@ -9,13 +9,17 @@
<table class="myTable mb30" cellspacing="0" cellpadding="0">
<tr>
<th class="sticky th-rank">排名</th>
<th v-for="(column, index) in columns" :key="index" :class="{ fixedWidth: index === 0, orgName: index === 0 && dataType !== 2 }">
<th v-for="(column, index) in columns" :key="index" :class="{ fixedWidth: index === 0, orgName: index === 0 }">
{{ column.name }}
</th>
</tr>
<tr v-show="values.length !== 0">
<td class="sticky bleft bright" colspan="2">合计</td>
<td class="bright" v-for="(total, i) in totals" :key="i">{{ total | blankFilter }}</td>
</tr>
<tr v-for="(value, index) in values" :key="index">
<td class="sticky bleft bright">{{ index + 1 }}</td>
<td v-for="(key, i) in needGettingKey" :key="i" class="bright" :class="{ orgName: key === 'name' && dataType !== 2 }">
<td v-for="(key, i) in needGettingKey" :key="i" class="bright" :class="{ orgName: i === 0 }">
{{ value[key] | blankFilter }}
</td>
</tr>
@@ -84,53 +88,73 @@ export default {
tableColumns: [
[
[
{ name: '机构', key: 'name' },
{ name: '预收标保(万元)', key: 'ysbb' },
{ name: '预收件数(件)', key: 'ysjs' },
{ name: '承保标保(万元)', key: 'bzbf' },
{ name: '承保件数(件)', key: 'cbjs' }
{ isInt: false, name: '机构', key: 'name' },
{ isInt: false, name: '预收标保(万元)', key: 'ysbb' },
{ isInt: true, name: '预收件数(件)', key: 'ysjs' },
{ isInt: false, name: '承保标保(万元)', key: 'bzbf' },
{ isInt: true, name: '承保件数(件)', key: 'cbjs' }
],
[
{ name: '机构', key: 'name' },
{ name: '预收标保(万元)', key: 'ysbb' },
{ name: '预收件数(件)', key: 'ysjs' },
{ name: '承保标保(万元)', key: 'bzbf' },
{ name: '承保件数(件)', key: 'cbjs' },
{ name: '承保同比', key: 'cbtb' },
{ name: '承保环比', key: 'cbhb' }
{ isInt: false, name: '机构', key: 'name' },
{ isInt: false, name: '预收标保(万元)', key: 'ysbb' },
{ isInt: true, name: '预收件数(件)', key: 'ysjs' },
{ isInt: false, name: '承保标保(万元)', key: 'bzbf' },
{ isInt: true, name: '承保件数(件)', key: 'cbjs' },
{ isInt: false, name: '承保同比', key: 'cbtb' },
{ isInt: false, name: '承保环比', key: 'cbhb' }
],
[
{ name: '机构', key: 'name' },
{ name: '承保标保(万元)', key: 'bzbf' },
{ name: '标保目标', key: 'bbmb' },
{ name: '标保目标达成率', key: 'bbmbdcl' },
{ name: '差距', key: 'cj' }
{ isInt: false, name: '机构', key: 'name' },
{ isInt: false, name: '承保标保(万元)', key: 'bzbf' },
{ isInt: false, name: '标保目标', key: 'bbmb' },
{ isInt: false, name: '标保目标达成率', key: 'bbmbdcl' },
{ isInt: false, name: '差距', key: 'cj' }
],
[
{ name: '机构', key: 'name' },
{ name: '承保标保(万元)', key: 'bzbf' }
{ isInt: false, name: '机构', key: 'name' },
{ isInt: false, name: '承保标保(万元)', key: 'bzbf' }
]
],
[
{ name: '机构', key: 'name' },
{ name: '活动人力(人)', key: 'hdrl' },
{ name: '合格人力(人)', key: 'hgrl' },
{ name: '桂冠人力(人)', key: 'ggrl' },
{ name: '桂冠正式会员(人)', key: 'gghy' },
{ name: '双冠人力(人)', key: 'sgrl' },
{ name: '新增人力(人)', key: 'xzrl' }
{ isInt: false, name: '机构', key: 'name' },
{ isInt: true, name: '活动人力(人)', key: 'hdrl' },
{ isInt: true, name: '合格人力(人)', key: 'hgrl' },
{ isInt: true, name: '桂冠人力(人)', key: 'ggrl' },
{ isInt: true, name: '桂冠正式会员(人)', key: 'gghy' },
{ isInt: true, name: '双冠人力(人)', key: 'sgrl' },
{ isInt: true, name: '新增人力(人)', key: 'xzrl' }
],
[
{ name: '产品', key: 'productName' },
{ name: '承保标保(万元)', key: 'cbbb' },
{ name: '承保件数(件)', key: 'cbItems' },
{ name: '保费占比(%)', key: 'percent' }
{ isInt: false, name: '产品', key: 'productName' },
{ isInt: false, name: '承保标保(万元)', key: 'cbbb' },
{ isInt: true, name: '承保件数(件)', key: 'cbItems' },
{ isInt: false, name: '保费占比(%)', key: 'percent' }
]
],
values: []
values: [],
totals: []
}
},
methods: {
calculateTotal() {
this.totals = []
let columns = JSON.parse(JSON.stringify(this.columns))
columns.splice(0, 1)
console.dir(columns)
for (let column of columns) {
let key = column.key
let total = this.values.reduce((prevVal, currVal) => {
let count = column.isInt ? parseInt(currVal[key]) : parseFloat(currVal[key])
return prevVal + count
}, 0)
if (column.isInt) {
this.totals.push(total)
} else {
this.totals.push(parseFloat(total.toFixed(2)))
}
}
},
setShortName() {
for (let org of this.values) {
for (let shortName of orgShortNames) {
@@ -145,24 +169,28 @@ export default {
case 'prem':
this.values = data.list ? data.list : []
this.setShortName()
this.calculateTotal()
break
case 'active':
this.values = data.listRL ? data.listRL : []
this.setShortName()
this.calculateTotal()
break
case 'product':
this.values = data.productDTO ? data.productDTO : []
this.calculate()
this.calculateTotal()
break
}
},
calculate() {
let allPrice = this.values.reduce((prevVal, currVal) => {
return prevVal + Number(currVal.cbbb)
return prevVal + parseFloat(currVal.cbbb)
}, 0)
this.values.map(product => {
product.allPrice = allPrice.toFixed(2)
product.percent = ((product.cbbb / allPrice) * 100).toFixed(2)
product.allPrice = allPrice
let percent = ((product.cbbb / allPrice) * 100).toFixed(8)
product.percent = percent
return product
})
}
@@ -177,7 +205,16 @@ export default {
},
filters: {
blankFilter(val) {
if (isNaN(parseFloat(val))) {
return val ? val : '-'
} else {
let res = parseFloat(val).toFixed(2)
if (res.endsWith('.00')) {
return res.split('.')[0]
} else {
return res
}
}
}
}
}
@@ -262,4 +299,8 @@ th.fixedWidth {
position: sticky;
left: 59px;
}
*::-webkit-scrollbar {
display: none;
}
</style>