index.vue 16 KB

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