mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2026-02-05 10:05:33 +08:00
jeecg-boot 1.0版本发布
This commit is contained in:
74
ant-design-jeecg-vue/src/components/jeecg/JDate.vue
Normal file
74
ant-design-jeecg-vue/src/components/jeecg/JDate.vue
Normal file
@ -0,0 +1,74 @@
|
||||
<template>
|
||||
<a-date-picker
|
||||
:disabled="readOnly"
|
||||
:placeholder="placeholder"
|
||||
@change="handleDateChange"
|
||||
:value="momVal"
|
||||
:showTime="showTime"
|
||||
:format="dateFormat"
|
||||
/>
|
||||
</template>
|
||||
<script>
|
||||
import moment from 'moment'
|
||||
export default {
|
||||
name: 'JDate',
|
||||
props: {
|
||||
placeholder:{
|
||||
type: String,
|
||||
default: '',
|
||||
required: false
|
||||
},
|
||||
value:{
|
||||
type: String,
|
||||
default: '',
|
||||
required: false
|
||||
},
|
||||
dateFormat:{
|
||||
type: String,
|
||||
default: 'YYYY-MM-DD',
|
||||
required: false
|
||||
},
|
||||
triggerChange:{
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false
|
||||
},
|
||||
readOnly:{
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false
|
||||
},
|
||||
showTime:{
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data () {
|
||||
let dateStr = this.value;
|
||||
return {
|
||||
decorator:"",
|
||||
momVal:!dateStr?null:moment(dateStr,this.dateFormat)
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
value (val) {
|
||||
if(!val){
|
||||
this.momVal = null
|
||||
}else{
|
||||
this.momVal = moment(val,this.dateFormat)
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
moment,
|
||||
handleDateChange(mom,dateStr){
|
||||
if(this.triggerChange){
|
||||
this.$emit('change', dateStr);
|
||||
}else{
|
||||
this.$emit('input', dateStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
43
ant-design-jeecg-vue/src/components/jeecg/README.md
Normal file
43
ant-design-jeecg-vue/src/components/jeecg/README.md
Normal file
@ -0,0 +1,43 @@
|
||||
日期组件
|
||||
说明:antd-vue日期组件需要用moment中转一下,用起来不是很方便,特二次封装,使用时只需要传字符串即可
|
||||
====
|
||||
|
||||
参数说明
|
||||
----
|
||||
placeholder:placeholder
|
||||
readOnly:true/false
|
||||
value:绑定v-model或是v-decorator后不需要设置
|
||||
showTime:是否展示时间true/false
|
||||
dateFormat:日期格式 默认'YYYY-MM-DD' 若showTime设置为true则需要将其设置成对应的时间格式(如:YYYY-MM-DD HH:mm:ss)
|
||||
triggerChange:触发组件值改变的事件是否是change,当使用v-decorator时且没有设置decorator的option.trigger为input需要设置该值为true
|
||||
|
||||
使用示例
|
||||
----
|
||||
1.组件带有v-model的使用方法
|
||||
<j-date v-model="dateStr"></j-date>
|
||||
|
||||
2.组件带有v-decorator的使用方法
|
||||
a).设置trigger-change属性为true
|
||||
<j-date :trigger-change="true" v-decorator="['dateStr',{}]"></j-date>
|
||||
b).设置decorator的option.trigger为input
|
||||
<j-date v-decorator="['dateStr',{trigger:'input'}]"></j-date>
|
||||
|
||||
3.其他使用
|
||||
添加style
|
||||
<j-date v-model="dateStr" style="width:100%"></j-date>
|
||||
添加placeholder
|
||||
<j-date v-model="dateStr" placeholder="请输入dateStr"></j-date>
|
||||
添加readOnly
|
||||
<j-date v-model="dateStr" :read-only="true"></j-date>
|
||||
|
||||
备注:
|
||||
script内需引入jdate
|
||||
<script>
|
||||
import JDate from '@/components/jeecg/JDate'
|
||||
export default {
|
||||
name: "demo",
|
||||
components: {
|
||||
JDate
|
||||
},
|
||||
....
|
||||
</script>
|
||||
Reference in New Issue
Block a user