<el-table
:data="tableData_shift_message" 在data初始化
:span-method="objectSpanMethod"
v-loading.body="tableLoading" 在data初始化
element-loading-text="正在加载中!!!" 在data初始化
size="small"
class="bos-table">
<el-table-column
type="selection"
width="50">
</el-table-column>
<el-table-column
prop="orgName"
label="科室">
</el-table-column>
<el-table-column
prop="userName"
label="人员">
</el-table-column>
<el-table-column
v-for="(item, index) of show_User "
:key="index"
:label="item.name"
:prop="item.value"
:formatter="valueFormatter">
</el-table-column>
<el-table-column
label="请假"
prop="leaveNumber"
>
</el-table-column>
</el-table>
handleStatisticalLeave(){
let that = this;
that.startTime = that.value[0];
that.endTime = that.value[1];
that.$http.get(that.baseUrl + '/selectStatisticalLeave?startTime=' + that.startTime + '&&' + 'endTime=' + that.endTime, {}).then((data) => {
that.tableData_shift_message = data;
that.rowspan();
if (that.tableData_shift_message.length === 0) {
that.$message.warning("暂无考勤记录")
}
}).catch(function (error) {
that.$message.error(error.message);
});
}
rowspan() {
let that = this;
that.tableData_shift_message.forEach((item, index) => {
if (index === 0) {
that.spanArr.push(1);
that.pos = 0;
} else {
//根据具体的名字进行合并
if (that.tableData_shift_message[index].orgName === that.tableData_shift_message[index - 1].orgName ) {
that.spanArr[that.pos] += 1;
that.spanArr.push(0);
}else {
this.spanArr.push(1);
this.pos = index;
}
}
});
},
//合并
objectSpanMethod({row, column, rowIndex, columnIndex}) {
if (columnIndex === 1) {//第几列
const _row = this.spanArr[rowIndex];
const _col = _row > 0 ? 1 : 0;
return {
rowspan: _row,
colspan: _col
}
}
},
效果图