detail.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  1. <template>
  2. <view class="container">
  3. <!-- 车牌号区域 -->
  4. <view class="box">
  5. <view class="left">车牌号</view>
  6. <view class="right2">
  7. <view class="item">
  8. <view :class="['select', form.selectValue != 0 ? 'selected' : '']" @tap="handleMultiple(form.selectIndex)">
  9. {{ form.selectValue != 0 ? form.selectValue : '请选择' }}
  10. </view>
  11. </view>
  12. <view class="right-img"><img src="../../static/bottom.png" /></view>
  13. </view>
  14. <!-- 车牌号选项弹窗区域 -->
  15. <transition>
  16. <multiple-picker
  17. title="请选择"
  18. :show="selectMultiple.show"
  19. :columns="selectMultiple.columns"
  20. :defaultIndex="selectMultiple.index"
  21. @confirm="confirmMultiple"
  22. @cancel="selectMultiple.show = false"
  23. @change="changeMultiple"
  24. ></multiple-picker>
  25. </transition>
  26. </view>
  27. <!-- 人数区域 -->
  28. <view class="box">
  29. <view class="left">容量</view>
  30. <view class="right">{{ info.contain }}</view>
  31. </view>
  32. <!-- 发车日期区域 -->
  33. <view class="box">
  34. <view class="left">发车日期</view>
  35. <view class="right">{{ info.yy_date }}</view>
  36. </view>
  37. <!-- 发车时间区域 -->
  38. <view class="box">
  39. <view class="left">发车时间</view>
  40. <picker style="width: 40%;" @change="bindPickerChange($event, 1)" mode="time" :value="info.ci_time" :start="getCurrentTime()">
  41. <view :class="['right', info.ci_time != 0 ? '' : 'unSelect']">
  42. {{ info.ci_time != 0 ? info.ci_time : '请选择' }}
  43. <view class="right-img"><img src="../../static/bottom.png" /></view>
  44. </view>
  45. </picker>
  46. </view>
  47. <!-- 扫码开始时间区域 -->
  48. <view class="box">
  49. <view class="left">扫码开始时间</view>
  50. <picker style="width: 40%;" @change="bindPickerChange($event, 4)" mode="time" :value="info.sm_start">
  51. <view :class="['right', info.sm_start != 0 ? '' : 'unSelect']">
  52. {{ info.sm_start != 0 ? info.sm_start : '请选择' }}
  53. <view class="right-img"><img src="../../static/bottom.png" /></view>
  54. </view>
  55. </picker>
  56. </view>
  57. <!-- 扫码结束时间区域 -->
  58. <view class="box">
  59. <view class="left">扫码结束时间</view>
  60. <picker style="width: 40%;" @change="bindPickerChange($event, 5)" mode="time" :value="info.sm_end">
  61. <view :class="['right', info.sm_end != 0 ? '' : 'unSelect']">
  62. {{ info.sm_end != 0 ? info.sm_end : '请选择' }}
  63. <view class="right-img"><img src="../../static/bottom.png" /></view>
  64. </view>
  65. </picker>
  66. </view>
  67. <!-- 预约截止时间区域 -->
  68. <view class="box">
  69. <view class="left">预约截止时间</view>
  70. <picker style="width: 40%;" @change="bindPickerChange($event, 7)" mode="time" :value="info.yy_end">
  71. <view :class="['right', info.yy_end != 0 ? '' : 'unSelect']">
  72. {{ info.yy_end != 0 ? info.yy_end : '请选择' }}
  73. <view class="right-img"><img src="../../static/bottom.png" /></view>
  74. </view>
  75. </picker>
  76. </view>
  77. <!-- 路线区域 -->
  78. <view class="box">
  79. <view class="left">路线</view>
  80. <picker style="width: 60%;" @change="bindPickerChange($event, 2)" :range="pathList" range-key="route">
  81. <view :class="['right', info.route ? '' : 'unSelect']">
  82. {{ info.route ? info.route : '请选择' }}
  83. <view class="right-img"><img src="../../static/bottom.png" /></view>
  84. </view>
  85. </picker>
  86. </view>
  87. <!-- 站点区域 -->
  88. <view class="box">
  89. <view class="left">站点</view>
  90. <picker style="width: 80%;" @change="bindPickerChange($event, 3)" :range="endList" range-key="route_end">
  91. <view :class="['right', info.route_end ? '' : 'unSelect']">
  92. {{ info.route_end ? info.route_end : '请选择' }}
  93. <view class="right-img"><img src="../../static/bottom.png" /></view>
  94. </view>
  95. </picker>
  96. </view>
  97. <!-- 状态区域 -->
  98. <view class="box">
  99. <view class="left">状态</view>
  100. <view class="right">{{ info.state_str }}</view>
  101. </view>
  102. <!-- 提前一天预约区域 -->
  103. <view class="box">
  104. <view class="left">可否提前一天预约</view>
  105. <view class="right">{{ info.before_state == 0 ? '不可以' : '可以' }}</view>
  106. </view>
  107. <!-- 保存按钮区域 -->
  108. <view class="saveBtn" @click="handleSave">保存</view>
  109. <!-- 人员名单区域 -->
  110. <view class="list">
  111. <view class="list-title" v-if="info.user_num != 0">
  112. <!-- 人员名单({{ info.user_num }}/{{ info.contain }}) -->
  113. <view class="list-title-left">人员名单({{ typeList[result_state].text }}{{ listData.length }}人)</view>
  114. <picker style="width: 38%;" :range="typeList" range-key="text" @change="bindPickerChange($event, 6)">
  115. <view class="list-title-right">
  116. {{ typeList[result_state].text }}
  117. <view class="right-img"><img src="../../static/bottom.png" /></view>
  118. </view>
  119. </picker>
  120. </view>
  121. <view class="list-item" v-for="(item, index) in listData" :key="index">
  122. <view class="item-img"><img src="../../static/man.png" /></view>
  123. <view class="item-info">
  124. <view class="info-name">
  125. <view>{{ item.user_name }}</view>
  126. </view>
  127. <view class="info-mes">
  128. {{ item.user_zz }}
  129. <span>{{ item.yy_time }}</span>
  130. </view>
  131. </view>
  132. <view v-if="item.yy_state === '1'" class="item-type"><img src="../../static/subscribe.png" /></view>
  133. <view v-else class="item-type"><img src="../../static/pass2.png" /></view>
  134. </view>
  135. <!-- 无数据时展示的区域 -->
  136. <view class="list-nodata" v-if="listData.length == 0">
  137. <img src="../../static/no-bus.png" />
  138. <view>暂无数据</view>
  139. </view>
  140. </view>
  141. </view>
  142. </template>
  143. <script setup>
  144. import { ref } from 'vue'
  145. import { onLoad } from '@dcloudio/uni-app'
  146. import { myRequest } from '@/util/api.js'
  147. import { isWeixin } from '@/util/isWeixin.js'
  148. import { time_to_sec, time_change } from '@/util/formatTime.js'
  149. onLoad(options => {
  150. if (isWeixin()) {
  151. let userInfo = JSON.parse(uni.getStorageSync('bus-userInfo'))
  152. // console.log(userInfo)
  153. if (userInfo.user_zz !== '车队长') {
  154. uni.redirectTo({
  155. url: '/pages/404/404?message=暂无权限'
  156. })
  157. } else {
  158. info.value = JSON.parse(options.info)
  159. // console.log(info.value)
  160. idRef.value = info.value.id
  161. // 获取人员列表
  162. getData()
  163. // 获取路线数组
  164. getPathList()
  165. // 获取终点站列表
  166. getEndList()
  167. // 获取车牌号列表
  168. getBusList()
  169. // 获取发车时间提前推迟多少分钟可以扫码数据
  170. getTimeConfig()
  171. // 处理车牌号数据
  172. form.value.selectValue = info.value.car_number
  173. setTimeout(() => {
  174. let temList = []
  175. selectMultiple.value.columns.forEach(item => {
  176. if (item.label == form.value.selectValue) {
  177. temList.push(item.value)
  178. }
  179. })
  180. form.value.selectIndex = temList
  181. }, 500)
  182. }
  183. } else {
  184. uni.redirectTo({
  185. url: '/pages/404/404?message=请在微信客户端打开链接'
  186. })
  187. }
  188. })
  189. // 带过来的预约详情数据
  190. const info = ref({})
  191. // 参数id
  192. const idRef = ref(null)
  193. // 车牌号绑定数据
  194. const form = ref({
  195. selectValue: '',
  196. selectIndex: []
  197. })
  198. // 车牌号数组相关数据
  199. const selectMultiple = ref({
  200. show: false,
  201. index: [],
  202. columns: []
  203. })
  204. // 路线数组
  205. const pathList = ref([])
  206. // 终点站数组
  207. const endList = ref([])
  208. // 人员列表数组
  209. const listData = ref([])
  210. // 发车时间提前多少分钟可以扫码
  211. const time_early = ref(null)
  212. // 发车时间推迟多少分钟可以扫码
  213. const time_late = ref(null)
  214. // 发车前多少分钟截止预约
  215. const time_yy_end = ref(null)
  216. // 人员名单筛选状态
  217. const result_state = ref(0)
  218. const typeList = ref([
  219. {
  220. text: '全部',
  221. value: 0
  222. },
  223. {
  224. text: '已预约未上车',
  225. value: 1
  226. },
  227. {
  228. text: '已上车',
  229. value: 2
  230. }
  231. ])
  232. // 获取路线数组请求
  233. const getPathList = async () => {
  234. const res = await myRequest({
  235. url: '/appqueryRoute.action'
  236. })
  237. // console.log(res);
  238. pathList.value = res.data
  239. }
  240. // 获取终点站数组请求
  241. const getEndList = async () => {
  242. const res = await myRequest({
  243. url: '/appqueryEndRoutes.action',
  244. data: {
  245. route: info.value.route
  246. }
  247. })
  248. // console.log(res);
  249. endList.value = res.data
  250. }
  251. // 获取车牌号数组请求
  252. const getBusList = async () => {
  253. const res = await myRequest({
  254. url: '/appqueryCarInfos.action'
  255. })
  256. // console.log(res);
  257. if (res.data.length) {
  258. let temList = []
  259. res.data.forEach((item, index) => {
  260. temList.push({
  261. label: item.car_number,
  262. value: index.toString()
  263. })
  264. })
  265. selectMultiple.value.columns = temList
  266. }
  267. }
  268. // 获取人员名单请求
  269. const getData = async () => {
  270. const res = await myRequest({
  271. url: '/appqueryAppointeds.action',
  272. data: {
  273. id: idRef.value,
  274. result_state: result_state.value
  275. }
  276. })
  277. // console.log(res)
  278. listData.value = res.data
  279. }
  280. // 保存按钮回调
  281. const handleSave = () => {
  282. if (info.value.car_number == 0) {
  283. uni.showToast({
  284. title: '请选择车牌号',
  285. icon: 'none'
  286. })
  287. return
  288. }
  289. if (info.value.ci_time == 0) {
  290. uni.showToast({
  291. title: '请选择发车时间',
  292. icon: 'none'
  293. })
  294. return
  295. }
  296. if (!info.value.sm_start) {
  297. uni.showToast({
  298. title: '请选择扫码开始时间',
  299. icon: 'none'
  300. })
  301. return
  302. }
  303. if (!info.value.sm_end) {
  304. uni.showToast({
  305. title: '请选择扫码结束时间',
  306. icon: 'none'
  307. })
  308. return
  309. }
  310. if (time_to_sec(info.value.sm_start) >= time_to_sec(info.value.ci_time)) {
  311. uni.showToast({
  312. title: '扫码开始时间不能晚于发车时间',
  313. icon: 'none',
  314. duration: 2000
  315. })
  316. return
  317. }
  318. if (time_to_sec(info.value.sm_end) < time_to_sec(info.value.ci_time)) {
  319. uni.showToast({
  320. title: '扫码结束时间不能早于发车时间',
  321. icon: 'none',
  322. duration: 2000
  323. })
  324. return
  325. }
  326. if (!info.value.yy_end) {
  327. uni.showToast({
  328. title: '请选择预约截止时间',
  329. icon: 'none'
  330. })
  331. return
  332. }
  333. if (!info.value.route) {
  334. uni.showToast({
  335. title: '请选择路线',
  336. icon: 'none'
  337. })
  338. return
  339. }
  340. if (!info.value.route_end) {
  341. uni.showToast({
  342. title: '请选择终点站',
  343. icon: 'none'
  344. })
  345. return
  346. }
  347. uni.showModal({
  348. title: '提示',
  349. content: '确定保存吗?',
  350. success: res => {
  351. if (res.confirm) {
  352. handleSaveRequest()
  353. } else if (res.cancel) {
  354. }
  355. }
  356. })
  357. }
  358. // 保存请求
  359. const handleSaveRequest = () => {
  360. // console.log(info.value)
  361. const { id, car_number, ci_time, route, route_end, contain, sm_start, sm_end, yy_end } = info.value
  362. const { user_name } = JSON.parse(uni.getStorageSync('bus-userInfo'))
  363. uni.request({
  364. url: '/carstop/carbook/scheupdate.action',
  365. method: 'post',
  366. header: {
  367. admin_name: user_name
  368. },
  369. data: {
  370. id,
  371. car_number,
  372. ci_time,
  373. route,
  374. route_end,
  375. contain,
  376. sm_start,
  377. sm_end,
  378. yy_end
  379. },
  380. success: res => {
  381. if (res.data.code == 200) {
  382. uni.showToast({
  383. title: res.data.message
  384. })
  385. setTimeout(() => {
  386. uni.redirectTo({
  387. url: '/pages/record/record'
  388. })
  389. }, 1500)
  390. } else {
  391. uni.showToast({
  392. title: res.data.message,
  393. icon: 'error'
  394. })
  395. }
  396. }
  397. })
  398. }
  399. // 点击车牌号下拉框回调
  400. const handleMultiple = val => {
  401. // console.log(val);
  402. selectMultiple.value.index = val || []
  403. selectMultiple.value.show = true
  404. }
  405. // 车牌号下拉框确定按钮回调
  406. const confirmMultiple = e => {
  407. // console.log(e);
  408. // console.log(e.value);
  409. if (selectMultiple.value.index != e.value) {
  410. let temp = []
  411. e.selected.forEach(item => {
  412. temp.push(item.label)
  413. })
  414. form.value.selectValue = temp.toString()
  415. info.value.car_number = temp.toString()
  416. }
  417. form.value.selectIndex = e.value
  418. selectMultiple.value.show = false
  419. // 获取汽车容量
  420. getBusContain()
  421. }
  422. // 获取汽车容量请求
  423. const getBusContain = async () => {
  424. const res = await myRequest({
  425. url: '/appqueryCarContain.action',
  426. data: {
  427. car_number: form.value.selectValue
  428. }
  429. })
  430. // console.log(res);
  431. info.value.contain = res.data
  432. }
  433. // 获取发车时间提前推迟多少分钟可以扫码数据
  434. const getTimeConfig = async () => {
  435. const res = await myRequest({
  436. url: '/cnqueryHb.action'
  437. })
  438. // console.log(res)
  439. time_early.value = res.sm_end
  440. time_late.value = res.sm_start
  441. time_yy_end.value = res.yy_end
  442. }
  443. // 下拉框选择时的回调
  444. const changeMultiple = e => {
  445. // console.log(e);
  446. }
  447. // 原生下拉框的选择回调事件
  448. const bindPickerChange = (e, type) => {
  449. if (type == 1) {
  450. info.value.ci_time = e.detail.value
  451. info.value.sm_start = time_change(info.value.ci_time, time_early.value * -1)
  452. info.value.sm_end = time_change(info.value.ci_time, time_late.value)
  453. info.value.yy_end = time_change(info.value.ci_time, time_yy_end.value * -1)
  454. } else if (type == 2) {
  455. info.value.route = pathList.value[e.detail.value].route
  456. getEndList()
  457. info.value.route_end = ''
  458. } else if (type == 3) {
  459. info.value.route_end = endList.value[e.detail.value].route_end
  460. } else if (type == 4) {
  461. info.value.sm_start = e.detail.value
  462. } else if (type == 5) {
  463. info.value.sm_end = e.detail.value
  464. } else if (type == 6) {
  465. result_state.value = e.detail.value
  466. getData()
  467. } else if (type == 7) {
  468. info.value.yy_end = e.detail.value
  469. }
  470. }
  471. // 获取当前时间 hh:mm
  472. const getCurrentTime = () => {
  473. const date = new Date()
  474. let H = (date.getHours() + '').padStart(2, '0')
  475. let M = (date.getMinutes() + '').padStart(2, '0')
  476. return `${H}:${M}`
  477. }
  478. </script>
  479. <style lang="scss" scoped>
  480. .container {
  481. background-color: #fff;
  482. .box {
  483. display: flex;
  484. justify-content: space-between;
  485. align-items: center;
  486. padding: 0 30rpx;
  487. height: 98rpx;
  488. font-size: 28rpx;
  489. border-bottom: 1rpx solid #e6e6e6;
  490. .left {
  491. flex: 1;
  492. color: #999999;
  493. }
  494. .right {
  495. flex: 1;
  496. display: flex;
  497. justify-content: flex-end;
  498. .right-img {
  499. margin-left: 27rpx;
  500. margin-top: -5rpx;
  501. width: 17rpx;
  502. height: 12rpx;
  503. img {
  504. width: 100%;
  505. height: 100%;
  506. }
  507. }
  508. }
  509. .right2 {
  510. flex: 2;
  511. display: flex;
  512. justify-content: flex-end;
  513. align-items: center;
  514. .item {
  515. flex: 1;
  516. padding: 20rpx 0;
  517. .select {
  518. width: 100%;
  519. padding-top: 6px;
  520. padding-bottom: 6px;
  521. padding-left: 9px;
  522. border-radius: 4px;
  523. font-size: 15px;
  524. text-align: end;
  525. box-sizing: border-box;
  526. color: #cccccc;
  527. line-height: 26px;
  528. &.selected {
  529. color: black;
  530. }
  531. }
  532. }
  533. .right-img {
  534. margin-left: 27rpx;
  535. margin-top: -30rpx;
  536. width: 17rpx;
  537. height: 12rpx;
  538. img {
  539. width: 100%;
  540. height: 100%;
  541. }
  542. }
  543. }
  544. .unSelect {
  545. color: #ccc;
  546. }
  547. }
  548. .saveBtn {
  549. margin: 20rpx 30rpx;
  550. line-height: 100rpx;
  551. text-align: center;
  552. color: #fff;
  553. font-size: 34rpx;
  554. border-radius: 15rpx;
  555. background: linear-gradient(180deg, #8684ff 0%, #3c50e8 100%);
  556. }
  557. .list {
  558. padding: 13rpx 30rpx;
  559. .list-title {
  560. display: flex;
  561. margin-top: 20rpx;
  562. height: 41rpx;
  563. color: #999999;
  564. font-size: 28rpx;
  565. .list-title-left {
  566. flex: 1;
  567. }
  568. .list-title-right {
  569. flex: 1;
  570. display: flex;
  571. justify-content: flex-end;
  572. color: #000;
  573. .right-img {
  574. margin-left: 27rpx;
  575. margin-top: -5rpx;
  576. width: 17rpx;
  577. height: 12rpx;
  578. img {
  579. width: 100%;
  580. height: 100%;
  581. }
  582. }
  583. }
  584. }
  585. .list-item {
  586. display: flex;
  587. align-items: center;
  588. box-sizing: border-box;
  589. padding: 29rpx 0 26rpx 0;
  590. height: 155rpx;
  591. border-bottom: 1rpx solid #e6e6e6;
  592. .item-img {
  593. width: 100rpx;
  594. height: 100rpx;
  595. border-radius: 50%;
  596. img {
  597. width: 100%;
  598. height: 100%;
  599. }
  600. }
  601. .item-info {
  602. flex: 1;
  603. display: flex;
  604. flex-direction: column;
  605. justify-content: space-evenly;
  606. margin-left: 6rpx;
  607. height: 100rpx;
  608. .info-name {
  609. display: flex;
  610. align-items: center;
  611. font-size: 32rpx;
  612. .info-name-img {
  613. margin-left: 26rpx;
  614. width: 30rpx;
  615. height: 35rpx;
  616. img {
  617. width: 100%;
  618. height: 100%;
  619. }
  620. }
  621. }
  622. .info-mes {
  623. font-size: 24rpx;
  624. color: #999999;
  625. span {
  626. margin-left: 26rpx;
  627. color: #a6a6a6;
  628. }
  629. }
  630. }
  631. .item-type {
  632. width: 104rpx;
  633. height: 41rpx;
  634. img {
  635. width: 100%;
  636. height: 100%;
  637. }
  638. }
  639. }
  640. .list-nodata {
  641. padding: 50rpx 0;
  642. background-color: #fff;
  643. text-align: center;
  644. color: #999999;
  645. img {
  646. width: 500rpx;
  647. }
  648. }
  649. }
  650. }
  651. .v-enter-active,
  652. .v-leave-active {
  653. transition: opacity 0.5s ease;
  654. }
  655. .v-enter-from,
  656. .v-leave-to {
  657. opacity: 0;
  658. }
  659. </style>