提交 030cc70e 编写于 作者: zhf's avatar zhf

feat: 更新模板

上级 2815a465
import { computed, defineComponent, ref, watch } from 'vue';
import { debounce } from 'lodash-es';
import { debounce, floor } from 'lodash-es';
import {
getEditorEmits,
getInputProps,
......@@ -8,8 +8,11 @@ import {
import '@ibiz-template/theme/style/components/editor/ibiz-input/ibiz-input.scss';
const fomatFloat = function (value: number, n: number) {
const f = Math.round(value * 10 ** n) / 10 ** n;
const f = value;
let s = f.toString();
if (n <= 0) {
return s;
}
const rs = s.indexOf('.');
if (rs < 0) {
s += '.';
......@@ -143,9 +146,7 @@ export const IBizInput = defineComponent({
const handleBlur = () => {
blurCacheValue = inputRef.value.currentValue;
if (c.model.precision !== -1) {
const multiplier = 10 ** c.model.precision;
const num =
Math.floor(Number(blurCacheValue) * multiplier) / multiplier;
const num = floor(Number(blurCacheValue), c.model.precision);
const number = blurCacheValue ? fomatFloat(num, c.model.precision) : '';
currentVal.value = number;
emit('change', number);
......@@ -174,9 +175,7 @@ export const IBizInput = defineComponent({
if (!e.target.value) {
e.target.value = '';
} else {
const multiplier = 10 ** c.model.precision;
const num =
Math.floor(Number(e.target.value) * multiplier) / multiplier;
const num = floor(Number(e.target.value), c.model.precision);
e.target.value = num;
}
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册