|
|
1
|
+<template>
|
|
|
2
|
+ <el-container>
|
|
|
3
|
+ <el-main>
|
|
|
4
|
+ <el-card style="background-color: #F5F7FA">
|
|
|
5
|
+ <!-- 搜素区域 -->
|
|
|
6
|
+ <div>
|
|
|
7
|
+ <el-row :gutter="24">
|
|
|
8
|
+ <el-col :span="5">
|
|
|
9
|
+ <el-input v-model="queryInfo.flightNo" prefix-icon="el-icon-search"
|
|
|
10
|
+ placeholder="请输入航班号" clearable style="width:220px">
|
|
|
11
|
+ </el-input>
|
|
|
12
|
+ </el-col>
|
|
|
13
|
+ <el-col :span="5">
|
|
|
14
|
+ <el-date-picker v-model="queryInfo.flightDate" type="date" value-format="yyyy-MM-dd"
|
|
|
15
|
+ placeholder="请选择航班日期"
|
|
|
16
|
+ style="width: 220px">
|
|
|
17
|
+ </el-date-picker>
|
|
|
18
|
+ </el-col>
|
|
|
19
|
+ <el-col :span="10">
|
|
|
20
|
+ <el-button type="primary" @click="getExitInfoList" style="width: 160px;"
|
|
|
21
|
+ icon="el-icon-search">
|
|
|
22
|
+ 数据统计查询
|
|
|
23
|
+ </el-button>
|
|
|
24
|
+ <el-button :loading="downloadLoading" type="success" icon="el-icon-s-home"
|
|
|
25
|
+ style="width: 160px;"
|
|
|
26
|
+ :disabled="socketResponse.socketStatus!=='200'"
|
|
|
27
|
+ @click="downLoadExcel">导出 Excel
|
|
|
28
|
+ </el-button>
|
|
|
29
|
+ </el-col>
|
|
|
30
|
+ </el-row>
|
|
|
31
|
+ <!-- 显示区域 -->
|
|
|
32
|
+ <el-row :gutter="24" style="margin-top: 30px">
|
|
|
33
|
+ <el-col :span="11" style="margin-top: 10px">
|
|
|
34
|
+ <!-- <el-progress :text-inside="true" :stroke-width="15" :percentage="proportion"-->
|
|
|
35
|
+ <!-- :color="customColors"-->
|
|
|
36
|
+ <!-- style="width: 455px"></el-progress>-->
|
|
|
37
|
+ <el-input v-model="message" type="textarea"
|
|
|
38
|
+ :autosize="{ minRows: 6, maxRows: 10}"
|
|
|
39
|
+ style="width: 455px;height: 400px"
|
|
|
40
|
+ placeholder="获取数据进度" readonly>
|
|
|
41
|
+ </el-input>
|
|
|
42
|
+ </el-col>
|
|
|
43
|
+ <el-col :span="4" style="margin-left: 40px;margin-top: 20px">
|
|
|
44
|
+ <el-progress type="circle" :percentage="proportion"
|
|
|
45
|
+ :stroke-width="12"
|
|
|
46
|
+ :color="customColors"
|
|
|
47
|
+ :width="proportion>6?200:126">
|
|
|
48
|
+ </el-progress>
|
|
|
49
|
+ </el-col>
|
|
|
50
|
+ </el-row>
|
|
|
51
|
+ </div>
|
|
|
52
|
+ </el-card>
|
|
|
53
|
+ </el-main>
|
|
|
54
|
+ </el-container>
|
|
|
55
|
+</template>
|
|
|
56
|
+
|
|
|
57
|
+<script>
|
|
|
58
|
+
|
|
|
59
|
+ import {getArrivalDataAnalysis, createArrivalExcel, downArrivalExcel} from "../../api/arrival_data_analysis";
|
|
|
60
|
+ import ArrivalWebsocket from '@/utils/arrival_web_socket';
|
|
|
61
|
+
|
|
|
62
|
+ export default {
|
|
|
63
|
+ name: "ExitAnalysis",
|
|
|
64
|
+ data() {
|
|
|
65
|
+ return {
|
|
|
66
|
+ /**
|
|
|
67
|
+ * 出港业务统计列表
|
|
|
68
|
+ */
|
|
|
69
|
+ exitInfoList: [],
|
|
|
70
|
+ resultStatus: '0',
|
|
|
71
|
+ message: '',
|
|
|
72
|
+
|
|
|
73
|
+
|
|
|
74
|
+ /**
|
|
|
75
|
+ * 返回结果
|
|
|
76
|
+ */
|
|
|
77
|
+ socketResponse: {
|
|
|
78
|
+ socketMessage: '',
|
|
|
79
|
+ socketStatus: '',
|
|
|
80
|
+ socketDataList: [],
|
|
|
81
|
+ socketCurrentNum: 1,
|
|
|
82
|
+ socketTotalNum: 1,
|
|
|
83
|
+ },
|
|
|
84
|
+ /**
|
|
|
85
|
+ * 查询列表
|
|
|
86
|
+ */
|
|
|
87
|
+ queryInfo: {
|
|
|
88
|
+ //航班号
|
|
|
89
|
+ flightNo: 'CV4481',
|
|
|
90
|
+ //航班日期
|
|
|
91
|
+ flightDate: '2019-06-11',
|
|
|
92
|
+ },
|
|
|
93
|
+
|
|
|
94
|
+ /* 列表加载 */
|
|
|
95
|
+ listLoading: false,
|
|
|
96
|
+ downloadLoading: false,
|
|
|
97
|
+
|
|
|
98
|
+ /**
|
|
|
99
|
+ * 百分比例
|
|
|
100
|
+ */
|
|
|
101
|
+ proportion: 0,
|
|
|
102
|
+
|
|
|
103
|
+ /**
|
|
|
104
|
+ * 百分比例,颜色
|
|
|
105
|
+ */
|
|
|
106
|
+ customColors: [
|
|
|
107
|
+ {color: '#6f7ad3', percentage: 20},
|
|
|
108
|
+ {color: '#f56c6c', percentage: 40},
|
|
|
109
|
+ {color: '#e6a23c', percentage: 60},
|
|
|
110
|
+ {color: '#5cb87a', percentage: 80},
|
|
|
111
|
+ {color: '#1989fa', percentage: 100},
|
|
|
112
|
+ ],
|
|
|
113
|
+ /**
|
|
|
114
|
+ * 下载路径的参数
|
|
|
115
|
+ */
|
|
|
116
|
+ fileName: "test.xls",
|
|
|
117
|
+ ipAddress: "",
|
|
|
118
|
+ url: "",
|
|
|
119
|
+ }
|
|
|
120
|
+ },
|
|
|
121
|
+ methods: {
|
|
|
122
|
+ /**
|
|
|
123
|
+ * 获取出港信息列表
|
|
|
124
|
+ */
|
|
|
125
|
+ getExitInfoList() {
|
|
|
126
|
+ let _this = this;
|
|
|
127
|
+ if (_this.queryInfo.flightNo === '') {
|
|
|
128
|
+ if (_this.queryInfo.flightDate === '' || _this.queryInfo.flightDate === null) {
|
|
|
129
|
+ return _this.$message.warning('航班号与航班日期,不能同时为空');
|
|
|
130
|
+ }
|
|
|
131
|
+ }
|
|
|
132
|
+ _this.$message.success('开始获取统计数据');
|
|
|
133
|
+ getArrivalDataAnalysis(_this.queryInfo).catch(error => {
|
|
|
134
|
+ // _this.$message.info("即将结束!请您稍候");
|
|
|
135
|
+ });
|
|
|
136
|
+ },
|
|
|
137
|
+
|
|
|
138
|
+ /**
|
|
|
139
|
+ * 下载excel
|
|
|
140
|
+ */
|
|
|
141
|
+ downLoadExcel() {
|
|
|
142
|
+ downArrivalExcel().then((response) => {
|
|
|
143
|
+ this.downloadLoading = true;
|
|
|
144
|
+ let res = response.data;
|
|
|
145
|
+ if (res.code !== '200') {
|
|
|
146
|
+ return this.$message.error('下载失败');
|
|
|
147
|
+ this.downloadLoading = false;
|
|
|
148
|
+ }
|
|
|
149
|
+ // console.log(res.msg)
|
|
|
150
|
+ //获取地址
|
|
|
151
|
+ this.ipAddress = res.msg;
|
|
|
152
|
+ this.url = this.ipAddress + this.fileName;
|
|
|
153
|
+ console.log(this.url)
|
|
|
154
|
+ // console.log(this.ipAddress)
|
|
|
155
|
+ this.down();
|
|
|
156
|
+ this.downloadLoading = false;
|
|
|
157
|
+ }).catch(error => {
|
|
|
158
|
+ this.downloadLoading = false;
|
|
|
159
|
+ console.log(error.toString())
|
|
|
160
|
+ this.$message.error(error.toString());
|
|
|
161
|
+ });
|
|
|
162
|
+
|
|
|
163
|
+ },
|
|
|
164
|
+
|
|
|
165
|
+ down() {
|
|
|
166
|
+ // 创建a标签
|
|
|
167
|
+ const link = document.createElement('a');
|
|
|
168
|
+ // download属性
|
|
|
169
|
+ link.setAttribute('download', 'excel.xls');
|
|
|
170
|
+ // href链接
|
|
|
171
|
+ link.setAttribute('href', this.url);
|
|
|
172
|
+
|
|
|
173
|
+ document.body.appendChild(link);
|
|
|
174
|
+ // 自执行点击事件
|
|
|
175
|
+ link.click()
|
|
|
176
|
+ },
|
|
|
177
|
+
|
|
|
178
|
+ /**
|
|
|
179
|
+ * 生成excel
|
|
|
180
|
+ */
|
|
|
181
|
+ generateExcel() {
|
|
|
182
|
+ createArrivalExcel(this.socketResponse.socketDataList).then((response) => {
|
|
|
183
|
+ let res = response.data;
|
|
|
184
|
+ if (res.code !== '200') {
|
|
|
185
|
+ return this.$message.error('生成excel失败');
|
|
|
186
|
+ }
|
|
|
187
|
+ this.fileName = res.msg;
|
|
|
188
|
+ console.log(this.fileName)
|
|
|
189
|
+ this.$message.success("Excel准备就绪")
|
|
|
190
|
+ }).catch(error => {
|
|
|
191
|
+ this.$message.error(error.toString());
|
|
|
192
|
+ });
|
|
|
193
|
+ },
|
|
|
194
|
+
|
|
|
195
|
+ socket_onmessage: function (e) {
|
|
|
196
|
+ console.log("从websocket接收到新的消息-->>" + e.data);
|
|
|
197
|
+ //this.message = this.message + e.data + "\n";
|
|
|
198
|
+ let msgJson = JSON.parse(e.data);
|
|
|
199
|
+ this.message = this.message + this.dataFormat(new Date()) + " -> " + msgJson.message + "\n";
|
|
|
200
|
+ this.socketResponse = JSON.parse(e.data);
|
|
|
201
|
+ this.socketResponse.socketMessage = msgJson.message;
|
|
|
202
|
+ this.socketResponse.socketCurrentNum = msgJson.currentNum;
|
|
|
203
|
+ this.socketResponse.socketTotalNum = msgJson.totalNum;
|
|
|
204
|
+ console.log(this.socketMessage);
|
|
|
205
|
+ this.socketResponse.socketStatus = msgJson.status;
|
|
|
206
|
+ this.socketResponse.socketDataList = msgJson.data;
|
|
|
207
|
+ console.log(msgJson);
|
|
|
208
|
+ if (this.socketResponse.socketTotalNum !== null && this.socketResponse.socketTotalNum !== 0) {
|
|
|
209
|
+ this.proportion = this.toPercent(this.socketResponse.socketCurrentNum / this.socketResponse.socketTotalNum);
|
|
|
210
|
+ }
|
|
|
211
|
+ if (this.socketResponse.socketCurrentNum === this.socketResponse.socketTotalNum &&
|
|
|
212
|
+ this.socketResponse.socketTotalNum !== 0 && this.socketResponse.socketCurrentNum !== 0) {
|
|
|
213
|
+ this.generateExcel();
|
|
|
214
|
+ }
|
|
|
215
|
+ },
|
|
|
216
|
+
|
|
|
217
|
+ socket_onopen: function (e) {
|
|
|
218
|
+ console.log("websocket->>链接已链接");
|
|
|
219
|
+ },
|
|
|
220
|
+
|
|
|
221
|
+ /**
|
|
|
222
|
+ * 重写日期函数格式化日期
|
|
|
223
|
+ */
|
|
|
224
|
+ dataFormat(time) {
|
|
|
225
|
+ return `${time.getFullYear()}-${time.getMonth() + 1 >= 10 ? (time.getMonth() + 1) : '0' + (time.getMonth() + 1)}-${time.getDate() >= 10 ? time.getDate() : '0' + time.getDate()} ${time.getHours() >= 10 ? time.getHours() : '0' + time.getHours()}:${time.getMinutes() >= 10 ? time.getMinutes() : '0' + time.getMinutes()}:${time.getSeconds() >= 10 ? time.getSeconds() : '0' + time.getSeconds()}`;
|
|
|
226
|
+ },
|
|
|
227
|
+
|
|
|
228
|
+ /**
|
|
|
229
|
+ * 将小数转换成百分比
|
|
|
230
|
+ * @param point
|
|
|
231
|
+ * @returns {string|number}
|
|
|
232
|
+ */
|
|
|
233
|
+ toPercent(point) {
|
|
|
234
|
+ if (point == 0) {
|
|
|
235
|
+ return 0;
|
|
|
236
|
+ }
|
|
|
237
|
+ let str = Number(point * 100).toFixed();
|
|
|
238
|
+ // str+="%";
|
|
|
239
|
+ return parseInt(str);
|
|
|
240
|
+ }
|
|
|
241
|
+ },
|
|
|
242
|
+ created() {
|
|
|
243
|
+ ArrivalWebsocket.onopen = this.socket_onopen;
|
|
|
244
|
+ ArrivalWebsocket.onmessage = this.socket_onmessage;
|
|
|
245
|
+ ArrivalWebsocket.init();
|
|
|
246
|
+ },
|
|
|
247
|
+ destroyed() {
|
|
|
248
|
+ },
|
|
|
249
|
+ watch: {},
|
|
|
250
|
+ }
|
|
|
251
|
+</script>
|
|
|
252
|
+
|
|
|
253
|
+<style scoped>
|
|
|
254
|
+
|
|
|
255
|
+</style> |