datepicker.vue 3.5 KB

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