From cb1eddc2b577a8f2b434c784ca742a91c5040f81 Mon Sep 17 00:00:00 2001 From: mrz <17966059@qq.com> Date: Thu, 23 Apr 2020 15:26:46 +0800 Subject: [PATCH] 进港统计导出增加字段 --- config/index.js | 5 +++-- src/views/Home.vue | 2 ++ src/views/excel/exportExcel-agent.vue | 207 ++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------------------------------- 3 files changed, 47 insertions(+), 167 deletions(-) diff --git a/config/index.js b/config/index.js index 7eb99cb..483c00c 100755 --- a/config/index.js +++ b/config/index.js @@ -30,8 +30,9 @@ module.exports = { assetsPublicPath: '/', proxyTable: { '/api':{ - target: 'http://192.168.1.53:12343',//设置你调用的接口域名和端口号 别忘了加http - // target: 'http://localhost:12343',//设置你调用的接口域名和端口号 别忘了加http + // target: 'http://192.168.1.53:12343',//设置你调用的接口域名和端口号 别忘了加http + // target: 'http://127.0.0.1:12343',//设置你调用的接口域名和端口号 别忘了加http + target: 'http://10.50.3.82:22343',//设置你调用的接口域名和端口号 别忘了加http changeOrigin: true, pathRewrite: { '^/api/': '/'//这里理解成用‘/api’代替target里面的地址,后面组件中我们掉接口时直接用api代替 比如我要调用'http://40.00.100.100:3002/user/add',直接写‘/api/user/add’即可 diff --git a/src/views/Home.vue b/src/views/Home.vue index 7be8296..d7d9a32 100755 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -240,6 +240,8 @@ aside { flex:0 0 230px; width: 230px; + overflow-y: scroll; + background: #606060; // position: absolute; // top: 0px; // bottom: 0px; diff --git a/src/views/excel/exportExcel-agent.vue b/src/views/excel/exportExcel-agent.vue index 2ba92b4..ef55e5d 100755 --- a/src/views/excel/exportExcel-agent.vue +++ b/src/views/excel/exportExcel-agent.vue @@ -14,51 +14,13 @@ placeholder="结束航班日期" ></el-date-picker> </el-form-item> - <el-form-item> - <el-button :loading="listLoading" style="margin:0 0 20px 20px;" type="primary" icon="document" @click="fetchData">查询</el-button> - </el-form-item> - <el-tag - :key="note.message" - :type="note.type"> - {{note.message}} - </el-tag> + <FilenameOption v-model="filename" /> + <el-button :loading="downloadLoading" style="margin:0 0 20px 20px;" type="primary" icon="document" @click="exportExcel">导出 Excel</el-button> </el-form> </el-col> - <div> - <FilenameOption v-model="filename" /> - <AutoWidthOption v-model="autoWidth" /> - <BookTypeOption v-model="bookType" /> - <el-button :loading="downloadLoading" style="margin:0 0 20px 20px;" type="primary" icon="document" @click="handleDownload">导出 Excel</el-button> - </div> - - <el-table v-loading="listLoading" element-loading-text="拼命加载中" border fit highlight-current-row> - <el-table-column align="center" label="Id" width="95"> - <template slot-scope="scope"> - {{ scope.$index }} - </template> - </el-table-column> - <el-table-column label="运单号"> - <template slot-scope="scope"> - {{ scope.row.autoid }} - </template> - </el-table-column> - <el-table-column label="承运人" width="110" align="center"> - <template slot-scope="scope"> - <el-tag>{{ scope.row.totalpiece }}</el-tag> - </template> - </el-table-column> - <el-table-column label="航班号" width="115" align="center"> - <template slot-scope="scope"> - {{ scope.row.manifesttotalpiece }} - </template> - </el-table-column> - <el-table-column align="center" label="航班日期" width="220" :formatter="dateFormat"> - <template slot-scope="scope"> - <i class="el-icon-time"/> - <span>{{ scope.row.manifesttotalweight | parseTime('{y}-{m}-{d}')}}</span> - </template> - </el-table-column> - </el-table> + <el-col :span="24" class="toolbar" style="padding-bottom: 0px;"> + <span>导出进度:{{downloadSize}}</span> + </el-col> </div> </template> @@ -68,12 +30,9 @@ import { parseTime } from '@/utils' // options components import FilenameOption from './components/FilenameOption' -import AutoWidthOption from './components/AutoWidthOption' -import BookTypeOption from './components/BookTypeOption' -import Export2Excel from '@/vendor/Export2Excel' export default { name: 'ExportExcel', - components: { FilenameOption, AutoWidthOption, BookTypeOption }, + components: { FilenameOption }, data() { return { list: [], @@ -90,7 +49,8 @@ export default { note: { type: 'info', message: '' - } + }, + downloadSize: 0 } }, @@ -105,125 +65,42 @@ export default { var t=new Date(row.updateTime);//row 表示一行数据, updateTime 表示要格式化的字段名称 return t.getFullYear()+"-"+(t.getMonth()+1)+"-"+t.getDate(); }, - fetchData() { - this.listLoading = true - getAnalysisList(this.searchText).then(response => { - this.list = response.data.data - this.listLoading = false - this.$message({ - message: '数据查询成功,可以下载excel', - type: 'success' - }); - this.note.message = '数据查询成功,可以下载excel;共'+this.list.length+'条数据'; - this.note.type = 'success'; - }) - }, - handleDownload() { - this.downloadLoading = true - import('@/vendor/Export2Excel').then(excel => { - const tHeader = ['运单号', - '航空托运人名称', - '航空销售代理人名称', - '航协编号', - '航空公司运输证明', - '运输条件鉴定书', - '承运人', - '航班号', - '航班日期', - '航班起始站', - '航班目的站', - '运单件数', - '运单重量', - '操作时间', - '关区', - '预配品名', - '收货人公司', - '收货人地址', - '收货人城市', - '收货人电话', - '收货人国家', - '收货人名称', - '发货人名称', - '发货人地址', - '发货人城市', - '发货人国家', - '发货人电话', - '发货人名称', - '海关回执状态', - '海关回执信息', - '发货人编码', - '收货人编码', - '货物品名', - '二级类名称', - '一级类名称', - '代理人三字码', - '代理人全称', - '代理人类别', - '代理联系人', - '代理联系人电话' - ] - const filterVal = [ - 'autoid', - 'waybillnomaster', - 'segment', - 'originatingstation', - 'destinationstation', - 'totalweight', - 'totalpiece', - 'manifesttotalpiece', - 'manifesttotalweight', - 'flightno', - 'productname', - 'customsstatus', - 'carrier1', - 'arrivalstation1', - 'carrier2', - 'arrivalstation2', - 'carrier3', - 'arrivalstation3', - 'paymode', - 'customscode', - 'specialgoodscode', - 'shippername', - 'shipperaddress', - 'consigneename', - 'consigneeaddress', - 'receiptinformation', - 'specificConsigneePhone', - 'consigneePhone', - 'status', - 'isbatch', - 'originatingstationBill', - 'destinationstationBill', - 'reportorder', - 'islast', - 'shipperCode', - 'shipperCountrycode', - 'shipperPhone', - 'shipperFax', - 'consigneeCode', - 'consigneeCountrycode' - ] - const list = this.list - const data = this.formatJson(filterVal, list) - excel.export_json_to_excel({ - header: tHeader, - data, - filename: this.filename, - autoWidth: this.autoWidth, - bookType: this.bookType - }) - this.downloadLoading = false + exportExcel(){ + let _this = this + this.$loading({ + fullscreen: true, + text: '正在导出', + spinner: 'el-icon-loading', + background: 'rgba(0, 0, 0, 0.6)' }) - }, - formatJson(filterVal, jsonData) { - return jsonData.map(v => filterVal.map(j => { - if (j === 'timestamp') { - return parseTime(v[j]) - } else { - return v[j] + this.$axios({ + method:"get", + url: "/analysis-agent/agent/analysis", + responseType: 'blob', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }, + params:this.searchText, + onDownloadProgress: function (progressEvent) { + _this.downloadSize = progressEvent.loaded + console.log(progressEvent.loaded) } - })) + }).then( + res=>{ + let data = res.data; + let url = window.URL.createObjectURL(new Blob([data])); + let link = document.createElement('a'); + link.style.display = 'none'; + link.href = url; + this.filename = this.filename == '' ? 'export' : this.filename + link.setAttribute('download', this.filename+'.xls'); + document.body.appendChild(link); + link.click() + this.$loading().close() + },err =>{ + this.$loading().close() + }); + } } } -- libgit2 0.24.0