wpxp123456 5 years ago
parent
commit
e90e579bf3
  1. 7
      src/controllers/constant.js
  2. 4
      src/controllers/dropCell.js
  3. 51
      src/controllers/handler.js
  4. 6
      src/controllers/menuButton.js
  5. 3
      src/controllers/pivotTable.js
  6. 12
      src/controllers/selection.js
  7. 9
      src/controllers/sheetBar.js
  8. 10
      src/controllers/sheetmanage.js
  9. 10
      src/controllers/sparkline.js
  10. 2
      src/controllers/updateCell.js
  11. 3
      src/core.js
  12. 42
      src/css/luckysheet-core.css
  13. 23
      src/global/browser.js
  14. 311
      src/global/draw.js
  15. 2
      src/global/validate.js
  16. 1
      src/index.html
  17. 4
      src/utils/util.js

7
src/controllers/constant.js

File diff suppressed because one or more lines are too long

4
src/controllers/dropCell.js

@ -441,6 +441,10 @@ const luckysheetDropCell = {
update: function(){
let _this = this;
if(Store.allowEdit===false){
return;
}
let d = editor.deepCopyFlowData(Store.flowdata);
let file = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)];

51
src/controllers/handler.js

@ -64,6 +64,8 @@ export default function luckysheetHandler() {
mobileinit();
}
const os = browser.detectOS(), isMac = os=="Mac"?true:false, scrollNum = isMac?1:3;
//滚动监听
$("#luckysheet-cell-main").scroll(function () {
@ -100,50 +102,49 @@ export default function luckysheetHandler() {
let rowscroll = 0;
//一次滚动三行或三列
if(event.deltaX != 0){
let col_ed;
if(event.deltaY != 0){
let row_ed;
if(event.deltaX < 0){
col_ed = col_st + 3;
if(event.deltaY < 0){
row_ed = row_st + scrollNum;
if(col_ed >= visibledatacolumn_c.length){
col_ed = visibledatacolumn_c.length - 1;
if(row_ed >= visibledatarow_c.length){
row_ed = visibledatarow_c.length - 1;
}
}
else{
col_ed = col_st - 3;
row_ed = row_st - scrollNum;
if(col_ed < 0){
col_ed = 0;
if(row_ed < 0){
row_ed = 0;
}
}
colscroll = col_ed == 0 ? 0 : visibledatacolumn_c[col_ed - 1];
rowscroll = row_ed == 0 ? 0 : visibledatarow_c[row_ed - 1];
$("#luckysheet-scrollbar-x").scrollLeft(colscroll);
$("#luckysheet-scrollbar-y").scrollTop(rowscroll);
}
else if(event.deltaX != 0){
let col_ed;
if(event.deltaY != 0){
let row_ed;
if(event.deltaY < 0){
row_ed = row_st + 3;
if((isMac && event.deltaX >0 ) || (!isMac && event.deltaX < 0)){
col_ed = col_st + scrollNum;
if(row_ed >= visibledatarow_c.length){
row_ed = visibledatarow_c.length - 1;
if(col_ed >= visibledatacolumn_c.length){
col_ed = visibledatacolumn_c.length - 1;
}
}
else{
row_ed = row_st - 3;
col_ed = col_st - scrollNum;
if(row_ed < 0){
row_ed = 0;
if(col_ed < 0){
col_ed = 0;
}
}
rowscroll = row_ed == 0 ? 0 : visibledatarow_c[row_ed - 1];
colscroll = col_ed == 0 ? 0 : visibledatacolumn_c[col_ed - 1];
$("#luckysheet-scrollbar-y").scrollTop(rowscroll);
$("#luckysheet-scrollbar-x").scrollLeft(colscroll);
}
});
@ -2667,7 +2668,7 @@ export default function luckysheetHandler() {
//选区拖动替换
$("#luckysheet-cell-main div.luckysheet-cs-draghandle").mousedown(function (event) {
if(isEditMode()){//此模式下禁用选区拖动
if(isEditMode() || Store.allowEdit===false){//此模式下禁用选区拖动
return;
}
@ -2709,7 +2710,7 @@ export default function luckysheetHandler() {
//选区下拉
$("#luckysheet-cell-main div.luckysheet-cs-fillhandle").mousedown(function (event) {
if(isEditMode()){//此模式下禁用选区下拉
if(isEditMode() || Store.allowEdit===false){//此模式下禁用选区下拉
return;
}

6
src/controllers/menuButton.js

@ -467,7 +467,7 @@ const menuButton = {
let fItem = locale_fontarray[a];
let ret = {};
ret.value = a;
ret.text = "<span class='luckysheet-mousedown-cancel' style='font-size:16px;font-family:"+fItem+"'>"+fItem+"</span>";
ret.text = "<span class='luckysheet-mousedown-cancel' style='font-size:11px;font-family:"+fItem+"'>"+fItem+"</span>";
ret.example = "";
itemdata.push(ret);
}
@ -2781,6 +2781,10 @@ const menuButton = {
updateFormat: function(d, attr, foucsStatus){
let _this = this;
if(Store.allowEdit===false){
return;
}
let canvasElement = document.createElement('canvas');
let canvas = canvasElement.getContext("2d");

3
src/controllers/pivotTable.js

@ -617,6 +617,9 @@ const pivotTable = {
}
},
createPivotTable: function (e) {
if(isEditMode() || Store.allowEdit===false){
return;
}
let _this = this;
let datasheetindex = Store.currentSheetIndex;

12
src/controllers/selection.js

@ -98,6 +98,8 @@ const selection = {
clipboardData = e.originalEvent.clipboardData;
}
Store.luckysheet_selection_range = [];
//copy范围
let minR = Store.luckysheet_select_save[0].row[0],
@ -549,6 +551,10 @@ const selection = {
paste: function (e, triggerType) {//paste事件
let _this = this;
if(Store.allowEdit===false){
return;
}
let textarea = $("#luckysheet-copy-content");
textarea.focus();
textarea.select();
@ -581,6 +587,9 @@ const selection = {
}, 10);
},
pasteHandler: function (data, borderInfo) {
if(Store.allowEdit===false){
return;
}
if(Store.luckysheet_select_save.length > 1){
if(isEditMode()){
alert("不能对多重选择区域执行此操作,请选择单个区域,然后再试");
@ -791,6 +800,9 @@ const selection = {
}
},
pasteHandlerOfCutPaste: function(copyRange){
if(Store.allowEdit===false){
return;
}
let cfg = $.extend(true, {}, Store.config);
if(cfg["merge"] == null){
cfg["merge"] = {};

9
src/controllers/sheetBar.js

@ -200,6 +200,9 @@ export function initialSheetBar(){
});
let luckysheetsheetnameeditor = function ($t) {
if(Store.allowEdit===false){
return;
}
$t.attr("contenteditable", "true").addClass("luckysheet-mousedown-cancel").data("oldtxt", $t.text());
setTimeout(function () {
@ -221,6 +224,9 @@ export function initialSheetBar(){
});
$("#luckysheet-sheet-area").on("blur", "span.luckysheet-sheets-item-name", function (e) {
if(Store.allowEdit===false){
return;
}
let $t = $(this);
let txt = $t.text(), oldtxt = $t.data("oldtxt");
@ -269,6 +275,9 @@ export function initialSheetBar(){
});
$("#luckysheet-sheet-area").on("keydown", "span.luckysheet-sheets-item-name", function (e) {
if(Store.allowEdit===false){
return;
}
let kcode = e.keyCode;
let $t = $(this);
if (kcode == keycode.ENTER) {

10
src/controllers/sheetmanage.js

@ -169,7 +169,7 @@ const sheetmanage = {
return Store.currentSheetIndex;
},
addNewSheet: function(e, isPivotTable) {
if(isEditMode()){
if(isEditMode() || Store.allowEdit===false){
// alert("非编辑模式下不允许该操作!");
return;
}
@ -352,7 +352,7 @@ const sheetmanage = {
}, 1)
},
copySheet: function(copyindex, e) {
if(isEditMode()){
if(isEditMode() || Store.allowEdit===false){
// alert("非编辑模式下不允许该操作!");
return;
}
@ -460,6 +460,10 @@ const sheetmanage = {
deleteSheet: function(index) {
let _this = this;
if(Store.allowEdit===false){
return;
}
let arrIndex = _this.getSheetIndex(index);
_this.setSheetHide(index);
@ -841,7 +845,7 @@ const sheetmanage = {
pivotTable.changePivotTable(index);
}
}
else {
else if($("#luckysheet-modal-dialog-slider-pivot").is(":visible")) {
Store.luckysheetcurrentisPivotTable = false;
$("#luckysheet-modal-dialog-slider-pivot").hide();
luckysheetsizeauto();

10
src/controllers/sparkline.js

@ -1,3 +1,5 @@
import Store from "../store";
//sparkline设置
let createClass = function (/* [baseclass, [mixin, ...]], definition */) {
let Class, args;
@ -1283,8 +1285,8 @@ const luckysheetSparkline = {
this.canvasWidth = el.mergedOptions.width;
this.canvasHeight = el.mergedOptions.height;
let barWidth = parseInt(options.get('barWidth'), 10),
barSpacing = parseInt(options.get('barSpacing'), 10);
let barWidth = parseInt(options.get('barWidth'), 10)*Store.devicePixelRatio,
barSpacing = parseInt(options.get('barSpacing'), 10)*Store.devicePixelRatio;
//tristate._super.init.call(this, el, values, options, width, height);
this.regionShapes = {};
@ -1905,8 +1907,8 @@ const luckysheetSparkline = {
_this.lastShapeId = null;
_this.mergedOptions = $.extend({}, base, extendedOptions, userOptions);
_this.mergedOptions.width = devicePixelRatio * _this.mergedOptions.width;
_this.mergedOptions.height = devicePixelRatio * _this.mergedOptions.height;
_this.mergedOptions.width = Store.devicePixelRatio * _this.mergedOptions.width;
_this.mergedOptions.height = Store.devicePixelRatio * _this.mergedOptions.height;
_this[_this.mergedOptions.type].render(_this, userValues);
return { shapes:_this.shapes, shapeseq:_this.shapeseq, offsetX:_this.mergedOptions.offsetX, offsetY:_this.mergedOptions.offsetY, pixelWidth:_this.mergedOptions.width, pixelHeight:_this.mergedOptions.height};

2
src/controllers/updateCell.js

@ -13,7 +13,7 @@ import cleargridelement from '../global/cleargridelement';
import Store from '../store';
export default function luckysheetupdateCell(row, row_pre, row_index, col, col_pre, col_index, d, cover, isnotfocus) {
if(isEditMode()){//此模式下禁用单元格编辑
if(isEditMode() || Store.allowEdit===false){//此模式下禁用单元格编辑
return;
}

3
src/core.js

@ -49,6 +49,7 @@ luckysheet.create = function (setting) {
Store.fullscreenmode = extendsetting.fullscreenmode;
Store.lang = extendsetting.lang; //language
Store.allowEdit = extendsetting.allowEdit;
Store.editMode = extendsetting.editMode;
server.gridKey = extendsetting.gridKey;
server.loadUrl = extendsetting.loadUrl;
@ -82,7 +83,7 @@ luckysheet.create = function (setting) {
luckysheetConfigsetting.enablePage = extendsetting.enablePage;
luckysheetConfigsetting.pageInfo = extendsetting.pageInfo;
luckysheetConfigsetting.editMode = extendsetting.editMode;
luckysheetConfigsetting.chartConfigChange = extendsetting.chartConfigChange;
luckysheetConfigsetting.beforeCreateDom = extendsetting.beforeCreateDom;

42
src/css/luckysheet-core.css

@ -1067,7 +1067,7 @@ div.luckysheet-sheets-add:hover, div.luckysheet-sheets-m:hover {
height: 18px;
line-height: 18px;
box-shadow: 0px 1px 2px rgba(0,0,0,0.3) inset;
background-color: #e2e2e2;
background-color: #f7f7f7;
border-color: #000;
border-top-color: #aaa;
border-width: 0 1px 1px 1px;
@ -1078,7 +1078,7 @@ div.luckysheet-sheets-add:hover, div.luckysheet-sheets-m:hover {
border-radius: 0 0 2px 2px;
margin-right: 1px;
cursor: pointer;
border-bottom: 1px solid #a5a5a5;
border-bottom: 1px solid #cacaca;
transition: all 0.1s;
padding-right: 20px;
font-size: 13px;
@ -1141,7 +1141,7 @@ div.luckysheet-sheets-add:hover, div.luckysheet-sheets-m:hover {
border-color: #aaa;
border-top-color: #fff;
color: #222;
box-shadow: 0 1px 2px rgba(0,0,0,0.4);
box-shadow: 0 1px 2px rgba(0,0,0,0.2);
cursor: default;
top: -2px;
border-bottom: none;
@ -1269,7 +1269,7 @@ div.luckysheet-sheets-add:hover, div.luckysheet-sheets-m:hover {
margin-left: 0px;
display: none;
/*transition: all 0.1s;*/
background-color: rgba(252,195,195, 0.5);
background-color: rgba(194, 194, 194, 0.4);
}
.luckysheet-cols-h-selected {
@ -1404,7 +1404,7 @@ body:not(.ewa-ipad) .luckysheet-cols-h-cell-nosel:hover, body:not(.ewa-ipad) .lu
margin-top: 2px;
display: none;
/*transition: all 0.1s;*/
background-color: rgba(194, 194, 194, 0.5);
background-color: rgba(194, 194, 194, 0.4);
}
.luckysheet-rows-h-selected {
@ -1579,7 +1579,8 @@ body:not(.ewa-ipad) .luckysheet-cols-h-cell-nosel:hover, body:not(.ewa-ipad) .lu
border: 1px solid #d9d9d9;
border-width: 1px 0 0 0;
box-shadow: none;
background-color: #f8f8f8
background-color: #f8f8f8;
border-bottom: 1px solid #d9d9d9;
}
.luckysheet-scrollbar-ltr::-webkit-scrollbar-button:horizontal:increment:hover {
background: no-repeat url("waffle_sprite.png") -395px -62px
@ -1591,7 +1592,8 @@ body:not(.ewa-ipad) .luckysheet-cols-h-cell-nosel:hover, body:not(.ewa-ipad) .lu
border-left: 1px solid #d9d9d9;
border-right: 1px solid #d9d9d9;
background: no-repeat url("waffle_sprite.png") -283px -62px;
width: 17px
width: 17px;
border-bottom: 1px solid #d9d9d9;
}
.luckysheet-scrollbar-ltr::-webkit-scrollbar-button:horizontal:hover {
background: no-repeat url("waffle_sprite.png") -145px -70px
@ -1602,6 +1604,7 @@ body:not(.ewa-ipad) .luckysheet-cols-h-cell-nosel:hover, body:not(.ewa-ipad) .lu
.luckysheet-scrollbar-ltr::-webkit-scrollbar-button:vertical:increment {
padding-top: 1px;
background: no-repeat url("waffle_sprite.png") -531px -24px;
border-left: 1px solid #d9d9d9;
height: 15px
}
.luckysheet-scrollbar-ltr::-webkit-scrollbar-button:vertical:increment:hover {
@ -1613,6 +1616,7 @@ body:not(.ewa-ipad) .luckysheet-cols-h-cell-nosel:hover, body:not(.ewa-ipad) .lu
.luckysheet-scrollbar-ltr::-webkit-scrollbar-button:vertical:decrement {
border-top: 1px solid #d9d9d9;
border-bottom: 1px solid #d9d9d9;
border-left: 1px solid #d9d9d9;
background: no-repeat url("waffle_sprite.png") -631px -27px;
height: 17px
}
@ -1625,7 +1629,7 @@ body:not(.ewa-ipad) .luckysheet-cols-h-cell-nosel:hover, body:not(.ewa-ipad) .lu
.luckysheet-scrollbar-x{
bottom: 0px;
left: 45px;
left: 44px;
overflow-x: scroll;
}
@ -2040,20 +2044,34 @@ body:not(.ewa-ipad) .luckysheet-cols-h-cell-nosel:hover, body:not(.ewa-ipad) .lu
}
.luckysheet-scrollbars::-webkit-scrollbar-track {
background-color: #E0E0E0;
background-color: #FFFFFF;
border: 1px solid #d9d9d9;
}
.luckysheet-scrollbar-x::-webkit-scrollbar-track {
border-left: 1px solid #d9d9d9;
border-right: none;
}
.luckysheet-scrollbar-y::-webkit-scrollbar-track {
border-top: none;
border-bottom: none;
}
.luckysheet-scrollbars::-webkit-scrollbar {
width: 12px;
height: 12px;
background-color: #E0E0E0;
background-color: #FFFFFF;
/*border:0 none;*/
}
.luckysheet-scrollbars::-webkit-scrollbar-thumb {
background-color: #fff;
border: 1px solid #A0A0A0;
background-color: rgba(0,0,0,.2);
background-clip: padding-box;
border: solid transparent;
border-radius: 12px;
border-width: 2px 1px 1px 2px;
box-shadow: inset 1px 1px 0 rgba(0,0,0,.1), inset 0 -1px 0 rgba(0,0,0,.07);
}
.luckysheet-scrollbars::-webkit-scrollbar-thumb:hover {

23
src/global/browser.js

@ -125,6 +125,29 @@ const browser = {
}
return _this.luckysheetrefreshfixednum;
},
detectOS() {
var userAgent = navigator.userAgent;
var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");
var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform == "Macintosh") || (navigator.platform == "MacIntel");
if (isMac) return "Mac";
var isUnix = (navigator.platform == "X11") && !isWin && !isMac;
if (isUnix) return "Unix";
var isLinux = (String(navigator.platform).indexOf("Linux") > -1);
if (isLinux) return "Linux";
if (isWin) {
var isWin2K = userAgent.indexOf("Windows NT 5.0") > -1 || userAgent.indexOf("Windows 2000") > -1;
if (isWin2K) return "Win2000";
var isWinXP = userAgent.indexOf("Windows NT 5.1") > -1 || userAgent.indexOf("Windows XP") > -1;
if (isWinXP) return "WinXP";
var isWin2003 = userAgent.indexOf("Windows NT 5.2") > -1 || userAgent.indexOf("Windows 2003") > -1;
if (isWin2003) return "Win2003";
var isWinVista= userAgent.indexOf("Windows NT 6.0") > -1 || userAgent.indexOf("Windows Vista") > -1;
if (isWinVista) return "WinVista";
var isWin7 = userAgent.indexOf("Windows NT 6.1") > -1 || userAgent.indexOf("Windows 7") > -1;
if (isWin7) return "Win7";
}
return "other";
}
};

311
src/global/draw.js

@ -3,7 +3,7 @@ import conditionformat from '../controllers/conditionformat';
import alternateformat from '../controllers/alternateformat';
import luckysheetSparkline from '../controllers/sparkline';
import menuButton from '../controllers/menuButton';
import { luckysheetdefaultstyle, luckysheet_CFiconsImg } from '../controllers/constant';
import { luckysheetdefaultstyle, luckysheet_CFiconsImg,luckysheetdefaultFont } from '../controllers/constant';
import { luckysheet_searcharray } from '../controllers/sheetSearch';
import { dynamicArrayCompute } from './dynamicArray';
import browser from './browser';
@ -20,12 +20,12 @@ function luckysheetDrawgrid(scrollWidth, scrollHeight, drawWidth, drawHeight, of
return;
}
if(Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["isPivotTable"]){
luckysheetDrawMain_back(scrollWidth, scrollHeight, drawWidth, drawHeight, offsetLeft, offsetTop);
}
else{
// if(Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["isPivotTable"]){
// luckysheetDrawMain_back(scrollWidth, scrollHeight, drawWidth, drawHeight, offsetLeft, offsetTop);
// }
// else{
luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, offsetLeft, offsetTop);
}
// }
$("#luckysheetTableContent").get(0).getContext("2d").clearRect(0, 0, 46, 20);
@ -54,7 +54,7 @@ function luckysheetDrawgridRowTitle(scrollHeight, drawHeight, offsetTop) {
drawHeight * Store.devicePixelRatio
);
luckysheetTableContent.font = luckysheetdefaultstyle.font;
luckysheetTableContent.font = luckysheetdefaultFont();
luckysheetTableContent.textBaseline = luckysheetdefaultstyle.textBaseline; //基准线 垂直居中
luckysheetTableContent.fillStyle = luckysheetdefaultstyle.fillStyle;
@ -156,7 +156,7 @@ function luckysheetDrawgridColumnTitle(scrollWidth, drawWidth, offsetLeft) {
);
luckysheetTableContent.font = luckysheetdefaultstyle.font;
luckysheetTableContent.font = luckysheetdefaultFont();
luckysheetTableContent.textBaseline = luckysheetdefaultstyle.textBaseline; //基准线 垂直居中
luckysheetTableContent.fillStyle = luckysheetdefaultstyle.fillStyle;
@ -367,7 +367,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
(fill_col_ed - scrollWidth) * Store.devicePixelRatio,
(fill_row_ed - scrollHeight) * Store.devicePixelRatio
);
luckysheetTableContent.font = luckysheetdefaultstyle.font;
luckysheetTableContent.font = luckysheetdefaultFont();
luckysheetTableContent.textBaseline = "top";
luckysheetTableContent.fillStyle = luckysheetdefaultstyle.fillStyle;
@ -398,80 +398,6 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
let end_c = Store.visibledatacolumn[c] - scrollWidth;
//数据透视表
if (!!Store.luckysheetcurrentisPivotTable && pivotTable.drawPivotTable) {
if ((c == 0 || c == 5) && r <= 11) {
luckysheetTableContent.beginPath();
luckysheetTableContent.moveTo(
Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft),
Store.devicePixelRatio * (start_r + offsetTop)
);
luckysheetTableContent.lineTo(
Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft),
Store.devicePixelRatio * (end_r - 2 + offsetTop)
);
luckysheetTableContent.lineWidth = Store.devicePixelRatio;
luckysheetTableContent.strokeStyle = "#000000";
luckysheetTableContent.closePath();
luckysheetTableContent.stroke();
}
if ((r == 2 || r == 11) && c <= 5) {
luckysheetTableContent.beginPath();
luckysheetTableContent.moveTo(
Store.devicePixelRatio * (start_c - 1 + offsetLeft),
Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop)
);
luckysheetTableContent.lineTo(
Store.devicePixelRatio * (end_c - 2 + offsetLeft),
Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop)
);
luckysheetTableContent.lineWidth = Store.devicePixelRatio;
luckysheetTableContent.strokeStyle = "#000000";
luckysheetTableContent.closePath();
luckysheetTableContent.stroke();
}
if (r == 6 && c == 3) {
luckysheetTableContent.fillText(
"数据透视表",
Store.devicePixelRatio * (start_c + 4 + offsetLeft),
Store.devicePixelRatio *(start_r + (end_r - start_r) / 2 - 1 + offsetTop)
);
}
}
else if (!!Store.luckysheetcurrentisPivotTable) {
if (c < pivotTable.pivotTableBoundary[1] && r < pivotTable.pivotTableBoundary[0]) {
luckysheetTableContent.beginPath();
luckysheetTableContent.moveTo(
Store.devicePixelRatio*(end_c - 2 + 0.5 + offsetLeft),
Store.devicePixelRatio*(start_r + offsetTop)
);
luckysheetTableContent.lineTo(
Store.devicePixelRatio*(end_c - 2 + 0.5 + offsetLeft),
Store.devicePixelRatio*(end_r - 2 + offsetTop)
);
luckysheetTableContent.lineWidth = Store.devicePixelRatio;
luckysheetTableContent.strokeStyle = "#000000";
luckysheetTableContent.closePath();
luckysheetTableContent.stroke();
luckysheetTableContent.beginPath();
luckysheetTableContent.moveTo(
Store.devicePixelRatio*(start_c - 1 + offsetLeft),
Store.devicePixelRatio*(end_r - 2 + 0.5 + offsetTop)
);
luckysheetTableContent.lineTo(
Store.devicePixelRatio*(end_c - 2 + offsetLeft),
Store.devicePixelRatio*(end_r - 2 + 0.5 + offsetTop)
);
luckysheetTableContent.lineWidth = Store.devicePixelRatio;
luckysheetTableContent.strokeStyle = "#000000";
luckysheetTableContent.closePath();
luckysheetTableContent.stroke();
}
}
if (Store.config["rowhidden"] != null && Store.config["rowhidden"][r] != null) {
}
@ -582,8 +508,8 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
temp1.shapes,
offsetX + x,
offsetY + y,
temp1.pixelWidth,
temp1.pixelHeight,
temp1.pixelWidth*Store.devicePixelRatio,
temp1.pixelHeight*Store.devicePixelRatio,
canvasid,
ctx
);
@ -645,7 +571,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
luckysheetTableContent.fillStyle = "#000000";
//文本宽度和高度
let fontset = luckysheetdefaultstyle.font;
let fontset = luckysheetdefaultFont();
luckysheetTableContent.font = fontset;
let textMetrics = luckysheetTableContent.measureText(value).width;
@ -689,6 +615,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
//即溢出单元格跨此单元格,此单元格不绘制右边框
if(!cellOverflow_colInObj.colIn || cellOverflow_colInObj.colLast){
//右边框
if(!Store.luckysheetcurrentisPivotTable){
luckysheetTableContent.beginPath();
luckysheetTableContent.moveTo(
Store.devicePixelRatio * (end_c + offsetLeft - 2 + 0.5),
@ -700,19 +627,14 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
);
luckysheetTableContent.lineWidth = Store.devicePixelRatio;
if (!!Store.luckysheetcurrentisPivotTable && !pivotTable.drawPivotTable) {
luckysheetTableContent.strokeStyle = "#000000";
}
else{
luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle;
}
luckysheetTableContent.stroke();
luckysheetTableContent.closePath();
}
}
//下边框
if(!Store.luckysheetcurrentisPivotTable){
luckysheetTableContent.beginPath();
luckysheetTableContent.moveTo(
Store.devicePixelRatio * (start_c + offsetLeft - 2),
@ -724,16 +646,11 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
);
luckysheetTableContent.lineWidth = Store.devicePixelRatio;
if (!!Store.luckysheetcurrentisPivotTable && !pivotTable.drawPivotTable) {
luckysheetTableContent.strokeStyle = "#000000";
}
else{
luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle;
}
luckysheetTableContent.stroke();
luckysheetTableContent.closePath();
}
}
//非空白单元格渲染
let cellRender = function(r, c, start_r, start_c, end_r, end_c, value, canvasType){
@ -1375,6 +1292,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
if(cellOverflow_bd_r_render){
//右边框
if(!Store.luckysheetcurrentisPivotTable){
luckysheetTableContent.beginPath();
luckysheetTableContent.moveTo(
Store.devicePixelRatio * (end_c + offsetLeft - 2 + 0.5),
@ -1386,18 +1304,13 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
);
luckysheetTableContent.lineWidth = Store.devicePixelRatio;
if (!!Store.luckysheetcurrentisPivotTable && !pivotTable.drawPivotTable) {
luckysheetTableContent.strokeStyle = "#000000";
}
else{
luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle;
}
luckysheetTableContent.stroke();
luckysheetTableContent.closePath();
}
}
//下边框
if(!Store.luckysheetcurrentisPivotTable){
luckysheetTableContent.beginPath();
luckysheetTableContent.moveTo(
Store.devicePixelRatio * (start_c + offsetLeft - 2),
@ -1409,16 +1322,10 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
);
luckysheetTableContent.lineWidth = Store.devicePixelRatio;
if (!!Store.luckysheetcurrentisPivotTable && !pivotTable.drawPivotTable) {
luckysheetTableContent.strokeStyle = "#000000";
}
else{
luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle;
}
luckysheetTableContent.stroke();
luckysheetTableContent.closePath();
}
}
//溢出单元格渲染
let cellOverflowRender = function(r, c, stc, edc){
@ -1688,6 +1595,106 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
}
}
//数据透视表边框渲染
for (let r = dataset_row_st; r <= dataset_row_ed; r++) {
let start_r;
if (r == 0) {
start_r = -scrollHeight - 1;
}
else {
start_r = Store.visibledatarow[r - 1] - scrollHeight - 1;
}
let end_r = Store.visibledatarow[r] - scrollHeight;
for (let c = dataset_col_st; c <= dataset_col_ed; c++) {
let start_c;
if (c == 0) {
start_c = -scrollWidth;
}
else {
start_c = Store.visibledatacolumn[c - 1] - scrollWidth;
}
let end_c = Store.visibledatacolumn[c] - scrollWidth;
//数据透视表\
if (!!Store.luckysheetcurrentisPivotTable && pivotTable.drawPivotTable) {
if ((c == 0 || c == 5) && r <= 11) {
luckysheetTableContent.beginPath();
luckysheetTableContent.moveTo(
Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft),
Store.devicePixelRatio * (start_r + offsetTop)
);
luckysheetTableContent.lineTo(
Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft),
Store.devicePixelRatio * (end_r - 2 + offsetTop)
);
luckysheetTableContent.lineWidth = Store.devicePixelRatio;
luckysheetTableContent.strokeStyle = "#000000";
luckysheetTableContent.closePath();
luckysheetTableContent.stroke();
}
if ((r == 2 || r == 11) && c <= 5) {
luckysheetTableContent.beginPath();
luckysheetTableContent.moveTo(
Store.devicePixelRatio * (start_c - 1 + offsetLeft),
Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop)
);
luckysheetTableContent.lineTo(
Store.devicePixelRatio * (end_c - 2 + offsetLeft),
Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop)
);
luckysheetTableContent.lineWidth = Store.devicePixelRatio;
luckysheetTableContent.strokeStyle = "#000000";
luckysheetTableContent.closePath();
luckysheetTableContent.stroke();
}
if (r == 6 && c == 3) {
luckysheetTableContent.fillText(
"数据透视表",
Store.devicePixelRatio * (start_c + 4 + offsetLeft),
Store.devicePixelRatio *(start_r + (end_r - start_r) / 2 - 1 + offsetTop)
);
}
}
else if (!!Store.luckysheetcurrentisPivotTable) {
if (c < pivotTable.pivotTableBoundary[1] && r < pivotTable.pivotTableBoundary[0]) {
luckysheetTableContent.beginPath();
luckysheetTableContent.moveTo(
Store.devicePixelRatio*(end_c - 2 + 0.5 + offsetLeft),
Store.devicePixelRatio*(start_r + offsetTop)
);
luckysheetTableContent.lineTo(
Store.devicePixelRatio*(end_c - 2 + 0.5 + offsetLeft),
Store.devicePixelRatio*(end_r - 2 + offsetTop)
);
luckysheetTableContent.lineWidth = Store.devicePixelRatio;
luckysheetTableContent.strokeStyle = "#000000";
luckysheetTableContent.closePath();
luckysheetTableContent.stroke();
luckysheetTableContent.beginPath();
luckysheetTableContent.moveTo(
Store.devicePixelRatio*(start_c - 1 + offsetLeft),
Store.devicePixelRatio*(end_r - 2 + 0.5 + offsetTop)
);
luckysheetTableContent.lineTo(
Store.devicePixelRatio*(end_c - 2 + offsetLeft),
Store.devicePixelRatio*(end_r - 2 + 0.5 + offsetTop)
);
luckysheetTableContent.lineWidth = Store.devicePixelRatio;
luckysheetTableContent.strokeStyle = "#000000";
luckysheetTableContent.closePath();
luckysheetTableContent.stroke();
}
}
}
}
//边框单独渲染
if(Store.config["borderInfo"] != null && Store.config["borderInfo"].length > 0){
//边框渲染
@ -2146,7 +2153,7 @@ function luckysheetDrawMain_back(scrollWidth, scrollHeight, drawWidth, drawHeigh
Store.luckysheetTableContentHW[1] * Store.devicePixelRatio
);
offlinecanvas.font = luckysheetdefaultstyle.font;
offlinecanvas.font = luckysheetdefaultFont();
offlinecanvas.textBaseline = "top";
offlinecanvas.fillStyle = luckysheetdefaultstyle.fillStyle;
@ -2239,43 +2246,43 @@ function luckysheetDrawMain_back(scrollWidth, scrollHeight, drawWidth, drawHeigh
}
end_c = Store.visibledatacolumn[c] - scrollWidth;
if(c==dataset_col_ed){
if (!Store.luckysheetcurrentisPivotTable && end_r <= drawHeight && start_r >= -1) {
//行
luckysheetTableContent.beginPath();
luckysheetTableContent.moveTo(
Store.devicePixelRatio * (offsetLeft - 1),
Store.devicePixelRatio * (end_r + offsetTop - 2 + 0.5)
);
luckysheetTableContent.lineTo(
Store.devicePixelRatio * (end_c + offsetLeft-2),
Store.devicePixelRatio * (end_r + offsetTop - 2 + 0.5)
);
luckysheetTableContent.lineWidth = Store.devicePixelRatio;
luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle;
luckysheetTableContent.closePath();
luckysheetTableContent.stroke();
}
}
if (r == dataset_row_st) {
if (!Store.luckysheetcurrentisPivotTable && end_c <= drawWidth + 18 && start_c >= -1) {
//列
luckysheetTableContent.beginPath();
luckysheetTableContent.moveTo(
Store.devicePixelRatio * (end_c + offsetLeft - 2 + 0.5),
Store.devicePixelRatio * (offsetTop - 1)
);
luckysheetTableContent.lineTo(
Store.devicePixelRatio * (end_c + offsetLeft - 2 + 0.5),
Store.devicePixelRatio * (fill_row_ed - fill_row_st + offsetTop-2)
);
luckysheetTableContent.lineWidth = Store.devicePixelRatio;
luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle;
luckysheetTableContent.closePath();
luckysheetTableContent.stroke();
}
}
// if(c==dataset_col_ed){
// if (!Store.luckysheetcurrentisPivotTable && end_r <= drawHeight && start_r >= -1) {
// //行
// luckysheetTableContent.beginPath();
// luckysheetTableContent.moveTo(
// Store.devicePixelRatio * (offsetLeft - 1),
// Store.devicePixelRatio * (end_r + offsetTop - 2 + 0.5)
// );
// luckysheetTableContent.lineTo(
// Store.devicePixelRatio * (end_c + offsetLeft-2),
// Store.devicePixelRatio * (end_r + offsetTop - 2 + 0.5)
// );
// luckysheetTableContent.lineWidth = Store.devicePixelRatio;
// luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle;
// luckysheetTableContent.closePath();
// luckysheetTableContent.stroke();
// }
// }
// if (r == dataset_row_st) {
// if (!Store.luckysheetcurrentisPivotTable && end_c <= drawWidth + 18 && start_c >= -1) {
// //列
// luckysheetTableContent.beginPath();
// luckysheetTableContent.moveTo(
// Store.devicePixelRatio * (end_c + offsetLeft - 2 + 0.5),
// Store.devicePixelRatio * (offsetTop - 1)
// );
// luckysheetTableContent.lineTo(
// Store.devicePixelRatio * (end_c + offsetLeft - 2 + 0.5),
// Store.devicePixelRatio * (fill_row_ed - fill_row_st + offsetTop-2)
// );
// luckysheetTableContent.lineWidth = Store.devicePixelRatio;
// luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle;
// luckysheetTableContent.closePath();
// luckysheetTableContent.stroke();
// }
// }
if (!!Store.luckysheetcurrentisPivotTable && pivotTable.drawPivotTable) {
if ((c == 0 || c == 5) && r <= 11) {
@ -2762,7 +2769,7 @@ function luckysheetDrawMain_back(scrollWidth, scrollHeight, drawWidth, drawHeigh
}
}
offlinecanvas.font = luckysheetdefaultstyle.font;
offlinecanvas.font = luckysheetdefaultFont();
luckysheetTableContent.drawImage($("#luckysheetTableContentF").get(0), cellsize[0], cellsize[1], cellsize[2], cellsize[3], cellsize[0], cellsize[1], cellsize[2], cellsize[3]);

2
src/global/validate.js

@ -68,7 +68,7 @@ function hasChinaword(s) {
//是否为非编辑模式
function isEditMode() {
if(luckysheetConfigsetting.editMode){
if(Store.editMode){
return true;
}
else{

1
src/index.html

@ -33,6 +33,7 @@
luckysheet.create({
container: 'luckysheet',
lang: 'en',
allowEdit:true,
plugins: ['chart'],
data: [sheetCell,sheetFormula,sheetConditionFormat,sheetTable,sheetSparkline,sheetComment,sheetPivotTableData,sheetPivotTable]
})

4
src/utils/util.js

@ -1,4 +1,4 @@
import { columeHeader_word, columeHeader_word_index, luckysheetdefaultstyle } from '../controllers/constant';
import { columeHeader_word, columeHeader_word_index,luckysheetdefaultFont } from '../controllers/constant';
import menuButton from '../controllers/menuButton';
import { isdatatype, isdatatypemulti } from '../global/datecontroll';
import { hasChinaword } from '../global/validate';
@ -349,7 +349,7 @@ function luckysheetfontformat(format) {
return font;
}
else {
return luckysheetdefaultstyle.font;
return luckysheetdefaultFont();
}
}

Loading…
Cancel
Save