datepicker.vue 3.1 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. console.log(this.date)
  79. this.leftindex = index
  80. this.year = item.date
  81. this.date[1].forEach(data => {
  82. data.forEach(itm => {
  83. if (itm.schedule_id == item.id) {
  84. this.rightday = data
  85. }
  86. })
  87. })
  88. },
  89. selectday(itm) {
  90. let arr = itm.year + " " + itm.end_time_period;
  91. arr = arr.split(/[- :]/)
  92. let nndate = new Date(arr[0], arr[1] - 1, arr[2], arr[3], arr[4]);
  93. nndate = Date.parse(nndate)
  94. let currentTime = Date.parse(new Date())
  95. if (nndate < currentTime) {
  96. uni.showToast({
  97. title: "不可预约已过时间",
  98. icon: "none"
  99. })
  100. return false
  101. }
  102. if (itm.can_appoint_num == 0) {
  103. uni.showToast({
  104. title: "已无号源可预约",
  105. icon: "none"
  106. })
  107. return false
  108. }
  109. if (this.year != "") {
  110. itm.year = this.year
  111. }
  112. this.$emit('callbacktime', itm)
  113. }
  114. }
  115. };
  116. </script>
  117. <style scoped>
  118. .main {
  119. display: flex;
  120. /* margin-left: 15rpx;
  121. margin-right: 15rpx; */
  122. }
  123. .leftcontainer {
  124. border-right: 1rpx solid #efefef;
  125. width: 25%;
  126. }
  127. .rightcontainer {
  128. width: 75%;
  129. }
  130. .leftstyle {
  131. width: 100%;
  132. height: 80rpx;
  133. display: flex;
  134. justify-content: center;
  135. align-items: center;
  136. font-size: 30rpx;
  137. color: #0B73B9;
  138. flex-direction: column;
  139. }
  140. .leftstyle_active {
  141. color: #fff;
  142. background-color: #0B73B9;
  143. }
  144. </style>