calendar.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <view class="leave_cont">
  3. <view class="ul">
  4. <view class="li">
  5. <view class="flex1">
  6. <picker mode="date" :value="start_date" :start="start_date" :end="other" @change="bindDateChange">
  7. <view class="date">{{start_date}}</view>
  8. </picker>
  9. </view>
  10. </view>
  11. ~
  12. <view class="li">
  13. <view class="flex1">
  14. <picker mode="date" :value="start_date" :start="start_date" @change="bindDateChange2">
  15. <view class="date">{{end_date}}</view>
  16. </picker>
  17. </view>
  18. </view>
  19. <image class="canlendar-icon" src="../../static/calendar.png" ></image>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. data() {
  26. const currentDate = this.getDate({
  27. format: true
  28. })
  29. return {
  30. start_date: '请选择开始日期',
  31. end_date: '请选择结束日期',
  32. other: '请输入'
  33. }
  34. },
  35. computed: {
  36. },
  37. methods: {
  38. // 选择日期
  39. bindDateChange: function(e) {
  40. this.start_date = e.target.value
  41. },
  42. bindDateChange2: function(e) {
  43. this.end_date = e.target.value;
  44. this.other = this.end_date;
  45. },
  46. // 获取当前时间
  47. getDate(type) {
  48. const date = new Date();
  49. let year = date.getFullYear();
  50. let month = date.getMonth() + 1;
  51. let day = date.getDate();
  52. if (type === 'start') {
  53. year = year - 60;
  54. } else if (type === 'end') {
  55. year = year + 2;
  56. }
  57. month = month > 9 ? month : '0' + month;;
  58. day = day > 9 ? day : '0' + day;
  59. return `${year}-${month}-${day}`;
  60. },
  61. }
  62. }
  63. </script>
  64. <style>
  65. .leave_cont .ul {
  66. border: 1px solid red;
  67. margin: 24rpx 24rpx;
  68. border: 1px solid #E8F1FF;
  69. border-radius: 36rpx;
  70. line-height: 70rpx;
  71. position:relative;
  72. }
  73. .leave_cont .ul .li {
  74. display: inline-block;
  75. text-align: center;
  76. width: 35%
  77. }
  78. .leave_cont .ul .li text {
  79. padding: 40rpx 0;
  80. font-size: 30rpx;
  81. color: #666666;
  82. text-align:center;
  83. }
  84. .leave_cont .ul .li .flex1 {
  85. flex: 1;
  86. color: #999999;
  87. font-size: 32rpx;
  88. }
  89. .date {
  90. height: 42rpx;
  91. }
  92. .canlendar-icon{
  93. width:36rpx;
  94. height:36rpx;
  95. position:absolute;
  96. right:30rpx;
  97. top:16rpx;
  98. }
  99. </style>