recordDriver.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <view class="container">
  3. <!-- 筛选区域 -->
  4. <Search :typeList="typeList" :timeList="busList" @handLeConveyData="getConveyData" />
  5. <!-- 列表区域 -->
  6. <view class="list" v-for="(item, index) in listData" :key="index" @click="handleLookDetail(item)">
  7. <view class="list-title">
  8. <view class="title-number">车牌:{{ item.car_number != 0 ? item.car_number : '无' }}</view>
  9. <view class="title-icon"><img src="../../static/right.png" /></view>
  10. </view>
  11. <view class="list-item">
  12. 状态:
  13. <span :class="item.state_str == '预约进行中' || item.state_str == '候补中' ? 'list-item-type' : ''">{{ item.state_str }}</span>
  14. </view>
  15. <view class="list-item">
  16. 发车日期:
  17. <span>{{ item.yy_date }}</span>
  18. </view>
  19. <view class="list-item" v-if="item.state_str == '预约进行中' || item.state_str == '已截止'">
  20. 发车时间:
  21. <span>{{ item.ci_time != 0 ? item.ci_time : '' }}</span>
  22. </view>
  23. <view class="list-item">
  24. 扫码时间:
  25. <span>{{ item.sm_start + '-' + item.sm_end }}</span>
  26. </view>
  27. <view class="list-item">
  28. 线路:
  29. <span>{{ item.route }}</span>
  30. </view>
  31. <view class="list-item">
  32. 站点:
  33. <span>{{ item.route_end }}</span>
  34. </view>
  35. <view class="list-item">
  36. 人数:
  37. <view class="list-item-progress" v-if="item.state_str == '预约进行中' || item.state_str == '已截止'">
  38. <progress activeColor="#3C50E8" stroke-width="9" :percent="item.percent ? item.percent : 0" />
  39. </view>
  40. <span v-if="item.state_str == '预约进行中' || item.state_str == '已截止'">{{ item.user_num + '/' + item.contain }}</span>
  41. <span v-else>{{ item.contain }}</span>
  42. </view>
  43. </view>
  44. <!-- 无数据时展示的区域 -->
  45. <view class="list-nodata" v-if="listData.length == 0">
  46. <img src="../../static/no-bus.png" />
  47. <view>暂无数据</view>
  48. </view>
  49. </view>
  50. </template>
  51. <script setup>
  52. import { ref } from 'vue'
  53. import { onLoad, onPullDownRefresh } from '@dcloudio/uni-app'
  54. import { myRequest } from '../../util/api.js'
  55. import { isWeixin } from '../../util/isWeixin.js'
  56. import Search from '../../components/search'
  57. onLoad(() => {
  58. if (isWeixin()) {
  59. let userInfo = uni.getStorageSync('bus-userInfo')
  60. if (!userInfo) {
  61. uni.redirectTo({
  62. url: '/pages/index/index'
  63. })
  64. } else {
  65. let info = JSON.parse(userInfo)
  66. if (info.user_zz !== '司机') {
  67. uni.redirectTo({
  68. url: '/pages/404/404?message=暂无权限'
  69. })
  70. } else {
  71. getBusList()
  72. getData()
  73. }
  74. }
  75. } else {
  76. uni.redirectTo({
  77. url: '/pages/404/404?message=请在微信客户端打开链接'
  78. })
  79. }
  80. })
  81. onPullDownRefresh(() => {
  82. getBusList()
  83. getData()
  84. setTimeout(function() {
  85. uni.stopPullDownRefresh()
  86. }, 500)
  87. })
  88. // 预约状态 全部:0 预约进行中:1 已截止:2 已分配:3 候补中:4
  89. const result_state = ref(0)
  90. // 预约状态数组
  91. const typeList = ref([
  92. {
  93. text: '全部',
  94. value: 0
  95. },
  96. {
  97. text: '预约进行中',
  98. value: 1
  99. },
  100. {
  101. text: '已截止',
  102. value: 2
  103. },
  104. {
  105. text: '已分配',
  106. value: 3
  107. },
  108. {
  109. text: '候补中',
  110. value: 4
  111. }
  112. ])
  113. // 当前选择车牌号 默认为全部
  114. const busNumber = ref('全部')
  115. // 车牌列表数据
  116. const busList = ref([
  117. {
  118. text: '全部',
  119. value: 0
  120. }
  121. ])
  122. // 预约记录数据
  123. const listData = ref([])
  124. // 获取预约记录数据
  125. const getData = async () => {
  126. const res = await myRequest({
  127. url: '/appcarCaptainManage.action',
  128. data: {
  129. result_state: result_state.value,
  130. car_number: busNumber.value
  131. }
  132. })
  133. // console.log(res.data)
  134. if (res.data.length) {
  135. res.data.forEach(item => {
  136. item.percent = Math.ceil((parseInt(item.user_num) / parseInt(item.contain)) * 100)
  137. })
  138. }
  139. listData.value = res.data
  140. }
  141. // 获取车牌号数组请求
  142. const getBusList = async () => {
  143. const res = await myRequest({
  144. url: '/appqueryCarInfos.action'
  145. })
  146. // console.log(res)
  147. if (res.data.length) {
  148. let temList = [
  149. {
  150. text: '全部',
  151. value: 0
  152. }
  153. ]
  154. res.data.forEach((item, index) => {
  155. temList.push({
  156. text: item.car_number,
  157. value: index + 1
  158. })
  159. })
  160. busList.value = temList
  161. }
  162. }
  163. // 点击每一条记录回调
  164. const handleLookDetail = item => {
  165. const info = JSON.stringify(item)
  166. uni.navigateTo({
  167. url: `/pages/detailDriver/detailDriver?info=${info}`
  168. })
  169. }
  170. // 条件筛选框选择回调
  171. const getConveyData = Obj => {
  172. // console.log(Obj)
  173. result_state.value = Obj.typeIndex
  174. busNumber.value = busList.value[Obj.timeIndex].text
  175. getData()
  176. }
  177. </script>
  178. <style lang="scss" scoped>
  179. .container {
  180. background-color: #f2f2f2;
  181. .list {
  182. margin-bottom: 20rpx;
  183. padding-bottom: 24rpx;
  184. background-color: #fff;
  185. .list-title {
  186. display: flex;
  187. justify-content: space-between;
  188. align-items: center;
  189. padding: 0 30rpx;
  190. margin-bottom: 20rpx;
  191. height: 94rpx;
  192. font-size: 32rpx;
  193. font-weight: bold;
  194. border-bottom: 1rpx solid #e6e6e6;
  195. .title-icon {
  196. margin-top: -20rpx;
  197. width: 15rpx;
  198. height: 25rpx;
  199. img {
  200. width: 100%;
  201. height: 100%;
  202. }
  203. }
  204. }
  205. .list-item {
  206. display: flex;
  207. align-items: center;
  208. padding: 0 30rpx;
  209. margin-bottom: 14rpx;
  210. color: #999999;
  211. font-size: 28rpx;
  212. span {
  213. color: #333333;
  214. }
  215. .list-item-type {
  216. color: #3d51e8;
  217. }
  218. .list-item-progress {
  219. margin-right: 36rpx;
  220. width: 437rpx;
  221. height: 22rpx;
  222. :deep(.uni-progress-bar),
  223. :deep(.uni-progress-inner-bar) {
  224. border-radius: 85rpx;
  225. }
  226. }
  227. }
  228. }
  229. .list-nodata {
  230. margin-top: -20rpx;
  231. padding-top: 100rpx;
  232. background-color: #fff;
  233. text-align: center;
  234. color: #999999;
  235. img {
  236. width: 600rpx;
  237. }
  238. }
  239. }
  240. </style>