From 92d7e1c399cec9744e52900d1c1fe6487efa3d09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=BF=97=E6=B5=A9?= <5601808+su_zhi_hao@user.noreply.gitee.com> Date: Thu, 31 Aug 2023 16:37:32 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=99=A8=E5=A2=9E=E5=BC=BA-=E6=96=B0=E5=A2=9E=E6=94=AF?= =?UTF-8?q?=E6=8C=81type=3Dnumber?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/plugins/inputSpinner/InputSpinner.js | 50 +++++++++++++++++++ .../resources/templates/index-topnav.html | 1 + .../src/main/resources/templates/index.html | 1 + .../resources/templates/tool/gen/edit.html | 1 + .../src/main/resources/vm/html/add.html.vm | 7 +++ .../src/main/resources/vm/html/edit.html.vm | 7 +++ 6 files changed, 67 insertions(+) create mode 100644 ruoyi-admin/src/main/resources/static/js/plugins/inputSpinner/InputSpinner.js diff --git a/ruoyi-admin/src/main/resources/static/js/plugins/inputSpinner/InputSpinner.js b/ruoyi-admin/src/main/resources/static/js/plugins/inputSpinner/InputSpinner.js new file mode 100644 index 000000000..bfd52d2fb --- /dev/null +++ b/ruoyi-admin/src/main/resources/static/js/plugins/inputSpinner/InputSpinner.js @@ -0,0 +1,50 @@ +/** + * Author and copyright: Stefan Haack (https://shaack.com) + * Repository: https://github.com/shaack/bootstrap-input-spinner + * License: MIT, see file 'LICENSE' + */ + + + // the default editor for parsing and rendering +const I18nEditor = function (props, element) { + const locale = props.locale || "en-US" + + this.parse = function (customFormat) { + const numberFormat = new Intl.NumberFormat(locale) + const thousandSeparator = numberFormat.format(11111).replace(/1/g, '') || '.' + const decimalSeparator = numberFormat.format(1.1).replace(/1/g, '') + return parseFloat(customFormat + .replace(new RegExp(' ', 'g'), '') + .replace(new RegExp('\\' + thousandSeparator, 'g'), '') + .replace(new RegExp('\\' + decimalSeparator), '.') + ) + } + + this.render = function (number) { + const decimals = parseInt(element.getAttribute("data-decimals")) || 0 + const digitGrouping = !(element.getAttribute("data-digit-grouping") === "false") + const numberFormat = new Intl.NumberFormat(locale, { + minimumFractionDigits: decimals, + maximumFractionDigits: decimals, + useGrouping: digitGrouping + }) + return numberFormat.format(number) + } + } + +let triggerKeyPressed = false +const originalVal = $.fn.val +$.fn.val = function (value) { + if (arguments.length >= 1) { + for (let i = 0; i < this.length; i++) { + if (this[i]["bootstrap-input-spinner"] && this[i].setValue) { + const element = this[i] + setTimeout(function () { + element.setValue(value) + }) + } + } + } + return originalVal.apply(this, arguments) +} + diff --git a/ruoyi-admin/src/main/resources/templates/index-topnav.html b/ruoyi-admin/src/main/resources/templates/index-topnav.html index b4e7c4bad..14cbb9a33 100644 --- a/ruoyi-admin/src/main/resources/templates/index-topnav.html +++ b/ruoyi-admin/src/main/resources/templates/index-topnav.html @@ -315,6 +315,7 @@ + diff --git a/ruoyi-admin/src/main/resources/templates/index.html b/ruoyi-admin/src/main/resources/templates/index.html index b08c4ea39..761389182 100644 --- a/ruoyi-admin/src/main/resources/templates/index.html +++ b/ruoyi-admin/src/main/resources/templates/index.html @@ -261,6 +261,7 @@ + diff --git a/ruoyi-generator/src/main/resources/templates/tool/gen/edit.html b/ruoyi-generator/src/main/resources/templates/tool/gen/edit.html index fee2b3604..420c401d6 100644 --- a/ruoyi-generator/src/main/resources/templates/tool/gen/edit.html +++ b/ruoyi-generator/src/main/resources/templates/tool/gen/edit.html @@ -598,6 +598,7 @@ + diff --git a/ruoyi-generator/src/main/resources/vm/html/add.html.vm b/ruoyi-generator/src/main/resources/vm/html/add.html.vm index c64ccd9da..c9c9e5b0b 100644 --- a/ruoyi-generator/src/main/resources/vm/html/add.html.vm +++ b/ruoyi-generator/src/main/resources/vm/html/add.html.vm @@ -58,6 +58,13 @@ +#elseif($column.htmlType == "number") +