中文冒号 金额补0

This commit is contained in:
fengachen
2021-09-15 15:51:32 +08:00
parent c259b6cac5
commit 7d8e25036a
3 changed files with 97 additions and 61 deletions
+34
View File
@@ -36,6 +36,7 @@ export function filterObj(obj) {
}
for ( let key in obj) {
// eslint-disable-next-line
if (obj.hasOwnProperty(key)
&& (obj[key] == null || obj[key] == undefined || obj[key] === '')) {
delete obj[key]
@@ -86,6 +87,7 @@ let indexRouter = [{
path: '/',
name: 'dashboard',
//component: () => import('@/components/layouts/BasicLayout'),
// eslint-disable-next-line
component: resolve => require(['@/components/layouts/TabLayout'], resolve),
meta: { title: '首页' },
redirect: '/dashboard/analysis',
@@ -136,6 +138,7 @@ function generateChildRouters (data) {
// }else if(item.component=="modules/online/cgreport/auto/OnlCgreportAutoList"){
// componentPath = onlineCommons.OnlCgreportAutoList
// }else{
// eslint-disable-next-line
componentPath = resolve => require(['@/' + component+'.vue'], resolve)
// }
@@ -587,3 +590,34 @@ export function isRepeat(arr) {
}
return false
}
/**
* 补充0
* */
export function addZero(e) {
// (e) => {e.target.value = e.target.value.replace(/[^0-9.]/g,'')}
console.log(e)
// 判断是否包含 .
let value = e.target.value
// 判断是否包含小数点
if (value.includes('.')) {
// 获取索引
let index = value.indexOf('.')
console.log('index', index)
// 小树点之前的数
let beforePointValue = value.slice(0, index + 1)
// 小数点之后的数字
let afterPointValue = value.slice(index + 1)
// 大于等于2
if (afterPointValue.length >= 2) {
e.target.value = beforePointValue + afterPointValue
}else {
// 不足2位补0
afterPointValue = afterPointValue.padEnd(2,'0')
e.target.value = beforePointValue + afterPointValue
}
}else {
// 不包括小数点
e.target.value = e.target.value + '.00'
}
}