diff --git a/src/controllers/handler.js b/src/controllers/handler.js index 770df04..c6bb6b6 100644 --- a/src/controllers/handler.js +++ b/src/controllers/handler.js @@ -45,7 +45,7 @@ import { mouseposition } from '../global/location'; import { rowlenByRange } from '../global/getRowlen'; -import { isRealNull, hasPartMC, isEditMode } from '../global/validate'; +import { isRealNull, hasPartMC, isEditMode, checkIsAllowEdit } from '../global/validate'; import { countfunc } from '../global/count'; import browser from '../global/browser'; import formula from '../global/formula'; @@ -4863,6 +4863,11 @@ export default function luckysheetHandler() { //菜单栏 插入图片按钮 $("#luckysheet-insertImg-btn-title").click(function () { + // *如果禁止前台编辑,则中止下一步操作 + if (!checkIsAllowEdit()) { + tooltip.info("", locale().pivotTable.errorNotAllowEdit); + return + } if(!checkProtectionAuthorityNormal(Store.currentSheetIndex, "editObjects")){ return; } @@ -4888,6 +4893,11 @@ export default function luckysheetHandler() { //菜单栏 插入链接按钮 $("#luckysheet-insertLink-btn-title").click(function () { + // *如果禁止前台编辑,则中止下一步操作 + if (!checkIsAllowEdit()) { + tooltip.info("", locale().pivotTable.errorNotAllowEdit); + return + } if(!checkProtectionNotEnable(Store.currentSheetIndex)){ return; } diff --git a/src/controllers/keyboard.js b/src/controllers/keyboard.js index ce2ac9d..496761a 100644 --- a/src/controllers/keyboard.js +++ b/src/controllers/keyboard.js @@ -587,7 +587,7 @@ export function keyboardInitial(){ $("#luckysheet-icon-italic").click(); } else if (kcode == 86) {//Ctrl + V 粘贴 - if(isEditMode()){//此模式下禁用粘贴 + if (isEditMode() || Store.allowEdit === false){//此模式下禁用粘贴 return; } diff --git a/src/controllers/menuButton.js b/src/controllers/menuButton.js index f7edb8e..26f635f 100644 --- a/src/controllers/menuButton.js +++ b/src/controllers/menuButton.js @@ -16,7 +16,7 @@ import {luckysheetupdateCell} from './updateCell'; import insertFormula from './insertFormula'; import sheetmanage from './sheetmanage'; import luckysheetPostil from './postil'; -import { isRealNum, isRealNull, isEditMode, hasPartMC } from '../global/validate'; +import { isRealNum, isRealNull, isEditMode, hasPartMC, checkIsAllowEdit } from '../global/validate'; import tooltip from '../global/tooltip'; import editor from '../global/editor'; import { genarate, update, is_date } from '../global/format'; @@ -119,6 +119,11 @@ const menuButton = { //格式刷 $("#luckysheet-icon-paintformat").click(function(e){ + // *如果禁止前台编辑,则中止下一步操作 + if (!checkIsAllowEdit()) { + tooltip.info("", locale().pivotTable.errorNotAllowEdit); + return + } e.stopPropagation(); let _locale = locale(); let locale_paint = _locale.paint; @@ -174,6 +179,11 @@ const menuButton = { _this.luckysheetPaintSingle = true; }); $("#luckysheet-icon-paintformat").dblclick(function(){ + // *如果禁止前台编辑,则中止下一步操作 + if (!checkIsAllowEdit()) { + tooltip.info("", locale().pivotTable.errorNotAllowEdit); + return + } let _locale = locale(); let locale_paint = _locale.paint; if(Store.luckysheet_select_save == null || Store.luckysheet_select_save.length == 0){ @@ -779,6 +789,11 @@ const menuButton = { //交替颜色 $menuButton.find(".luckysheet-icon-alternateformat").click(function(){ + // *如果禁止前台编辑,则中止下一步操作 + if (!checkIsAllowEdit()) { + tooltip.info("", locale().pivotTable.errorNotAllowEdit); + return + } $menuButton.hide(); luckysheetContainerFocus(); @@ -927,7 +942,11 @@ const menuButton = { //边框设置 $("#luckysheet-icon-border-all").click(function(){ - + // *如果禁止前台编辑,则中止下一步操作 + if (!checkIsAllowEdit()) { + tooltip.info("", locale().pivotTable.errorNotAllowEdit); + return + } if(!checkProtectionFormatCells(Store.currentSheetIndex)){ return; } @@ -1085,6 +1104,11 @@ const menuButton = { // border choose menu $menuButton.find(".luckysheet-cols-menuitem").click(function(){ + // *如果禁止前台编辑,则中止下一步操作 + if (!checkIsAllowEdit()) { + tooltip.info("", locale().pivotTable.errorNotAllowEdit); + return + } $menuButton.hide(); luckysheetContainerFocus(); @@ -1226,7 +1250,6 @@ const menuButton = { //合并单元格 $("#luckysheet-icon-merge-button").click(function(){ - if(!checkProtectionNotEnable(Store.currentSheetIndex)){ return; } @@ -3128,7 +3151,9 @@ const menuButton = { return; } - if(Store.allowEdit===false){ + // *如果禁止前台编辑,则中止下一步操作 + if (!checkIsAllowEdit()) { + tooltip.info("", locale().pivotTable.errorNotAllowEdit); return; } @@ -3175,6 +3200,11 @@ const menuButton = { jfrefreshgrid(d, Store.luckysheet_select_save, allParam, false); }, updateFormat_mc: function(d, foucsStatus){ + // *如果禁止前台编辑,则中止下一步操作 + if (!checkIsAllowEdit()) { + tooltip.info("", locale().pivotTable.errorNotAllowEdit); + return + } let cfg = $.extend(true, {}, Store.config); if(cfg["merge"] == null){ cfg["merge"] = {}; diff --git a/src/controllers/rowColumnOperation.js b/src/controllers/rowColumnOperation.js index d881ae4..59c4af5 100644 --- a/src/controllers/rowColumnOperation.js +++ b/src/controllers/rowColumnOperation.js @@ -21,7 +21,7 @@ import { colLocationByIndex, mouseposition } from '../global/location'; -import { isRealNull, isRealNum, hasPartMC, isEditMode } from '../global/validate'; +import { isRealNull, isRealNum, hasPartMC, isEditMode, checkIsAllowEdit } from '../global/validate'; import { countfunc } from '../global/count'; import formula from '../global/formula'; import { luckysheetextendtable, luckysheetdeletetable, luckysheetDeleteCell } from '../global/extend'; @@ -381,6 +381,10 @@ export function rowColumnOperationInitial(){ $("#luckysheet-rows-change-size").css("opacity", 0); }).mouseup(function (event) { if (event.which == 3) { + // *如果禁止前台编辑,则中止下一步操作 + if (!checkIsAllowEdit()) { + return + } if(isEditMode()){ //非编辑模式下禁止右键功能框 return; } @@ -815,6 +819,10 @@ export function rowColumnOperationInitial(){ $("#luckysheet-cols-change-size").css("opacity", 0); }).mouseup(function (event) { if (event.which == 3) { + // *如果禁止前台编辑,则中止下一步操作 + if (!checkIsAllowEdit()) { + return + } if(isEditMode()){ //非编辑模式下禁止右键功能框 return; } @@ -904,6 +912,10 @@ export function rowColumnOperationInitial(){ //表格行标题 改变行高按钮 $("#luckysheet-rows-change-size").mousedown(function (event) { + // *如果禁止前台编辑,则中止下一步操作 + if (!checkIsAllowEdit()) { + return + } //有批注在编辑时 luckysheetPostil.removeActivePs(); @@ -948,6 +960,10 @@ export function rowColumnOperationInitial(){ //表格列标题 改变列宽按钮 $("#luckysheet-cols-change-size").mousedown(function (event) { + // *如果禁止前台编辑,则中止下一步操作 + if (!checkIsAllowEdit()) { + return + } //有批注在编辑时 luckysheetPostil.removeActivePs(); @@ -996,6 +1012,11 @@ export function rowColumnOperationInitial(){ // 列标题的下拉箭头 $("#luckysheet-cols-menu-btn").click(function (event) { + // *如果禁止前台编辑,则中止下一步操作 + if (!checkIsAllowEdit()) { + tooltip.info("", locale().pivotTable.errorNotAllowEdit); + return + } let $menu = $("#luckysheet-rightclick-menu"); let offset = $(this).offset(); $("#luckysheet-cols-rows-shift").show(); diff --git a/src/global/validate.js b/src/global/validate.js index ddcd559..adbb91f 100644 --- a/src/global/validate.js +++ b/src/global/validate.js @@ -76,6 +76,20 @@ function isEditMode() { } } +/** + * @description: 检查是否允许前台进行表格编辑 + * @param {*} + * @return {Boolean} true:允许编辑 fasle:不允许 + */ +function checkIsAllowEdit(){ + if (Store.allowEdit) { + return true; + } + else { + return false; + } +} + //范围是否只包含部分合并单元格 function hasPartMC(cfg, r1, r2, c1, c2) { let hasPartMC = false; @@ -200,6 +214,7 @@ export { valueIsError, hasChinaword, isEditMode, + checkIsAllowEdit, hasPartMC, checkWordByteLength } \ No newline at end of file