gui-datetime-between.vue 3.6 KB

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