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

feat: 更新模板

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