fix:统计添加合计行
This commit is contained in:
parent
d9d8fdca34
commit
60ee27cb44
|
|
@ -15,18 +15,18 @@
|
|||
<el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button>
|
||||
</div>
|
||||
</el-header>
|
||||
<el-main>
|
||||
<el-main id="mainDom">
|
||||
<el-card shadow="never" style="margin-bottom: 8px;">
|
||||
<el-row :gutter="10">
|
||||
<el-col :lg="12">
|
||||
<el-col :lg="11">
|
||||
<el-card shadow="never">
|
||||
<div id="bachart1" style="width:100%;height:300px;"></div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :lg="12">
|
||||
<el-col :lg="13">
|
||||
<el-card shadow="never" style="position: relative;">
|
||||
<el-button @click="handleExport('1')" class="tables" type="primary">导出</el-button>
|
||||
<el-table :data="dataList" id="exportDiv1" :height="300">
|
||||
<el-table :data="dataList" id="exportDiv1" :height="tableHeight" :summary-method="getSummaries" show-summary>
|
||||
<el-table-column type="index" width="50" />
|
||||
<el-table-column label="物料名" prop="物料名">
|
||||
</el-table-column>
|
||||
|
|
@ -47,35 +47,6 @@
|
|||
</el-col>
|
||||
</el-row>
|
||||
</el-card>
|
||||
<!-- <el-card shadow="never" style="margin-bottom: 8px;">
|
||||
<el-row :gutter="10">
|
||||
<el-col :lg="12">
|
||||
<el-card shadow="never">
|
||||
<div id="bachart2" style="width:100%;height:300px;"></div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :lg="12">
|
||||
<el-card shadow="never" style="position: relative;">
|
||||
<el-button @click="handleExport('2')" class="tables" type="primary">导出</el-button>
|
||||
<el-table :data="tableData10" id="exportDiv2" :height="300">
|
||||
<el-table-column type="index" width="50" />
|
||||
<el-table-column label="物料名" prop="物料名">
|
||||
</el-table-column>
|
||||
<el-table-column label="月份" prop="月" v-if="queryType == '年'">
|
||||
</el-table-column>
|
||||
<el-table-column label="周" prop="周" v-else>
|
||||
</el-table-column>
|
||||
<el-table-column label="规格" prop="规格">
|
||||
</el-table-column>
|
||||
<el-table-column label="型号" prop="型号">
|
||||
</el-table-column>
|
||||
<el-table-column label="数量" prop="数量">
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-card> -->
|
||||
</el-main>
|
||||
</el-container>
|
||||
</template>
|
||||
|
|
@ -94,6 +65,7 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
tableHeight: 300,
|
||||
queryType: '月',
|
||||
queryDate: '',
|
||||
start_date: '',
|
||||
|
|
@ -155,6 +127,11 @@ export default {
|
|||
that.xAxisOrigin.push('第' + i + '周');
|
||||
}
|
||||
that.xAxisData = that.xAxisOrigin;
|
||||
let height = document.getElementById('mainDom').clientHeight;
|
||||
console.log('height',height);
|
||||
height= height-60;
|
||||
that.tableHeight = height;
|
||||
document.getElementById('bachart1').style.height = height + 'px';
|
||||
that.getDataHL();
|
||||
},
|
||||
methods: {
|
||||
|
|
@ -316,6 +293,34 @@ export default {
|
|||
}
|
||||
that.getDataHL();
|
||||
},
|
||||
getSummaries({ columns, data }) {
|
||||
const sums = [];
|
||||
columns.forEach((column, index) => {
|
||||
if (index === 0) {
|
||||
sums[index] = "合计";
|
||||
return;
|
||||
}
|
||||
if (index == 5||index == 6) {
|
||||
const values = data.map((item) =>
|
||||
Number(item[column.property])
|
||||
);
|
||||
if (!values.every((value) => Number.isNaN(value))) {
|
||||
sums[index] = values.reduce((prev, curr) => {
|
||||
const value = Number(curr); //Number转换为数值
|
||||
let sum = Number(
|
||||
Number(prev) + Number(curr)
|
||||
).toFixed(2); //toFixed(2)数据项保留两位小数
|
||||
if (!isNaN(value)) {
|
||||
return sum;
|
||||
} else {
|
||||
return prev;
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
return sums;
|
||||
},
|
||||
handleExport(val) {
|
||||
this.exportLoading = true;
|
||||
let id = '#exportDiv' + val;
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@
|
|||
:data="tableData1"
|
||||
id="exportDiv1"
|
||||
:height="tableHeight"
|
||||
:summary-method="getSummaries" show-summary
|
||||
>
|
||||
<el-table-column type="index" width="50" />
|
||||
<el-table-column
|
||||
|
|
@ -149,6 +150,7 @@
|
|||
:height="rightHeight"
|
||||
hideDo
|
||||
hidePagination
|
||||
:summary-method="getSummaries" show-summary
|
||||
>
|
||||
<el-table-column type="index" width="50" />
|
||||
<el-table-column
|
||||
|
|
@ -400,6 +402,34 @@ export default {
|
|||
that.getSaleData();
|
||||
}
|
||||
},
|
||||
getSummaries({ columns, data }) {
|
||||
const sums = [];
|
||||
columns.forEach((column, index) => {
|
||||
if (index === 0) {
|
||||
sums[index] = "合计";
|
||||
return;
|
||||
}
|
||||
if (index == 6) {
|
||||
const values = data.map((item) =>
|
||||
Number(item[column.property])
|
||||
);
|
||||
if (!values.every((value) => Number.isNaN(value))) {
|
||||
sums[index] = values.reduce((prev, curr) => {
|
||||
const value = Number(curr); //Number转换为数值
|
||||
let sum = Number(
|
||||
Number(prev) + Number(curr)
|
||||
).toFixed(2); //toFixed(2)数据项保留两位小数
|
||||
if (!isNaN(value)) {
|
||||
return sum;
|
||||
} else {
|
||||
return prev;
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
return sums;
|
||||
},
|
||||
setChartData(data){
|
||||
let that = this;
|
||||
let option = deepCopy(that.basicOption);
|
||||
|
|
|
|||
|
|
@ -80,6 +80,8 @@
|
|||
:data="tableData1"
|
||||
id="exportDiv1"
|
||||
:height="tableHeight"
|
||||
:summary-method="getSummaries"
|
||||
show-summary
|
||||
>
|
||||
<el-table-column type="index" width="50" />
|
||||
<el-table-column
|
||||
|
|
@ -134,6 +136,8 @@
|
|||
:height="rightHeight"
|
||||
hideDo
|
||||
hidePagination
|
||||
:summary-method="getSummaries"
|
||||
show-summary
|
||||
>
|
||||
<el-table-column type="index" width="50" />
|
||||
<el-table-column
|
||||
|
|
@ -432,6 +436,34 @@ export default {
|
|||
option.series = seriesData;
|
||||
that.setChart("bachart1", option);
|
||||
},
|
||||
getSummaries({ columns, data }) {
|
||||
const sums = [];
|
||||
columns.forEach((column, index) => {
|
||||
if (index === 0) {
|
||||
sums[index] = "合计";
|
||||
return;
|
||||
}
|
||||
if (index == 6) {
|
||||
const values = data.map((item) =>
|
||||
Number(item[column.property])
|
||||
);
|
||||
if (!values.every((value) => Number.isNaN(value))) {
|
||||
sums[index] = values.reduce((prev, curr) => {
|
||||
const value = Number(curr); //Number转换为数值
|
||||
let sum = Number(
|
||||
Number(prev) + Number(curr)
|
||||
).toFixed(2); //toFixed(2)数据项保留两位小数
|
||||
if (!isNaN(value)) {
|
||||
return sum;
|
||||
} else {
|
||||
return prev;
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
return sums;
|
||||
},
|
||||
handleExport(val) {
|
||||
this.exportLoading = true;
|
||||
let id = "#exportDiv" + val;
|
||||
|
|
|
|||
|
|
@ -56,6 +56,8 @@
|
|||
:data="tableData7"
|
||||
id="exportDiv7"
|
||||
:height="300"
|
||||
:summary-method="getSummaries"
|
||||
show-summary
|
||||
>
|
||||
<el-table-column type="index" width="50" />
|
||||
<el-table-column
|
||||
|
|
@ -122,6 +124,8 @@
|
|||
:data="tableData10"
|
||||
id="exportDiv10"
|
||||
:height="300"
|
||||
:summary-method="getSummaries"
|
||||
show-summary
|
||||
>
|
||||
<el-table-column type="index" width="50" />
|
||||
<el-table-column
|
||||
|
|
@ -182,6 +186,8 @@
|
|||
:data="tableData6"
|
||||
id="exportDiv6"
|
||||
:height="300"
|
||||
:summary-method="getSummaries2"
|
||||
show-summary
|
||||
>
|
||||
<el-table-column type="index" width="50" />
|
||||
<el-table-column
|
||||
|
|
@ -228,44 +234,6 @@
|
|||
</el-col>
|
||||
</el-row>
|
||||
</el-card>
|
||||
<!-- <el-card shadow="never" style="margin-bottom: 8px">
|
||||
<el-row :gutter="10">
|
||||
<el-col :lg="12">
|
||||
<el-card shadow="never">
|
||||
<div id="bachart4"></div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :lg="12">
|
||||
<el-card shadow="never" style="position: relative">
|
||||
<el-button
|
||||
@click="handleExport('AVG')"
|
||||
class="tables"
|
||||
type="primary"
|
||||
>导出</el-button
|
||||
>
|
||||
<el-table
|
||||
:data="tableDataAVG"
|
||||
id="exportDivAVG"
|
||||
:height="300"
|
||||
>
|
||||
<el-table-column type="index" width="50" />
|
||||
<el-table-column label="物料名" prop="物料名">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="月份"
|
||||
prop="月"
|
||||
v-if="queryType == '年'"
|
||||
>
|
||||
</el-table-column>
|
||||
<el-table-column label="周" prop="周" v-else>
|
||||
</el-table-column>
|
||||
<el-table-column label="合格数" prop="count_ok">
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-card> -->
|
||||
</el-main>
|
||||
</el-container>
|
||||
</template>
|
||||
|
|
@ -365,7 +333,6 @@ export default {
|
|||
that.getData6();
|
||||
that.getData7();
|
||||
that.getData10();
|
||||
// that.getDataDAVG();
|
||||
},
|
||||
methods: {
|
||||
setChart(name, option = null) {
|
||||
|
|
@ -584,40 +551,62 @@ export default {
|
|||
}
|
||||
});
|
||||
},
|
||||
// getDataDAVG() {
|
||||
// let that = this;
|
||||
// let option = deepCopy(that.basicOption);
|
||||
// option.xAxis.data = that.xAxisData;
|
||||
// option.title.text = "AVG";
|
||||
// let obj = {
|
||||
// query: { start_date: that.start_date, end_date: that.end_date },
|
||||
// };
|
||||
// let exec = that.queryType == "月" ? "AVGWeek" : "AVGMonth";
|
||||
// that.$API.bi.dataset.exec.req(exec, obj).then((res) => {
|
||||
// let tableDataAVG = res.data2.ds0 ? res.data2.ds0 : [];
|
||||
// let seriesData = [];
|
||||
// if (tableDataAVG.length > 0) {
|
||||
// tableDataAVG.forEach((item) => {
|
||||
// let index = 0;
|
||||
// if (that.queryType == "月") {
|
||||
// index = item.month - 1;
|
||||
// } else {
|
||||
// index = item.周 - that.firstWeekNum;
|
||||
// }
|
||||
// seriesData[index] = item.合格数;
|
||||
// });
|
||||
// let obj = {};
|
||||
// obj.name = "AVG";
|
||||
// obj.type = "bar";
|
||||
// obj.barWidth = "15px";
|
||||
// obj.data = seriesData;
|
||||
// option.series.push(obj);
|
||||
// that.setChart("bachart4", option);
|
||||
// } else {
|
||||
// that.setChart("bachart4", option);
|
||||
// }
|
||||
// });
|
||||
// },
|
||||
getSummaries({ columns, data }) {
|
||||
const sums = [];
|
||||
columns.forEach((column, index) => {
|
||||
if (index === 0) {
|
||||
sums[index] = "合计";
|
||||
return;
|
||||
}
|
||||
if (index == 5||index == 6||index == 7||index == 8) {
|
||||
const values = data.map((item) =>
|
||||
Number(item[column.property])
|
||||
);
|
||||
if (!values.every((value) => Number.isNaN(value))) {
|
||||
sums[index] = values.reduce((prev, curr) => {
|
||||
const value = Number(curr); //Number转换为数值
|
||||
let sum = Number(
|
||||
Number(prev) + Number(curr)
|
||||
).toFixed(2); //toFixed(2)数据项保留两位小数
|
||||
if (!isNaN(value)) {
|
||||
return sum;
|
||||
} else {
|
||||
return prev;
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
return sums;
|
||||
},
|
||||
getSummaries2({ columns, data }) {
|
||||
const sums = [];
|
||||
columns.forEach((column, index) => {
|
||||
if (index === 0) {
|
||||
sums[index] = "合计";
|
||||
return;
|
||||
}
|
||||
if (index == 6||index == 7||index == 8||index == 9) {
|
||||
const values = data.map((item) =>
|
||||
Number(item[column.property])
|
||||
);
|
||||
if (!values.every((value) => Number.isNaN(value))) {
|
||||
sums[index] = values.reduce((prev, curr) => {
|
||||
const value = Number(curr); //Number转换为数值
|
||||
let sum = Number(
|
||||
Number(prev) + Number(curr)
|
||||
).toFixed(2); //toFixed(2)数据项保留两位小数
|
||||
if (!isNaN(value)) {
|
||||
return sum;
|
||||
} else {
|
||||
return prev;
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
return sums;
|
||||
},
|
||||
handleQuery() {
|
||||
let that = this;
|
||||
if (that.queryType == "月") {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
<el-row :gutter="10">
|
||||
<el-col :lg="12">
|
||||
<el-card shadow="never">
|
||||
<scEcharts height="300px" :option="option"></scEcharts>
|
||||
<scEcharts id="bachart1" height="300px" :option="option"></scEcharts>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :lg="12">
|
||||
|
|
@ -55,6 +55,8 @@
|
|||
:data="tableData"
|
||||
:height="tableHeight"
|
||||
id="exportDiv"
|
||||
:summary-method="getSummaries"
|
||||
show-summary
|
||||
>
|
||||
<el-table-column type="index" width="50" />
|
||||
<el-table-column label="工段" prop="工段">
|
||||
|
|
@ -146,7 +148,9 @@ export default {
|
|||
that.start_date = year + "-" + month + "-01";
|
||||
that.end_date =year + "-" + month + "-" + days;
|
||||
that.queryDate = year + "-" + month;
|
||||
that.tableHeight = document.getElementById("elMain").clientHeight - 40;
|
||||
let height = document.getElementById("elMain").clientHeight - 40;
|
||||
that.tableHeight = height;
|
||||
document.getElementById('bachart1').style.height = height + 'px';
|
||||
that.getData6();
|
||||
},
|
||||
methods: {
|
||||
|
|
@ -247,6 +251,34 @@ export default {
|
|||
}
|
||||
this.getData6();
|
||||
},
|
||||
getSummaries({ columns, data }) {
|
||||
const sums = [];
|
||||
columns.forEach((column, index) => {
|
||||
if (index === 0) {
|
||||
sums[index] = "合计";
|
||||
return;
|
||||
}
|
||||
if (index == 3||index == 4||index == 5||index == 6) {
|
||||
const values = data.map((item) =>
|
||||
Number(item[column.property])
|
||||
);
|
||||
if (!values.every((value) => Number.isNaN(value))) {
|
||||
sums[index] = values.reduce((prev, curr) => {
|
||||
const value = Number(curr); //Number转换为数值
|
||||
let sum = Number(
|
||||
Number(prev) + Number(curr)
|
||||
).toFixed(2); //toFixed(2)数据项保留两位小数
|
||||
if (!isNaN(value)) {
|
||||
return sum;
|
||||
} else {
|
||||
return prev;
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
return sums;
|
||||
},
|
||||
handleExport() {
|
||||
this.exportLoading = true;
|
||||
this.$XLSX("#exportDiv", "工序合格数");
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
<el-card shadow="never" style="margin-bottom: 8px">
|
||||
<el-row :gutter="15">
|
||||
<el-col :lg="8">
|
||||
<scEcharts height="300px" :option="option1"></scEcharts>
|
||||
<scEcharts height="400px" :option="option1"></scEcharts>
|
||||
</el-col>
|
||||
<el-col :lg="16" style="position: relative">
|
||||
<el-button
|
||||
|
|
@ -50,7 +50,9 @@
|
|||
<el-table
|
||||
:data="tableData7"
|
||||
id="exportDiv7"
|
||||
:height="300"
|
||||
:height="400"
|
||||
:summary-method="getSummaries"
|
||||
show-summary
|
||||
>
|
||||
<el-table-column
|
||||
label="年"
|
||||
|
|
@ -105,7 +107,7 @@
|
|||
<el-card shadow="never" style="margin-bottom: 8px">
|
||||
<el-row :gutter="15">
|
||||
<el-col :lg="8">
|
||||
<scEcharts height="300px" :option="option2"></scEcharts>
|
||||
<scEcharts height="400px" :option="option2"></scEcharts>
|
||||
</el-col>
|
||||
<el-col :lg="16" style="position: relative">
|
||||
<el-button
|
||||
|
|
@ -117,7 +119,9 @@
|
|||
<el-table
|
||||
:data="tableData10"
|
||||
id="exportDiv10"
|
||||
:height="300"
|
||||
:height="400"
|
||||
:summary-method="getSummaries"
|
||||
show-summary
|
||||
>
|
||||
<el-table-column
|
||||
label="年"
|
||||
|
|
@ -176,7 +180,7 @@
|
|||
<el-card shadow="never" style="margin-bottom: 8px">
|
||||
<el-row :gutter="15">
|
||||
<el-col :lg="8">
|
||||
<scEcharts height="300px" :option="option3"></scEcharts>
|
||||
<scEcharts height="400px" :option="option3"></scEcharts>
|
||||
</el-col>
|
||||
<el-col :lg="16" style="position: relative">
|
||||
<el-button
|
||||
|
|
@ -188,7 +192,9 @@
|
|||
<el-table
|
||||
:data="tableData8"
|
||||
id="exportDiv8"
|
||||
:height="300"
|
||||
:height="400"
|
||||
:summary-method="getSummaries"
|
||||
show-summary
|
||||
>
|
||||
<el-table-column
|
||||
label="年"
|
||||
|
|
@ -289,8 +295,8 @@ export default {
|
|||
series: {
|
||||
name: "7车间预制棒",
|
||||
type: "pie",
|
||||
radius: ["40%", "70%"],
|
||||
center: ["50%", "60%"],
|
||||
radius: ["35%", "65%"],
|
||||
center: ["50%", "55%"],
|
||||
label: {
|
||||
show: true,
|
||||
position: "outside",
|
||||
|
|
@ -318,8 +324,8 @@ export default {
|
|||
series: {
|
||||
name: "10车间预制管",
|
||||
type: "pie",
|
||||
radius: ["40%", "70%"],
|
||||
center: ["50%", "60%"],
|
||||
radius: ["35%", "65%"],
|
||||
center: ["50%", "55%"],
|
||||
label: {
|
||||
show: true,
|
||||
position: "outside",
|
||||
|
|
@ -348,8 +354,8 @@ export default {
|
|||
series: {
|
||||
name: "退火预制管",
|
||||
type: "pie",
|
||||
radius: ["40%", "70%"],
|
||||
center: ["50%", "60%"],
|
||||
radius: ["35%", "65%"],
|
||||
center: ["50%", "55%"],
|
||||
label: {
|
||||
show: true,
|
||||
position: "outside",
|
||||
|
|
@ -603,6 +609,34 @@ export default {
|
|||
this.getData7();
|
||||
this.getData10();
|
||||
},
|
||||
getSummaries({ columns, data }) {
|
||||
const sums = [];
|
||||
columns.forEach((column, index) => {
|
||||
if (index === 0) {
|
||||
sums[index] = "合计";
|
||||
return;
|
||||
}
|
||||
if (index == 4||index == 5) {
|
||||
const values = data.map((item) =>
|
||||
Number(item[column.property])
|
||||
);
|
||||
if (!values.every((value) => Number.isNaN(value))) {
|
||||
sums[index] = values.reduce((prev, curr) => {
|
||||
const value = Number(curr); //Number转换为数值
|
||||
let sum = Number(
|
||||
Number(prev) + Number(curr)
|
||||
).toFixed(2); //toFixed(2)数据项保留两位小数
|
||||
if (!isNaN(value)) {
|
||||
return sum;
|
||||
} else {
|
||||
return prev;
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
return sums;
|
||||
},
|
||||
handleExport(val) {
|
||||
this.exportLoading = true;
|
||||
let id = "#exportDiv" + val;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@
|
|||
</el-col>
|
||||
<el-col :lg="16" style="position: relative;">
|
||||
<el-button @click="handleExport('1')" class="tables" type="primary">导出</el-button>
|
||||
<el-table :data="tableData" :height="500" id="exportDiv1">
|
||||
<el-table :data="tableData" :height="500" id="exportDiv1" :summary-method="getSummaries" show-summary>
|
||||
<el-table-column type="index" width="50" />
|
||||
<el-table-column label="日期" prop="date">
|
||||
<template #default="scope">
|
||||
|
|
@ -238,6 +238,34 @@
|
|||
}
|
||||
this.getData();
|
||||
},
|
||||
getSummaries({ columns, data }) {
|
||||
const sums = [];
|
||||
columns.forEach((column, index) => {
|
||||
if (index === 0) {
|
||||
sums[index] = "合计";
|
||||
return;
|
||||
}
|
||||
if (index == 4) {
|
||||
const values = data.map((item) =>
|
||||
Number(item[column.property])
|
||||
);
|
||||
if (!values.every((value) => Number.isNaN(value))) {
|
||||
sums[index] = values.reduce((prev, curr) => {
|
||||
const value = Number(curr); //Number转换为数值
|
||||
let sum = Number(
|
||||
Number(prev) + Number(curr)
|
||||
).toFixed(2); //toFixed(2)数据项保留两位小数
|
||||
if (!isNaN(value)) {
|
||||
return sum;
|
||||
} else {
|
||||
return prev;
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
return sums;
|
||||
},
|
||||
handleExport(val) {
|
||||
this.exportLoading = true;
|
||||
let id = '#exportDiv' + val;
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@
|
|||
stripe
|
||||
hideDo
|
||||
hidePagination
|
||||
:summary-method="getSummaries" show-summary
|
||||
>
|
||||
<el-table-column type="index" width="50" />
|
||||
<el-table-column label="物料名" prop="material_name" />
|
||||
|
|
@ -64,6 +65,8 @@
|
|||
id="exportDiv1"
|
||||
stripe
|
||||
hideDo
|
||||
:summary-method="getSummaries2"
|
||||
show-summary
|
||||
>
|
||||
<el-table-column type="index" width="50" />
|
||||
<el-table-column
|
||||
|
|
@ -405,6 +408,32 @@ export default {
|
|||
this.getTableData();
|
||||
},
|
||||
getSummaries({ columns, data }) {
|
||||
const sums = [];
|
||||
columns.forEach((column, index) => {
|
||||
if (index === 0) {
|
||||
sums[index] = "合计";
|
||||
return;
|
||||
}
|
||||
if (index == 5) {
|
||||
const values = data.map((item) =>
|
||||
Number(item[column.property])
|
||||
);
|
||||
if (!values.every((value) => Number.isNaN(value))) {
|
||||
sums[index] = values.reduce((prev, curr) => {
|
||||
const value = Number(curr);
|
||||
let sum = Number(Number(prev) + Number(curr)).toFixed(2);
|
||||
if (!isNaN(value)) {
|
||||
return sum;
|
||||
} else {
|
||||
return prev;
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
return sums;
|
||||
},
|
||||
getSummaries2({ columns, data }) {
|
||||
const sums = [];
|
||||
columns.forEach((column, index) => {
|
||||
if (index === 0) {
|
||||
|
|
|
|||
|
|
@ -67,6 +67,8 @@
|
|||
:data="tableData1"
|
||||
id="exportDiv7"
|
||||
:height="tableHeight"
|
||||
:summary-method="getSummaries"
|
||||
show-summary
|
||||
>
|
||||
<el-table-column type="index" width="50" />
|
||||
<el-table-column
|
||||
|
|
@ -96,6 +98,8 @@
|
|||
:data="tableData2"
|
||||
id="exportDiv10"
|
||||
:height="tableHeight"
|
||||
:summary-method="getSummaries"
|
||||
show-summary
|
||||
>
|
||||
<el-table-column type="index" width="50" />
|
||||
<el-table-column
|
||||
|
|
@ -125,6 +129,8 @@
|
|||
:data="tableData3"
|
||||
id="exportDiv6"
|
||||
:height="tableHeight"
|
||||
:summary-method="getSummaries"
|
||||
show-summary
|
||||
>
|
||||
<el-table-column type="index" width="50" />
|
||||
<el-table-column
|
||||
|
|
@ -430,6 +436,34 @@ export default {
|
|||
this.getData7();
|
||||
this.getData10();
|
||||
},
|
||||
getSummaries({ columns, data }) {
|
||||
const sums = [];
|
||||
columns.forEach((column, index) => {
|
||||
if (index === 0) {
|
||||
sums[index] = "合计";
|
||||
return;
|
||||
}
|
||||
if (index == 2||index == 3) {
|
||||
const values = data.map((item) =>
|
||||
Number(item[column.property])
|
||||
);
|
||||
if (!values.every((value) => Number.isNaN(value))) {
|
||||
sums[index] = values.reduce((prev, curr) => {
|
||||
const value = Number(curr); //Number转换为数值
|
||||
let sum = Number(
|
||||
Number(prev) + Number(curr)
|
||||
).toFixed(2); //toFixed(2)数据项保留两位小数
|
||||
if (!isNaN(value)) {
|
||||
return sum;
|
||||
} else {
|
||||
return prev;
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
return sums;
|
||||
},
|
||||
handleExport(val) {
|
||||
this.exportLoading = true;
|
||||
let id = "#exportDiv" + val;
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@
|
|||
id="exportDiv"
|
||||
style="width: 100%"
|
||||
:height="chartHeight"
|
||||
:summary-method="getSummaries"
|
||||
show-summary
|
||||
>
|
||||
<el-table-column type="index" width="50" />
|
||||
<el-table-column label="日期" prop="date">
|
||||
|
|
@ -144,21 +146,20 @@ export default {
|
|||
this.currentYear = year;
|
||||
this.currentMonth = month;
|
||||
this.start_date = year + "-" + month + "-01";
|
||||
this.end_date =
|
||||
year + "-" + month + "-" + new Date(year, month, 0).getDate();
|
||||
this.end_date =year + "-" + month + "-" + days;
|
||||
month = month < 10 ? "0" + month : month;
|
||||
this.queryDate = year + "-" + month;
|
||||
this.getData();
|
||||
this.getDept();
|
||||
let mainHeight = document.getElementById("elMain").clientHeight;
|
||||
this.chartHeight = mainHeight - 40 + "px";
|
||||
},
|
||||
methods: {
|
||||
getDept() {
|
||||
this.$API.system.dept.list
|
||||
.req({ page: 0, type: "dept" })
|
||||
.then((res) => {
|
||||
this.deptData = res;
|
||||
this.queryBelongDept = res[0].name;
|
||||
let that = this;
|
||||
this.$API.system.dept.list.req({ page: 0, type: "dept" }).then((res) => {
|
||||
that.deptData = res;
|
||||
that.queryBelongDept = res[0].name;
|
||||
that.getData();
|
||||
});
|
||||
},
|
||||
queryTypeChange(value) {
|
||||
|
|
@ -211,6 +212,34 @@ export default {
|
|||
console.log("查询query", this.start_date, this.end_date);
|
||||
this.getData();
|
||||
},
|
||||
getSummaries({ columns, data }) {
|
||||
const sums = [];
|
||||
columns.forEach((column, index) => {
|
||||
if (index === 0) {
|
||||
sums[index] = "合计";
|
||||
return;
|
||||
}
|
||||
if (index == 5||index == 6||index == 7) {
|
||||
const values = data.map((item) =>
|
||||
Number(item[column.property])
|
||||
);
|
||||
if (!values.every((value) => Number.isNaN(value))) {
|
||||
sums[index] = values.reduce((prev, curr) => {
|
||||
const value = Number(curr); //Number转换为数值
|
||||
let sum = Number(
|
||||
Number(prev) + Number(curr)
|
||||
).toFixed(2); //toFixed(2)数据项保留两位小数
|
||||
if (!isNaN(value)) {
|
||||
return sum;
|
||||
} else {
|
||||
return prev;
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
return sums;
|
||||
},
|
||||
handleExport() {
|
||||
this.exportLoading = true;
|
||||
this.$XLSX("#exportDiv", "人员统计");
|
||||
|
|
|
|||
Loading…
Reference in New Issue