fix:统计添加合计行

This commit is contained in:
shijing 2025-05-26 09:44:01 +08:00
parent d9d8fdca34
commit 60ee27cb44
10 changed files with 373 additions and 131 deletions

View File

@ -15,18 +15,18 @@
<el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button> <el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button>
</div> </div>
</el-header> </el-header>
<el-main> <el-main id="mainDom">
<el-card shadow="never" style="margin-bottom: 8px;"> <el-card shadow="never" style="margin-bottom: 8px;">
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :lg="12"> <el-col :lg="11">
<el-card shadow="never"> <el-card shadow="never">
<div id="bachart1" style="width:100%;height:300px;"></div> <div id="bachart1" style="width:100%;height:300px;"></div>
</el-card> </el-card>
</el-col> </el-col>
<el-col :lg="12"> <el-col :lg="13">
<el-card shadow="never" style="position: relative;"> <el-card shadow="never" style="position: relative;">
<el-button @click="handleExport('1')" class="tables" type="primary">导出</el-button> <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 type="index" width="50" />
<el-table-column label="物料名" prop="物料名"> <el-table-column label="物料名" prop="物料名">
</el-table-column> </el-table-column>
@ -47,36 +47,7 @@
</el-col> </el-col>
</el-row> </el-row>
</el-card> </el-card>
<!-- <el-card shadow="never" style="margin-bottom: 8px;"> </el-main>
<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> </el-container>
</template> </template>
<script> <script>
@ -94,6 +65,7 @@ export default {
}, },
data() { data() {
return { return {
tableHeight: 300,
queryType: '月', queryType: '月',
queryDate: '', queryDate: '',
start_date: '', start_date: '',
@ -155,6 +127,11 @@ export default {
that.xAxisOrigin.push('第' + i + '周'); that.xAxisOrigin.push('第' + i + '周');
} }
that.xAxisData = that.xAxisOrigin; 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(); that.getDataHL();
}, },
methods: { methods: {
@ -316,6 +293,34 @@ export default {
} }
that.getDataHL(); 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) { handleExport(val) {
this.exportLoading = true; this.exportLoading = true;
let id = '#exportDiv' + val; let id = '#exportDiv' + val;

View File

@ -95,6 +95,7 @@
:data="tableData1" :data="tableData1"
id="exportDiv1" id="exportDiv1"
:height="tableHeight" :height="tableHeight"
:summary-method="getSummaries" show-summary
> >
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
<el-table-column <el-table-column
@ -149,6 +150,7 @@
:height="rightHeight" :height="rightHeight"
hideDo hideDo
hidePagination hidePagination
:summary-method="getSummaries" show-summary
> >
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
<el-table-column <el-table-column
@ -400,6 +402,34 @@ export default {
that.getSaleData(); 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){ setChartData(data){
let that = this; let that = this;
let option = deepCopy(that.basicOption); let option = deepCopy(that.basicOption);

View File

@ -80,6 +80,8 @@
:data="tableData1" :data="tableData1"
id="exportDiv1" id="exportDiv1"
:height="tableHeight" :height="tableHeight"
:summary-method="getSummaries"
show-summary
> >
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
<el-table-column <el-table-column
@ -134,6 +136,8 @@
:height="rightHeight" :height="rightHeight"
hideDo hideDo
hidePagination hidePagination
:summary-method="getSummaries"
show-summary
> >
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
<el-table-column <el-table-column
@ -432,6 +436,34 @@ export default {
option.series = seriesData; option.series = seriesData;
that.setChart("bachart1", option); 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) { handleExport(val) {
this.exportLoading = true; this.exportLoading = true;
let id = "#exportDiv" + val; let id = "#exportDiv" + val;

View File

@ -56,6 +56,8 @@
:data="tableData7" :data="tableData7"
id="exportDiv7" id="exportDiv7"
:height="300" :height="300"
:summary-method="getSummaries"
show-summary
> >
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
<el-table-column <el-table-column
@ -122,6 +124,8 @@
:data="tableData10" :data="tableData10"
id="exportDiv10" id="exportDiv10"
:height="300" :height="300"
:summary-method="getSummaries"
show-summary
> >
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
<el-table-column <el-table-column
@ -182,6 +186,8 @@
:data="tableData6" :data="tableData6"
id="exportDiv6" id="exportDiv6"
:height="300" :height="300"
:summary-method="getSummaries2"
show-summary
> >
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
<el-table-column <el-table-column
@ -228,44 +234,6 @@
</el-col> </el-col>
</el-row> </el-row>
</el-card> </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-main>
</el-container> </el-container>
</template> </template>
@ -365,7 +333,6 @@ export default {
that.getData6(); that.getData6();
that.getData7(); that.getData7();
that.getData10(); that.getData10();
// that.getDataDAVG();
}, },
methods: { methods: {
setChart(name, option = null) { setChart(name, option = null) {
@ -584,40 +551,62 @@ export default {
} }
}); });
}, },
// getDataDAVG() { getSummaries({ columns, data }) {
// let that = this; const sums = [];
// let option = deepCopy(that.basicOption); columns.forEach((column, index) => {
// option.xAxis.data = that.xAxisData; if (index === 0) {
// option.title.text = "AVG"; sums[index] = "合计";
// let obj = { return;
// query: { start_date: that.start_date, end_date: that.end_date }, }
// }; if (index == 5||index == 6||index == 7||index == 8) {
// let exec = that.queryType == "" ? "AVGWeek" : "AVGMonth"; const values = data.map((item) =>
// that.$API.bi.dataset.exec.req(exec, obj).then((res) => { Number(item[column.property])
// let tableDataAVG = res.data2.ds0 ? res.data2.ds0 : []; );
// let seriesData = []; if (!values.every((value) => Number.isNaN(value))) {
// if (tableDataAVG.length > 0) { sums[index] = values.reduce((prev, curr) => {
// tableDataAVG.forEach((item) => { const value = Number(curr); //Number
// let index = 0; let sum = Number(
// if (that.queryType == "") { Number(prev) + Number(curr)
// index = item.month - 1; ).toFixed(2); //toFixed(2)
// } else { if (!isNaN(value)) {
// index = item. - that.firstWeekNum; return sum;
// } } else {
// seriesData[index] = item.; return prev;
// }); }
// let obj = {}; }, 0);
// obj.name = "AVG"; }
// obj.type = "bar"; }
// obj.barWidth = "15px"; });
// obj.data = seriesData; return sums;
// option.series.push(obj); },
// that.setChart("bachart4", option); getSummaries2({ columns, data }) {
// } else { const sums = [];
// that.setChart("bachart4", option); 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() { handleQuery() {
let that = this; let that = this;
if (that.queryType == "月") { if (that.queryType == "月") {

View File

@ -40,7 +40,7 @@
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :lg="12"> <el-col :lg="12">
<el-card shadow="never"> <el-card shadow="never">
<scEcharts height="300px" :option="option"></scEcharts> <scEcharts id="bachart1" height="300px" :option="option"></scEcharts>
</el-card> </el-card>
</el-col> </el-col>
<el-col :lg="12"> <el-col :lg="12">
@ -55,6 +55,8 @@
:data="tableData" :data="tableData"
:height="tableHeight" :height="tableHeight"
id="exportDiv" id="exportDiv"
:summary-method="getSummaries"
show-summary
> >
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
<el-table-column label="工段" prop="工段"> <el-table-column label="工段" prop="工段">
@ -146,7 +148,9 @@ export default {
that.start_date = year + "-" + month + "-01"; that.start_date = year + "-" + month + "-01";
that.end_date =year + "-" + month + "-" + days; that.end_date =year + "-" + month + "-" + days;
that.queryDate = year + "-" + month; 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(); that.getData6();
}, },
methods: { methods: {
@ -247,6 +251,34 @@ export default {
} }
this.getData6(); 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() { handleExport() {
this.exportLoading = true; this.exportLoading = true;
this.$XLSX("#exportDiv", "工序合格数"); this.$XLSX("#exportDiv", "工序合格数");

View File

@ -38,7 +38,7 @@
<el-card shadow="never" style="margin-bottom: 8px"> <el-card shadow="never" style="margin-bottom: 8px">
<el-row :gutter="15"> <el-row :gutter="15">
<el-col :lg="8"> <el-col :lg="8">
<scEcharts height="300px" :option="option1"></scEcharts> <scEcharts height="400px" :option="option1"></scEcharts>
</el-col> </el-col>
<el-col :lg="16" style="position: relative"> <el-col :lg="16" style="position: relative">
<el-button <el-button
@ -50,7 +50,9 @@
<el-table <el-table
:data="tableData7" :data="tableData7"
id="exportDiv7" id="exportDiv7"
:height="300" :height="400"
:summary-method="getSummaries"
show-summary
> >
<el-table-column <el-table-column
label="年" label="年"
@ -105,7 +107,7 @@
<el-card shadow="never" style="margin-bottom: 8px"> <el-card shadow="never" style="margin-bottom: 8px">
<el-row :gutter="15"> <el-row :gutter="15">
<el-col :lg="8"> <el-col :lg="8">
<scEcharts height="300px" :option="option2"></scEcharts> <scEcharts height="400px" :option="option2"></scEcharts>
</el-col> </el-col>
<el-col :lg="16" style="position: relative"> <el-col :lg="16" style="position: relative">
<el-button <el-button
@ -117,7 +119,9 @@
<el-table <el-table
:data="tableData10" :data="tableData10"
id="exportDiv10" id="exportDiv10"
:height="300" :height="400"
:summary-method="getSummaries"
show-summary
> >
<el-table-column <el-table-column
label="年" label="年"
@ -176,7 +180,7 @@
<el-card shadow="never" style="margin-bottom: 8px"> <el-card shadow="never" style="margin-bottom: 8px">
<el-row :gutter="15"> <el-row :gutter="15">
<el-col :lg="8"> <el-col :lg="8">
<scEcharts height="300px" :option="option3"></scEcharts> <scEcharts height="400px" :option="option3"></scEcharts>
</el-col> </el-col>
<el-col :lg="16" style="position: relative"> <el-col :lg="16" style="position: relative">
<el-button <el-button
@ -188,7 +192,9 @@
<el-table <el-table
:data="tableData8" :data="tableData8"
id="exportDiv8" id="exportDiv8"
:height="300" :height="400"
:summary-method="getSummaries"
show-summary
> >
<el-table-column <el-table-column
label="年" label="年"
@ -289,8 +295,8 @@ export default {
series: { series: {
name: "7车间预制棒", name: "7车间预制棒",
type: "pie", type: "pie",
radius: ["40%", "70%"], radius: ["35%", "65%"],
center: ["50%", "60%"], center: ["50%", "55%"],
label: { label: {
show: true, show: true,
position: "outside", position: "outside",
@ -318,8 +324,8 @@ export default {
series: { series: {
name: "10车间预制管", name: "10车间预制管",
type: "pie", type: "pie",
radius: ["40%", "70%"], radius: ["35%", "65%"],
center: ["50%", "60%"], center: ["50%", "55%"],
label: { label: {
show: true, show: true,
position: "outside", position: "outside",
@ -348,8 +354,8 @@ export default {
series: { series: {
name: "退火预制管", name: "退火预制管",
type: "pie", type: "pie",
radius: ["40%", "70%"], radius: ["35%", "65%"],
center: ["50%", "60%"], center: ["50%", "55%"],
label: { label: {
show: true, show: true,
position: "outside", position: "outside",
@ -603,6 +609,34 @@ export default {
this.getData7(); this.getData7();
this.getData10(); 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) { handleExport(val) {
this.exportLoading = true; this.exportLoading = true;
let id = "#exportDiv" + val; let id = "#exportDiv" + val;

View File

@ -52,7 +52,7 @@
</el-col> </el-col>
<el-col :lg="16" style="position: relative;"> <el-col :lg="16" style="position: relative;">
<el-button @click="handleExport('1')" class="tables" type="primary">导出</el-button> <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 type="index" width="50" />
<el-table-column label="日期" prop="date"> <el-table-column label="日期" prop="date">
<template #default="scope"> <template #default="scope">
@ -238,6 +238,34 @@
} }
this.getData(); 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) { handleExport(val) {
this.exportLoading = true; this.exportLoading = true;
let id = '#exportDiv' + val; let id = '#exportDiv' + val;

View File

@ -39,6 +39,7 @@
stripe stripe
hideDo hideDo
hidePagination hidePagination
:summary-method="getSummaries" show-summary
> >
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
<el-table-column label="物料名" prop="material_name" /> <el-table-column label="物料名" prop="material_name" />
@ -64,6 +65,8 @@
id="exportDiv1" id="exportDiv1"
stripe stripe
hideDo hideDo
:summary-method="getSummaries2"
show-summary
> >
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
<el-table-column <el-table-column
@ -405,6 +408,32 @@ export default {
this.getTableData(); this.getTableData();
}, },
getSummaries({ columns, data }) { 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 = []; const sums = [];
columns.forEach((column, index) => { columns.forEach((column, index) => {
if (index === 0) { if (index === 0) {

View File

@ -67,6 +67,8 @@
:data="tableData1" :data="tableData1"
id="exportDiv7" id="exportDiv7"
:height="tableHeight" :height="tableHeight"
:summary-method="getSummaries"
show-summary
> >
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
<el-table-column <el-table-column
@ -96,6 +98,8 @@
:data="tableData2" :data="tableData2"
id="exportDiv10" id="exportDiv10"
:height="tableHeight" :height="tableHeight"
:summary-method="getSummaries"
show-summary
> >
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
<el-table-column <el-table-column
@ -125,6 +129,8 @@
:data="tableData3" :data="tableData3"
id="exportDiv6" id="exportDiv6"
:height="tableHeight" :height="tableHeight"
:summary-method="getSummaries"
show-summary
> >
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
<el-table-column <el-table-column
@ -430,6 +436,34 @@ export default {
this.getData7(); this.getData7();
this.getData10(); 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) { handleExport(val) {
this.exportLoading = true; this.exportLoading = true;
let id = "#exportDiv" + val; let id = "#exportDiv" + val;

View File

@ -55,6 +55,8 @@
id="exportDiv" id="exportDiv"
style="width: 100%" style="width: 100%"
:height="chartHeight" :height="chartHeight"
:summary-method="getSummaries"
show-summary
> >
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
<el-table-column label="日期" prop="date"> <el-table-column label="日期" prop="date">
@ -144,22 +146,21 @@ export default {
this.currentYear = year; this.currentYear = year;
this.currentMonth = month; this.currentMonth = month;
this.start_date = year + "-" + month + "-01"; this.start_date = year + "-" + month + "-01";
this.end_date = this.end_date =year + "-" + month + "-" + days;
year + "-" + month + "-" + new Date(year, month, 0).getDate(); month = month < 10 ? "0" + month : month;
this.queryDate = year + "-" + month; this.queryDate = year + "-" + month;
this.getData();
this.getDept(); this.getDept();
let mainHeight = document.getElementById("elMain").clientHeight; let mainHeight = document.getElementById("elMain").clientHeight;
this.chartHeight = mainHeight - 40 + "px"; this.chartHeight = mainHeight - 40 + "px";
}, },
methods: { methods: {
getDept() { getDept() {
this.$API.system.dept.list let that = this;
.req({ page: 0, type: "dept" }) this.$API.system.dept.list.req({ page: 0, type: "dept" }).then((res) => {
.then((res) => { that.deptData = res;
this.deptData = res; that.queryBelongDept = res[0].name;
this.queryBelongDept = res[0].name; that.getData();
}); });
}, },
queryTypeChange(value) { queryTypeChange(value) {
this.queryDate = ""; this.queryDate = "";
@ -211,6 +212,34 @@ export default {
console.log("查询query", this.start_date, this.end_date); console.log("查询query", this.start_date, this.end_date);
this.getData(); 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() { handleExport() {
this.exportLoading = true; this.exportLoading = true;
this.$XLSX("#exportDiv", "人员统计"); this.$XLSX("#exportDiv", "人员统计");