index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. <template>
  2. <!-- 运单页面 -->
  3. <view>
  4. <u-navbar title="我的运单" autoBack placeholder></u-navbar>
  5. <view class="tab_order">
  6. <u-tabs :list="tableList" lineColor="#333333" lineWidth="60" :scrollable="false" :current="current"
  7. @change="tabClick"></u-tabs>
  8. </view>
  9. <view class="card_order_mangement" v-if="orderList.length > 0">
  10. <x-orderManagement :orderList="orderList" :userInfo="userInfo" @sendOrders="sendOrders"
  11. @operateSuccessfully="operateSuccessfully" @proofRenewal="proofRenewal"
  12. :key="Math.random()"></x-orderManagement>
  13. <view v-if="loadingMore" style="width: 50%;"><u-divider :text="loading"></u-divider></view>
  14. </view>
  15. <u-empty mode="order" marginTop="50" v-else></u-empty>
  16. <u-popup :show="sendShow" closeable round="8" :closeOnClickOverlay="false" @close="close">
  17. <view class="card_send">
  18. <view class="send_title">派单</view>
  19. <view class="card_input_send">
  20. <view class="incubator_title"><span>*</span>保温箱</view>
  21. <view class="card_search_gray frame" @click="focus(false)">
  22. <span v-if="incubator.name">{{incubator.name}}</span>
  23. <span class="title_gray" v-else>请选择保温箱</span>
  24. <u-icon name="arrow-down" color="#c8c9cc" size="18"></u-icon>
  25. </view>
  26. <!-- <u-input :placeholder="hintTitle" border="surround" v-model="incubatorValue" @input="incubatorInput"
  27. @focus="focus" @blur="blur"></u-input>
  28. <view class="card_thermostat" v-if="searchShow">
  29. <scroll-view class="scroll-view" :class="[searchShow ? 'is-fold' : '']" scroll-y="true"
  30. @scrolltolower="loadMore">
  31. <view v-if="thermostatList.length > 0">
  32. <view class="card_item_option" :style="{backgroundColor:item.flag ? '#F5F7FA' : ''}"
  33. v-for="(item,index) in thermostatList" :key="index"
  34. @click.stop="selectIncubator(item)">
  35. <view :style="{color:item.flag ? '#409EFF' : ''}">{{item.name}}</view>
  36. <view v-if="item.flag"><u-icon :color="item.flag ? '#409EFF' : ''" name="checkmark"
  37. size="20"></u-icon></view>
  38. </view>
  39. </view>
  40. <view class="nomatchingData" v-else>暂无保温箱</view>
  41. </scroll-view>
  42. <view class="popper_arrow"></view>
  43. </view> -->
  44. </view>
  45. <view class="card_input_send">
  46. <view class="incubator_title"><span>*</span>冰排编号</view>
  47. <u-input placeholder="请输入冰排编号" border="surround" v-model="iceNumber" @blur="iceRaftBlur">
  48. <template slot="suffix">
  49. <u-icon name="scan" size="24" @click="sweep"></u-icon>
  50. </template>
  51. </u-input>
  52. <view class="add_card center_in" @click="addIce">
  53. <u-icon name="plus" size="18"></u-icon>
  54. </view>
  55. </view>
  56. <view class="card_frequency">
  57. <view class="card_high space_between">
  58. <view class="card_frequency_title">已扫冰排编号</view>
  59. <view class="card_bottle">已扫<span>{{iceList.length}}</span></view>
  60. </view>
  61. <scroll-view :scroll-top="scrollTop" scroll-y="true" class="swept_card">
  62. <view class="scrollView" style="width: 100%;" v-if="iceList.length > 0">
  63. <view class="item_coding" v-for="(item,index) in iceList" :key="index">
  64. <view style="display: flex;align-items: center;">
  65. <view class="num_index">{{index + 1}}</view>
  66. <view class="title_coding">{{item}}</view>
  67. </view>
  68. <u-icon name="close-circle-fill" color="#c0c4cc" size="20"
  69. @click="removeWaybill(item)"></u-icon>
  70. </view>
  71. </view>
  72. </scroll-view>
  73. </view>
  74. <view style="width: 100%;height: 120rpx;"></view>
  75. <view class="card_btn">
  76. <u-button type="primary" text="确定" @click="confirm"></u-button>
  77. </view>
  78. </view>
  79. </u-popup>
  80. </view>
  81. </template>
  82. <script>
  83. export default {
  84. data() {
  85. return {
  86. tableList: [],
  87. list: [{
  88. name: '全部',
  89. }, {
  90. id: 1,
  91. name: '已下单',
  92. }, {
  93. id: 2,
  94. name: '配送中'
  95. }, {
  96. id: 3,
  97. name: '已送达'
  98. }, {
  99. id: 4,
  100. name: '已拒收'
  101. }],
  102. current: 0,
  103. userInfo: {},
  104. orderList: [],
  105. pageSize: 10,
  106. currentPage: 1,
  107. loadingMore: true,
  108. loading: '加载中',
  109. status: null,
  110. sendShow: false,
  111. incubatorValue: '',
  112. thermostatList: [],
  113. incubatorMore: true,
  114. Pagination: 1,
  115. searchShow: false,
  116. hintTitle: '请选择保温箱',
  117. currentItem: '',
  118. iceNumber: '',
  119. iceList: [],
  120. scrollTop: null,
  121. incubator: {
  122. id: null,
  123. name: '',
  124. },
  125. }
  126. },
  127. beforeDestroy() {
  128. // console.log('页面销毁')
  129. this.getempty()
  130. },
  131. onShow() {
  132. let incubator = uni.getStorageSync('incubatorValue')
  133. if (incubator) {
  134. this.incubator.id = incubator.id
  135. this.incubator.name = incubator.name
  136. }
  137. },
  138. onReachBottom() {
  139. if (!this.loadingMore) {
  140. this.getList()
  141. }
  142. },
  143. onLoad(value) {
  144. if (value.current) {
  145. this.current = Number(value.current)
  146. }
  147. var userInfo = this.$cache.getCache('userInfo')
  148. // console.log(userInfo, 25)
  149. this.userInfo = userInfo
  150. this.tableList = this.list
  151. let statusType = ''
  152. if (this.current != 0 || this.current) {
  153. statusType = this.tableList[this.current].id
  154. }
  155. this.status = statusType
  156. this.getList()
  157. },
  158. methods: {
  159. getempty() {
  160. this.iceList = []
  161. this.incubator.id = ''
  162. this.incubator.name = ''
  163. this.iceNumber = ''
  164. uni.removeStorageSync('incubatorValue');
  165. this.Pagination = 1
  166. this.currentItem = ''
  167. this.incubatorValue = ''
  168. this.hintTitle = '请选择保温箱'
  169. this.sendShow = false
  170. this.incubatorMore = true
  171. this.thermostatList = []
  172. },
  173. // 获取司机和仓管运单列表
  174. getList() {
  175. this.loadingMore = true;
  176. this.$api.get('/api/waybill', {
  177. page: this.currentPage,
  178. pageSize: this.pageSize,
  179. status: this.status,
  180. }).then(res => {
  181. if (res.code == 200) {
  182. const data = res.data.list
  183. if (this.loadingMore == true && data) {
  184. this.orderList = this.orderList.concat(data);
  185. }
  186. if (data.length < this.pageSize) {
  187. this.loadingMore = true
  188. this.loading = '没有更多了'
  189. } else {
  190. this.loading = '加载中'
  191. this.loadingMore = false
  192. this.currentPage++
  193. }
  194. }
  195. })
  196. },
  197. // 防拆更新
  198. proofRenewal() {
  199. this.currentPage = 1
  200. this.orderList = []
  201. this.getList()
  202. },
  203. // 派单
  204. sendOrders(value) {
  205. // console.log(value, 3333)
  206. this.waybillId = value.id
  207. this.sendShow = true
  208. // this.getIncubator()
  209. },
  210. // 重新获取列表
  211. operateSuccessfully() {
  212. this.currentPage = 1
  213. this.orderList = []
  214. this.getList()
  215. },
  216. // 获取保温箱
  217. getIncubator() {
  218. this.$api.get('/api/cooler-box', {
  219. page: this.Pagination,
  220. pageSize: this.pageSize,
  221. name: this.incubatorValue,
  222. status: '2',
  223. }).then(res => {
  224. if (res.code == 200) {
  225. const data = res.data.list
  226. data.forEach(item => {
  227. item.flag = false
  228. })
  229. if (this.incubatorMore == true) {
  230. this.thermostatList = this.thermostatList.concat(data);
  231. }
  232. if (data.length < this.pageSize) {
  233. this.incubatorMore = false
  234. } else {
  235. this.incubatorMore = true
  236. }
  237. }
  238. })
  239. },
  240. // 确定派单
  241. confirm() {
  242. if (this.incubator.id) {
  243. if (this.iceList.length > 0) {
  244. const arr = []
  245. arr.push(this.waybillId)
  246. this.$api.post('/api/waybill/delivery', {
  247. waybillIds: arr,
  248. coolerBoxId: this.incubator.id,
  249. iceRaftCode: this.iceList,
  250. }).then(res => {
  251. if (res.code == 200) {
  252. this.currentPage = 1
  253. uni.$u.toast(res.msg)
  254. this.sendShow = false
  255. this.tabClick()
  256. } else if (res.code == 2000) {
  257. let arrTitle = res.data
  258. let title = ' ,请将冰排' + arrTitle.toString() + '重新入库'
  259. uni.$u.toast(res.msg + title)
  260. this.sendShow = false
  261. this.tabClick()
  262. } else {
  263. uni.$u.toast(res.msg)
  264. }
  265. })
  266. } else {
  267. uni.$u.toast('请先扫描冰排')
  268. }
  269. } else {
  270. uni.$u.toast('请先选择保温箱')
  271. }
  272. },
  273. // 滚动加载更多
  274. loadMore() {
  275. if (this.incubatorMore) {
  276. this.Pagination++
  277. this.getIncubator()
  278. }
  279. },
  280. // tab运单
  281. tabClick(row) {
  282. this.currentPage = 1
  283. this.orderList = []
  284. if (row) {
  285. this.status = row.id
  286. }
  287. this.getList()
  288. this.getempty()
  289. },
  290. close() {
  291. this.getempty()
  292. },
  293. // 搜索保温箱
  294. incubatorInput(value) {
  295. if (this.searchShow) {
  296. this.incubatorMore = true
  297. this.Pagination = 1
  298. this.thermostatList = []
  299. // this.getIncubator()
  300. }
  301. },
  302. // 鼠标聚焦
  303. focus() {
  304. uni.navigateTo({
  305. url: '/pages/order/Incubator'
  306. });
  307. // this.searchShow = true
  308. // if (this.currentItem) {
  309. // this.incubatorValue = ''
  310. // this.hintTitle = this.currentItem
  311. // } else {
  312. // this.hintTitle = '请选择保温箱'
  313. // }
  314. },
  315. // 鼠标失去焦点
  316. blur(value) {
  317. setTimeout(() => {
  318. this.searchShow = false
  319. if (this.currentItem) {
  320. this.incubatorValue = this.currentItem
  321. }
  322. })
  323. },
  324. // 冰排失去焦点
  325. iceRaftBlur(value) {
  326. if (value) {
  327. this.iceList.push(value)
  328. this.iceList = this.uniqueArray(this.iceList)
  329. }
  330. },
  331. // 选择保温箱
  332. selectIncubator(value) {
  333. this.thermostatList.forEach(item => {
  334. if (item.id == value.id) {
  335. item.flag = true
  336. this.incubatorValue = item.name
  337. this.currentItem = item.name
  338. this.searchShow = false
  339. this.getCoolerBox(item.id)
  340. } else {
  341. item.flag = false
  342. }
  343. })
  344. },
  345. // 获取保温箱内冰排
  346. getCoolerBox(id) {
  347. this.$api.get('/api/ice-raft/cooler-box', {
  348. coolerBoxId: id,
  349. }).then(res => {
  350. if (res.code == 200) {
  351. this.iceList = res.data
  352. }
  353. })
  354. },
  355. // 移除错误运单号
  356. removeWaybill(value) {
  357. if (this.iceNumber == value) {
  358. this.iceNumber = ''
  359. }
  360. const arr = deleteElementById(this.iceList, value)
  361. this.iceList = arr
  362. function deleteElementById(arr, key) {
  363. return arr.filter((item) => item !== key);
  364. }
  365. },
  366. // 扫一扫
  367. sweep() {
  368. // 允许从相机和相册扫码
  369. uni.scanCode({
  370. scanType: ['barCode'],
  371. // scanType: ['qrCode'],
  372. autoZoom: false,
  373. success: (res) => {
  374. console.log(res);
  375. if (res.result) {
  376. let url = res.result;
  377. this.iceNumber = url
  378. this.iceList.push(url)
  379. function methods1(arr) {
  380. return Array.from(new Set(arr));
  381. }
  382. this.iceList = methods1(this.iceList)
  383. } else {
  384. console.log('请重新扫描');
  385. return false;
  386. }
  387. },
  388. fail: (res) => {
  389. console.log('未识别到二维码');
  390. }
  391. })
  392. },
  393. // 添加冰排
  394. addIce() {
  395. if (this.iceNumber) {
  396. this.iceList.push(this.iceNumber)
  397. this.iceList = this.uniqueArray(this.iceList)
  398. this.$nextTick(() => {
  399. // 获取scroll-view的高度
  400. const query = uni.createSelectorQuery().in(this);
  401. query.select('.scrollView').boundingClientRect(data => {
  402. this.scrollTop = data.height;
  403. }).exec();
  404. });
  405. }
  406. },
  407. // 去重
  408. uniqueArray(arr) {
  409. return [...new Set(arr)];
  410. },
  411. }
  412. }
  413. </script>
  414. <style lang="scss">
  415. .tab_order {
  416. background-color: #fff;
  417. }
  418. .card_order_mangement {
  419. display: flex;
  420. flex-direction: column;
  421. align-items: center;
  422. }
  423. .card_send {
  424. padding: 20rpx;
  425. min-height: 600rpx;
  426. }
  427. .send_title {
  428. text-align: center;
  429. margin: 10px;
  430. }
  431. .card_input_send {
  432. position: relative;
  433. display: flex;
  434. align-items: center;
  435. margin-bottom: 20rpx;
  436. }
  437. .card_thermostat {
  438. position: absolute;
  439. bottom: 100rpx;
  440. background-color: #fff;
  441. width: 100%;
  442. border-radius: 8rpx;
  443. border: 2rpx solid #E4E7ED;
  444. background-color: #FFF;
  445. box-shadow: 0 4rpx 24rpx 0 rgba(0, 0, 0, .1);
  446. z-index: 2024;
  447. }
  448. .popper_arrow {
  449. position: absolute;
  450. bottom: -6px;
  451. left: 50%;
  452. margin-right: 3px;
  453. border-top-color: #ebeef5;
  454. border-bottom-width: 0;
  455. border-width: 6px;
  456. filter: drop-shadow(0 2px 12px rgba(0, 0, 0, .03));
  457. }
  458. .popper_arrow::after {
  459. position: absolute;
  460. display: block;
  461. width: 0;
  462. height: 0;
  463. border-color: transparent;
  464. border-style: solid;
  465. bottom: -6px;
  466. margin-left: -6px;
  467. border-top-color: #fff;
  468. border-bottom-width: 0;
  469. content: " ";
  470. border-width: 6px;
  471. }
  472. .incubator_title {
  473. width: 150rpx;
  474. margin-right: 10rpx;
  475. font-size: 30rpx;
  476. span {
  477. color: red;
  478. }
  479. }
  480. .add_card {
  481. margin-left: 10rpx;
  482. width: 50rpx;
  483. height: 46rpx;
  484. border-radius: 8rpx;
  485. padding: 6px 9px;
  486. border: 1px solid #dadbde;
  487. }
  488. .card_btn {
  489. position: absolute;
  490. bottom: 20rpx;
  491. left: 30rpx;
  492. right: 30rpx;
  493. padding: 20rpx 0rpx;
  494. }
  495. .scroll-view {
  496. transition: max-height 1s ease-out;
  497. max-height: 0;
  498. overflow: hidden;
  499. }
  500. .is-fold {
  501. max-height: 600rpx;
  502. }
  503. .card_item_option {
  504. display: flex;
  505. justify-content: space-between;
  506. align-items: center;
  507. padding: 20rpx;
  508. }
  509. .nomatchingData {
  510. display: flex;
  511. justify-content: center;
  512. align-items: center;
  513. padding: 20rpx;
  514. color: #c8c9cc;
  515. }
  516. .card_frequency {
  517. display: flex;
  518. flex-wrap: wrap;
  519. }
  520. .swept_card {
  521. padding: 0rpx 20rpx;
  522. width: calc(100% - 40rpx);
  523. max-height: 600rpx;
  524. // overflow-y: auto;
  525. }
  526. .card_high {
  527. margin-bottom: 20rpx;
  528. }
  529. .card_frequency_title {
  530. font-size: 32rpx;
  531. }
  532. .card_bottle {
  533. font-size: 30rpx;
  534. span {
  535. color: red;
  536. }
  537. }
  538. .item_coding {
  539. display: flex;
  540. justify-content: space-between;
  541. align-items: center;
  542. width: 100%;
  543. padding: 20rpx 0rpx;
  544. }
  545. .num_index {
  546. font-size: 30rpx;
  547. margin-right: 10rpx;
  548. }
  549. .title_coding {
  550. font-size: 30rpx;
  551. }
  552. .card_search_gray {
  553. display: flex;
  554. flex-direction: row;
  555. align-items: center;
  556. justify-content: space-between;
  557. flex: 1;
  558. padding: 12rpx 18rpx;
  559. border-radius: 8rpx;
  560. line-height: 48rpx;
  561. }
  562. .title_gray {
  563. font-size: 30rpx;
  564. color: #c8c9cc;
  565. }
  566. // 伪元素1rpx边框
  567. .frame {
  568. position: relative; //重要
  569. }
  570. .frame::after {
  571. position: absolute;
  572. content: '';
  573. border: 2rpx solid #e7e6e4;
  574. border-radius: 16rpx;
  575. width: 200%;
  576. height: 200%;
  577. top: 0;
  578. left: 0;
  579. transform: scale(0.5);
  580. transform-origin: 0 0;
  581. pointer-events: none;
  582. /* 使伪元素不会阻止鼠标事件 */
  583. }
  584. </style>