<div class="table_wrap" v-show="isCenter">
<el-table ref="tableRef" v-show="centerLoad && countData.length>0" class="margin_top20" :data="countData" border>
<el-table-column width="140" fixed>
<template slot="header">
<div class="slash_wrap">
<span class="text_right margin_bottom15">{{quarter==0?'季度':'月份'}}</span>
<span class="text_left margin_top15">部门</span>
</div>
</template>
<template slot-scope="scope">
<span>{{scope.row[0].dealDepartNa}}</span>
</template>
</el-table-column>
<el-table-column align="center" :label="item.monthOrQuarter==0?'合计':(quarter==0?getChinese(item.monthOrQuarter)+'季度':item.monthOrQuarter+'月') " v-for="(item,index) in countData[0]" :key="index">
<el-table-column min-width="120" align="right" prop="targetAmou" label="任务目标(万元)" >
<template slot-scope="scope">{{scope.row[index].targetAm}}</template>
</el-table-column>
<el-table-column min-width="120" align="right" prop="amoun" label="回收金额(万元)" >
<template slot-scope="scope">{{scope.row[index].amoun}}</template>
</el-table-column>
<el-table-column min-width="120" align="right" prop="rat" label="完成率(%)" >
<template slot-scope="scope">{{scope.row[index].rate}}</template>
</el-table-column>
</el-table-column>
</el-table>
</div>
//切换季度
async quarterChange(val){
let [data] = this.data?.filter((item)=>item.quarter == val) || []
this.countData = await this.handleData(data?.children)
},
/**
* 根据指定的键函数对数组进行分组。
*/
export function groupBy(array, keyFunction) {
return array.reduce((result, currentValue) => {
const key = keyFunction(currentValue);
if (!result[key]) {
result[key] = [];
}
result[key].push(currentValue);
return result;
}, {});
}
//处理数据,使用Object.groupBy 百分浏览器不支持封装方法groupBy
handleData(newData = []){
return Object.values(groupBy(newData,(item)=>item.dealDepartmentName+`,${item.dealDepartmentId}`))
},
//数字替换中文
getChinese(num){
let chinese = ['零','一','二','三','四','五','六','七','八','九','十'];
return chinese[num]
},
组合动态列表
于 2024-08-02 10:29:01 首次发布