leisure-core 0.6.55 → 0.6.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -228,8 +228,24 @@ export default {
228
228
  },
229
229
 
230
230
  formatNumber(value) {
231
+ let filtered = value.replace(/[^\d.-]/g, "").replace(/(\..*)\./g, "$1");
232
+
233
+ // 如果限制小数位数,且不允许小数,则移除小数点
234
+ if (this.number && !this.allowDecimal) {
235
+ filtered = filtered.replace(/\./g, "");
236
+ }
237
+
238
+ // 如果限制小数位数,且允许小数,则限制小数位数
239
+ if (this.number && this.allowDecimal && this.decimalLimit > 0) {
240
+ const parts = filtered.split(".");
241
+ if (parts.length === 2 && parts[1].length > this.decimalLimit) {
242
+ filtered = parts[0] + "." + parts[1].substring(0, this.decimalLimit);
243
+ }
244
+ }
245
+
246
+ return filtered;
231
247
  // 只允许数字、小数点、负号
232
- return value.replace(/[^\d.-]/g, "").replace(/(\..*)\./g, "$1");
248
+ // return value.replace(/[^\d.-]/g, "").replace(/(\..*)\./g, "$1");
233
249
  },
234
250
 
235
251
  formatMobile(value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leisure-core",
3
- "version": "0.6.55",
3
+ "version": "0.6.57",
4
4
  "description": "leisure-core是京心数据基于vue2.x开发的一套后台管理系统桌面端组件库,封装了大量实用的UI控件模板,非常方便开发者快速搭建前端应用",
5
5
  "private": false,
6
6
  "author": "北方乐逍遥(zcx7878)",