From a71c92a5f05aaed6c3df1556a81fc1b2ed97419a Mon Sep 17 00:00:00 2001 From: wbfsa Date: Thu, 8 Oct 2020 20:32:07 +0800 Subject: [PATCH] feat(protection feature): protection feature similar to Excel fix some bug --- gulpfile.js | 3 +- package.json | 4 +- src/controllers/cellFormat.js | 191 ++++ src/controllers/conditionformat.js | 37 + src/controllers/constant.js | 23 +- src/controllers/dropCell.js | 5 + src/controllers/filter.js | 13 + src/controllers/handler.js | 66 +- src/controllers/imageCtrl.js | 29 +- src/controllers/inlineString.js | 5 +- src/controllers/menuButton.js | 37 + src/controllers/orderBy.js | 7 +- src/controllers/pivotTable.js | 14 +- src/controllers/postil.js | 24 + src/controllers/print.js | 13 + src/controllers/protection.js | 1148 +++++++++++++++++++++++++ src/controllers/resize.js | 9 +- src/controllers/rowColumnOperation.js | 68 +- src/controllers/selection.js | 23 +- src/controllers/sheetmanage.js | 174 ++-- src/controllers/updateCell.js | 20 +- src/css/luckysheet-cellFormat.css | 67 ++ src/css/luckysheet-protection.css | 255 ++++++ src/global/api.js | 28 +- src/global/extend.js | 38 +- src/global/formula.js | 39 + src/global/method.js | 253 +++++- src/global/sort.js | 7 + src/index.html | 1 + src/locale/en.js | 85 +- src/locale/zh.js | 82 +- src/plugins/js/crypto-api.min.js | 2 + src/utils/util.js | 75 +- 33 files changed, 2731 insertions(+), 114 deletions(-) create mode 100644 src/controllers/cellFormat.js create mode 100644 src/controllers/print.js create mode 100644 src/controllers/protection.js create mode 100644 src/css/luckysheet-cellFormat.css create mode 100644 src/css/luckysheet-protection.css create mode 100644 src/plugins/js/crypto-api.min.js diff --git a/gulpfile.js b/gulpfile.js index ae08e0e24..3e3962125 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -89,7 +89,8 @@ const paths = { 'src/plugins/js/localforage.min.js', 'src/plugins/js/lodash.min.js', 'src/plugins/js/daterangepicker.js', - 'src/plugins/js/jstat.min.js' + 'src/plugins/js/jstat.min.js', + 'src/plugins/js/crypto-api.min.js' ], //plugins concat diff --git a/package.json b/package.json index 1e9a0fd90..c6c9d8636 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,9 @@ "standard-version": "^8.0.2", "vuepress": "^1.5.0" }, - "dependencies": {}, + "dependencies": { + "jspdf": "^2.1.1" + }, "scripts": { "build": "cross-env NODE_ENV=production gulp build", "dev": "cross-env NODE_ENV=development gulp dev", diff --git a/src/controllers/cellFormat.js b/src/controllers/cellFormat.js new file mode 100644 index 000000000..87c69c90f --- /dev/null +++ b/src/controllers/cellFormat.js @@ -0,0 +1,191 @@ +import Store from '../store'; +import { replaceHtml,transformRangeToAbsolute,openSelfModel } from '../utils/util'; +import { modelHTML } from './constant'; +import sheetmanage from './sheetmanage'; +import menuButton from './menuButton'; +import {checkProtectionNotEnable} from './protection'; +import { jfrefreshgrid } from '../global/refresh'; +import locale from '../locale/locale'; + + +let isInitialCellFormatModel = false; + +function initialCellFormatModelEvent(){ + const _locale = locale(); + const local_cellFormat = _locale.cellFormat; + + $("#luckysheet-cellFormat-confirm").click(function(){ + let locked = $("#luckysheet-protection-check-locked").is(':checked'); + let hidden = $("#luckysheet-protection-check-hidden").is(':checked'); + + locked = locked==true?1:0; + hidden = hidden==true?1:0; + + let d = recycleSeletion( + function(cell){ + cell.lo = locked; + cell.hi = hidden; + }, + function(){ + alert(local_cellFormat.sheetDataIsNullAlert); + } + ); + + jfrefreshgrid(d, undefined, undefined, false); + + $("#luckysheet-cellFormat-config").hide(); + $("#luckysheet-modal-dialog-mask").hide(); + }); +} + +function recycleSeletion(cycleFunction, dataIsNullFunction){ + if(Store.luckysheet_select_save != null && Store.luckysheet_select_save.length > 0){ + let sheetFile = sheetmanage.getSheetByIndex(), data=sheetFile.data; + if(data!=null){ + + for(let i=0;i