gui-datetime-between.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <view>
  3. <view @tap.stop="open"><slot></slot></view>
  4. <view class="gui-dateBT-shade gui-flex gui-columns gui-justify-content-end"
  5. v-if="show" :style="{zIndex:zIndex}">
  6. <view class="gui-bg-white">
  7. <view class="graceDateTime-header gui-flex gui-rows gui-space-between gui-bg-gray">
  8. <text class="graceDateTime-header-btn"
  9. :style="{color:cancelTColor}"
  10. @tap="close">{{cancelText}}</text>
  11. <text class="graceDateTime-header-btn"
  12. :style="{textAlign:'right', color:confirmColor}"
  13. @tap="confirm">{{confirmText}}</text>
  14. </view>
  15. <view>
  16. <text class="graceDateTimeBT-text gui-block-text">{{titles[0]}}</text>
  17. </view>
  18. <!-- 起始时间 -->
  19. <view style="overflow:hidden;">
  20. <gui-datetime-bt-base :value="startValue" @change="chang1"
  21. :isTime="isTime"
  22. :isSecond="isSecond"
  23. :isMinute="isMinute"
  24. :startYear="startYear"
  25. :endYear="endYear"
  26. :units="units"></gui-datetime-bt-base>
  27. </view>
  28. <!-- 结束时间 -->
  29. <view class="gui-margin-top">
  30. <text class="graceDateTimeBT-text gui-block-text">{{titles[1]}}</text>
  31. </view>
  32. <view style="overflow:hidden;">
  33. <gui-datetime-bt-base
  34. :value="endValue"
  35. :isTime="isTime"
  36. :isMinute="isMinute"
  37. @change="chang2"
  38. :isSecond="isSecond"
  39. :startYear="startYear"
  40. :endYear="endYear"
  41. :units="units"></gui-datetime-bt-base>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. export default {
  49. name : "gui-datetime-between",
  50. props : {
  51. cancelText : { type : String, default : '取消' },
  52. cancelTColor : { type : String, default : '#888888' },
  53. confirmText : { type : String, default : '确定' },
  54. confirmColor : { type : String, default : '#008AFF' },
  55. startValue : { type : String , default : ''},
  56. endValue : { type : String , default : ''},
  57. isTime : { type : Boolean, default : true},
  58. isMinute : { type : Boolean, default : true},
  59. isSecond : { type : Boolean, default : true},
  60. startYear : { type : Number, default : 1980},
  61. endYear : { type : Number, default : 2050},
  62. units : { type : Array , default : function(){return new Array('年','月','日','时','分','秒')}},
  63. titles : { type : Array , default : function(){return new Array('开始时间','结束时间')}},
  64. zIndex : { type : Number, default : 90 }
  65. },
  66. data() {
  67. return {
  68. indicatorStyle : 'height:35px',
  69. defaultVal : [0,0,0,0,0,0],
  70. sDate:[[],[],[],[],[],[]],
  71. recDate:[[],[]],
  72. show : false
  73. }
  74. },
  75. methods:{
  76. open : function () {
  77. this.show = true;
  78. },
  79. close : function () {
  80. this.show = false;
  81. },
  82. confirm : function(){
  83. this.$emit('confirm', this.recDate);
  84. this.close();
  85. },
  86. chang1 : function(res){
  87. this.recDate[0] = res;
  88. },
  89. chang2 : function(res){
  90. this.recDate[1] = res;
  91. },
  92. }
  93. }
  94. </script>
  95. <style scoped>
  96. .gui-dateBT-shade{width:750rpx; position:fixed; z-index:99; left:0; top:0; bottom:0; flex:1; overflow:hidden; background-color:rgba(0,0,0,0.5);}
  97. .graceDateTime-header{padding:25rpx;}
  98. .graceDateTime-header-btn{width:200rpx; line-height:38rpx; height:38rpx; font-size:28rpx;}
  99. .graceDateTimeBT-text{padding:15rpx; background-color:#FFFFFF; line-height:80rpx; height:80rpx; color:rgba(69, 90, 100, 0.6); font-size:26rpx;}
  100. </style>