<template>
<div>
<el-button @click="cancle">返回</el-button>
<h3>待结算</h3>
<el-table :data="tableData" border style=" 100%;margin-top:10px;" v-loading="loading">
<el-table-column fixed label="结算类别" width="120" align="center">
<template slot-scope="scope">{{serviceType(scope.row).text}}</template>
</el-table-column>
<el-table-column prop="name" align="center" label="被推荐人" width="170"></el-table-column>
<el-table-column label="被推荐人类别" align="center">
<template slot-scope="scope">{{workerType(scope.row).text}}</template>
</el-table-column>
<el-table-column label="所属地区" width="140" align="center">
<template slot-scope="scope">{{scope.row.province}}-{{scope.row.city}}</template>
</el-table-column>
<el-table-column prop="hospitalName" label="所属医院" width="180" align="center"></el-table-column>
<el-table-column prop="commission" label="佣金" width="100" align="center" sortable></el-table-column>
<el-table-column prop="successTime" label="审核时间" width="170" align="center" sortable></el-table-column>
<el-table-column prop="firstOrderTime" label="首单时间" width="170" align="center" sortable></el-table-column>
</el-table>
<div v-for="(item, index) in newtableData" :key="index">
<h3>结算日期:{{item[0].cashOutDate}} </h3>
<el-table
:data="item"
style=" 100%;margin-top:10px;"
v-loading="loading"
border
:summary-method="getSummaries"
show-summary
>
<el-table-column fixed label="结算类别" width="120" align="center">
<template slot-scope="scope">{{serviceType(scope.row).text}}</template>
</el-table-column>
<el-table-column prop="name" align="center" label="被推荐人" width="170"></el-table-column>
<el-table-column label="所属地区" width="140" align="center">
<template slot-scope="scope">{{scope.row.province}}-{{scope.row.city}}</template>
</el-table-column>
<el-table-column prop="hospitalName" label="所属医院" width="180" align="center"></el-table-column>
<el-table-column prop="commission" label="佣金" width="100" align="center" sortable></el-table-column>
<el-table-column prop="successTime" label="审核时间" width="170" align="center" sortable></el-table-column>
<el-table-column prop="firstOrderTime" label="首单时间" width="170" align="center" sortable></el-table-column>
<el-table-column label="任务类别" align="center">
<template slot-scope="scope">{{renwuType(scope.row).text}}</template>
</el-table-column>
</el-table>
</div>
</div>
</template>
<script>
import dataNew from "../dataNew";
export default {
name: "actDetail",
components: {},
mixins: [dataNew],
data() {
return {
loading: false,
tableData: [],
newtableData: [],
id: this.$route.query.id
};
},
mounted() {
this.search();
},
methods: {
cancle() {
this.$router.go(-1);
},
search() {
this.loading = true;
this.axios
.post("/hd/info/" + this.id)
.then(res => {
if (res.data.code == 200) {
this.loading = false;
if (!res.data) return;
// this.tableData = res.data.data;
let dataDeal = data => {
let listArr = [];
data.forEach(function(value, index) {
let obj = [];
for (let i = 0; i < listArr.length; i++) {
// 对比相同的字段key,相同放入对应的数组
if (
listArr[i][0].cashOutDate == value.cashOutDate &&
listArr[i][0].cashOut == value.cashOut
) {
listArr[i].push(value);
return;
}
}
// 第一次对比没有参照,放入参照
obj.push(value);
listArr.push(obj);
});
return listArr;
};
let resultDataDeal = dataDeal(res.data.data);
var that = this;
// console.log("resultDataDeal",resultDataDeal)
resultDataDeal.forEach(function(value, index) {
if (value[0].cashOutDate == null) {
that.tableData = JSON.parse(JSON.stringify(value));
// console.log("待结算:", that.tableData);
} else {
// that.newtableData = JSON.parse(JSON.stringify(value));
that.newtableData.push(JSON.parse(JSON.stringify(value)));
// console.log("that.newtableData", that.newtableData);
}
});
}
})
.catch(err => {
this.$message(err.message);
});
},
getSummaries(param) {
const { columns, data } = param;
const sums = [];
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = "总计";
return;
}
if (
index === 1 ||
index === 2 ||
index === 3 ||
index === 5 ||
index === 6 ||
index === 7
) {
sums[index] = "";
return;
}
const values = data.map(item => Number(item[column.property]));
if (!values.every(value => isNaN(value))) {
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {
return prev + curr;
} else {
return prev;
}
}, 0);
sums[index];
} else {
sums[index];
}
});
return sums;
}
}
};
</script>
<style lang="less" scoped>
.el-row {
&:last-child {
margin-bottom: 0;
}
}
.dis_flex {
display: flex;
font-display: row;
align-items: center;
}
.box {
120px;
text-align: center;
height: 50px;
line-height: 25px;
}
</style>