vue-ele-form-yd
Version:
基于 element-ui 的数据驱动表单组件
47 lines (42 loc) • 1.57 kB
JavaScript
import dayjs from 'dayjs'
export default {
methods: {
// displayModel===>dataModel
// 存储数据格式化方法
custormValueFormatter(value) {
let newVal = value
if (value && !(this.attrs.valueFormat || this.attrs['value-format'])) {
newVal = dayjs(value).unix()
}
return newVal
}
// newValue=>dataModel
// handleChange (value) {
// let newVal = value
// if (value && !(this.attrs.valueFormat || this.attrs['value-format'])) {
// newVal = dayjs(value).unix()
// }
// this.$emit('input', newVal)
// },
// 获取值: 数字(秒 -> 毫秒) / 字符串
// getValue (value) {
// if (value && !(this.attrs.valueFormat || this.attrs['value-format'])) {
// value = typeof value === 'number' ? value * 1000 : value
// return dayjs(value).format()
// } else {
// return value
// }
// },
// // 自定义值处理 dataModel=>newValue
// customInit (value) {
// if (value && this.attrs && !(this.attrs.displayFormat || this.attrs['display-format'])) {
// value = typeof value === 'number' ? value * 1000 : value
// console.log('datatime customInit (value) :' + this.defDesc.label + ':format:' + dayjs(value).format())
// return dayjs(value).format()
// } else {
// console.log('datatime customInit (value) :' + this.defDesc.label + ':' + value + dayjs(value).format())
// return '2010-12-22 12:22:12'
// }
// }
}
}