作者 王勇

功能基本完善

1 import http from './http.js' 1 import http from './http.js'
  2 +import axios from "axios";
2 3
3 let baseUrl = 'cgonms-provide' 4 let baseUrl = 'cgonms-provide'
4 // let baseUrl = 'http://127.0.0.1:9999/dispatch' 5 // let baseUrl = 'http://127.0.0.1:9999/dispatch'
@@ -6,4 +7,8 @@ let baseUrl = 'cgonms-provide' @@ -6,4 +7,8 @@ let baseUrl = 'cgonms-provide'
6 7
7 export const getExitDataAnalysis = params =>{return http.get(`${baseUrl}/cgoNms/getInfo`, params);}; 8 export const getExitDataAnalysis = params =>{return http.get(`${baseUrl}/cgoNms/getInfo`, params);};
8 9
9 -export const downExcel = params => { return http.post(`${baseUrl}/exit/excel`,params)}; 10 +export const createExcel = params => { return http.post(`${baseUrl}/exit/excel`,params)};
  11 +
  12 +
  13 +
  14 +export const downExcel = params => { return axios.get(`${baseUrl}/exit/downExcel`, { params: params }); };
@@ -17,12 +17,14 @@ @@ -17,12 +17,14 @@
17 </el-date-picker> 17 </el-date-picker>
18 </el-col> 18 </el-col>
19 <el-col :span="10"> 19 <el-col :span="10">
20 - <el-button type="primary" @click="getExitInfoList" style="width: 160px;" icon="el-icon-search"> 20 + <el-button type="primary" @click="getExitInfoList" style="width: 160px;"
  21 + icon="el-icon-search">
21 数据统计查询 22 数据统计查询
22 </el-button> 23 </el-button>
23 <el-button :loading="downloadLoading" type="success" icon="el-icon-s-home" 24 <el-button :loading="downloadLoading" type="success" icon="el-icon-s-home"
24 - :disabled="socketResponse.socketStatus!=='200'" style="width: 160px;"  
25 - @click="downExcel">导出 Excel 25 + style="width: 160px;"
  26 + :disabled="socketResponse.socketStatus!=='200'"
  27 + @click="downLoadExcel">导出 Excel
26 </el-button> 28 </el-button>
27 </el-col> 29 </el-col>
28 </el-row> 30 </el-row>
@@ -34,19 +36,18 @@ @@ -34,19 +36,18 @@
34 style="width: 455px"></el-progress> 36 style="width: 455px"></el-progress>
35 <el-input v-model="message" type="textarea" 37 <el-input v-model="message" type="textarea"
36 :autosize="{ minRows: 6, maxRows: 10}" 38 :autosize="{ minRows: 6, maxRows: 10}"
37 - style="width: 455px;" 39 + style="width: 455px;height: 400px"
38 placeholder="获取数据进度" readonly> 40 placeholder="获取数据进度" readonly>
39 </el-input> 41 </el-input>
40 </el-col> 42 </el-col>
41 <el-col :span="4" style="margin-left: 40px;margin-top: 20px"> 43 <el-col :span="4" style="margin-left: 40px;margin-top: 20px">
42 <el-progress type="circle" :percentage="proportion" 44 <el-progress type="circle" :percentage="proportion"
  45 + :stroke-width="12"
43 :color="customColors" 46 :color="customColors"
44 :width="proportion>6?200:126"></el-progress> 47 :width="proportion>6?200:126"></el-progress>
45 </el-col> 48 </el-col>
46 </el-row> 49 </el-row>
47 -  
48 </div> 50 </div>
49 -  
50 </el-card> 51 </el-card>
51 </el-main> 52 </el-main>
52 </el-container> 53 </el-container>
@@ -54,7 +55,7 @@ @@ -54,7 +55,7 @@
54 55
55 <script> 56 <script>
56 57
57 - import {downExcel, getExitDataAnalysis} from "../../api/exit_data_analysis"; 58 + import {downExcel, createExcel, getExitDataAnalysis} from "../../api/exit_data_analysis";
58 import VueWebsocket from '@/utils/websocket'; 59 import VueWebsocket from '@/utils/websocket';
59 60
60 export default { 61 export default {
@@ -81,9 +82,9 @@ @@ -81,9 +82,9 @@
81 */ 82 */
82 queryInfo: { 83 queryInfo: {
83 //航班号 84 //航班号
84 - flightNo: 'RU186', 85 + flightNo: 'SL965',
85 //航班日期 86 //航班日期
86 - flightDate: '2019-10-31', 87 + flightDate: '2019-04-12',
87 }, 88 },
88 89
89 /* 列表加载 */ 90 /* 列表加载 */
@@ -95,7 +96,13 @@ @@ -95,7 +96,13 @@
95 {color: '#e6a23c', percentage: 60}, 96 {color: '#e6a23c', percentage: 60},
96 {color: '#5cb87a', percentage: 80}, 97 {color: '#5cb87a', percentage: 80},
97 {color: '#1989fa', percentage: 100}, 98 {color: '#1989fa', percentage: 100},
98 - ] 99 + ],
  100 + /**
  101 + * 下载路径的参数
  102 + */
  103 + fileName: "test.xls",
  104 + ipAddress: "",
  105 + url: "",
99 } 106 }
100 }, 107 },
101 methods: { 108 methods: {
@@ -112,14 +119,47 @@ @@ -112,14 +119,47 @@
112 /** 119 /**
113 * 下载excel 120 * 下载excel
114 */ 121 */
115 - downExcel() { 122 + downLoadExcel() {
  123 + downExcel().then((response) => {
  124 + let res = response.data;
  125 + if (res.code !== '200') {
  126 + return this.$message.error('下载失败');
  127 + }
  128 + // console.log(res.msg)
  129 + //获取地址
  130 + this.ipAddress = res.msg;
  131 + this.url = this.ipAddress + this.fileName;
  132 + console.log(this.url)
  133 + // console.log(this.ipAddress)
  134 + this.down();
  135 + }).catch(error => {
  136 + console.log(error.toString())
  137 + this.$message.error(error.toString());
  138 + });
116 139
117 }, 140 },
  141 + down() {
  142 + // 创建a标签
  143 + const link = document.createElement('a')
  144 + // download属性
  145 + link.setAttribute('download', 'excel.xls')
  146 + // href链接
  147 + link.setAttribute('href', this.url)
  148 + document.body.appendChild(link)
  149 + // 自执行点击事件
  150 + link.click()
  151 + },
118 /** 152 /**
119 * 生成excel 153 * 生成excel
120 */ 154 */
121 - downExcelExit() {  
122 - downExcel(this.socketResponse.socketDataList).then((response) => { 155 + generateExcel() {
  156 + createExcel(this.socketResponse.socketDataList).then((response) => {
  157 + let res = response.data;
  158 + if (res.code !== '200') {
  159 + return this.$message.error('生成excel失败');
  160 + }
  161 + this.fileName = res.msg;
  162 + console.log(this.fileName)
123 this.$message.success("Excel准备就绪") 163 this.$message.success("Excel准备就绪")
124 }).catch(error => { 164 }).catch(error => {
125 this.$message.error(error.toString()); 165 this.$message.error(error.toString());
@@ -143,7 +183,7 @@ @@ -143,7 +183,7 @@
143 } 183 }
144 if (this.socketResponse.socketCurrentNum === this.socketResponse.socketTotalNum && 184 if (this.socketResponse.socketCurrentNum === this.socketResponse.socketTotalNum &&
145 this.socketResponse.socketTotalNum !== 0 && this.socketResponse.socketCurrentNum !== 0) { 185 this.socketResponse.socketTotalNum !== 0 && this.socketResponse.socketCurrentNum !== 0) {
146 - this.downExcelExit(); 186 + this.generateExcel();
147 } 187 }
148 }, 188 },
149 socket_onopen: function (e) { 189 socket_onopen: function (e) {
@@ -147,7 +147,7 @@ @@ -147,7 +147,7 @@
147 tableList: [], 147 tableList: [],
148 total: 0, 148 total: 0,
149 pageNum: 1, 149 pageNum: 1,
150 - pageSize: 100, 150 + pageSize: 1000,
151 listLoading: false, 151 listLoading: false,
152 sels: [],//列表选中列 152 sels: [],//列表选中列
153 //编辑界面是否显示 153 //编辑界面是否显示