gui-datetime-between.vue 3.5 KB

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