mirror of
https://gitee.com/xuliangzhan_admin/vxe-table.git
synced 2026-01-21 05:27:57 +08:00
优化重构
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
import Vue from 'vue'
|
||||
import i18n from '@/i18n'
|
||||
import Element from 'element-ui'
|
||||
import 'element-ui/lib/theme-chalk/index.css'
|
||||
|
||||
// Vue.use(Element, { size: 'small', zIndex: 3000 })
|
||||
Vue.use(Element, {
|
||||
i18n: (key, value) => i18n.t(key, value)
|
||||
})
|
||||
Vue.use(Element)
|
||||
|
||||
@@ -3,29 +3,33 @@ import XEUtils from 'xe-utils'
|
||||
|
||||
// 自定义全局的格式化处理函数
|
||||
VXETable.formats.mixin({
|
||||
// 格式化性别
|
||||
formatSex (cellValue) {
|
||||
return cellValue ? (cellValue === '1' ? '男' : '女') : ''
|
||||
},
|
||||
// 格式化下拉选项
|
||||
select (cellValue, list) {
|
||||
formatSelect (cellValue, list) {
|
||||
const item = list.find(item => item.value === cellValue)
|
||||
return item ? item.label : ''
|
||||
},
|
||||
// 格式化日期,默认 yyyy-MM-dd HH:mm:ss
|
||||
date (cellValue, format) {
|
||||
formatDate (cellValue, format) {
|
||||
return XEUtils.toDateString(cellValue, format || 'yyyy-MM-dd HH:mm:ss')
|
||||
},
|
||||
// 格式金额,默认2位数
|
||||
amount (cellValue, digits) {
|
||||
formatAmount (cellValue, digits) {
|
||||
return XEUtils.commafy(cellValue, { digits: digits || 2 })
|
||||
},
|
||||
// 格式化银行卡,默认每4位隔开
|
||||
bankcard (cellValue) {
|
||||
formatBankcard (cellValue) {
|
||||
return XEUtils.commafy(cellValue, { spaceNumber: 4, separator: ' ' })
|
||||
},
|
||||
// 四舍五入,默认两位数
|
||||
fixedNumber (cellValue, digits) {
|
||||
formatFixedNumber (cellValue, digits) {
|
||||
return XEUtils.toNumber(cellValue).toFixed(digits || 2)
|
||||
},
|
||||
// 截取小数,默认两位数
|
||||
cutNumber (cellValue, digits) {
|
||||
formatCutNumber (cellValue, digits) {
|
||||
return XEUtils.toFixedString(cellValue, digits || 2)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user