diff --git a/src/controllers/constant.js b/src/controllers/constant.js index d2ae6c7..e286c19 100644 --- a/src/controllers/constant.js +++ b/src/controllers/constant.js @@ -246,7 +246,9 @@ const columeHeader_word = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K' //右键菜单dom function rightclickHTML(){ - const rightclick = locale().rightclick; + const _locale = locale(); + const rightclick = _locale.rightclick; + const toolbar = _locale.toolbar; return `
@@ -349,6 +351,12 @@ function rightclickHTML(){
${rightclick.chartGeneration}
+
+
${toolbar.insertImage}
+
+
+
${toolbar.dataVerification}
+
diff --git a/src/controllers/dataVerificationCtrl.js b/src/controllers/dataVerificationCtrl.js index 95572da..37c2688 100644 --- a/src/controllers/dataVerificationCtrl.js +++ b/src/controllers/dataVerificationCtrl.js @@ -12,6 +12,7 @@ import { selectionCopyShow } from './select'; import server from './server'; import menuButton from './menuButton'; import { getSheetIndex, getRangetxt } from '../methods/get'; +import locale from '../locale/locale'; import Store from '../store'; const dataVerificationCtrl = { @@ -55,57 +56,62 @@ const dataVerificationCtrl = { createDialog: function(){ let _this = this; + const _locale = locale(); + const dvText = _locale.dataVerification; + const toolbarText = _locale.toolbar; + const buttonText = _locale.button; + $("#luckysheet-modal-dialog-mask").show(); $("#luckysheet-dataVerification-dialog").remove(); let content = `
-
单元格范围
+
${dvText.cellRange}
- +
-
验证条件
+
${dvText.verificationCondition}
- - + +
- 选择时 —— - + ${dvText.selected} —— +
- 未选择 —— - + ${dvText.notSelected} —— +
@@ -113,29 +119,29 @@ const dataVerificationCtrl = {
- +
- +
@@ -143,19 +149,19 @@ const dataVerificationCtrl = {
- +
@@ -168,8 +174,8 @@ const dataVerificationCtrl = {
@@ -177,18 +183,18 @@ const dataVerificationCtrl = {
- +
- +
- +
- +
`; @@ -196,11 +202,11 @@ const dataVerificationCtrl = { $("body").append(replaceHtml(modelHTML, { "id": "luckysheet-dataVerification-dialog", "addclass": "luckysheet-dataVerification-dialog", - "title": "数据验证", + "title": toolbarText.dataVerification, "content": content, - "botton": ` - - `, + "botton": ` + + `, "style": "z-index:100003" })); let $t = $("#luckysheet-dataVerification-dialog").find(".luckysheet-modal-dialog-content").css("min-width", 350).end(), @@ -220,6 +226,8 @@ const dataVerificationCtrl = { init: function(){ let _this = this; + const dvText = locale().dataVerification; + //单元格数据验证 类型是 下拉列表 $(document).off("click.dropdownBtn").on("click.dropdownBtn", "#luckysheet-dataVerification-dropdown-btn", function(e) { _this.dropdownListShow(); @@ -539,7 +547,7 @@ const dataVerificationCtrl = { let range = _this.getRangeByTxt(rangeTxt); if(range.length == 0){ - tooltip.info('', '请选择单元格范围'); + tooltip.info('', dvText.selectCellRange2); return; } @@ -550,7 +558,7 @@ const dataVerificationCtrl = { value1 = $("#luckysheet-dataVerification-dialog .show-box-item-dropdown .data-verification-value1").val().trim(); if(value1.length == 0){ - tooltip.info('', '下拉列表选项不可为空'); + tooltip.info('', dvText.tooltipInfo1); return; } } @@ -559,7 +567,7 @@ const dataVerificationCtrl = { value2 = $("#luckysheet-dataVerification-dialog .show-box-item-checkbox .data-verification-value2").val().trim(); if(value1.length == 0 || value2.length == 0){ - tooltip.info('', '复选框内容不可为空'); + tooltip.info('', dvText.tooltipInfo2); return; } } @@ -568,7 +576,7 @@ const dataVerificationCtrl = { value1 = $("#luckysheet-dataVerification-dialog .show-box-item-number .data-verification-value1").val().trim(); if(!isRealNum(value1)){ - tooltip.info('', '输入的值不是数值类型'); + tooltip.info('', dvText.tooltipInfo3); return; } @@ -576,12 +584,12 @@ const dataVerificationCtrl = { value2 = $("#luckysheet-dataVerification-dialog .show-box-item-number .data-verification-value2").val().trim(); if(!isRealNum(value2)){ - tooltip.info('', '输入的值不是数值类型'); + tooltip.info('', dvText.tooltipInfo3); return; } if(Number(value2) < Number(value1)){ - tooltip.info('', '数值2不能小于数值1'); + tooltip.info('', dvText.tooltipInfo4); return; } } @@ -591,7 +599,7 @@ const dataVerificationCtrl = { value1 = $("#luckysheet-dataVerification-dialog .show-box-item-text .data-verification-value1").val().trim(); if(value1.length == 0){ - tooltip.info('', '文本内容不能为空'); + tooltip.info('', dvText.tooltipInfo5); return; } } @@ -600,7 +608,7 @@ const dataVerificationCtrl = { value1 = $("#luckysheet-dataVerification-dialog .show-box-item-textLength .data-verification-value1").val().trim(); if(!isRealNum(value1)){ - tooltip.info('', '输入的值不是数值类型'); + tooltip.info('', dvText.tooltipInfo3); return; } @@ -608,12 +616,12 @@ const dataVerificationCtrl = { value2 = $("#luckysheet-dataVerification-dialog .show-box-item-textLength .data-verification-value2").val().trim(); if(!isRealNum(value2)){ - tooltip.info('', '输入的值不是数值类型'); + tooltip.info('', dvText.tooltipInfo3); return; } if(Number(value2) < Number(value1)){ - tooltip.info('', '数值2不能小于数值1'); + tooltip.info('', dvText.tooltipInfo4); return; } } @@ -623,7 +631,7 @@ const dataVerificationCtrl = { value1 = $("#luckysheet-dataVerification-dialog .show-box-item-date .data-verification-value1").val().trim(); if(!isdatetime(value1)){ - tooltip.info('', '输入的值不是日期类型'); + tooltip.info('', dvText.tooltipInfo6); return; } @@ -631,12 +639,12 @@ const dataVerificationCtrl = { value2 = $("#luckysheet-dataVerification-dialog .show-box-item-date .data-verification-value2").val().trim(); if(!isdatetime(value2)){ - tooltip.info('', '输入的值不是日期类型'); + tooltip.info('', dvText.tooltipInfo6); return; } if(diff(value1, value2) > 0){ - tooltip.info('', '日期2不能小于日期1'); + tooltip.info('', dvText.tooltipInfo7); return; } } @@ -699,6 +707,30 @@ const dataVerificationCtrl = { //删除验证按钮 $(document).off("click.delete").on("click.delete", "#luckysheet-dataVerification-dialog-delete", function(e) { + let rangeTxt = $("#luckysheet-dataVerification-dialog #data-verification-range input").val().trim(); + let range = _this.getRangeByTxt(rangeTxt); + + if(range.length == 0){ + tooltip.info('', dvText.selectCellRange2); + return; + } + + let historyDataVerification = $.extend(true, {}, _this.dataVerification); + let currentDataVerification = $.extend(true, {}, _this.dataVerification); + + let str = range[range.length - 1].row[0], + edr = range[range.length - 1].row[1], + stc = range[range.length - 1].column[0], + edc = range[range.length - 1].column[1]; + + for(let r = str; r <= edr; r++){ + for(let c = stc; c <= edc; c++){ + delete currentDataVerification[r + '_' + c]; + } + } + + _this.ref(historyDataVerification, currentDataVerification, Store.currentSheetIndex); + $("#luckysheet-modal-dialog-mask").hide(); $("#luckysheet-dataVerification-dialog").hide(); }); @@ -822,16 +854,20 @@ const dataVerificationCtrl = { rangeDialog: function(dataSource, txt){ let _this = this; + const _locale = locale(); + const dvText = _locale.dataVerification; + const buttonText = _locale.button; + $("#luckysheet-modal-dialog-mask").hide(); $("#luckysheet-dataVerificationRange-dialog").remove(); $("body").append(replaceHtml(modelHTML, { "id": "luckysheet-dataVerificationRange-dialog", "addclass": "luckysheet-dataVerificationRange-dialog", - "title": "点击选择单元格范围", - "content": ``, - "botton": ` - `, + "title": dvText.selectCellRange, + "content": ``, + "botton": ` + `, "style": "z-index:100003" })); let $t = $("#luckysheet-dataVerificationRange-dialog") @@ -925,6 +961,14 @@ const dataVerificationCtrl = { 'left': col - 20, 'top': row_pre + (row - row_pre - 20) / 2 }) + + if($("#luckysheet-dataVerification-dropdown-List").is(":visible")){ + let dataIndex = $("#luckysheet-dataVerification-dropdown-List").prop("data-index"); + + if(dataIndex != (r + '_' + c)){ + $("#luckysheet-dataVerification-dropdown-List").hide(); + } + } } else{ $("#luckysheet-dataVerification-dropdown-List").hide(); @@ -1249,7 +1293,11 @@ const dataVerificationCtrl = { optionHtml += ``; }) - $("#luckysheet-dataVerification-dropdown-List").html(optionHtml).show().css({ + $("#luckysheet-dataVerification-dropdown-List") + .html(optionHtml) + .prop("data-index", rowIndex + '_' + colIndex) + .show() + .css({ 'width': col - col_pre - 1, 'left': col_pre, 'top': row, diff --git a/src/controllers/handler.js b/src/controllers/handler.js index 572a20c..7449e49 100644 --- a/src/controllers/handler.js +++ b/src/controllers/handler.js @@ -4277,6 +4277,10 @@ export default function luckysheetHandler() { $("#luckysheet-insertImg-btn-title").click(function () { $("#luckysheet-imgUpload").click(); }); + $("#luckysheetInsertImage").click(function () { + $("#luckysheet-imgUpload").click(); + $("#luckysheet-rightclick-menu").hide(); + }) $("#luckysheet-imgUpload").click(function (e) { e.stopPropagation(); }); @@ -4301,6 +4305,10 @@ export default function luckysheetHandler() { dataVerificationCtrl.createDialog(); dataVerificationCtrl.init(); }) + $("#luckysheetDataVerification").click(function () { + $("#luckysheet-dataVerification-btn-title").click(); + $("#luckysheet-rightclick-menu").hide(); + }) //冻结行列 $("#luckysheet-freezen-btn-horizontal").click(function () { diff --git a/src/controllers/menuButton.js b/src/controllers/menuButton.js index 56ef056..f9b1980 100644 --- a/src/controllers/menuButton.js +++ b/src/controllers/menuButton.js @@ -2948,10 +2948,10 @@ const menuButton = { } if(attr == "tb" || attr == "tr" || attr == "fs"){ - jfrefreshgrid(d, Store.luckysheet_select_save, cfg, null, true, false); + jfrefreshgrid(d, Store.luckysheet_select_save, cfg, null, true, null, false); } else{ - jfrefreshgrid(d, Store.luckysheet_select_save, undefined, undefined,undefined,false); + jfrefreshgrid(d, Store.luckysheet_select_save, undefined, undefined,undefined,undefined,false); } }, updateFormat_mc: function(d, foucsStatus){ diff --git a/src/global/draw.js b/src/global/draw.js index d96fbef..0120760 100644 --- a/src/global/draw.js +++ b/src/global/draw.js @@ -1320,8 +1320,10 @@ let cellRender = function(r, c, start_r, start_c, end_r, end_c, value, luckyshee luckysheetTableContent.rect(pos_x, pos_y, cellWidth, cellHeight); luckysheetTableContent.clip(); luckysheetTableContent.scale(Store.zoomRatio,Store.zoomRatio); - - textMetrics += 14; + + let measureText = getMeasureText(value, luckysheetTableContent); + let textMetrics = measureText.width + 14; + let oneLineTextHeight = measureText.actualBoundingBoxDescent + measureText.actualBoundingBoxAscent; let horizonAlignPos = (pos_x + space_width) ; //默认为1,左对齐 if(horizonAlign == "0"){ //居中对齐 diff --git a/src/locale/en.js b/src/locale/en.js index e364e6e..fab45f9 100644 --- a/src/locale/en.js +++ b/src/locale/en.js @@ -609,7 +609,6 @@ export default { "space":"space", }, - findAndReplace:{ find:"Find", replace:"Replace", @@ -867,6 +866,55 @@ export default { fiveQuadrantDiagram: 'Five-quadrant diagram', fiveBoxes: '5 Boxes', }, + dataVerification: { + cellRange: 'Cell range', + selectCellRange: 'Click to select cell range', + selectCellRange2: 'Please select a range of cells', + verificationCondition: 'Verification condition', + dropdown: 'drop-down list', + checkbox: 'Checkbox', + number: 'Number', + number_integer: 'Number-integer', + number_decimal: 'Number-decimal', + text_content: 'Text-content', + text_length: 'Text-length', + date: 'Date', + validity: 'Effectiveness', + placeholder1: 'Please enter the options, separated by commas, such as 1,2,3,4,5', + placeholder2: 'Please enter content', + placeholder3: 'Numeric value, such as 10', + placeholder4: 'Please enter the specified text', + placeholder5: 'Please enter the prompt displayed when the cell is selected', + selected: 'Selected', + notSelected: 'Not selected', + between: 'Between', + notBetween: 'Not between', + equal: 'Equal', + notEqualTo: 'Not equal to', + moreThanThe: 'More than the', + lessThan: 'Less than', + greaterOrEqualTo: 'Greater or equal to', + lessThanOrEqualTo: 'Less than or equal to', + include: 'Include', + exclude: 'Exclude', + earlierThan: 'Earlier than', + noEarlierThan: 'No earlier than', + laterThan: 'Later than', + noLaterThan: 'No later than', + identificationNumber: 'Identification number', + phoneNumber: 'Phone number', + remote: 'Automatic remote acquisition option', + prohibitInput: 'Prohibit input when input data is invalid', + hintShow: 'Show prompt when cell is selected', + deleteVerification: 'Delete verification', + tooltipInfo1: 'The drop-down list option cannot be empty', + tooltipInfo2: 'Checkbox content cannot be empty', + tooltipInfo3: 'The value entered is not a numeric type', + tooltipInfo4: 'The value 2 cannot be less than the value 1', + tooltipInfo5: 'The text content cannot be empty', + tooltipInfo6: 'The value entered is not a date type', + tooltipInfo7: 'Date 2 cannot be less than date 1', + }, formula:{ sum:"Sum", average:"Average", diff --git a/src/locale/zh.js b/src/locale/zh.js index c695b02..0e1be53 100644 --- a/src/locale/zh.js +++ b/src/locale/zh.js @@ -884,6 +884,55 @@ export default { fiveQuadrantDiagram: '五象限图', fiveBoxes: '5个框', }, + dataVerification: { + cellRange: '单元格范围', + selectCellRange: '点击选择单元格范围', + selectCellRange2: '请选择单元格范围', + verificationCondition: '验证条件', + dropdown: '下拉列表', + checkbox: '复选框', + number: '数字', + number_integer: '数字-整数', + number_decimal: '数字-小数', + text_content: '文本-内容', + text_length: '文本-长度', + date: '日期', + validity: '有效性', + placeholder1: '请输入选项,以英文逗号分隔,如1,2,3,4,5', + placeholder2: '请输入内容', + placeholder3: '数值,如10', + placeholder4: '请输入指定的文本', + placeholder5: '请输入选中单元格时显示的提示语', + selected: '选择时', + notSelected: '未选择', + between: '介于', + notBetween: '不介于', + equal: '等于', + notEqualTo: '不等于', + moreThanThe: '大于', + lessThan: '小于', + greaterOrEqualTo: '大于等于', + lessThanOrEqualTo: '小于等于', + include: '包括', + exclude: '不包括', + earlierThan: '早于', + noEarlierThan: '不早于', + laterThan: '晚于', + noLaterThan: '不晚于', + identificationNumber: '身份证号码', + phoneNumber: '手机号', + remote: '自动远程获取选项', + prohibitInput: '输入数据无效时禁止输入', + hintShow: '选中单元格时显示提示语', + deleteVerification: '删除验证', + tooltipInfo1: '下拉列表选项不可为空', + tooltipInfo2: '复选框内容不可为空', + tooltipInfo3: '输入的值不是数值类型', + tooltipInfo4: '数值2不能小于数值1', + tooltipInfo5: '文本内容不能为空', + tooltipInfo6: '输入的值不是日期类型', + tooltipInfo7: '日期2不能小于日期1', + }, formula:{ sum:"求和", average:"平均值",