班级考勤统计优化;新增总计

This commit is contained in:
paidaxing444 2020-09-28 15:27:46 +08:00
parent 730bab82fc
commit 12f6f0cfd2
2 changed files with 62 additions and 2 deletions

View File

@ -160,6 +160,10 @@ export default {
column_name: "name",
sort: "姓名",
});
this.tableHead.push({
column_name: "zj",
sort: "总计",
});
response.rows.forEach((res) => {
this.tableHead.push({
column_name: "",
@ -178,12 +182,45 @@ export default {
listChildCheck(this.queryParams).then((response) => {
console.log(response.rows);
this.bjmc = response.rows[0].bjmc;
this.childcount = response.rows.length;
this.childcount = response.rows.length - 1;
this.jsmc = response.rows[0].zbjsmc;
// this.tableData = response.rows;
response.rows.forEach((res) => {
this.tableData.push({
name: res.name,
zj: this.avg([
res.day1,
res.day2,
res.day3,
res.day4,
res.day5,
res.day6,
res.day7,
res.day8,
res.day9,
res.day10,
res.day11,
res.day12,
res.day13,
res.day14,
res.day15,
res.day16,
res.day17,
res.day18,
res.day19,
res.day20,
res.day21,
res.day22,
res.day23,
res.day24,
res.day25,
res.day26,
res.day27,
res.day28,
res.day29,
res.day30,
res.day31,
]),
day1: res.day1 == "0%" ? "" : res.day1,
day2: res.day2 == "0%" ? "" : res.day2,
day3: res.day3 == "0%" ? "" : res.day3,
@ -220,6 +257,29 @@ export default {
this.loading = false;
});
},
avg(a1) {
console.log("a" + a1);
//bug a
var a = 0;
var sum = 0;
a1.forEach((res) => {
if (res != "" && res != "0%" && res != null) {
// console.log("res:" + res);
a = a + 1;
if (res == "在园") {
sum = sum + 1;
}
if (res.indexOf("%") != -1) {
// console.log(res.split("%")[0]);
sum = sum + parseInt(res.split("%")[0])/100;
}
}
});
if (a == 0) {
return "";
}
return parseFloat(((sum / a) * 100).toFixed(2)) + "%";
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;

View File

@ -365,7 +365,7 @@ export default {
});
},
avg(a1) {
console.log("a" + a1.length);
// console.log("a" + a1.length);
//bug a
var a = 0;
var sum = 0;