graceDateTimeBetween.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <view>
  3. <view @tap.stop="open"><slot></slot></view>
  4. <view class="graceDateTimeBT" v-if="show" @touchmove.stop="" @tap.self="close" :style="{backgroundColor:background}"></view>
  5. <view class="graceDateTimeBT-body" :class="[show?'gdIn':'gdOut']" @touchmove.stop="" :style="{paddingBottom:paddingBottom}">
  6. <view class="graceDateTimeBT-header grace-space-between">
  7. <text class="graceDateTime-header-btn"
  8. :style="{color:cancelTColor}" @tap="close">{{cancelText}}</text>
  9. <text class="graceDateTime-header-btn"
  10. :style="{textAlign:'right', color:confirmColor}" @tap="confirm">{{confirmText}}</text>
  11. </view>
  12. <view>
  13. <text class="graceDateTimeBT-text">{{titles[0]}}</text>
  14. </view>
  15. <view>
  16. <graceDateTimeBetweenBase :value="startValue" :isTime="isTime" @change="chang1"
  17. :isSecond="isSecond" :startYear="startYear" :endYear="endYear" :units="units"></graceDateTimeBetweenBase>
  18. </view>
  19. <view>
  20. <text class="graceDateTimeBT-text">{{titles[1]}}</text>
  21. </view>
  22. <view>
  23. <graceDateTimeBetweenBase :value="endValue" :isTime="isTime" @change="chang2"
  24. :isSecond="isSecond" :startYear="startYear" :endYear="endYear" :units="units"></graceDateTimeBetweenBase>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. import graceDateTimeBetweenBase from "./graceDateTimeBetweenBase.vue";
  31. export default {
  32. components:{
  33. graceDateTimeBetweenBase
  34. },
  35. props: {
  36. background:{ type : String, default : 'rgba(0, 0, 0, 0.5)' },
  37. cancelText : { type : String, default : '取消' },
  38. cancelTColor : { type : String, default : '#888888' },
  39. confirmText : { type : String, default : '确定' },
  40. confirmColor : { type : String, default : '#3688FF' },
  41. startValue : { type : String , default:''},
  42. endValue : { type : String , default:''},
  43. isTime : {type : Boolean, default : true},
  44. isSecond : {type : Boolean, default : true},
  45. startYear : {type : Number, default : 1980},
  46. endYear : {type : Number, default : 2050},
  47. units : {type : Array , default:function(){return new Array('年','月','日','时','分','秒')}},
  48. titles : {type : Array , default:function(){return new Array('请选择开始时间','请选择结束时间')}},
  49. paddingBottom:{type : String , default:'0rpx'}
  50. },
  51. data() {
  52. return {
  53. show:false,
  54. indicatorStyle : 'height:35px',
  55. defaultVal : [0,0,0,0,0,0],
  56. sDate:[[],[],[],[],[],[]],
  57. recDate:[[],[]]
  58. }
  59. },
  60. methods:{
  61. open : function () {
  62. this.show = true;
  63. },
  64. close : function () {
  65. this.show = false;
  66. },
  67. confirm : function(){
  68. this.show = false;
  69. this.$emit('confirm', this.recDate);
  70. },
  71. chang1 : function(res){
  72. this.recDate[0] = res;
  73. },
  74. chang2 : function(res){
  75. this.recDate[1] = res;
  76. }
  77. }
  78. }
  79. </script>
  80. <style>
  81. .graceDateTimeBT{position:fixed; width:100%; height:100%; top:0; left:0; bottom:0; z-index:998;}
  82. .graceDateTimeBT-body{background-color:#FFFFFF; position:fixed; z-index:999; bottom:-1000px; left:0; width:100%;}
  83. .graceDateTimeBT-header{padding:25rpx;}
  84. .graceDateTimeBT-header-btn{width:200rpx; line-height:38rpx; height:38rpx; display:block; font-size:28rpx;}
  85. .graceDateTimeBT-text{display:block; box-sizing:border-box; padding:15rpx; background-color:#FFFFFF; width:100%; line-height:60rpx; height:100rpx; color:#666666; font-size:28rpx;}
  86. @keyframes gdIn{ from {bottom:-1000px; } 100% { bottom: 0px; }}
  87. .gdIn {animation:gdIn 200ms ease-in forwards;}
  88. @keyframes gdOut{ from {bottom:0px;} 100% { bottom:-1000px; }}
  89. .gdOut {animation:gdOut 200ms ease-out forwards;}
  90. </style>