Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
fix(bug): bug
Browse files Browse the repository at this point in the history
bug
  • Loading branch information
wpxp123456 committed Sep 25, 2020
1 parent f4625d1 commit 6bb113b
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 42 deletions.
199 changes: 161 additions & 38 deletions src/controllers/dataVerificationCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -976,11 +998,94 @@ const dataVerificationCtrl = {

//提示语
if(item.hintShow){
let hintText = item.hintText;
let hintText;

if(Store.lang == 'en'){
hintText = '<span style="color:#f5a623;">Hint: </span>';
}
else{
hintText = '<span style="color:#f5a623;">提示:</span>';
}

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 = '<span style="color:#f72626;">Failure: </span>';
}
else{
failureText = '<span style="color:#f72626;">失效:</span>';
}

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 += '<span style="color:#f5a623;">提示:</span>';
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 += '请选择下拉列表中的选项';
}
Expand Down Expand Up @@ -1021,75 +1126,93 @@ const dataVerificationCtrl = {
hintText += '请输入正确的' + _this.optionLabel[item.type2];
}
}
else{
hintText = '<span style="color:#f5a623;">提示:</span>' + 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 = '<span style="color:#f72626;">失效:</span>';
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;
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/imageCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
})

//边框颜色 选择
Expand Down
2 changes: 2 additions & 0 deletions src/controllers/sheetmanage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"]);
},
Expand Down
16 changes: 13 additions & 3 deletions src/global/formula.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 6bb113b

Please sign in to comment.