diff --git a/src/views/modules/base/smartExcel/cpts/excel-view.vue b/src/views/modules/base/smartExcel/cpts/excel-view.vue index 72cb621ab..ebf75d9f1 100644 --- a/src/views/modules/base/smartExcel/cpts/excel-view.vue +++ b/src/views/modules/base/smartExcel/cpts/excel-view.vue @@ -83,12 +83,12 @@ export default { async loadWorkBook() { const data = await this.$http.post(`/actual/base/luckySheet/workbook/load?workbookId=${this.workbookId}`) window.luckysheet.destroy(); - options.data = data.data + options.data = data.data; window.luckysheet.create({ ...options, hook: { cellEditBefore: this.handleCellEditBefore, - // cellUpdateBefore: this.handleCellUpdateBefore, + updated: this.handleCellUpdateBefore, sheetCreateAfter: this.handleSheetCreateAfter, cellUpdated: this.handleCellUpdated, }, @@ -97,10 +97,13 @@ export default { handleSheetCreateAfter(e) { console.log('setsheet', e); }, + isOpen(ws) { + return ws.readyState === ws.OPEN + }, initSocket() { const {id} = this.$store.state.user;//${location.origin} const token = localStorage.getItem("token") - this.socket = new WebSocket(`ws://192.168.1.144/api/actual/base/ws/luckysheet/${this.workbookId}/${id}`,token); + this.socket = new WebSocket(`ws://219.146.91.110:30801/api/actual/base/ws/luckysheet/${this.workbookId}/${id}`,token); this.socket.addEventListener('open', () => { console.log('WebSocket连接已打开'); }); @@ -111,7 +114,11 @@ export default { }); }, sendMessage(message) { - this.socket.send(JSON.stringify(message)); + if (this.isOpen(this.socket)) { + this.socket.send(JSON.stringify(message)); + } else { + console.info('链接已经断开'); + } }, handleClickMenu(i) { this.menuActive = i; @@ -178,8 +185,8 @@ export default { this.selectedCell = "第" + row + "行" + "第" + column + "列"; }, - handleCellUpdateBefore() { - this.selectedCell = ""; + handleCellUpdateBefore(e) { + console.log(e); }, handleTabClick(tab, event) { console.log(tab, event);