| | |
| | | <div style="display: flex;justify-content: space-between;align-items: center;margin: 10px 0 20px;height: 40px"> |
| | | <div style="width: 140px"></div> |
| | | <h2 style="text-align: center;margin: 0">{{taskName}}{{ activeTab==1?'批发':'零售' }}环节信息报送汇总表({{sheetStatus==1?'省级层面':(sheetStatus==2?'市级层面':'区县级')}})</h2> |
| | | <el-button icon="el-icon-download" v-if="sheetStatus==1||sheetStatus==2" style="width: 140px" size="medium" type="primary" @click="exportSheet()" id="export">导出汇总表</el-button> |
| | | <div v-else style="width: 140px"></div> |
| | | <el-button icon="el-icon-download" style="width: 140px" size="medium" type="primary" @click="exportSheet()" id="export">导出汇总表</el-button> |
| | | </div> |
| | | <div class="tabpanel"> |
| | | <table v-show="sheetStatus==1||sheetStatus==2" class="data-table" id="tableExcel" v-if="thisLevelStatistic && institutionalData && institutionalData.length>0"> |
| | |
| | | import { getCheckUnitType,getDataStatistics, getSpecialCheckTask } from "@/api/specialCheck" |
| | | import areaForm from "./areaForm" |
| | | import checkEnterprises from "./checkEnterprises" |
| | | import FileSaver from 'file-saver' |
| | | import XLSX from 'xlsx' |
| | | |
| | | export default { |
| | | name: "sumSheet", |
| | |
| | | }, |
| | | async getDataStatistics(){ |
| | | const t = this |
| | | const loading = this.$loading({ |
| | | lock: true, |
| | | target: document.querySelector('.tabpanel'), |
| | | text: '正在获取汇总数据', |
| | | spinner: 'el-icon-loading', |
| | | fullscreen: false |
| | | }); |
| | | const data = {id: t.taskId,enterpriseType: t.activeTab,enterpriseCity: t.enterpriseCity,enterpriseArea: t.enterpriseArea,pageIndex: t.currentPage,pageSize: t.pageSize} |
| | | const res = await getDataStatistics(data) |
| | | if(res.data.code === "200"){ |
| | |
| | | message:res.data.message |
| | | }) |
| | | } |
| | | loading.close(); |
| | | }, |
| | | switchSheet() { |
| | | const t = this |
| | |
| | | const t = this |
| | | if(t.sheetStatus==1){ |
| | | t.enterpriseCity = city |
| | | t.getDataStatistics() |
| | | t.sheetStatus = 2 |
| | | t.getDataStatistics() |
| | | }else{ |
| | | t.sheetStatus = 3 |
| | | t.$refs.areaSheet.taskId = t.taskId |
| | |
| | | } |
| | | }, |
| | | tableToExcel(tableid,btnname,sheetname) { |
| | | var uri = 'data:application/vnd.ms-excel;base64,' |
| | | let uri = 'data:application/vnd.ms-excel;base64,' |
| | | , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><meta charset="UTF-8"><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>' |
| | | , base64 = function (s) { return window.btoa(unescape(encodeURIComponent(s))) } |
| | | , format = function (s, c) { return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; }) } |
| | | //根据ID获取table表格HTML |
| | | var table = document.getElementById(tableid); |
| | | var ctx = { worksheet: 'Worksheet', table: table.innerHTML }; |
| | | var alink = document.createElement("a"); |
| | | let table = document.getElementById(tableid); |
| | | let ctx = { worksheet: 'Worksheet', table: table.innerHTML }; |
| | | let alink = document.createElement("a"); |
| | | alink.href = uri + base64(format(template, ctx)); |
| | | alink.download = sheetname + ').xls'; |
| | | alink.click(); |
| | |
| | | exportSheet(){ |
| | | const t = this |
| | | const sheetName = t.taskName + (t.activeTab==1 ?'批发':'零售') + '环节信息报送汇总表(' + (t.sheetStatus==1?'省级层面':(t.sheetStatus==2?'市级层面':'区县级')) |
| | | t.tableToExcel("tableExcel", "export",sheetName); |
| | | } |
| | | if(t.sheetStatus==1||t.sheetStatus==2){ |
| | | t.tableToExcel("tableExcel", "export",sheetName); |
| | | }else{ |
| | | let wb = XLSX.utils.table_to_book(document.querySelector('#' + 'areaSheet')) |
| | | let wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' }) |
| | | try { |
| | | FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), sheetName + ').xlsx') |
| | | } catch (e) { if (typeof console !== 'undefined') console.log(e, wbout) } |
| | | // return wbout |
| | | } |
| | | }, |
| | | } |
| | | } |
| | | </script> |