index.html 21.5 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812
<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<!-- import CSS -->
	<link rel="stylesheet" href="./css/index.css">
	<style>
		[v-cloak] {
			display: none !important;
		}

		.div-class:after,
		.div-class:before {
			content: '';
			display: table;
		}

		.div-class:after {
			clear: both;
		}

		.div-class {
			margin-bottom: 10px;
		}

		.condition-left {
			float: left;
		}

		.condition-right {
			float: right;
		}

		.input-class {
			width: 200px;
		}

		.refress-sel {
			width: 100px;
		}

		.refresh-text {
			color: #303133;
		}

		.fixed-box {
			position: absolute;
			right: 0;
			top: 0;
			z-index: 999;
			height: 100vh;
			width: 50vw;
			background-color: rgba(255, 255, 255, 1);
			color: #000;
			box-shadow: 1px 1px 1px 1px rgba(0, 0, 0, .5);
			overflow: auto;
		}

		.collapse-span {
			display: block;
			width: 12px;
			height: 60px;
			line-height: 60px;
			text-align: center;
			border-radius: 2px;
			padding: 4px 0;
			box-shadow: 1px 1px 1px 1px rgba(0, 0, 0, .5);
			cursor: pointer;
			position: absolute;
			right: 50%;
			top: 50%;
			margin-left: -7px;
		}
		.message-text {
			margin: 0;
			padding: 10px 5px 10px;
			text-align: left;
			font-size: 14px;
			border-bottom: 1px dashed #ccc;
		}
		/* .order-span {
			position: relative;
			z-index: 1;
			display: inline-flex;
			justify-content: center;
			align-items: center;
			width: 14px; 
			height: 14px;
			font-size: 12px;
			box-sizing: border-box;
			background: #fff;
			transition: .15s ease-out;
			border-radius: 50%;
			border: 1px solid;
			border-color: #000;
		}
		.order-span-inner {
			display: inline-block;
			user-select: none;
			text-align: center;
			font-weight: normal;
			line-height: 1;
			color: #888;
		} */
		.el-table--enable-row-hover .el-table__body tr.offline-row:hover>td {
			color: #fb453d;	/*#fb453d*/
		}

		/* .el-table--border .offline-row td {
			border-right-color: #FF5151;
		} */

		.offline-row {
			color: #fb453d !important;
			/* color: #fff; */
		}
		.shake {
			font-size: 16px;
			animation: shake 1s ease-in infinite;
		}

		.test {
			color: #000;
		}

		.iplink-column {
			text-decoration: underline;
		}

		.slide-wrapper {
			position: absolute;
			top: 10px;
			right: 38px;
			z-index: 2;
		}

		.expirationtime-span {
			padding-right: 10px;
		}

		.download-btn {
			border-radius: 2px;
		}

		.upload-btn {
			 display: inline-block;
		}

		@keyframes shake {
			0% {
				opacity: 1;
				font-size: 16px;
			}
			100% {
				opacity: 0;
				font-size: 12px;
			}
		}
	</style>
</head>

<body>
	<div id="app" v-cloak>
		<div class="slide-wrapper">
			<span>授权到期时间: </span>
			<span class="expirationtime-span">{{ overTime }}</span>
			<el-button type="primary" @click="handleDownload" size="mini" class="inline-btn download-btn"><i class="el-icon-download el-icon--left"></i>服务器信息下载</el-button>
			<el-upload
				class="inline-btn upload-btn"
				:show-file-list="false"
				:action="uploadUrl"
				:before-upload="handleBeforeUpload"
				:on-change="handleChange"
				:on-success="handleSuccess"
				:on-error="handleError">
				<el-button size="mini" type="primary" :loading="uploadLoading">{{uploadText}}</el-button>
				<!-- <div slot="tip" class="el-upload__tip">只能上传.lic文件,且不超过500kb</div> -->
			</el-upload>
		</div> 
		<el-tabs v-model="activeName">
			<el-tab-pane label="设备列表" name="first">
				<div class="div-class">
					<div class="condition-left">
						<el-input class="input-class" v-model="searchIpVal" placeholder="请输入IP">
						</el-input>
						<el-input class="input-class" v-model="searchserialVal" placeholder="请输入序列号">
						</el-input>
						<el-select v-model="devStatus" placeholder="请选择设备状态">
							<el-option label="全部" value=""></el-option>
							<el-option label="在线" value="在线"></el-option>
							<el-option label="离线" value="离线"></el-option>
						</el-select>
						<el-button @click="search">查询</el-button>
					</div>
					<div class="condition-right">
						<span class="refresh-text">间隔刷新:</span>
						<el-select v-model="refreshTime" placeholder="请选择刷新间隔" @change="refreshHandle" class="refress-sel">
							<el-option label="30s" :value="30"></el-option>
							<el-option label="60s" :value="60"></el-option>
							<el-option label="90s" :value="90"></el-option>
						</el-select>
						<el-switch
							style="margin-left: 10px;margin-right: 30px;"
							sortable
							@change="change1"
							v-model="isDetail"
							active-text="详细"
							inactive-text="简洁">
						</el-switch>
					</div>
					<!-- <span class="shake">在线</span> -->
				</div>
				
				<!-- order: 'descending' -->
				<el-table
				  :border='true'
				  sortable
				  :height='heights'
				  :data="tableData"
				  :row-class-name="rowToggleClass"
				  :cell-class-name="cellToggleClass"
				  @row-click="rowClickHandle"
				  tooltip-effect="light"
				  :default-sort="{ prop: 'ip' }"
				  style="width: 100%">
					<el-table-column type="index" width="50" align="center">
					</el-table-column>
					<el-table-column
					  v-for="col in cols"
					  sortable
					  align="center"
					  show-overflow-tooltip
					  :prop="col.prop"
					  :label="col.label"
					  :formatter="col.formatter">
						<!-- <template slot-scope="scope">
							<a :href="scope.row.ip ? 'http://' + scope.row.ip + ':8080' : 'javascript:;'" class="iplink-column" target="_blank" v-if="scope.row.ip">{{ scope.row }}</a>
							<span v-else>{{ scope.row }}</span>
						</template> -->
					</el-table-column>
					
				</el-table>
			</el-tab-pane>
			<!-- <el-tab-pane label="系统日志" name="second">
		    	<el-switch
		  		 style="float: right;margin-bottom: 10px;margin-right: 30px;"
		  		 @change="logChange"
				  v-model="isLogDetail"
				  active-text="详细"
				  inactive-text="简洁">
				</el-switch>
		    	<el-table
		    	  :border='true'
			      :data="logData"
			       :height='heights'
			      style="width: 100%">
			      <el-table-column v-for="col in logCols"
			        :prop="col.prop"
			        :label="col.label">
			      </el-table-column>
			    </el-table>
			    <el-pagination
			    	@current-change="pageChange"
				    layout="prev, pager, next"
				    :total="pageTotal">
				  </el-pagination>

		    </el-tab-pane>
		    <el-tab-pane label="配置管理" name="third">角色管理</el-tab-pane> -->
		</el-tabs>
		<div class="fixed-box" v-show="detailVisible">
			<div class="message-text" v-for="(item, index) in wsMessage">
				<!-- <div class="order-span">
					<div class="order-span-inner">{{ index + 1 }}</div>
				</div> -->
				<span>{{ index + 1 }}.</span>
				<span>{{ item }}</span>
			</div>
		</div>
		<span class="collapse-span" @click="collapse" v-show="detailVisible" title="折叠">></span>
	</div>
	<script src="./js/jquery-3.1.0.min.js" type="text/javascript" charset="utf-8"></script>
	<!-- import Vue before Element -->
	<script src="js/vue.js"></script>
	<!-- import JavaScript -->
	<script src="js/index.js"></script>
	<script src="js/common.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/data.js"></script>
	<script>
		var tableHeight = $(window).height() - 150;
		function formatterStatus(row, column, cellValue, index) {
			var time = Date.parse(new Date());
			// console.log(timestamp3)
			if (row.lastALiveTime) {
				var lastALiveTime = Date.parse(row.lastALiveTime)
				if ((time - lastALiveTime) < 300000) {
					return '在线'
				} else {
					return '离线'
				}
			} else {
				return '离线'
			}
		}
		new Vue({
			el: '#app',
			watch: {
				// 比较是否同为在线/离线
				// tableData(newVal, oldVal) {
				// 	console.log(newVal, oldVal)
				// 	if(newVal.length == oldVal.length) {
				// 		newVal.forEach((item, index) => {
				// 			if(item.serialNum === oldVal[index].serialNum && item.status !== oldVal[index].status) {
				// 				// 状态更新了
				// 			} else {
				// 				// 状态未改变
				// 			}
				// 		})
				// 	}
					
				// }
			},
			data: function () {
				return {
					heights: tableHeight,
					activeName: 'first',
					isDetail: false,
					isLogDetail: false,
					pageTotal: 0,
					tableData: [],
					logData: [],
					searchVal: '',
					searchIpVal: '',
					searchserialVal: '',
					cols: [
						{ prop: 'name', label: '设备名称' },
						{ prop: 'ip', label: '设备IP' },
						{ prop: 'serialNum', label: '设备序列号' },
						{ prop: 'vasType', label: '设备类型' },
						{ prop: 'lastALiveTime', label: '心跳时间' },
						// {prop:'state',label:'连接状态',formatter:formatterStatus}
						{ prop: 'status', label: '连接状态' }
					],
					logCols: [
						{ prop: 'id', label: '序号' },
						{ prop: 'date', label: '时间' },
						{ prop: 'standardLevel', label: '级别' },
						{ prop: 'message', label: '日志信息' }
					],
					devWs: null,
					devWsClock: null,
					stateWs: null,
					stateWsClock: null,
					detailVisible: false,
					wsMessage: [],
					panelShow: false,
					refreshTime: 30,
					devStatus: '',
					dataTimer: null,
					overTime: 'xxxx - xx - xx',
					uploadUrl: processUrl + '/api/v1/license/upload',
					uploadText: '点击上传',
					uploadLoading: false
				}
			},
			created: function () {
				// this.getMockData();
				this.getExpirationTime();	// 获取到期时间
				this.getRemoteData();
				var that = this;
				document.addEventListener('click', function(ev) {
					var e = ev || window.event;
					if(that.panelShow) {
						var panel = $('.fixed-box');
						if (!panel.is(e.target) && panel.has(e.target).length == 0) {
							try {
								that.collapse();
							} catch (error) { }
						}
					}
				})
			},
			mounted() {
				window.sessionStorage.removeItem('tablelist');
			},
			methods: {
				singleCellClass(col) {
					// console.log('singleCellClass', col)
					// if(col.prop === 'status') {
					// 	return 'shake';
					// }
				},
				rowToggleClass(row) {
					// console.log('row', row.row)
					if(row.row.status === '离线') {
						return 'offline-row'
					} else {
						return '';
					}
				},
				cellToggleClass({row, column, rowIndex, columnIndex}) {
					// console.log('cell', row, column, rowIndex, columnIndex)
					// if(rowIndex >= 0 && columnIndex === 6) {
					// 	return 'shake';
					// } else {
					// 	return ''
					// }
				},
				getMockData() {
					// data
					window.sessionStorage.removeItem('tablelist');
					this.tableData = data.data;
					var time = Date.parse(new Date());
					this.tableData.forEach(item => {
						if (item.lastALiveTime) {
							var lastALiveTime = Date.parse(item.lastALiveTime)
							if ((time - lastALiveTime) < 300000) {
								return item.status = '在线'
							} else {
								return item.status = '离线';
							}
						} else {
							return item.status = '离线'
						}
					});
					window.sessionStorage.setItem('tablelist', JSON.stringify(this.tableData));
					// console.log(data.data)
					let _this = this;
					if(_this.refreshTime) {
						clearInterval(_this.dataTimer);
						_this.dataTimer = setInterval(function() {
							// console.log(data.data)
							data.data.push({
								"vaCount": 4,
								"localPort": 0,
								"vasType": 2,
								"state": 1,
								"connectionType": 2,
								"code": "VIONCOUNT_1001",
								"name": "192.168.100.103",
								"analysisVer": "COUNT_ALG-2.1.0_r65859_face",
								"serialNum": "CBC2-5533-5401-AFCB",
								"nic": "00-10-14-00-3c-f3",
								"ip": "192.168.100.103",
								"softwareVer": "COUNT_SOFT_CBOX_V.2.1_r69665",
								"hardwareVer": "VIONCOUNT_HARD_CBOX_1.0",
								"description": "",
								"lastALiveTime": "2019-03-11 13:34:55",
								"needResponse": true
							})
							_this.getMockData();
						}, _this.refreshTime * 1000);
					}
				},
				getExpirationTime() {
					var _this = this;
					_this.overTime = 'xxxx - xx - xx';
					$.ajax({
						url: processUrl + "/api/v1/license/date",
						async: true,
						success: function (data) {
							if(data.code == 200) {
								_this.overTime = data.data || 'xxxx - xx - xx';
							}
						},
						error: function(err) {
							console.log(err)
						}
					});
				},
				getRemoteData() {
					var _this = this;
						// _apiUrl = 'http://mall.keliuyun.com:9502/';
					$.ajax({
						url: apiUrl + "/api/v1/devices",
						async: true,
						success: function (data) {
							window.sessionStorage.removeItem('tablelist');
							_this.tableData = data.data;
							var time = Date.parse(new Date());
							_this.tableData.forEach(item => {
								if(item.connectionType == 1) {
									item.status = item.lastALiveTime ? _this.httpStatus(item.lastALiveTime) : '离线';
								} else {
									item.status = item.state == 0 ? '离线' : '在线';	// connectType: 2
								}
							});
							window.sessionStorage.setItem('tablelist', JSON.stringify(_this.tableData));
							if(!_this.stateWs) {
								_this.loadStateWs();
							}
							if(_this.refreshTime) {
								clearInterval(_this.dataTimer);
								_this.dataTimer = setInterval(function() {
									_this.getRemoteData();
								}, _this.refreshTime * 1000);
							}
							// console.log(_this.tableData)
						},
						error: function(err) {
							console.log(err)
						}
					});
					// console.log('local data', data)
				},
				refreshHandle() {
					var _this = this;
					clearInterval(_this.dataTimer);
					_this.dataTimer = setInterval(function() {
						_this.getRemoteData();
					}, _this.refreshTime * 1000);
				},
				// connectType: 1
				httpStatus(lastALiveTime) {
					var status = '';
					var time = Date.parse(new Date());
					var lastALive = Date.parse(lastALiveTime)
					if ((time - lastALive) < 300000) {
						status = '在线';
					} else {
						status = '离线';
					}
					return status;
				},
				loadStateWs() {
					var wsHost = apiUrl ? apiUrl : window.location.host;	// window.location.host
					if(this.stateWs) {
						this.stateWs.close();
						this.stateWs = null;
					}
					var socketUrl = '';
					// socketUrl = 'ws://' + wsHost + '/devices/log/' + row.serialNum;
					socketUrl = 'ws://' + wsHost + '/devices/status';
					this.openStateWs(socketUrl);
				},
				openStateWs(wsUrl) {
					// browser 兼容
					var that = this;
					if ("WebSocket" in window) {
						this.stateWs = new WebSocket(wsUrl);
					} else if ("MozWebSocket" in window) {
						this.stateWs = new MozWebSocket(wsUrl);
					} else {
						this.stateWs = new SockJS(wsUrl);
					}
					try {
						this.stateWs.onopen = function (event) {
							console.log("WebSocket:已连接");
							// console.log('stateWs', that.stateWs)
							// stateWsClock = setInterval(this.wsClock, 20000);
						}
						this.stateWs.onclosed = function () {
							console.log("WebSocket关闭")
						};

						this.stateWs.onmessage = function (evt) {
							console.log('Received stateWs message:' + evt.data, JSON.parse(evt.data));
							// that.wsMessage.push(evt.data.replace(/\"/g, ''));
							// devWs.close();
						}

						this.stateWs.onerror = function (event) {
							console.log("设备WebSocket:发生错误 ");
							console.log(event);
						};
					} catch (error) {
						
					}
				},
				search() {
					// filter [ip, serialNum, status]
					var queryStr = this.searchIpVal || this.searchserialVal || this.devStatus;
					// console.log('queryStr', queryStr)
					var that = this;
					this.querySearch(queryStr, function(res) {
						that.tableData = res;
					})
				},
				querySearch(queryString, cb) {
					var localList = JSON.parse(window.sessionStorage.getItem('tablelist'));
					var filters = { ip: 'ip', serialNum: 'serialNum', status: 'status' };
					var filterKeys = Object.keys(filters);
					queryString = queryString.toLocaleLowerCase();
					var result = queryString
						? localList.filter((item) => {
							if(!!~item['ip'].toLocaleLowerCase().indexOf(queryString)) {
								return true;
							}
							if(!!~item['serialNum'].toLocaleLowerCase().indexOf(queryString)) {
								return true;
							}
							if(!!~item['status'].toLocaleLowerCase().indexOf(queryString)) {
								return true;
							}
						})
						: localList;
					// console.log('filter result', result)
					cb(result);
				},
				checkType(item) {
					var _tostring = Object.prototype.toString;
					return toString.call(item).slice(8, -1);
				},
				isExist(filterArr, key, val) {
					if(filterArr.length > 0) {
						return filterArr.some(item => item[key] == val);
					} else {
						return false;
					}
				},
				addCol: function () {
					var arr = [
						{ prop: 'vaCount', label: '通道数' },
						{ prop: 'nic', label: '网卡地址' },
						{ prop: 'analysisVer', label: '算法版本' },
						{ prop: 'softwareVer', label: '软件版本' },
						{ prop: 'hardwareVer', label: '硬件版本' }
					]
					for (var i = 0; i < arr.length; i++) {
						this.cols.push(arr[i])
					}
				},
				delCol: function () {
					var index = 0;
					for (var i = 0; i < this.cols.length; i++) {
						if (this.cols[i].prop == 'vaCount') {
							index = i;
							break;
						}
					}
					this.cols.splice(index, 5);
				},
				change1: function (val) {
					if (val) {
						this.addCol();
					} else {
						this.delCol()
					}
				},
				logChange: function (val) {
					if (val) {
						this.addLogCol();
					} else {
						this.delLogCol()
					}
				},
				addLogCol: function () {
					var arr = [
						{ prop: 'className', label: 'className' },
						{ prop: 'methodName', label: 'methodName' },
						{ prop: 'lineNumber', label: 'lineNumber' }
					]
					for (var i = 0; i < arr.length; i++) {
						var index = i + 2;
						this.logCols.splice(index, 0, arr[i])
					}
				},
				delLogCol: function () {
					var index = 0;
					for (var i = 0; i < this.logCols.length; i++) {
						if (this.logCols[i].prop == 'date') {
							index = i + 1;
							break;
						}
					}
					this.logCols.splice(index, 3);
				},
				pageChange: function (page) {
					var _this = this;
					$.ajax({
						type: "get",
						// url: "http://192.168.9.242:9502/api/v1/logs",
						url:urls+"/logs",
						async: true,
						data: {
							page: page,
							pageSize: 20
						},
						success: function (data) {
							_this.logData = [];
							for (var i = 0; i < data.data.length; i++) {
								var index = 1 + i;
								var item = {
									id: index,
									standardLevel: data.data[i].level,
									message: data.data[i].message,
									className: data.data[i].source.className,
									methodName: data.data[i].source.methodName,
									lineNumber: data.data[i].source.lineNumber,
									date: data.data[i].date
								}
								_this.logData.push(item)
							}
						}
					});
				},	
				rowClickHandle(row, event, column) {
					// console.log('row click:', row, event, column)
					var wsHost = apiUrl || window.location.host;	// window.location.host
					if(this.devWs) {
						this.devWs.close();
						this.devWs = null;
					}
					this.detailVisible = true;
					this.wsMessage = [];
					var socketUrl = '';
					// socketUrl = 'ws://' + wsHost + '/devices/log/' + row.serialNum;
					socketUrl = 'ws://' + wsHost + '/devices/log/' + row.serialNum;
					this.openWs(socketUrl);
				},
				openWs(wsUrl) {
					// browser 兼容
					// var devWs = null;
					var that = this;
					if ("WebSocket" in window) {
						this.devWs = new WebSocket(wsUrl);
					} else if ("MozWebSocket" in window) {
						this.devWs = new MozWebSocket(wsUrl);
					} else {
						this.devWs = new SockJS(wsUrl);
					}
					try {
						this.devWs.onopen = function (event) {
							console.log("WebSocket:已连接");
							that.panelShow = true;
							// console.log('devWs', that.devWs)
							// devWsClock = setInterval(this.wsClock, 20000);
						}
						this.devWs.onclosed = function () {
							console.log("WebSocket关闭")
						};

						this.devWs.onmessage = function (evt) {
							// console.log('Received message:' + evt.data);
							that.wsMessage.push(evt.data.replace(/\"/g, ''));
							// devWs.close();
						}

						this.devWs.onerror = function (event) {
							console.log("设备WebSocket:发生错误 ");
							console.log(event);
						};
					} catch (error) {
						
					}
				},
				collapse() {
					this.wsMessage = [];
					this.detailVisible = false;
					if(this.devWs) {
						this.devWs.close();
					}
					this.panelShow = false;
				},
				wsClock() {
					var date = new Date();
					var datatimes = date.getTime();
					if (devWs.readyState == 1) {
						try {
							// devWs.send(JSON.stringify(devMessage));
						} catch (err) {
							console.log(err);
						}
					} else {
						clearInterval(devWsClock);
					}
				},
				handleBeforeUpload(file) {
					var fileName = file.name;
					var ext = fileName.slice((fileName.lastIndexOf('.') - 1 >>> 0) + 2);
					var isLic = ext === 'lic';
					if(!isLic) {
						this.$message.error('格式错误! 请上传正确格式的授权文件!');
					}
					return isLic;
				},
				handleChange(file, fileList) {
					this.uploadText = '上传中...';
					this.uploadLoading = true;
				},
				handleSuccess(response, file, fileList) {
					if(response.code == 200) {
						this.$message.success('上传成功!');
						this.getExpirationTime();
					} else {
						this.$message.error(response.msg);
					}
					var that = this;
					setTimeout(function() {
						that.uploadText = '点击上传';
						that.uploadLoading = false;
					}, 1000)
				},
				handleError(err, file, fileList) {
					this.$message.error('上传失败!' + err.msg);
					var that = this;
					setTimeout(function() {
						that.uploadText = '点击上传';
						that.uploadLoading = false;
					}, 1000)
				},
				handleDownload() {
					var _this = this;
					window.location.href = processUrl + "/api/v1/license/machineInfo";
				}
			}
		})
	</script>
</body>

</html>