Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
fix(fix #209): highlight
Browse files Browse the repository at this point in the history
highlight follow
  • Loading branch information
renxxing committed Nov 25, 2020
1 parent 080f027 commit ab2d8b7
Show file tree
Hide file tree
Showing 7 changed files with 261 additions and 168 deletions.
9 changes: 3 additions & 6 deletions src/controllers/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ export default function luckysheetHandler() {
if(isMobile){
mobileinit();
}


if (!Date.now)
Date.now = function() { return new Date().getTime(); };
//requestAnimationFrame method
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand All @@ -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]];
Expand Down
358 changes: 210 additions & 148 deletions src/controllers/select.js

Large diffs are not rendered by default.

36 changes: 31 additions & 5 deletions src/controllers/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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");
Expand All @@ -166,19 +168,28 @@ 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 成功或失败

}
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;
Expand All @@ -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);
}
Expand Down
2 changes: 0 additions & 2 deletions src/controllers/sheetBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 6 additions & 5 deletions src/global/refresh.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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"]){
Expand Down Expand Up @@ -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"]) == "{}"){
Expand Down Expand Up @@ -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();
Expand Down
9 changes: 8 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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:[
{
Expand Down
4 changes: 3 additions & 1 deletion src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ const Store = {
cooperativeEdit:{
usernameTimeout:{

}
},
changeCollaborationSize:[], //改变行高或者列宽时,协同提示框需要跟随改变所需数据
allDataColumnlen:[],//列宽发生过改变的列
}

}
Expand Down

0 comments on commit ab2d8b7

Please sign in to comment.