datepicker.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. {{item.date}}
  8. </view>
  9. </scroll-view>
  10. </view>
  11. <view class="rightcontainer">
  12. <scroll-view scroll-y="true" style="height: 700rpx;">
  13. <u-grid :col="3">
  14. <u-grid-item v-for="(itm,idx) in rightday" @click="selectday(itm)" :key="idx">
  15. <view class="">
  16. 预约时间:
  17. </view>
  18. <view class="margin-top-sm">{{itm.start_time_period}} - {{itm.end_time_period}}</view>
  19. <view class="margin-top-sm text-blue text-sm">
  20. 可预约号源:{{itm.can_appoint_num}}
  21. </view>
  22. </u-grid-item>
  23. </u-grid>
  24. </scroll-view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. props: {
  31. date: {
  32. type: Array,
  33. }
  34. },
  35. mounted() {
  36. },
  37. data() {
  38. return {
  39. leftindex: 0,
  40. rightday: [],
  41. year: ""
  42. }
  43. },
  44. methods: {
  45. selectdate(item, index) {
  46. this.leftindex = index
  47. this.year = item.date
  48. this.date[1].forEach(data => {
  49. data.forEach(itm => {
  50. if (itm.schedule_id == item.id) {
  51. this.rightday = data
  52. }
  53. })
  54. })
  55. },
  56. selectday(itm) {
  57. let arr = itm.year + " " + itm.end_time_period;
  58. arr = arr.split(/[- :]/)
  59. let nndate = new Date(arr[0], arr[1] - 1, arr[2], arr[3], arr[4]);
  60. nndate = Date.parse(nndate)
  61. let currentTime = Date.parse(new Date())
  62. if (nndate < currentTime) {
  63. uni.showToast({
  64. title: "不可预约已过时间",
  65. icon: "none"
  66. })
  67. return false
  68. }
  69. if (this.year != "") {
  70. itm.year = this.year
  71. }
  72. this.$emit('callbacktime', itm)
  73. }
  74. }
  75. };
  76. </script>
  77. <style scoped>
  78. .main {
  79. display: flex;
  80. /* margin-left: 15rpx;
  81. margin-right: 15rpx; */
  82. }
  83. .leftcontainer {
  84. border-right: 1rpx solid #efefef;
  85. width: 25%;
  86. }
  87. .rightcontainer {
  88. width: 75%;
  89. }
  90. .leftstyle {
  91. width: 100%;
  92. height: 80rpx;
  93. display: flex;
  94. justify-content: center;
  95. align-items: center;
  96. font-size: 30rpx;
  97. color: #0B73B9;
  98. }
  99. .leftstyle_active {
  100. color: #fff;
  101. background-color: #0B73B9;
  102. }
  103. </style>