datepicker.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <view class="main">
  3. <view class="leftcontainer">
  4. <scroll-view scroll-y="true" style="height: 700rpx;">
  5. <view :class="leftindex==index?'leftstyle leftstyle_active':'leftstyle'" v-for="(item,index) in date[0]" @click="selectdate(item,index)"
  6. :key="index">
  7. <view class="">
  8. {{formatdate(item.week)}}
  9. </view>
  10. <view class="">
  11. {{item.date}}
  12. </view>
  13. </view>
  14. </scroll-view>
  15. </view>
  16. <view class="rightcontainer">
  17. <scroll-view scroll-y="true" style="height: 700rpx;">
  18. <u-grid :col="3">
  19. <u-grid-item v-for="(itm,idx) in rightday" @click="selectday(itm)" :key="idx">
  20. <view class="text-sm">
  21. {{itm.intro}}
  22. </view>
  23. <view class="margin-top-sm">{{itm.start_time_period}} - {{itm.end_time_period}}</view>
  24. <view :class="itm.can_appoint_num==0?'margin-top-sm text-gray text-sm':'margin-top-sm text-blue text-sm'">
  25. 可预约号源:{{itm.can_appoint_num}}
  26. </view>
  27. </u-grid-item>
  28. </u-grid>
  29. </scroll-view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. props: {
  36. date: {
  37. type: Array,
  38. }
  39. },
  40. mounted() {
  41. },
  42. data() {
  43. return {
  44. leftindex: 0,
  45. rightday: [],
  46. year: ""
  47. }
  48. },
  49. methods: {
  50. formatdate(week) {
  51. switch (week) {
  52. case 1:
  53. return "周一"
  54. break;
  55. case 2:
  56. return "周二"
  57. break;
  58. case 3:
  59. return "周三"
  60. break;
  61. case 4:
  62. return "周四"
  63. break;
  64. case 5:
  65. return "周五"
  66. break;
  67. case 6:
  68. return "周六"
  69. break;
  70. case 7:
  71. return "周日"
  72. break;
  73. default:
  74. break;
  75. }
  76. },
  77. selectdate(item, index) {
  78. this.leftindex = index
  79. this.year = item.date
  80. this.date[1].forEach(data => {
  81. data.forEach(itm => {
  82. if (itm.schedule_id == item.id) {
  83. this.rightday = data
  84. }
  85. })
  86. })
  87. },
  88. selectday(itm) {
  89. let arr = itm.year + " " + itm.end_time_period;
  90. arr = arr.split(/[- :]/)
  91. let nndate = new Date(arr[0], arr[1] - 1, arr[2], arr[3], arr[4]);
  92. nndate = Date.parse(nndate)
  93. let currentTime = Date.parse(new Date())
  94. if (nndate < currentTime) {
  95. uni.showToast({
  96. title: "不可预约已过时间",
  97. icon: "none"
  98. })
  99. return false
  100. }
  101. if (itm.can_appoint_num == 0) {
  102. uni.showToast({
  103. title: "已无号源可预约",
  104. icon: "none"
  105. })
  106. return false
  107. }
  108. if (this.year != "") {
  109. itm.year = this.year
  110. }
  111. this.$emit('callbacktime', itm)
  112. }
  113. }
  114. };
  115. </script>
  116. <style scoped>
  117. .main {
  118. display: flex;
  119. /* margin-left: 15rpx;
  120. margin-right: 15rpx; */
  121. }
  122. .leftcontainer {
  123. border-right: 1rpx solid #efefef;
  124. width: 25%;
  125. }
  126. .rightcontainer {
  127. width: 75%;
  128. }
  129. .leftstyle {
  130. width: 100%;
  131. height: 80rpx;
  132. display: flex;
  133. justify-content: center;
  134. align-items: center;
  135. font-size: 30rpx;
  136. color: #0B73B9;
  137. flex-direction: column;
  138. }
  139. .leftstyle_active {
  140. color: #fff;
  141. background-color: #0B73B9;
  142. }
  143. </style>