|
@@ -1,64 +1,61 @@
|
|
|
<template>
|
|
<template>
|
|
|
- <date-picker :readonly="readonly" :date="starttime" :option="option" style="padding: 0px; border: none;"></date-picker>
|
|
|
|
|
|
|
+ <input type="time" :readonly="readonly" v-model="innerValue">
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
-var VueDatepicker = require("../../vue-datepicker/src/vue-datepicker.vue").default;
|
|
|
|
|
-var VueDatepickerOption2 = require("./vue-datepicker-setting.js");
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
module.exports = {
|
|
|
name: 'time',
|
|
name: 'time',
|
|
|
props:[
|
|
props:[
|
|
|
- "dateValue", "readonly"
|
|
|
|
|
|
|
+ "modelValue",
|
|
|
|
|
+ "readonly",
|
|
|
],
|
|
],
|
|
|
|
|
|
|
|
data: function(){
|
|
data: function(){
|
|
|
- var vueDatepickerOption = VueDatepickerOption2();
|
|
|
|
|
-
|
|
|
|
|
- vueDatepickerOption.option.type = 'min';
|
|
|
|
|
- vueDatepickerOption.option.format = 'YYYY-MM-DD';
|
|
|
|
|
-
|
|
|
|
|
- vueDatepickerOption.timeoption.type = 'min';
|
|
|
|
|
- vueDatepickerOption.timeoption.format = 'HH:mm';
|
|
|
|
|
-
|
|
|
|
|
- vueDatepickerOption.multiOption.type = 'multi-day';
|
|
|
|
|
- vueDatepickerOption.multiOption.format = 'HH:mm';
|
|
|
|
|
-
|
|
|
|
|
return{
|
|
return{
|
|
|
- starttime: {
|
|
|
|
|
- time: this.dateValue
|
|
|
|
|
- },
|
|
|
|
|
- endtime: {
|
|
|
|
|
- time: ''
|
|
|
|
|
- },
|
|
|
|
|
- testTime: '',
|
|
|
|
|
- multiTime: '',
|
|
|
|
|
- option: vueDatepickerOption.option,
|
|
|
|
|
- timeoption: vueDatepickerOption.timeoption,
|
|
|
|
|
- multiOption: vueDatepickerOption.multiOption,
|
|
|
|
|
- limit: vueDatepickerOption.limit,
|
|
|
|
|
|
|
+ innerValue : ''
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
+ methods: {
|
|
|
|
|
+ getTimeValue: function(value){
|
|
|
|
|
+ if(value != null && value.length == 8){
|
|
|
|
|
+ return value.substring(0, 5);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ return value;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
components: {
|
|
components: {
|
|
|
- 'date-picker': VueDatepicker
|
|
|
|
|
|
|
+
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
watch:{
|
|
watch:{
|
|
|
- // 'value': function(val){
|
|
|
|
|
- // // 监听外部对props属性value的变更,并同步到组件内
|
|
|
|
|
- // starttime.time = val;
|
|
|
|
|
- // },
|
|
|
|
|
|
|
+ modelValue: {
|
|
|
|
|
+ handler(newValue, oldValue){
|
|
|
|
|
+ if(newValue != null && newValue != ''){
|
|
|
|
|
+ this.innerValue = this.getTimeValue(newValue);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ this.innerValue = newValue;
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ immediate: true,
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
- 'starttime.time': function(val){
|
|
|
|
|
- // 组件内对starttime.time变更后向外部发送事件通知
|
|
|
|
|
- this.$emit("on-value-change", val);
|
|
|
|
|
- this.$emit("input", val);
|
|
|
|
|
- console.log('name has been changed:', val );
|
|
|
|
|
|
|
+ innerValue: function(newValue, oldValue){
|
|
|
|
|
+ // 向外部发送事件通知
|
|
|
|
|
+ let newValue1 = '';
|
|
|
|
|
+ if(newValue == null || newValue == ''){
|
|
|
|
|
+ newValue1 = newValue;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ newValue1 = newValue + ':00';
|
|
|
|
|
+ }
|
|
|
|
|
+ console.log('time has been changed:', newValue1);
|
|
|
|
|
+ this.$emit("update:modelValue", newValue1);
|
|
|
|
|
+ this.$emit("on-value-change", newValue1);
|
|
|
},
|
|
},
|
|
|
- dateValue: function(val){
|
|
|
|
|
- this.starttime.time = val;
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
</script>
|
|
</script>
|