graceDateTimeBetween.nvue 3.2 KB

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