From 6bb113bb4421fc0497f7cf833975e4e2e7544aaa Mon Sep 17 00:00:00 2001
From: wpxp123456 <2677556700@qq.com>
Date: Fri, 25 Sep 2020 15:15:54 +0800
Subject: [PATCH] fix(bug): bug
bug
---
src/controllers/dataVerificationCtrl.js | 199 +++++++++++++++++++-----
src/controllers/imageCtrl.js | 2 +-
src/controllers/sheetmanage.js | 2 +
src/global/formula.js | 16 +-
4 files changed, 177 insertions(+), 42 deletions(-)
diff --git a/src/controllers/dataVerificationCtrl.js b/src/controllers/dataVerificationCtrl.js
index dc3d798d5..5251501b7 100644
--- a/src/controllers/dataVerificationCtrl.js
+++ b/src/controllers/dataVerificationCtrl.js
@@ -53,6 +53,28 @@ const dataVerificationCtrl = {
'card': '身份证号码',
'phone': '手机号'
},
+ optionLabel_en: {
+ 'number': 'numeric',
+ 'number_integer': 'integer',
+ 'number_decimal': 'decimal',
+ 'bw': 'between',
+ 'nb': 'not between',
+ 'eq': 'equal to',
+ 'ne': 'not equal to',
+ 'gt': 'greater',
+ 'lt': 'less than',
+ 'gte': 'greater or equal to',
+ 'lte': 'less than or equal to',
+ 'include': 'include',
+ 'exclude': 'not include',
+ 'equal': 'equal to',
+ 'bf': 'earlier than',
+ 'nbf': 'not earlier than',
+ 'af': 'later than',
+ 'naf': 'not later than',
+ 'card': 'identification number',
+ 'phone': 'phone number'
+ },
createDialog: function(){
let _this = this;
@@ -976,11 +998,94 @@ const dataVerificationCtrl = {
//提示语
if(item.hintShow){
- let hintText = item.hintText;
+ let hintText;
+
+ if(Store.lang == 'en'){
+ hintText = 'Hint: ';
+ }
+ else{
+ hintText = '提示:';
+ }
+
+ hintText += _this.getHintText(item);
+
+ $("#luckysheet-dataVerification-showHintBox").html(hintText).show().css({
+ 'left': col_pre,
+ 'top': row
+ });
+
+ return;
+ }
+
+ //数据验证未通过
+ let cellValue = getcellvalue(r, c, null);
+
+ if(cellValue == null || cellValue == ""){
+ return;
+ }
+
+ let validate = _this.validateCellData(cellValue, item);
+
+ if(!validate){
+ let failureText;
+
+ if(Store.lang == 'en'){
+ failureText = 'Failure: ';
+ }
+ else{
+ failureText = '失效:';
+ }
+
+ failureText += _this.getFailureText(item);
+
+ $("#luckysheet-dataVerification-showHintBox").html(failureText).show().css({
+ 'left': col_pre,
+ 'top': row
+ });
+ }
+ },
+ getHintText: function(item) {
+ let _this = this;
- if(hintText.length == 0){
- hintText += '提示:';
+ let hintText = item.hintText || '';
+ if(hintText.length == 0){
+ if(Store.lang == 'en'){
+ if(item.type == 'dropdown'){
+ hintText += 'please select an option in the drop-down list';
+ }
+ else if(item.type == 'checkbox'){
+
+ }
+ else if(item.type == 'number' || item.type == 'number_integer' || item.type == 'number_decimal'){
+ hintText += 'please enter a ' + _this.optionLabel_en[item.type] + ' ' + _this.optionLabel_en[item.type2] + ' ' + item.value1;
+
+ if(item.type2 == 'bw' || item.type2 == 'nb'){
+ hintText += ' and ' + item.value2;
+ }
+ }
+ else if(item.type == 'text_content'){
+ hintText += 'please enter text ' + _this.optionLabel_en[item.type2] + ' ' + item.value1;
+ }
+ else if(item.type == 'text_length'){
+ hintText += 'please enter text with length ' + _this.optionLabel_en[item.type2] + ' ' + item.value1;
+
+ if(item.type2 == 'bw' || item.type2 == 'nb'){
+ hintText += ' and ' + item.value2;
+ }
+ }
+ else if(item.type == 'date'){
+ hintText += 'please enter a date ' + _this.optionLabel_en[item.type2] + ' ' + item.value1;
+
+ if(item.type2 == 'bw' || item.type2 == 'nb'){
+ hintText += ' and ' + item.value2;
+ }
+ }
+ else if(item.type == 'validity'){
+ hintText += 'please enter the correct ' + _this.optionLabel_en[item.type2];
+ }
+ }
+ else{
if(item.type == 'dropdown'){
hintText += '请选择下拉列表中的选项';
}
@@ -1021,75 +1126,93 @@ const dataVerificationCtrl = {
hintText += '请输入正确的' + _this.optionLabel[item.type2];
}
}
- else{
- hintText = '提示:' + hintText;
- }
+ }
- $("#luckysheet-dataVerification-showHintBox").html(hintText).show().css({
- 'left': col_pre,
- 'top': row
- });
+ return hintText;
+ },
+ getFailureText: function(item) {
+ let _this = this;
- return;
- }
-
- //数据验证未通过
- let cellValue = getcellvalue(r, c, null);
+ let failureText = '';
- if(cellValue == null || cellValue == ""){
- return;
- }
+ if(Store.lang == 'en'){
+ if(item.type == 'dropdown'){
+ failureText += 'what you selected is not an option in the drop-down list';
+ }
+ else if(item.type == 'checkbox'){
- let validate = _this.validateCellData(cellValue, item);
+ }
+ else if(item.type == 'number' || item.type == 'number_integer' || item.type == 'number_decimal'){
+ failureText += 'what you entered is not a ' + _this.optionLabel_en[item.type] + ' ' + _this.optionLabel_en[item.type2] + ' ' + item.value1;
- if(!validate){
- let hintText = '失效:';
+ if(item.type2 == 'bw' || item.type2 == 'nb'){
+ failureText += ' and ' + item.value2;
+ }
+ }
+ else if(item.type == 'text_content'){
+ failureText += 'what you entered is not text that ' + _this.optionLabel_en[item.type2] + ' ' + item.value1;
+ }
+ else if(item.type == 'text_length'){
+ failureText += 'the text you entered is not length ' + _this.optionLabel_en[item.type2] + ' ' + item.value1;
+
+ if(item.type2 == 'bw' || item.type2 == 'nb'){
+ failureText += ' and ' + item.value2;
+ }
+ }
+ else if(item.type == 'date'){
+ failureText += 'the date you entered is not ' + _this.optionLabel_en[item.type2] + ' ' + item.value1;
+ if(item.type2 == 'bw' || item.type2 == 'nb'){
+ failureText += ' and ' + item.value2;
+ }
+ }
+ else if(item.type == 'validity'){
+ failureText += 'what you entered is not a correct ' + _this.optionLabel_en[item.type2];
+ }
+ }
+ else{
if(item.type == 'dropdown'){
- hintText += '你选择的不是下拉列表中的选项';
+ failureText += '你选择的不是下拉列表中的选项';
}
else if(item.type == 'checkbox'){
}
else if(item.type == 'number' || item.type == 'number_integer' || item.type == 'number_decimal'){
- hintText += '你输入的不是' + _this.optionLabel[item.type2] + item.value1;
+ failureText += '你输入的不是' + _this.optionLabel[item.type2] + item.value1;
if(item.type2 == 'bw' || item.type2 == 'nb'){
- hintText += '和' + item.value2 + '之间';
+ failureText += '和' + item.value2 + '之间';
}
- hintText += '的' + _this.optionLabel[item.type];
+ failureText += '的' + _this.optionLabel[item.type];
}
else if(item.type == 'text_content'){
- hintText += '你输入的不是内容' + _this.optionLabel[item.type2] + item.value1 + '的文本';
+ failureText += '你输入的不是内容' + _this.optionLabel[item.type2] + item.value1 + '的文本';
}
else if(item.type == 'text_length'){
- hintText += '你输入的不是长度' + _this.optionLabel[item.type2] + item.value1;
+ failureText += '你输入的不是长度' + _this.optionLabel[item.type2] + item.value1;
if(item.type2 == 'bw' || item.type2 == 'nb'){
- hintText += '和' + item.value2 + '之间';
+ failureText += '和' + item.value2 + '之间';
}
- hintText += '的文本';
+ failureText += '的文本';
}
else if(item.type == 'date'){
- hintText += '你输入的不是' + _this.optionLabel[item.type2] + item.value1;
+ failureText += '你输入的不是' + _this.optionLabel[item.type2] + item.value1;
if(item.type2 == 'bw' || item.type2 == 'nb'){
- hintText += '和' + item.value2 + '之间';
+ failureText += '和' + item.value2 + '之间';
}
- hintText += '的日期';
+ failureText += '的日期';
}
else if(item.type == 'validity'){
- hintText += '你输入的不是一个正确的' + _this.optionLabel[item.type2];
+ failureText += '你输入的不是一个正确的' + _this.optionLabel[item.type2];
}
-
- $("#luckysheet-dataVerification-showHintBox").html(hintText).show().css({
- 'left': col_pre,
- 'top': row
- });
}
+
+ return failureText;
},
validateCellData: function(cellValue, item){
let _this = this;
diff --git a/src/controllers/imageCtrl.js b/src/controllers/imageCtrl.js
index 374bd7943..0cefb024b 100644
--- a/src/controllers/imageCtrl.js
+++ b/src/controllers/imageCtrl.js
@@ -306,7 +306,7 @@ const imageCtrl = {
//边框样式
$("#luckysheet-modal-dialog-slider-imageCtrl").off("change.borderStyle").on("change.borderStyle", "#imgItemBorderStyle", function() {
- _this.configChange("border-radius", this.value);
+ _this.configChange("border-style", this.value);
})
//边框颜色 选择
diff --git a/src/controllers/sheetmanage.js b/src/controllers/sheetmanage.js
index 2b0c8f4dd..7ae2d7147 100644
--- a/src/controllers/sheetmanage.js
+++ b/src/controllers/sheetmanage.js
@@ -886,9 +886,11 @@ const sheetmanage = {
//图片
imageCtrl.images = file.images;
imageCtrl.allImagesShow();
+ imageCtrl.init();
//数据验证
dataVerificationCtrl.dataVerification = file.dataVerification;
+ dataVerificationCtrl.init();
createFilterOptions(file["filter_select"], file["filter"]);
},
diff --git a/src/global/formula.js b/src/global/formula.js
index b329411c8..828cfde1b 100644
--- a/src/global/formula.js
+++ b/src/global/formula.js
@@ -6,6 +6,7 @@ import sheetmanage from '../controllers/sheetmanage';
import menuButton from '../controllers/menuButton';
import server from '../controllers/server';
import luckysheetFreezen from '../controllers/freezen';
+import dataVerificationCtrl from '../controllers/dataVerificationCtrl';
import { seletedHighlistByindex, luckysheet_count_show } from '../controllers/select';
import { isRealNum, isRealNull, valueIsError, isEditMode } from './validate';
import { isdatetime, isdatatype } from './datecontroll';
@@ -1201,13 +1202,22 @@ const luckysheetformula = {
let $input = $("#luckysheet-rich-text-editor");
let inputText = $input.text(), inputHtml = $input.html();
-
-
-
if (_this.rangetosheet != null && _this.rangetosheet != Store.currentSheetIndex) {
sheetmanage.changeSheetExec(_this.rangetosheet);
}
+ //数据验证 输入数据无效时禁止输入
+ if(dataVerificationCtrl.dataVerification != null){
+ let dvItem = dataVerificationCtrl.dataVerification[r + '_' + c];
+
+ if(dvItem != null && dvItem.prohibitInput && !dataVerificationCtrl.validateCellData(inputText, dvItem)){
+ let failureText = dataVerificationCtrl.getFailureText(dvItem);
+ tooltip.info(failureText, '');
+ _this.cancelNormalSelected();
+ return;
+ }
+ }
+
let curv = Store.flowdata[r][c];
let isPrevInline = isInlineStringCell(curv);
let isCurInline = (inputText.slice(0, 1) != "=" && inputHtml.indexOf("span")>-1);