detail.vue 17 KB

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