reservation.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <!-- 预约 -->
  3. <view class="content">
  4. <view>
  5. <app-header @back="back">扫码预约</app-header>
  6. <view style="margin-bottom: 50px;">
  7. <u-cell title="选择粮库" :value="form.orgName" :is-link="true" @click="storehouseSelectShow = true"></u-cell>
  8. <u-cell title="选择日期" :value="form.date" :is-link="true" @click="dateSelectShow = true"></u-cell>
  9. <u-gap height="10" bgColor="#fff"></u-gap>
  10. <view class="title">请选择车辆到库时间段</view>
  11. <view>
  12. <u-list :height="300">
  13. <u-list-item v-for="(item, index) in timeRange" :key="index">
  14. <u-cell :title="`${item.begin} - ${item.end}`" @click="onTimeSelect(item, index)">
  15. <u-icon v-if="item.checked" slot="right-icon" name="checkmark-circle" color="#f2786f"></u-icon>
  16. </u-cell>
  17. </u-list-item>
  18. </u-list>
  19. </view>
  20. <u-gap height="1" bgColor="#fff"></u-gap>
  21. <view class="title">请填写车辆基本信息</view>
  22. <view>
  23. <user-info ref="userInfo"></user-info>
  24. <view>
  25. <u-button @click="submit" type="primary">提交</u-button>
  26. </view>
  27. </view>
  28. </view>
  29. <u-action-sheet2 :actions="orgList" :closeOnClickOverlay="true" :closeOnClickAction="true" title="选择粮库"
  30. :show="storehouseSelectShow" @select="onOrgSelect" @close="storehouseSelectShow = false">
  31. </u-action-sheet2>
  32. <u-calendar :show="dateSelectShow" :closeOnClickOverlay="true" @confirm="onDateSelect"
  33. @close="dateSelectShow = false">
  34. </u-calendar>
  35. </view>
  36. <tabbar></tabbar>
  37. </view>
  38. </template>
  39. <script>
  40. import { HOME_INDEX, CAR_INDEX, MONITOR_INDEX, LIVE_INDEX } from '@/config/constants'
  41. import {
  42. simpleRequired,
  43. mkRules
  44. } from '@/utils/rules.js'
  45. import {
  46. getVehicleTypes,
  47. getOrgTypes,
  48. gsqReservationRegisterAdd,
  49. } from '@/api/basic'
  50. import { showErr } from '@/utils/common'
  51. import userInfo from '@/pages/components/userInfo.vue'
  52. import appHeader from '@/pages/components/header/header.vue'
  53. import tabbar from '@/pages/components/tabbar.vue'
  54. import uActionSheet2 from '@/components/u-action-sheet/my-action-sheet.vue'
  55. export default {
  56. components: {userInfo, appHeader, tabbar, uActionSheet2},
  57. data() {
  58. return {
  59. form: {
  60. orgName: null,
  61. orgId: null,
  62. date: null,
  63. time: null,
  64. },
  65. orgList: [],
  66. vehicleTypeList: [],
  67. timeRange: [],
  68. dateSelectShow: false,
  69. storehouseSelectShow: false,
  70. }
  71. },
  72. mounted() {
  73. this.timeRange = this.generateTimeSlots(8, 15)
  74. getOrgTypes().then(resp => {
  75. const list = resp.data || list
  76. list.forEach(d => {
  77. d.name = d.orgName
  78. })
  79. this.orgList = resp.data || []
  80. })
  81. },
  82. methods: {
  83. back(){
  84. getApp().globalData.tabIndex = CAR_INDEX
  85. uni.redirectTo({
  86. url: '/pages/carManager/carManager'
  87. })
  88. },
  89. generateTimeSlots(start, end) {
  90. const result = [];
  91. for (let i = start; i < end; i++) {
  92. let timeSlot = {
  93. begin: `${i.toString().padStart(2, '0')}:00:00`,
  94. end: `${(i + 1).toString().padStart(2, '0')}:00:00`,
  95. checked: false,
  96. };
  97. result.push(timeSlot);
  98. }
  99. return result;
  100. },
  101. onOrgSelect(data) {
  102. console.log('choose', data);
  103. this.form.orgName = data.orgName
  104. this.form.orgId = data.orgId
  105. },
  106. onDateSelect([date]) {
  107. this.form.date = date
  108. this.dateSelectShow = false
  109. },
  110. onTimeSelect(item, index) {
  111. this.timeRange.forEach(d => d.checked = false)
  112. item.checked = true
  113. this.form.time = item
  114. },
  115. submit() {
  116. if(!this.form.date) {
  117. return showErr('请选择日期')
  118. }else if(! this.form.time) {
  119. return showErr('请选择时间')
  120. }else if(! this.form.orgId) {
  121. return showErr('请选择库')
  122. }
  123. this.$refs.userInfo.getUserInfo().then(info => {
  124. gsqReservationRegisterAdd({
  125. type: 1,
  126. startTime: `${this.form.date} ${this.form.time.begin}`,
  127. endTime: `${this.form.date} ${this.form.time.end}`,
  128. orgId: this.form.orgId,
  129. driverName: info.driverName,
  130. identificationNumber: info.identificationNumber,
  131. mobileNumber: info.mobileNumber,
  132. vehicleType: info.vehicleType,
  133. licensePlateNumber: info.licensePlateNumber,
  134. driverAddress: info.driverAddress,
  135. }).then(resp => {
  136. console.log('123123', resp);
  137. if(resp.code === 200) {
  138. uni.redirectTo({
  139. url: `/pages/reservation/success?licensePlateNumber=${info.identificationNumber}&date=${this.form.date}&orgName=${this.form.orgName}`
  140. })
  141. }
  142. })
  143. }).catch(err => {
  144. if(err) {
  145. showErr(err)
  146. }
  147. })
  148. }
  149. }
  150. }
  151. </script>
  152. <style lang="scss" scoped>
  153. .date-list {
  154. max-height: 800rpx;
  155. overflow-y: scroll;
  156. }
  157. .title {
  158. display: flex;
  159. justify-content: center;
  160. }
  161. </style>