|
@@ -5,16 +5,16 @@
|
|
|
<div class="query-item">
|
|
|
<div class="lable">选择日期:</div>
|
|
|
<div class="search-input">
|
|
|
- <el-date-picker v-model="month" type="month" value-format="YYYY-MM" placeholder="选择日期"
|
|
|
- popper-class="date-select">
|
|
|
- </el-date-picker>
|
|
|
+ <el-date-picker v-model="month" type="month" value-format="YYYY-MM" placeholder="选择日期" popper-class="date-select"> </el-date-picker>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <div class="query-actions">
|
|
|
+ <button class="btn" @click="exportExcel()">导出</button>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<panel :title="monthTitle + '发电量预测'" :showLine="false">
|
|
|
- <el-table :data="tableData" height="85vh" style="width: 100%" show-summary :summary-method="getSummaries"
|
|
|
- :span-method="yhmxdbMethod">
|
|
|
+ <el-table :data="tableData" height="85vh" style="width: 100%;" class="" show-summary :summary-method="getSummaries" :span-method="yhmxdbMethod">
|
|
|
<el-table-column fixed prop="region" label="名称" width="120" />
|
|
|
<el-table-column fixed prop="speed" label="" width="50" />
|
|
|
<el-table-column label="日期">
|
|
@@ -24,6 +24,15 @@
|
|
|
<el-table-column fixed="right" prop="hj" label="平均风速/合计" width="100" align="center" />
|
|
|
<el-table-column fixed="right" prop="dqhj" label="地区合并" width="100" align="center" />
|
|
|
</el-table>
|
|
|
+ <el-table :data="tableDataExport" height="85vh" style="width: 100%;display: none;" id="out-table" :span-method="yhmxdbMethod">
|
|
|
+ <el-table-column prop="region" label="名称" width="120" />
|
|
|
+ <el-table-column prop="speed" label="" width="50" />
|
|
|
+ <el-table-column label="日期">
|
|
|
+ <el-table-column v-for="(item, index) in dateS" :key="index" :prop="item.prop" :label="item.label" width="70" align="center" />
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="hj" label="平均风速/合计" width="100" align="center" />
|
|
|
+ <el-table-column prop="dqhj" label="地区合并" width="100" align="center" />
|
|
|
+ </el-table>
|
|
|
</panel>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -31,9 +40,13 @@
|
|
|
<script>
|
|
|
import $ from "jquery";
|
|
|
import Panel from "@/components/coms/panel/panel.vue";
|
|
|
+ import FileSaver from "file-saver";
|
|
|
+ import XLSX from "xlsx";
|
|
|
export default {
|
|
|
components: {
|
|
|
Panel,
|
|
|
+ FileSaver,
|
|
|
+ XLSX
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
@@ -42,6 +55,7 @@
|
|
|
spanArr: [],
|
|
|
pos: 0,
|
|
|
spanArrHj: [],
|
|
|
+ SUM:[],
|
|
|
dateS: [{
|
|
|
prop: "01",
|
|
|
label: 1,
|
|
@@ -58,10 +72,12 @@
|
|
|
dqhj: 6,
|
|
|
"01": 55,
|
|
|
wpid: "NSS_FDC",
|
|
|
- }, ],
|
|
|
+ }],
|
|
|
+ tableDataExport:[]
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
|
+ this.monthTit(this.month);
|
|
|
this.list(new Date(this.month).valueOf());
|
|
|
},
|
|
|
mounted() {
|
|
@@ -141,7 +157,7 @@
|
|
|
data.forEach((ele) => {
|
|
|
let dd = new Date(ele.recodedate).formatDate("dd");
|
|
|
let wpidName = ele.pjid.split("_")[0].match(/^[a-z|A-Z]+/gi)[0];
|
|
|
- let power = parseFloat((ele.daypower + ele.nightpower).toFixed(2));
|
|
|
+ let power = ele.daypower + ele.nightpower;
|
|
|
if (pjid.indexOf(ele.pjid) === -1) {//判断有木有id,若没有,则加进去,并新增一条tableData的白天和夜间
|
|
|
pjid.push(ele.pjid);
|
|
|
tableData.push({
|
|
@@ -167,19 +183,20 @@
|
|
|
wpid: ele.wpid,
|
|
|
pjid: ele.pjid,
|
|
|
});
|
|
|
-
|
|
|
- dqhj[wpidName] != undefined ?(dqhj[wpidName] += power) :(dqhj[wpidName] = power);
|
|
|
+ dqhj[wpidName] != undefined ?
|
|
|
+ (dqhj[wpidName] += power) :
|
|
|
+ (dqhj[wpidName] = power);
|
|
|
} else {//匹配tableData的id,并分别传到夜间和白天data中
|
|
|
tableData.forEach((ele2, index2) => {
|
|
|
if (ele2.pjid === ele.pjid) {
|
|
|
if (ele2.speed === "白天") {
|
|
|
tableData[index2][dd] = ele.daypower;
|
|
|
- tableData[index2].hj = parseFloat((tableData[index2].hj + power).toFixed(2));
|
|
|
+ tableData[index2].hj += power;
|
|
|
} else if (ele2.speed === "夜间") {
|
|
|
tableData[index2][dd] = ele.nightpower;
|
|
|
} else {
|
|
|
tableData[index2][dd] = power;
|
|
|
- dqhj[wpidName] = parseFloat((dqhj[wpidName] + power).toFixed(2));
|
|
|
+ dqhj[wpidName] += power;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -187,7 +204,7 @@
|
|
|
});
|
|
|
tableData.find((ele) => {//地区合并
|
|
|
if (ele.dqhj == 1) {
|
|
|
- ele.dqhj = parseFloat(dqhj[ele.wpid.split("_")[0]]);
|
|
|
+ ele.dqhj = dqhj[ele.wpid.split("_")[0]];
|
|
|
}
|
|
|
});
|
|
|
let arr = [];
|
|
@@ -199,7 +216,6 @@
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
- console.log(arr)
|
|
|
that.getSpanArr(arr);
|
|
|
that.tableData = arr;
|
|
|
},
|
|
@@ -221,7 +237,7 @@
|
|
|
return [_row, _col];
|
|
|
}
|
|
|
},
|
|
|
- getSpanArr(data) {
|
|
|
+ getSpanArr(data,port) {
|
|
|
this.spanArr = [];
|
|
|
for (var i = 0; i < data.length; i++) {
|
|
|
if (i === 0) {
|
|
@@ -231,6 +247,9 @@
|
|
|
if (data[i].region === data[i - 1].region) {
|
|
|
this.spanArr[this.pos] += 1;
|
|
|
this.spanArr.push(0);
|
|
|
+ }else if (data[i].region === '合计') {
|
|
|
+ this.spanArr.push(1);
|
|
|
+ this.pos = i;
|
|
|
} else {
|
|
|
this.spanArr.push(1);
|
|
|
this.pos = i;
|
|
@@ -243,13 +262,18 @@
|
|
|
if (ele === 2) {
|
|
|
idx.push(index + 2);
|
|
|
spanArrIndex.push(1);
|
|
|
- } else if (this.spanArr[index - 1] === 2) {
|
|
|
+ } else if (this.spanArr[index - 1] === 2 || ele === 1) {
|
|
|
spanArrIndex.push(1);
|
|
|
- } else {
|
|
|
+ }else {
|
|
|
spanArrIndex.push(0);
|
|
|
}
|
|
|
});
|
|
|
- idx.push(this.spanArr.length + 2);
|
|
|
+
|
|
|
+ if(port){
|
|
|
+ idx.push(this.spanArr.length + 1);
|
|
|
+ }else{
|
|
|
+ idx.push(this.spanArr.length + 2);
|
|
|
+ }
|
|
|
idx.forEach((ele, index) => {
|
|
|
if (idx[index + 1]) {
|
|
|
spanArrIndex[ele] = idx[index + 1] - (ele + 2);
|
|
@@ -274,7 +298,7 @@
|
|
|
sums[index] = values.reduce((prev, curr) => {
|
|
|
const value = Number(curr);
|
|
|
if (!isNaN(value)) {
|
|
|
- return parseFloat((prev + curr).toFixed(2));
|
|
|
+ return prev + curr;
|
|
|
} else {
|
|
|
return prev;
|
|
|
}
|
|
@@ -284,17 +308,59 @@
|
|
|
}
|
|
|
});
|
|
|
sums[sums.length - 1] = "";
|
|
|
+ this.SUM = sums;
|
|
|
return sums;
|
|
|
},
|
|
|
- },
|
|
|
- watch: {
|
|
|
- month(e) {
|
|
|
- this.list(new Date(e).valueOf());
|
|
|
+ tableDataE(tableData,SUM){
|
|
|
+ let tableDataExport = [...tableData],
|
|
|
+ sums = {},
|
|
|
+ dateS = [];
|
|
|
+ this.dateS.forEach(ele=>{
|
|
|
+ dateS.push(ele.prop)
|
|
|
+ })
|
|
|
+ SUM.forEach((ele,index)=>{
|
|
|
+ if(index === 0){
|
|
|
+ sums['region'] = ele;
|
|
|
+ }else if(index < SUM.length - 2 && index > 1){
|
|
|
+ sums[dateS[index - 2]] = ele;
|
|
|
+ }else if(index === SUM.length - 2){
|
|
|
+ sums['dqhj'] = ele
|
|
|
+ }else if(index === SUM.length - 1){
|
|
|
+ sums['hj'] = ele
|
|
|
+ }
|
|
|
+ })
|
|
|
+ tableDataExport.push(sums);
|
|
|
+ this.getSpanArr(tableDataExport,true);
|
|
|
+ this.tableDataExport = tableDataExport;
|
|
|
+ /* 从表生成工作簿对象 */
|
|
|
+ setTimeout(()=>{
|
|
|
+ let wb = XLSX.utils.table_to_book(document.querySelector('#out-table'))
|
|
|
+ /* 获取二进制字符串作为输出 */
|
|
|
+ var wbout = XLSX.write(wb, {bookType: 'xlsx',bookSST: true,type: 'array'})
|
|
|
+ try {
|
|
|
+ FileSaver.saveAs(
|
|
|
+ new Blob([wbout], { type: 'application/octet-stream' }),this.monthTitle + '预测拟合风速电量.xlsx')
|
|
|
+ } catch (e) {
|
|
|
+ if (typeof console !== 'undefined') console.log(e, wbout)
|
|
|
+ }
|
|
|
+ return wbout
|
|
|
+ },1500)
|
|
|
+ },
|
|
|
+ exportExcel() {
|
|
|
+ this.tableDataE(this.tableData,this.SUM)
|
|
|
+ },
|
|
|
+ monthTit(e){
|
|
|
let tit = e.split("-");
|
|
|
if (tit[1].indexOf(0) != -1) {
|
|
|
tit[1] = tit[1].split("0")[1];
|
|
|
}
|
|
|
this.monthTitle = tit[0] + "年" + tit[1] + "月";
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ month(e) {
|
|
|
+ this.list(new Date(e).valueOf());
|
|
|
+ this.monthTit(e);
|
|
|
},
|
|
|
},
|
|
|
};
|