From ab2d8b7b5467200e12c8d4c1ece014ebfc6ee7cc Mon Sep 17 00:00:00 2001 From: renxxing <74659302+renxxing@users.noreply.github.com> Date: Wed, 25 Nov 2020 16:40:37 +0800 Subject: [PATCH] fix(fix #209): highlight highlight follow --- src/controllers/handler.js | 9 +- src/controllers/select.js | 358 +++++++++++++++++++++--------------- src/controllers/server.js | 36 +++- src/controllers/sheetBar.js | 2 - src/global/refresh.js | 11 +- src/index.html | 9 +- src/store/index.js | 4 +- 7 files changed, 261 insertions(+), 168 deletions(-) diff --git a/src/controllers/handler.js b/src/controllers/handler.js index 2af6e34ec..5d4904a1f 100644 --- a/src/controllers/handler.js +++ b/src/controllers/handler.js @@ -76,8 +76,6 @@ export default function luckysheetHandler() { if(isMobile){ mobileinit(); } - - if (!Date.now) Date.now = function() { return new Date().getTime(); }; //requestAnimationFrame method @@ -3263,7 +3261,6 @@ export default function luckysheetHandler() { }); //表格mouseup $(document).on("mouseup.luckysheetEvent",function (event) { - if(luckysheetConfigsetting && luckysheetConfigsetting.hook && luckysheetConfigsetting.hook.sheetMouseup){ let mouse = mouseposition(event.pageX, event.pageY); let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft(); @@ -3661,14 +3658,14 @@ export default function luckysheetHandler() { jfrefreshgrid_rhcw(Store.flowdata.length, null); } - + //改变列宽 if (Store.luckysheet_cols_change_size) { Store.luckysheet_cols_change_size = false; $("#luckysheet-change-size-line").hide(); $("#luckysheet-cols-change-size").css("opacity", 0); $("#luckysheet-sheettable, #luckysheet-cols-h-c, .luckysheet-cols-h-cells, .luckysheet-cols-h-cells canvas").css("cursor", "default"); - + let mouse = mouseposition(event.pageX, event.pageY); let scrollLeft = $("#luckysheet-cols-h-c").scrollLeft(); let x = mouse[0] + scrollLeft; @@ -3681,9 +3678,9 @@ export default function luckysheetHandler() { col = col_location[1], col_pre = col_location[0], col_index = col_location[2]; - let size = (x + 3) - Store.luckysheet_cols_change_size_start[0]; + let firstcolumnlen = Store.defaultcollen; if (Store.config["columnlen"] != null && Store.config["columnlen"][Store.luckysheet_cols_change_size_start[1]] != null) { firstcolumnlen = Store.config["columnlen"][Store.luckysheet_cols_change_size_start[1]]; diff --git a/src/controllers/select.js b/src/controllers/select.js index a4c1b01cc..1ff029f03 100644 --- a/src/controllers/select.js +++ b/src/controllers/select.js @@ -10,61 +10,61 @@ import locale from '../locale/locale'; //公式函数 选区实体框 function seletedHighlistByindex(id, r1, r2, c1, c2) { - let row = Store.visibledatarow[r2], + let row = Store.visibledatarow[r2], row_pre = r1 - 1 == -1 ? 0 : Store.visibledatarow[r1 - 1]; - let col = Store.visibledatacolumn[c2], + let col = Store.visibledatacolumn[c2], col_pre = c1 - 1 == -1 ? 0 : Store.visibledatacolumn[c1 - 1]; - $('#' + id).css({ - "left": col_pre, - "width": col - col_pre - 1, - "top": row_pre, - "height": row - row_pre - 1 + $('#' + id).css({ + "left": col_pre, + "width": col - col_pre - 1, + "top": row_pre, + "height": row - row_pre - 1 }); } //Set selection highlight -function selectHightlightShow(isRestore=false) { +function selectHightlightShow(isRestore = false) { $("#luckysheet-cell-selected-boxs").show(); $("#luckysheet-cell-selected-boxs #luckysheet-cell-selected").siblings(".luckysheet-cell-selected").remove(); - if(Store.luckysheet_select_save.length > 0){ - for(let i = 0; i < Store.luckysheet_select_save.length; i++){ - let r1 = Store.luckysheet_select_save[i].row[0], - r2 = Store.luckysheet_select_save[i].row[1]; - let c1 = Store.luckysheet_select_save[i].column[0], + if (Store.luckysheet_select_save.length > 0) { + for (let i = 0; i < Store.luckysheet_select_save.length; i++) { + let r1 = Store.luckysheet_select_save[i].row[0], + r2 = Store.luckysheet_select_save[i].row[1]; + let c1 = Store.luckysheet_select_save[i].column[0], c2 = Store.luckysheet_select_save[i].column[1]; - + let rf, cf; - if(Store.luckysheet_select_save[i].row_focus == null){ + if (Store.luckysheet_select_save[i].row_focus == null) { rf = r1; } - else{ - rf = Store.luckysheet_select_save[i].row_focus; + else { + rf = Store.luckysheet_select_save[i].row_focus; } - if(Store.luckysheet_select_save[i].column_focus == null){ + if (Store.luckysheet_select_save[i].column_focus == null) { cf = c1; } - else{ + else { cf = Store.luckysheet_select_save[i].column_focus; } - let row = Store.visibledatarow[r2], + let row = Store.visibledatarow[r2], row_pre = r1 - 1 == -1 ? 0 : Store.visibledatarow[r1 - 1]; - let col = Store.visibledatacolumn[c2], + let col = Store.visibledatacolumn[c2], col_pre = c1 - 1 == -1 ? 0 : Store.visibledatacolumn[c1 - 1]; - let row_f = Store.visibledatarow[rf], + let row_f = Store.visibledatarow[rf], row_pre_f = rf - 1 == -1 ? 0 : Store.visibledatarow[rf - 1]; - let col_f = Store.visibledatacolumn[cf], + let col_f = Store.visibledatacolumn[cf], col_pre_f = cf - 1 == -1 ? 0 : Store.visibledatacolumn[cf - 1]; let margeset = menuButton.mergeborer(Store.flowdata, rf, cf); - if(!!margeset){ + if (!!margeset) { row_f = margeset.row[1]; row_pre_f = margeset.row[0]; - + col_f = margeset.column[1]; col_pre_f = margeset.column[0]; } @@ -85,81 +85,81 @@ function selectHightlightShow(isRestore=false) { Store.luckysheet_select_save[i]["top_move"] = row_pre; Store.luckysheet_select_save[i]["height_move"] = row - row_pre - 1; - if(i == 0){ - if(Store.luckysheet_select_save.length == 1){ - if(browser.mobilecheck()){//移动端 - $("#luckysheet-cell-selected-boxs #luckysheet-cell-selected").css({ - "left": Store.luckysheet_select_save[i]["left_move"], - "width": Store.luckysheet_select_save[i]["width_move"], - "top": Store.luckysheet_select_save[i]["top_move"], - "height": Store.luckysheet_select_save[i]["height_move"], - "display": "block", - "border": "1px solid #0188fb" + if (i == 0) { + if (Store.luckysheet_select_save.length == 1) { + if (browser.mobilecheck()) {//移动端 + $("#luckysheet-cell-selected-boxs #luckysheet-cell-selected").css({ + "left": Store.luckysheet_select_save[i]["left_move"], + "width": Store.luckysheet_select_save[i]["width_move"], + "top": Store.luckysheet_select_save[i]["top_move"], + "height": Store.luckysheet_select_save[i]["height_move"], + "display": "block", + "border": "1px solid #0188fb" }) - .find(".luckysheet-cs-draghandle") - .css("display", "block") - .end() - .find(".luckysheet-cs-fillhandle") - .css("display", "none") - .end() - .find(".luckysheet-cs-touchhandle") - .css("display", "block"); + .find(".luckysheet-cs-draghandle") + .css("display", "block") + .end() + .find(".luckysheet-cs-fillhandle") + .css("display", "none") + .end() + .find(".luckysheet-cs-touchhandle") + .css("display", "block"); } - else{ - $("#luckysheet-cell-selected-boxs #luckysheet-cell-selected").css({ - "left": Store.luckysheet_select_save[i]["left_move"], - "width": Store.luckysheet_select_save[i]["width_move"], - "top": Store.luckysheet_select_save[i]["top_move"], - "height": Store.luckysheet_select_save[i]["height_move"], - "display": "block", - "border": "1px solid #0188fb" + else { + $("#luckysheet-cell-selected-boxs #luckysheet-cell-selected").css({ + "left": Store.luckysheet_select_save[i]["left_move"], + "width": Store.luckysheet_select_save[i]["width_move"], + "top": Store.luckysheet_select_save[i]["top_move"], + "height": Store.luckysheet_select_save[i]["height_move"], + "display": "block", + "border": "1px solid #0188fb" }) + .find(".luckysheet-cs-draghandle") + .css("display", "block") + .end() + .find(".luckysheet-cs-fillhandle") + .css("display", "block") + .end() + .find(".luckysheet-cs-touchhandle") + .css("display", "none"); + } + } + else { + $("#luckysheet-cell-selected-boxs #luckysheet-cell-selected").css({ + "left": Store.luckysheet_select_save[i]["left_move"], + "width": Store.luckysheet_select_save[i]["width_move"], + "top": Store.luckysheet_select_save[i]["top_move"], + "height": Store.luckysheet_select_save[i]["height_move"], + "display": "block", + "border": "1px solid rgba(1, 136, 251, 0.15)" + }) .find(".luckysheet-cs-draghandle") - .css("display", "block") + .css("display", "none") .end() .find(".luckysheet-cs-fillhandle") - .css("display", "block") - .end() - .find(".luckysheet-cs-touchhandle") .css("display", "none"); - } - } - else{ - $("#luckysheet-cell-selected-boxs #luckysheet-cell-selected").css({ - "left": Store.luckysheet_select_save[i]["left_move"], - "width": Store.luckysheet_select_save[i]["width_move"], - "top": Store.luckysheet_select_save[i]["top_move"], - "height": Store.luckysheet_select_save[i]["height_move"], - "display": "block", - "border": "1px solid rgba(1, 136, 251, 0.15)" - }) - .find(".luckysheet-cs-draghandle") - .css("display", "none") - .end() - .find(".luckysheet-cs-fillhandle") - .css("display", "none"); } } - else{ - $("#luckysheet-cell-selected-boxs").append('
'); + else { + $("#luckysheet-cell-selected-boxs").append('
'); } - if(i == Store.luckysheet_select_save.length - 1){ + if (i == Store.luckysheet_select_save.length - 1) { //focus 取选区数组最后一个 - $("#luckysheet-cell-selected-focus").css({ - "left": Store.luckysheet_select_save[i]["left"], - "width": Store.luckysheet_select_save[i]["width"], - "top": Store.luckysheet_select_save[i]["top"], - "height": Store.luckysheet_select_save[i]["height"], - "display": "block" + $("#luckysheet-cell-selected-focus").css({ + "left": Store.luckysheet_select_save[i]["left"], + "width": Store.luckysheet_select_save[i]["width"], + "top": Store.luckysheet_select_save[i]["top"], + "height": Store.luckysheet_select_save[i]["height"], + "display": "block" }); //行列数 luckysheet_count_show( - Store.luckysheet_select_save[i]["left_move"], - Store.luckysheet_select_save[i]["top_move"], - Store.luckysheet_select_save[i]["width_move"], - Store.luckysheet_select_save[i]["height_move"], - [r1, r2], + Store.luckysheet_select_save[i]["left_move"], + Store.luckysheet_select_save[i]["top_move"], + Store.luckysheet_select_save[i]["width_move"], + Store.luckysheet_select_save[i]["height_move"], + [r1, r2], [c1, c2] ); //左上角选择区域框 @@ -170,13 +170,13 @@ function selectHightlightShow(isRestore=false) { } //行列标题栏 - selectTitlesShow(Store.luckysheet_select_save,isRestore); + selectTitlesShow(Store.luckysheet_select_save, isRestore); //左上角范围显示 selectHelpboxFill(); - + //动态数组显示 - if(Store.luckysheet_select_save.length == 1 && Store.luckysheet_select_save[0].row[0] == Store.luckysheet_select_save[0].row[1] && Store.luckysheet_select_save[0].column[0] == Store.luckysheet_select_save[0].column[1]){ + if (Store.luckysheet_select_save.length == 1 && Store.luckysheet_select_save[0].row[0] == Store.luckysheet_select_save[0].row[1] && Store.luckysheet_select_save[0].column[0] == Store.luckysheet_select_save[0].column[1]) { dynamicArrayHightShow(Store.luckysheet_select_save[0].row[0], Store.luckysheet_select_save[0].column[0]); } } @@ -185,19 +185,19 @@ function selectHightlightShow(isRestore=false) { } //选区标题栏 -function selectTitlesShow(rangeArr,isRestore=false) { +function selectTitlesShow(rangeArr, isRestore = false) { let s = $.extend(true, [], rangeArr); let rowTitleMap = {}, columnTitleMap = {}; - for(let i = 0; i < s.length; i++){ + for (let i = 0; i < s.length; i++) { let r1 = s[i]["row"][0], r2 = s[i]["row"][1], c1 = s[i]["column"][0], c2 = s[i]["column"][1]; - + // if(isRestore){ // let margeset = menuButton.mergeborer(Store.flowdata, r1, c1); // if(!!margeset){ // r1 = margeset.row[2]; // r2 = margeset.row[3]; - + // c1 = margeset.column[2]; // c2 = margeset.column[3]; // } @@ -212,29 +212,30 @@ function selectTitlesShow(rangeArr,isRestore=false) { $("#luckysheet-rows-h-selected").empty(); let rowTitleRange = selectTitlesRange(rowTitleMap); - for(let i = 0; i < rowTitleRange.length; i++){ + for (let i = 0; i < rowTitleRange.length; i++) { let r1 = rowTitleRange[i][0], r2 = rowTitleRange[i][rowTitleRange[i].length - 1]; let row = rowLocationByIndex(r2)[1], row_pre = rowLocationByIndex(r1)[0]; - - $("#luckysheet-rows-h-selected").append('
'); + + $("#luckysheet-rows-h-selected").append('
'); } //列标题 $("#luckysheet-cols-h-selected").empty(); let columnTitleRange = selectTitlesRange(columnTitleMap); - for(let j = 0; j < columnTitleRange.length; j++){ + for (let j = 0; j < columnTitleRange.length; j++) { let c1 = columnTitleRange[j][0], c2 = columnTitleRange[j][columnTitleRange[j].length - 1]; let col = colLocationByIndex(c2)[1], col_pre = colLocationByIndex(c1)[0]; - - $("#luckysheet-cols-h-selected").append('
'); + + $("#luckysheet-cols-h-selected").append('
'); + } } function selectTitlesMap(rangeMap, range1, range2) { let map = $.extend(true, {}, rangeMap); - - for(let i = range1; i <= range2; i++){ - if(i in map){ + + for (let i = range1; i <= range2; i++) { + if (i in map) { continue; } @@ -245,51 +246,51 @@ function selectTitlesMap(rangeMap, range1, range2) { } function selectTitlesRange(map) { let mapArr = []; - - for(let i in map){ + + for (let i in map) { mapArr.push(i); } - mapArr.sort(function(a, b){ return a - b; }); + mapArr.sort(function (a, b) { return a - b; }); let rangeArr = []; let item = []; - if(mapArr.length > 1){ - for(let j = 1; j < mapArr.length; j++){ - if(mapArr[j] - mapArr[j - 1] == 1){ + if (mapArr.length > 1) { + for (let j = 1; j < mapArr.length; j++) { + if (mapArr[j] - mapArr[j - 1] == 1) { item.push(mapArr[j - 1]); - - if(j == mapArr.length - 1){ + + if (j == mapArr.length - 1) { item.push(mapArr[j]); rangeArr.push(item); } } - else{ - if(j == 1){ - if(j == mapArr.length - 1){ + else { + if (j == 1) { + if (j == mapArr.length - 1) { item.push(mapArr[j - 1]); rangeArr.push(item); rangeArr.push([mapArr[j]]); } - else{ - rangeArr.push(mapArr[0]); + else { + rangeArr.push(mapArr[0]); } } - else if(j == mapArr.length - 1){ + else if (j == mapArr.length - 1) { item.push(mapArr[j - 1]); rangeArr.push(item); rangeArr.push([mapArr[j]]); } - else{ + else { item.push(mapArr[j - 1]); rangeArr.push(item); - item = []; + item = []; } } } } - else{ + else { rangeArr.push([mapArr[0]]); } @@ -298,26 +299,26 @@ function selectTitlesRange(map) { //选区是否重叠 function selectIsOverlap(range) { - if(range == null){ + if (range == null) { range = Store.luckysheet_select_save; } let overlap = false; let map = {}; - for(let s = 0; s < range.length; s++){ - let str_r = range[s].row[0], + for (let s = 0; s < range.length; s++) { + let str_r = range[s].row[0], end_r = range[s].row[1]; - let str_c = range[s].column[0], + let str_c = range[s].column[0], end_c = range[s].column[1]; - for(let r = str_r; r <= end_r; r++){ - for(let c = str_c; c <= end_c; c++){ - if((r + "_" + c) in map){ + for (let r = str_r; r <= end_r; r++) { + for (let c = str_c; c <= end_c; c++) { + if ((r + "_" + c) in map) { overlap = true; break; } - else{ + else { map[r + "_" + c] = 0; } } @@ -326,32 +327,92 @@ function selectIsOverlap(range) { return overlap; } +// 协同提示框 +function collaborativeEditBox(val1,val2) { + let all_data = luckysheet.getLuckysheetfile(); //获取整个表格数据 + let all_width = [];//当前操作页的所有列距离左边的距离 + let all_height = [];//当前操作页的所有列距离顶部的距离 + all_data.forEach((value1) => { + if(value1.index == Store.currentSheetIndex) { + all_width = value1.visibledatacolumn + all_height = value1.visibledatarow + } + }) + Store.cooperativeEdit.changeCollaborationSize.forEach(value => { + if (value.i == Store.currentSheetIndex) { + if(val1 !== null) { + for(let k in val1) { + if(value.v.column[0] <= k && k <= value.v.column[1]) { + Store.luckysheet_cols_change_size_start[1] = k - 0 + break + } + } + } + if(val2 !== null) { + for(let k in val2) { + if(value.v.row[0] <= k && k <= value.v.row[1]) { + Store.luckysheet_rows_change_size_start[1] = k - 0 + break + } + } + } + let flag1 = value.v.column[0] <= Store.luckysheet_cols_change_size_start[1] && Store.luckysheet_cols_change_size_start[1] <= value.v.column[1] + if(flag1) { + if(Store.luckysheet_cols_change_size_start[1] == 0) { + let change_width = all_width[0] - 1 + $("#luckysheet-multipleRange-show-" + value.id).css({"width":change_width}) + } else { + let count1 = value.v.column[0]; + let count2 = value.v.column[1]; + let change_width1 = all_width[count2] - all_width[count1 - 1] - (count2 - count1 + 1) + $("#luckysheet-multipleRange-show-" + value.id).css({"width":change_width1}) + } + } + let change_width2 = all_width[value.v.column[0] - 1] - 1 + $("#luckysheet-multipleRange-show-" + value.id).css({"left":change_width2 + 'px'}) + let flag2 = value.v.row[0] <= Store.luckysheet_rows_change_size_start[1] && Store.luckysheet_rows_change_size_start[1] <= value.v.row[1] + if(flag2) { + if(Store.luckysheet_rows_change_size_start[1] == 0) { + let change_height = all_height[0] - 1 + $("#luckysheet-multipleRange-show-" + value.id).css({"height":change_height}) + } else { + let count1 = value.v.row[0]; + let count2 = value.v.row[1]; + let change_height1 = all_height[count2] - all_height[count1 - 1] - (count2 - count1 + 1) + $("#luckysheet-multipleRange-show-" + value.id).css({"height":change_height1}) + } + } + let change_height2 = all_height[value.v.row[0] - 1] - 1 + $("#luckysheet-multipleRange-show-" + value.id).css({"top":change_height2 + 'px'}) + } + }) +} //复制选区虚线框 function selectionCopyShow(range) { $("#luckysheet-selection-copy").empty(); - if(range == null){ + if (range == null) { range = Store.luckysheet_selection_range; } - if(range.length > 0){ - for(let s = 0; s < range.length; s++){ + if (range.length > 0) { + for (let s = 0; s < range.length; s++) { let r1 = range[s].row[0], r2 = range[s].row[1]; let c1 = range[s].column[0], c2 = range[s].column[1]; - let row = Store.visibledatarow[r2], + let row = Store.visibledatarow[r2], row_pre = r1 - 1 == -1 ? 0 : Store.visibledatarow[r1 - 1]; - let col = Store.visibledatacolumn[c2], + let col = Store.visibledatacolumn[c2], col_pre = c1 - 1 == -1 ? 0 : Store.visibledatacolumn[c1 - 1]; - let copyDomHtml = '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'; + let copyDomHtml = '
' + + '
' + + '
' + + '
' + + '
' + + '
' + + '
'; $("#luckysheet-selection-copy").append(copyDomHtml); } } @@ -359,11 +420,11 @@ function selectionCopyShow(range) { //选区行列数显示 function luckysheet_count_show(left, top, width, height, rowseleted, columnseleted) { - let rowl = rowseleted[1] - rowseleted[0] + 1, + let rowl = rowseleted[1] - rowseleted[0] + 1, coll = columnseleted[1] - columnseleted[0] + 1; - let drawWidth = Store.luckysheetTableContentHW[0], + let drawWidth = Store.luckysheetTableContentHW[0], drawHeight = Store.luckysheetTableContentHW[1]; - let scrollWidth = $("#luckysheet-cell-main").scrollLeft(), + let scrollWidth = $("#luckysheet-cell-main").scrollLeft(), scrollHeight = $("#luckysheet-cell-main").scrollTop(); const _locale = locale(); @@ -384,7 +445,7 @@ function luckysheet_count_show(left, top, width, height, rowseleted, columnselet topv = scrollHeight + drawHeight / 2; } - $("#luckysheet-row-count-show").css({ "left": leftv, "top": topv, "display": "block","width":"11px" }).html("
" + rowl.toString().split("").join("
") + "
"+locale_info.row+"
"); + $("#luckysheet-row-count-show").css({ "left": leftv, "top": topv, "display": "block", "width": "11px" }).html("
" + rowl.toString().split("").join("
") + "
" + locale_info.row + "
"); } else { $("#luckysheet-row-count-show").hide(); @@ -412,19 +473,19 @@ function luckysheet_count_show(left, top, width, height, rowseleted, columnselet } } -function selectHelpboxFill(){ +function selectHelpboxFill() { let range = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]; let rf = range["row_focus"], cf = range["column_focus"]; - if(Store.config["merge"] != null && (rf + "_" + cf) in Store.config["merge"]){ + if (Store.config["merge"] != null && (rf + "_" + cf) in Store.config["merge"]) { $("#luckysheet-helpbox-cell").text(getRangetxt(Store.currentSheetIndex, { - column:[cf, cf], - row:[rf, rf], + column: [cf, cf], + row: [rf, rf], })); } - else{ + else { $("#luckysheet-helpbox-cell").text(getRangetxt(Store.currentSheetIndex, range)); } - + } export { @@ -432,6 +493,7 @@ export { selectHightlightShow, selectIsOverlap, selectionCopyShow, + collaborativeEditBox, luckysheet_count_show, selectHelpboxFill } \ No newline at end of file diff --git a/src/controllers/server.js b/src/controllers/server.js index 6075c489f..cbd7708c4 100644 --- a/src/controllers/server.js +++ b/src/controllers/server.js @@ -10,9 +10,11 @@ import luckysheetPostil from './postil'; import { getObjType, replaceHtml, getByteLen } from '../utils/util'; import { getSheetIndex } from '../methods/get'; import Store from '../store'; +import { collaborativeEditBox } from './select' import locale from '../locale/locale'; import dayjs from "dayjs"; import imageCtrl from './imageCtrl'; +import json from '../global/json'; const server = { gridKey: null, @@ -152,10 +154,10 @@ const server = { //连接建立时触发 _this.websocket.onopen = function() { - console.info('WebSocket连接成功'); + console.info('WebSocket连接成功'); hideloading(); - _this.wxErrorCount = 0; - + _this.wxErrorCount = 0; + //防止websocket长时间不发送消息导致断连 setInterval(function(){ _this.websocket.send("rub"); @@ -166,12 +168,15 @@ const server = { _this.websocket.onmessage = function(result){ Store.result = result let data = eval('(' + result.data + ')'); - console.info(data); + console.info(data); let type = data.type; let {message,id} = data; // 用户退出时,关闭协同编辑时其提示框 if(message === '用户退出') { $("#luckysheet-multipleRange-show-" + id).hide(); + Store.cooperativeEdit.changeCollaborationSize = Store.cooperativeEdit.changeCollaborationSize.filter(value => { + return value.id != id + }) } if(type == 1){ //send 成功或失败 @@ -179,6 +184,12 @@ const server = { else if(type == 2){ //更新数据 let item = JSON.parse(data.data); _this.wsUpdateMsg(item); + let chang_data = JSON.parse(data.data) + if(chang_data.k == 'columnlen') { + collaborativeEditBox(chang_data.v,null) + } else if(chang_data.k == 'rowlen') { + collaborativeEditBox(null,chang_data.v) + } } else if(type == 3){ //多人操作不同选区("t": "mv")(用不同颜色显示其他人所操作的选区) let id = data.id; @@ -188,7 +199,22 @@ const server = { let type = item.t, index = item.i, value = item.v; - + if(Store.cooperativeEdit.changeCollaborationSize.length === 0) { + Store.cooperativeEdit.changeCollaborationSize.push({id:id,v:item.v[0],i:index}) + } + let flag = Store.cooperativeEdit.changeCollaborationSize.some(value1 => { + return value1.id == id + }) + if(flag) { + Store.cooperativeEdit.changeCollaborationSize.forEach(val => { + if(val.id == id) { + val.v = item.v[0] + val.i = index + } + }) + } else { + Store.cooperativeEdit.changeCollaborationSize.push({id:id,v:item.v[0],i:index}) + } if(getObjType(value) != "array" && getObjType(value) !== "object"){ value = JSON.parse(value); } diff --git a/src/controllers/sheetBar.js b/src/controllers/sheetBar.js index f48ae47c6..bafd920fe 100644 --- a/src/controllers/sheetBar.js +++ b/src/controllers/sheetBar.js @@ -206,8 +206,6 @@ export function initialSheetBar(){ let $t = $(this), $cur = $(e.target); luckysheetsheetrightclick($t, $cur, e); - let result = Store.result - server.websocket.onmessage(result) }); let luckysheetsheetnameeditor = function ($t) { diff --git a/src/global/refresh.js b/src/global/refresh.js index 2399035e5..938c3bc83 100644 --- a/src/global/refresh.js +++ b/src/global/refresh.js @@ -15,7 +15,7 @@ import sheetmanage from '../controllers/sheetmanage'; import luckysheetPostil from '../controllers/postil'; import dataVerificationCtrl from '../controllers/dataVerificationCtrl'; import hyperlinkCtrl from '../controllers/hyperlinkCtrl'; -import { selectHightlightShow, selectionCopyShow } from '../controllers/select'; +import { selectHightlightShow, selectionCopyShow, collaborativeEditBox } from '../controllers/select'; import { createFilterOptions } from '../controllers/filter'; import { getSheetIndex } from '../methods/get'; import Store from '../store'; @@ -378,7 +378,7 @@ function jfrefreshrange(data, range, cdformat) { //删除、增加行列 刷新表格 function jfrefreshgrid_adRC(data, cfg, ctrlType, ctrlValue, calc, filterObj, cf, af, freezen, dataVerification, hyperlink){ let file = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]; - + collaborativeEditBox(); //merge改变对应的单元格值改变 let mcData = []; for(let m in cfg["merge"]){ @@ -583,6 +583,7 @@ function jfrefreshgrid_adRC(data, cfg, ctrlType, ctrlValue, calc, filterObj, cf, function jfrefreshgrid_deleteCell(data, cfg, ctrl, calc, filterObj, cf, dataVerification, hyperlink){ let file = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]; clearTimeout(refreshCanvasTimeOut); + collaborativeEditBox(); //merge改变对应的单元格值改变 let mcData = []; if(JSON.stringify(cfg["merge"]) == "{}"){ @@ -945,13 +946,13 @@ function jfrefreshgrid_rhcw(rowheight, colwidth, isRefreshCanvas=true){ Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].data = Store.flowdata; } - + //批注框同步 luckysheetPostil.positionSync(); - //选区同步 selectHightlightShow(); - + // 协同提示框同步 + collaborativeEditBox(); //改变单元格行高,复制虚线框同步 if($(".luckysheet-selection-copy").is(":visible")){ selectionCopyShow(); diff --git a/src/index.html b/src/index.html index f013574b4..3cf911ec3 100644 --- a/src/index.html +++ b/src/index.html @@ -56,7 +56,14 @@ luckysheet.create({ container: 'luckysheet', lang: lang, - forceCalculation:false, + forceCalculation:false, + allowUpdate:true, + updateImageUrl:"http://luckysheet.lashuju.com/luckysheet/api/updateImg", + //updateUrl: "ws://127.0.0.1:85/dataqk/websocket/qksheet", + updateUrl: "ws://luckysheet.lashuju.com/luckysheet/websocket/qksheet", + "gridKey": "1079500#-8803#7c45f52b7d01486d88bc53cb17dcd2c3", + loadUrl: "http://luckysheet.lashuju.com/luckysheet/api/load", + loadSheetUrl:"http://luckysheet.lashuju.com/luckysheet/api/loadsheet", plugins: ['chart'], fontList:[ { diff --git a/src/store/index.js b/src/store/index.js index 6134f8776..ee033e59c 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -141,7 +141,9 @@ const Store = { cooperativeEdit:{ usernameTimeout:{ - } + }, + changeCollaborationSize:[], //改变行高或者列宽时,协同提示框需要跟随改变所需数据 + allDataColumnlen:[],//列宽发生过改变的列 } }