修改bug
This commit is contained in:
@@ -13,7 +13,9 @@
|
||||
:limit="queryParams.pageSize"
|
||||
:table-props="tableProps"
|
||||
:table-data="list"
|
||||
:selectWidth="55"
|
||||
:max-height="tableH"
|
||||
@selection-change="selectChange"
|
||||
/>
|
||||
<pagination
|
||||
:page.sync="queryParams.pageNo"
|
||||
@@ -25,9 +27,11 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getEnergyQuantityRealtimePage, exportEnergyQuantityRealtimeExcel } from "@/api/base/energyQuantityRealtime";
|
||||
import { getEnergyTypeListAll } from "@/api/base/energyType";
|
||||
import { getEnergyQuantityRealtimePage, exportEnergyQuantityRealtimeExcel } from "@/api/base/energyQuantityRealtime"
|
||||
import { getEnergyTypeListAll } from "@/api/base/energyType"
|
||||
// import { publicFormatter } from '@/utils/dict'
|
||||
import FileSaver from "file-saver"
|
||||
import * as XLSX from 'xlsx/xlsx.mjs'
|
||||
const tableProps = [
|
||||
{
|
||||
prop: 'objName',
|
||||
@@ -113,7 +117,8 @@ export default {
|
||||
startTime: null,
|
||||
endTime: null
|
||||
},
|
||||
energyTypeList: []
|
||||
energyTypeList: [],
|
||||
exportList: []
|
||||
};
|
||||
},
|
||||
created() {
|
||||
@@ -134,12 +139,13 @@ export default {
|
||||
this.getList()
|
||||
break
|
||||
default:
|
||||
this.$modal.confirm('是否确认导出').then(() => {
|
||||
return exportEnergyQuantityRealtimeExcel({...this.queryParams});
|
||||
}).then(response => {
|
||||
console.log(response)
|
||||
this.$download.excel(response, '能源抄表.xls');
|
||||
}).catch(() => {})
|
||||
this.exportTable()
|
||||
// this.$modal.confirm('是否确认导出').then(() => {
|
||||
// return exportEnergyQuantityRealtimeExcel({...this.queryParams});
|
||||
// }).then(response => {
|
||||
// console.log(response)
|
||||
// this.$download.excel(response, '能源抄表.xls');
|
||||
// }).catch(() => {})
|
||||
}
|
||||
},
|
||||
/** 查询列表 */
|
||||
@@ -147,6 +153,7 @@ export default {
|
||||
getEnergyQuantityRealtimePage(this.queryParams).then(response => {
|
||||
this.list = response.data.list || []
|
||||
this.total = response.data.total;
|
||||
this.exportList = []
|
||||
});
|
||||
},
|
||||
getTypeList() {
|
||||
@@ -154,6 +161,48 @@ export default {
|
||||
this.formConfig[0].selectOptions = res.data || []
|
||||
this.energyTypeList = res.data || []
|
||||
})
|
||||
},
|
||||
selectChange(val) {
|
||||
console.log(val)
|
||||
this.exportList = val
|
||||
},
|
||||
// 勾选导出
|
||||
exportTable() {
|
||||
if (this.exportList.length > 0) {
|
||||
let body = this.exportList.map((x) => [
|
||||
x.objName,
|
||||
x.objRemark,
|
||||
x.energyTypeName,
|
||||
x.startValue,
|
||||
x.endValue,
|
||||
x.diffValue,
|
||||
x.amount
|
||||
])
|
||||
let header = []
|
||||
this.tableProps.map((y) => {
|
||||
header.push(y.label)
|
||||
})
|
||||
body.unshift(header)
|
||||
console.log(body)
|
||||
const filename = '能源抄表.xlsx'
|
||||
const ws_name = 'Sheet1'
|
||||
const wb = XLSX.utils.book_new()
|
||||
const ws = XLSX.utils.aoa_to_sheet(body)
|
||||
XLSX.utils.book_append_sheet(wb, ws, ws_name)
|
||||
let wbout = XLSX.write(wb, {
|
||||
bookType: 'xlsx',
|
||||
bookSST: false,
|
||||
type: 'array'
|
||||
})
|
||||
FileSaver.saveAs(
|
||||
new Blob([wbout], {
|
||||
type: 'application/octet-stream'
|
||||
}),
|
||||
filename
|
||||
)
|
||||
} else {
|
||||
this.$modal.msgWarning('请勾选需要导出的数据')
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user