Commit d41451df authored by 高宇's avatar 高宇

修改

parent f09179cc
......@@ -12,6 +12,8 @@ import App from './App'
import store from './store'
import router from './router'
import permission from './directive/permission'
// 千分位转换
import thousand from '@/utils/thousand'
// import drective from '@/utils/directive.js'
import '@/icons' // icon
import '@/assets/icons' // icon
......@@ -54,6 +56,7 @@ Viewer.setDefaults({
})
// 全局方法挂载
Vue.prototype.thousand = thousand
Vue.prototype.getDicts = getDicts
Vue.prototype.getConfigKey = getConfigKey
Vue.prototype.parseTime = parseTime
......
const thousand = {
// 千分位格式化:10000转为10,000 n=0,不允许有小数
fmoney(s, n) {
if (s == '' || s == null || (s == undefined) | isNaN(Number(s))) {
return s
}
s = Number(s) ? Number(s) : s
// n = (n || n == 0) && n > -1 && n <= 20 ? n : 2;
n = 0
s = parseFloat((s + '').replace(/[^\d\.-]/g, '')).toFixed(n) + ''
var l = s.split('.')[0].split('').reverse()
var r = s.split('.')[1]
var t = ''
for (var i = 0; i < l.length; i++) {
t += l[i] + ((i + 1) % 3 == 0 && i + 1 != l.length ? ',' : '')
}
if (n > 0) {
r = '.' + r
} else if (n == 0) {
r = ''
}
let returnT = t.split('').reverse().join('') + r
// 负数处理
if (returnT[0] == '-' && returnT[1] == ',') {
returnT = '-' + returnT.substring(2)
}
return returnT
},
// 千分位反格式化:10,000.00转为10000
rmoney(s) {
let str = ''
if (s) {
str = String(s).replace(/,/g, '')
}
if (s && (s + '').indexOf('.') > -1 && Number(str)) {
return String(s).replace(/[^\d\.-]/g, '')
} else if (s && Number(str)) {
return str
} else {
return s
}
},
//用于会显示,带有小数点的数字转化为千分位
decimalFmoney(num) {
const res=num.toString().replace(/\d+/, function(n){ // 先提取小数点前后的整数部分
//(\d)(?=(\d{3})正则的意思是匹配连续三个数结尾的数字,例如1234,1后面有234连续三个数的数字,就可以匹配上,匹配的是1这个数字。如果是123,因为1后面是两位数,所以就匹配不上了
return n.replace(/(\d)(?=(\d{3})+$)/g,function($1){
return $1+",";
});
})
return res;
}
}
export default thousand
......@@ -10,7 +10,7 @@
<el-input v-model.trim="form.name" :disabled="formdisable" :maxlength="30" placeholder="请输入活动名称" />
</el-form-item>
<el-form-item label="活动价格" prop="price" style="flex: 1">
<el-input v-model.trim="form.price" :disabled="formdisable" :maxlength="30" placeholder="请输入活动价格" />
<el-input v-model.trim="form.price" :disabled="formdisable" :maxlength="30" placeholder="请输入活动价格" />
</el-form-item>
</div>
<div style="display: flex;justify-content: space-between">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment