calendar.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <view>
  3. <view class="form-item">
  4. <view class="title">
  5. <text class="necessary">*</text>
  6. 开始时间:
  7. </view>
  8. <picker mode="date" :value="start_date" :start="start_date" :end="other" @change="bindDateChange" style="">
  9. <view class="date">{{start_date}}</view>
  10. </picker>
  11. </view>
  12. <view class="form-item">
  13. <view class="title">结束时间:</view>
  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. <!-- <view class="leave_cont">
  20. <view class="ul">
  21. <view class="li">
  22. <view class="flex1">
  23. <picker mode="date" :value="start_date" :start="start_date" :end="other" @change="bindDateChange">
  24. <view class="date">{{start_date}}</view>
  25. </picker>
  26. </view>
  27. </view>
  28. ~
  29. <view class="li">
  30. <view class="flex1">
  31. <picker mode="date" :value="start_date" :start="start_date" @change="bindDateChange2">
  32. <view class="date">{{end_date}}</view>
  33. </picker>
  34. </view>
  35. </view>
  36. </view>
  37. </view> -->
  38. </template>
  39. <script>
  40. export default {
  41. name: 'calendar',
  42. data() {
  43. const currentDate = this.getTime({
  44. format: true
  45. })
  46. return {
  47. start_date: '2021-07-06 16:05:48',
  48. end_date: '2021-07-06 18:05:48',
  49. other: '请输入'
  50. }
  51. },
  52. computed: {
  53. },
  54. methods: {
  55. // 选择日期
  56. bindDateChange: function(e) {
  57. this.start_date = e.target.value
  58. },
  59. bindDateChange2: function(e) {
  60. this.end_date = e.target.value;
  61. this.other = this.end_date;
  62. },
  63. // 获取当前时间
  64. // getDate(type) {
  65. // const date = new Date();
  66. // let year = date.getFullYear();
  67. // let month = date.getMonth() + 1;
  68. // let day = date.getDate();
  69. // if (type === 'start') {
  70. // year = year - 60;
  71. // } else if (type === 'end') {
  72. // year = year + 2;
  73. // }
  74. // month = month > 9 ? month : '0' + month;;
  75. // day = day > 9 ? day : '0' + day;
  76. // return `${year}-${month}-${day}`;
  77. // },
  78. getTime() {
  79. var date = new Date(),
  80. year = date.getFullYear(),
  81. month = date.getMonth() + 1,
  82. day = date.getDate(),
  83. hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(),
  84. minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(),
  85. second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
  86. month >= 1 && month <= 9 ? (month = "0" + month) : "";
  87. day >= 0 && day <= 9 ? (day = "0" + day) : "";
  88. var timer = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second;
  89. return timer;
  90. }
  91. }
  92. }
  93. </script>
  94. <style>
  95. picker{
  96. border:1px solid #EDEDED;display: block;
  97. height: 100%;width:500rpx;line-height:70rpx;height:70rpx;padding:0 20rpx
  98. }
  99. .date{
  100. color:#999
  101. }
  102. /* .leave_cont .ul {
  103. border: 1px solid red;
  104. margin: 24rpx 24rpx;
  105. border: 1px solid #E8F1FF;
  106. border-radius: 36rpx;
  107. line-height: 70rpx;
  108. position: relative;
  109. }
  110. .leave_cont .ul .li {
  111. display: inline-block;
  112. text-align: center;
  113. width: 35%
  114. }
  115. .leave_cont .ul .li text {
  116. padding: 40rpx 0;
  117. font-size: 30rpx;
  118. color: #666666;
  119. text-align: center;
  120. }
  121. .leave_cont .ul .li .flex1 {
  122. flex: 1;
  123. color: #999999;
  124. font-size: 32rpx;
  125. }
  126. .date {
  127. height: 42rpx;
  128. }
  129. .canlendar-icon {
  130. width: 36rpx;
  131. height: 36rpx;
  132. position: absolute;
  133. right: 30rpx;
  134. top: 16rpx;
  135. } */
  136. </style>