gui-datetime-between.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. :style="{zIndex:zIndex, left:show?'0rpx':'-1000rpx'}">
  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. :isDay="isDay"
  27. :units="units"></gui-datetime-bt-base>
  28. </view>
  29. <!-- 结束时间 -->
  30. <view class="gui-margin-top">
  31. <text class="graceDateTimeBT-text gui-block-text">{{titles[1]}}</text>
  32. </view>
  33. <view style="overflow:hidden;">
  34. <gui-datetime-bt-base
  35. :value="endValue"
  36. :isTime="isTime"
  37. :isMinute="isMinute"
  38. @change="chang2"
  39. :isSecond="isSecond"
  40. :isDay="isDay"
  41. :startYear="startYear"
  42. :endYear="endYear"
  43. :units="units"></gui-datetime-bt-base>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. export default {
  51. name : "gui-datetime-between",
  52. props : {
  53. cancelText : { type : String, default : '取消' },
  54. cancelTColor : { type : String, default : '#888888' },
  55. confirmText : { type : String, default : '确定' },
  56. confirmColor : { type : String, default : '#008AFF' },
  57. startValue : { type : String , default : ''},
  58. endValue : { type : String , default : ''},
  59. isTime : { type : Boolean, default : true},
  60. isMinute : { type : Boolean, default : true},
  61. isSecond : { type : Boolean, default : true},
  62. startYear : { type : Number, default : 1980},
  63. endYear : { type : Number, default : 2050},
  64. units : { type : Array , default : function(){return new Array('年','月','日','时','分','秒')}},
  65. titles : { type : Array , default : function(){return new Array('开始时间','结束时间')}},
  66. zIndex : { type : Number, default : 90 },
  67. isDay : { type : Boolean, default : true }
  68. },
  69. data() {
  70. return {
  71. indicatorStyle : 'height:35px',
  72. defaultVal : [0,0,0,0,0,0],
  73. sDate:[[],[],[],[],[],[]],
  74. recDate:[[],[]],
  75. show : false
  76. }
  77. },
  78. methods:{
  79. open : function () {
  80. this.show = true;
  81. },
  82. close : function () {
  83. this.show = false;
  84. },
  85. confirm : function(){
  86. this.$emit('confirm', this.recDate);
  87. this.close();
  88. },
  89. chang1 : function(res){
  90. this.recDate[0] = res;
  91. },
  92. chang2 : function(res){
  93. this.recDate[1] = res;
  94. },
  95. }
  96. }
  97. </script>
  98. <style scoped>
  99. .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);}
  100. .graceDateTime-header{padding:25rpx;}
  101. .graceDateTime-header-btn{width:200rpx; line-height:38rpx; height:38rpx; font-size:28rpx;}
  102. .graceDateTimeBT-text{padding:15rpx; background-color:#FFFFFF; line-height:80rpx; height:80rpx; color:rgba(69, 90, 100, 0.6); font-size:26rpx;}
  103. </style>