Browse Source

Merge pull request #862 from nekobc1998923/fix-allowEdit-false

fix: 修复了一波在禁止编辑情况下仍然可以编辑的问题。
master
mengshukeji 4 years ago
committed by GitHub
parent
commit
48811186a0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      src/controllers/handler.js
  2. 2
      src/controllers/keyboard.js
  3. 38
      src/controllers/menuButton.js
  4. 23
      src/controllers/rowColumnOperation.js
  5. 15
      src/global/validate.js

12
src/controllers/handler.js

@ -45,7 +45,7 @@ import {
mouseposition mouseposition
} from '../global/location'; } from '../global/location';
import { rowlenByRange } from '../global/getRowlen'; 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 { countfunc } from '../global/count';
import browser from '../global/browser'; import browser from '../global/browser';
import formula from '../global/formula'; import formula from '../global/formula';
@ -4863,6 +4863,11 @@ export default function luckysheetHandler() {
//菜单栏 插入图片按钮 //菜单栏 插入图片按钮
$("#luckysheet-insertImg-btn-title").click(function () { $("#luckysheet-insertImg-btn-title").click(function () {
// *如果禁止前台编辑,则中止下一步操作
if (!checkIsAllowEdit()) {
tooltip.info("", locale().pivotTable.errorNotAllowEdit);
return
}
if(!checkProtectionAuthorityNormal(Store.currentSheetIndex, "editObjects")){ if(!checkProtectionAuthorityNormal(Store.currentSheetIndex, "editObjects")){
return; return;
} }
@ -4888,6 +4893,11 @@ export default function luckysheetHandler() {
//菜单栏 插入链接按钮 //菜单栏 插入链接按钮
$("#luckysheet-insertLink-btn-title").click(function () { $("#luckysheet-insertLink-btn-title").click(function () {
// *如果禁止前台编辑,则中止下一步操作
if (!checkIsAllowEdit()) {
tooltip.info("", locale().pivotTable.errorNotAllowEdit);
return
}
if(!checkProtectionNotEnable(Store.currentSheetIndex)){ if(!checkProtectionNotEnable(Store.currentSheetIndex)){
return; return;
} }

2
src/controllers/keyboard.js

@ -587,7 +587,7 @@ export function keyboardInitial(){
$("#luckysheet-icon-italic").click(); $("#luckysheet-icon-italic").click();
} }
else if (kcode == 86) {//Ctrl + V 粘贴 else if (kcode == 86) {//Ctrl + V 粘贴
if(isEditMode()){//此模式下禁用粘贴 if (isEditMode() || Store.allowEdit === false){//此模式下禁用粘贴
return; return;
} }

38
src/controllers/menuButton.js

@ -16,7 +16,7 @@ import {luckysheetupdateCell} from './updateCell';
import insertFormula from './insertFormula'; import insertFormula from './insertFormula';
import sheetmanage from './sheetmanage'; import sheetmanage from './sheetmanage';
import luckysheetPostil from './postil'; 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 tooltip from '../global/tooltip';
import editor from '../global/editor'; import editor from '../global/editor';
import { genarate, update, is_date } from '../global/format'; import { genarate, update, is_date } from '../global/format';
@ -119,6 +119,11 @@ const menuButton = {
//格式刷 //格式刷
$("#luckysheet-icon-paintformat").click(function(e){ $("#luckysheet-icon-paintformat").click(function(e){
// *如果禁止前台编辑,则中止下一步操作
if (!checkIsAllowEdit()) {
tooltip.info("", locale().pivotTable.errorNotAllowEdit);
return
}
e.stopPropagation(); e.stopPropagation();
let _locale = locale(); let _locale = locale();
let locale_paint = _locale.paint; let locale_paint = _locale.paint;
@ -174,6 +179,11 @@ const menuButton = {
_this.luckysheetPaintSingle = true; _this.luckysheetPaintSingle = true;
}); });
$("#luckysheet-icon-paintformat").dblclick(function(){ $("#luckysheet-icon-paintformat").dblclick(function(){
// *如果禁止前台编辑,则中止下一步操作
if (!checkIsAllowEdit()) {
tooltip.info("", locale().pivotTable.errorNotAllowEdit);
return
}
let _locale = locale(); let _locale = locale();
let locale_paint = _locale.paint; let locale_paint = _locale.paint;
if(Store.luckysheet_select_save == null || Store.luckysheet_select_save.length == 0){ 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(){ $menuButton.find(".luckysheet-icon-alternateformat").click(function(){
// *如果禁止前台编辑,则中止下一步操作
if (!checkIsAllowEdit()) {
tooltip.info("", locale().pivotTable.errorNotAllowEdit);
return
}
$menuButton.hide(); $menuButton.hide();
luckysheetContainerFocus(); luckysheetContainerFocus();
@ -927,7 +942,11 @@ const menuButton = {
//边框设置 //边框设置
$("#luckysheet-icon-border-all").click(function(){ $("#luckysheet-icon-border-all").click(function(){
// *如果禁止前台编辑,则中止下一步操作
if (!checkIsAllowEdit()) {
tooltip.info("", locale().pivotTable.errorNotAllowEdit);
return
}
if(!checkProtectionFormatCells(Store.currentSheetIndex)){ if(!checkProtectionFormatCells(Store.currentSheetIndex)){
return; return;
} }
@ -1085,6 +1104,11 @@ const menuButton = {
// border choose menu // border choose menu
$menuButton.find(".luckysheet-cols-menuitem").click(function(){ $menuButton.find(".luckysheet-cols-menuitem").click(function(){
// *如果禁止前台编辑,则中止下一步操作
if (!checkIsAllowEdit()) {
tooltip.info("", locale().pivotTable.errorNotAllowEdit);
return
}
$menuButton.hide(); $menuButton.hide();
luckysheetContainerFocus(); luckysheetContainerFocus();
@ -1226,7 +1250,6 @@ const menuButton = {
//合并单元格 //合并单元格
$("#luckysheet-icon-merge-button").click(function(){ $("#luckysheet-icon-merge-button").click(function(){
if(!checkProtectionNotEnable(Store.currentSheetIndex)){ if(!checkProtectionNotEnable(Store.currentSheetIndex)){
return; return;
} }
@ -3128,7 +3151,9 @@ const menuButton = {
return; return;
} }
if(Store.allowEdit===false){ // *如果禁止前台编辑,则中止下一步操作
if (!checkIsAllowEdit()) {
tooltip.info("", locale().pivotTable.errorNotAllowEdit);
return; return;
} }
@ -3175,6 +3200,11 @@ const menuButton = {
jfrefreshgrid(d, Store.luckysheet_select_save, allParam, false); jfrefreshgrid(d, Store.luckysheet_select_save, allParam, false);
}, },
updateFormat_mc: function(d, foucsStatus){ updateFormat_mc: function(d, foucsStatus){
// *如果禁止前台编辑,则中止下一步操作
if (!checkIsAllowEdit()) {
tooltip.info("", locale().pivotTable.errorNotAllowEdit);
return
}
let cfg = $.extend(true, {}, Store.config); let cfg = $.extend(true, {}, Store.config);
if(cfg["merge"] == null){ if(cfg["merge"] == null){
cfg["merge"] = {}; cfg["merge"] = {};

23
src/controllers/rowColumnOperation.js

@ -21,7 +21,7 @@ import {
colLocationByIndex, colLocationByIndex,
mouseposition mouseposition
} from '../global/location'; } 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 { countfunc } from '../global/count';
import formula from '../global/formula'; import formula from '../global/formula';
import { luckysheetextendtable, luckysheetdeletetable, luckysheetDeleteCell } from '../global/extend'; import { luckysheetextendtable, luckysheetdeletetable, luckysheetDeleteCell } from '../global/extend';
@ -381,6 +381,10 @@ export function rowColumnOperationInitial(){
$("#luckysheet-rows-change-size").css("opacity", 0); $("#luckysheet-rows-change-size").css("opacity", 0);
}).mouseup(function (event) { }).mouseup(function (event) {
if (event.which == 3) { if (event.which == 3) {
// *如果禁止前台编辑,则中止下一步操作
if (!checkIsAllowEdit()) {
return
}
if(isEditMode()){ //非编辑模式下禁止右键功能框 if(isEditMode()){ //非编辑模式下禁止右键功能框
return; return;
} }
@ -815,6 +819,10 @@ export function rowColumnOperationInitial(){
$("#luckysheet-cols-change-size").css("opacity", 0); $("#luckysheet-cols-change-size").css("opacity", 0);
}).mouseup(function (event) { }).mouseup(function (event) {
if (event.which == 3) { if (event.which == 3) {
// *如果禁止前台编辑,则中止下一步操作
if (!checkIsAllowEdit()) {
return
}
if(isEditMode()){ //非编辑模式下禁止右键功能框 if(isEditMode()){ //非编辑模式下禁止右键功能框
return; return;
} }
@ -904,6 +912,10 @@ export function rowColumnOperationInitial(){
//表格行标题 改变行高按钮 //表格行标题 改变行高按钮
$("#luckysheet-rows-change-size").mousedown(function (event) { $("#luckysheet-rows-change-size").mousedown(function (event) {
// *如果禁止前台编辑,则中止下一步操作
if (!checkIsAllowEdit()) {
return
}
//有批注在编辑时 //有批注在编辑时
luckysheetPostil.removeActivePs(); luckysheetPostil.removeActivePs();
@ -948,6 +960,10 @@ export function rowColumnOperationInitial(){
//表格列标题 改变列宽按钮 //表格列标题 改变列宽按钮
$("#luckysheet-cols-change-size").mousedown(function (event) { $("#luckysheet-cols-change-size").mousedown(function (event) {
// *如果禁止前台编辑,则中止下一步操作
if (!checkIsAllowEdit()) {
return
}
//有批注在编辑时 //有批注在编辑时
luckysheetPostil.removeActivePs(); luckysheetPostil.removeActivePs();
@ -996,6 +1012,11 @@ export function rowColumnOperationInitial(){
// 列标题的下拉箭头 // 列标题的下拉箭头
$("#luckysheet-cols-menu-btn").click(function (event) { $("#luckysheet-cols-menu-btn").click(function (event) {
// *如果禁止前台编辑,则中止下一步操作
if (!checkIsAllowEdit()) {
tooltip.info("", locale().pivotTable.errorNotAllowEdit);
return
}
let $menu = $("#luckysheet-rightclick-menu"); let $menu = $("#luckysheet-rightclick-menu");
let offset = $(this).offset(); let offset = $(this).offset();
$("#luckysheet-cols-rows-shift").show(); $("#luckysheet-cols-rows-shift").show();

15
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) { function hasPartMC(cfg, r1, r2, c1, c2) {
let hasPartMC = false; let hasPartMC = false;
@ -200,6 +214,7 @@ export {
valueIsError, valueIsError,
hasChinaword, hasChinaword,
isEditMode, isEditMode,
checkIsAllowEdit,
hasPartMC, hasPartMC,
checkWordByteLength checkWordByteLength
} }
Loading…
Cancel
Save