index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  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. console.log(4)
  180. this.getList()
  181. })
  182. },
  183. methods: {
  184. openCenter() {
  185. uni.navigateTo({
  186. url: '/pages/order/orderSearch'
  187. });
  188. },
  189. getempty() {
  190. this.iceList = []
  191. this.incubator.id = ''
  192. this.incubator.name = ''
  193. this.iceNumber = ''
  194. uni.removeStorageSync('incubatorValue');
  195. this.Pagination = 1
  196. this.currentItem = ''
  197. this.incubatorValue = ''
  198. this.hintTitle = '请选择保温箱'
  199. this.sendShow = false
  200. this.incubatorMore = true
  201. this.thermostatList = []
  202. },
  203. // 获取司机和仓管运单列表
  204. getList() {
  205. uni.showLoading({
  206. title: '加载中',
  207. mask: true, // 是否显示透明蒙层,防止触摸穿透
  208. })
  209. this.loadStatus = 'loading'
  210. this.loadingMore = true;
  211. this.$api.get('/api/waybill', {
  212. page: this.currentPage,
  213. pageSize: this.pageSize,
  214. status: this.status,
  215. assignment_status: 2,
  216. }).then(res => {
  217. if (res.code == 200) {
  218. const data = res.data.list
  219. if (this.loadingMore == true && data) {
  220. this.orderList = this.orderList.concat(data);
  221. }
  222. if (data.length < this.pageSize) {
  223. this.loadingMore = true
  224. this.loading = '没有更多了'
  225. this.loadStatus = 'nomore'
  226. } else {
  227. this.loading = '加载中'
  228. this.loadStatus = 'loading'
  229. this.loadingMore = false
  230. this.currentPage++
  231. }
  232. }
  233. uni.hideLoading();
  234. this.$forceUpdate()
  235. }).catch(() => {
  236. uni.hideLoading();
  237. this.loadingMore = true
  238. this.loadStatus = 'nomore'
  239. })
  240. },
  241. // 防拆更新
  242. proofRenewal() {
  243. this.currentPage = 1
  244. this.orderList = []
  245. this.getList()
  246. },
  247. // 派单
  248. sendOrders(value) {
  249. // console.log(value, 3333)
  250. this.waybillId = value.id
  251. this.sendShow = true
  252. // this.getIncubator()
  253. },
  254. // 重新获取列表
  255. operateSuccessfully() {
  256. this.currentPage = 1
  257. this.orderList = []
  258. this.getList()
  259. },
  260. // 获取保温箱
  261. getIncubator() {
  262. this.$api.get('/api/cooler-box', {
  263. page: this.Pagination,
  264. pageSize: this.pageSize,
  265. name: this.incubatorValue,
  266. status: '2',
  267. }).then(res => {
  268. if (res.code == 200) {
  269. const data = res.data.list
  270. data.forEach(item => {
  271. item.flag = false
  272. })
  273. if (this.incubatorMore == true) {
  274. this.thermostatList = this.thermostatList.concat(data);
  275. }
  276. if (data.length < this.pageSize) {
  277. this.incubatorMore = false
  278. } else {
  279. this.incubatorMore = true
  280. }
  281. }
  282. })
  283. },
  284. // 确定派单
  285. confirm() {
  286. if (this.incubator.id) {
  287. if (this.iceList.length > 0) {
  288. const arr = []
  289. arr.push(this.waybillId)
  290. this.$api.post('/api/waybill/delivery', {
  291. waybillIds: arr,
  292. coolerBoxId: this.incubator.id,
  293. iceRaftCode: this.iceList,
  294. }).then(res => {
  295. if (res.code == 200) {
  296. this.currentPage = 1
  297. uni.$u.toast(res.msg)
  298. this.sendShow = false
  299. this.tabClick()
  300. } else if (res.code == 2000) {
  301. let arrTitle = res.data
  302. let title = ' ,请将冰排' + arrTitle.toString() + '重新入库'
  303. uni.$u.toast(res.msg + title)
  304. this.sendShow = false
  305. this.tabClick()
  306. } else {
  307. uni.$u.toast(res.msg)
  308. }
  309. })
  310. } else {
  311. uni.$u.toast('请先扫描冰排')
  312. }
  313. } else {
  314. uni.$u.toast('请先选择保温箱')
  315. }
  316. },
  317. // 滚动加载更多
  318. loadMore() {
  319. if (this.incubatorMore) {
  320. this.Pagination++
  321. this.getIncubator()
  322. }
  323. },
  324. // tab运单
  325. tabClick(row) {
  326. this.loadStatus = 'loading'
  327. this.keyId = row.index
  328. this.loadingMore = true
  329. this.currentPage = 1
  330. this.orderList = []
  331. if (row) {
  332. this.status = row.id
  333. this.classifyId = row.id
  334. }
  335. this.getList()
  336. this.getempty()
  337. },
  338. close() {
  339. this.getempty()
  340. },
  341. // 搜索保温箱
  342. incubatorInput(value) {
  343. if (this.searchShow) {
  344. this.incubatorMore = true
  345. this.Pagination = 1
  346. this.thermostatList = []
  347. // this.getIncubator()
  348. }
  349. },
  350. // 鼠标聚焦
  351. focus() {
  352. uni.navigateTo({
  353. url: '/pages/order/Incubator'
  354. });
  355. // this.searchShow = true
  356. // if (this.currentItem) {
  357. // this.incubatorValue = ''
  358. // this.hintTitle = this.currentItem
  359. // } else {
  360. // this.hintTitle = '请选择保温箱'
  361. // }
  362. },
  363. // 鼠标失去焦点
  364. blur(value) {
  365. setTimeout(() => {
  366. this.searchShow = false
  367. if (this.currentItem) {
  368. this.incubatorValue = this.currentItem
  369. }
  370. })
  371. },
  372. // 冰排失去焦点
  373. iceRaftBlur(value) {
  374. if (value) {
  375. this.iceList.push(value)
  376. this.iceList = this.uniqueArray(this.iceList)
  377. }
  378. },
  379. // 选择保温箱
  380. selectIncubator(value) {
  381. this.thermostatList.forEach(item => {
  382. if (item.id == value.id) {
  383. item.flag = true
  384. this.incubatorValue = item.name
  385. this.currentItem = item.name
  386. this.searchShow = false
  387. this.getCoolerBox(item.id)
  388. } else {
  389. item.flag = false
  390. }
  391. })
  392. },
  393. // 获取保温箱内冰排
  394. getCoolerBox(id) {
  395. this.$api.get('/api/ice-raft/cooler-box', {
  396. coolerBoxId: id,
  397. }).then(res => {
  398. if (res.code == 200) {
  399. this.iceList = res.data
  400. }
  401. })
  402. },
  403. // 移除错误运单号
  404. removeWaybill(value) {
  405. if (this.iceNumber == value) {
  406. this.iceNumber = ''
  407. }
  408. const arr = deleteElementById(this.iceList, value)
  409. this.iceList = arr
  410. function deleteElementById(arr, key) {
  411. return arr.filter((item) => item !== key);
  412. }
  413. },
  414. // 扫一扫
  415. sweep() {
  416. // 允许从相机和相册扫码
  417. uni.scanCode({
  418. scanType: ['barCode'],
  419. // scanType: ['qrCode'],
  420. autoZoom: false,
  421. success: (res) => {
  422. // console.log(res);
  423. if (res.result) {
  424. let url = res.result;
  425. this.iceNumber = url
  426. this.iceList.push(url)
  427. function methods1(arr) {
  428. return Array.from(new Set(arr));
  429. }
  430. this.iceList = methods1(this.iceList)
  431. } else {
  432. console.log('请重新扫描');
  433. return false;
  434. }
  435. },
  436. fail: (res) => {
  437. console.log('未识别到二维码');
  438. }
  439. })
  440. },
  441. // 添加冰排
  442. addIce() {
  443. if (this.iceNumber) {
  444. this.iceList.push(this.iceNumber)
  445. this.iceList = this.uniqueArray(this.iceList)
  446. this.$nextTick(() => {
  447. // 获取scroll-view的高度
  448. const query = uni.createSelectorQuery().in(this);
  449. query.select('.scrollView').boundingClientRect(data => {
  450. this.scrollTop = data.height;
  451. }).exec();
  452. });
  453. this.iceNumber = ''
  454. }
  455. },
  456. // 签名板
  457. async getUpload(file) {
  458. const result = await this.uploadFilePromise(file)
  459. if (this.$refs.order) {
  460. this.$refs.order.imageData = result
  461. }
  462. },
  463. uploadFilePromise(url) {
  464. return new Promise((resolve, reject) => {
  465. let a = uni.uploadFile({
  466. url: ENV.APP_DEV_URL + '/api/upload', // 仅为示例,非真实的接口地址
  467. filePath: url,
  468. name: 'file',
  469. header: {
  470. 'Authorization': 'Bearer ' + uni.getStorageSync('access_token'),
  471. },
  472. success: (res) => {
  473. let state = JSON.parse(res.data)
  474. setTimeout(() => {
  475. if (state.code == 200) {
  476. resolve(state.data)
  477. }
  478. }, 100)
  479. }
  480. });
  481. })
  482. },
  483. // 去重
  484. uniqueArray(arr) {
  485. return [...new Set(arr)];
  486. },
  487. }
  488. }
  489. </script>
  490. <style lang="scss">
  491. .nav_center {
  492. display: flex;
  493. align-items: center;
  494. justify-content: flex-end;
  495. padding-right: 30rpx;
  496. width: 100%;
  497. }
  498. .tab_order {
  499. background-color: #fff;
  500. }
  501. .card_order_mangement {
  502. display: flex;
  503. flex-direction: column;
  504. align-items: center;
  505. }
  506. .card_send {
  507. padding: 20rpx;
  508. min-height: 600rpx;
  509. }
  510. .send_title {
  511. text-align: center;
  512. margin: 10px;
  513. }
  514. .card_input_send {
  515. position: relative;
  516. display: flex;
  517. align-items: center;
  518. margin-bottom: 20rpx;
  519. }
  520. .card_thermostat {
  521. position: absolute;
  522. bottom: 100rpx;
  523. background-color: #fff;
  524. width: 100%;
  525. border-radius: 8rpx;
  526. border: 2rpx solid #E4E7ED;
  527. background-color: #FFF;
  528. box-shadow: 0 4rpx 24rpx 0 rgba(0, 0, 0, .1);
  529. z-index: 2024;
  530. }
  531. .popper_arrow {
  532. position: absolute;
  533. bottom: -6px;
  534. left: 50%;
  535. margin-right: 3px;
  536. border-top-color: #ebeef5;
  537. border-bottom-width: 0;
  538. border-width: 6px;
  539. filter: drop-shadow(0 2px 12px rgba(0, 0, 0, .03));
  540. }
  541. .popper_arrow::after {
  542. position: absolute;
  543. display: block;
  544. width: 0;
  545. height: 0;
  546. border-color: transparent;
  547. border-style: solid;
  548. bottom: -6px;
  549. margin-left: -6px;
  550. border-top-color: #fff;
  551. border-bottom-width: 0;
  552. content: " ";
  553. border-width: 6px;
  554. }
  555. .incubator_title {
  556. width: 150rpx;
  557. margin-right: 10rpx;
  558. font-size: 30rpx;
  559. span {
  560. color: red;
  561. }
  562. }
  563. .add_card {
  564. margin-left: 10rpx;
  565. width: 50rpx;
  566. height: 46rpx;
  567. border-radius: 8rpx;
  568. padding: 6px 9px;
  569. border: 1px solid #dadbde;
  570. }
  571. .card_btn {
  572. position: absolute;
  573. bottom: 20rpx;
  574. left: 30rpx;
  575. right: 30rpx;
  576. padding: 20rpx 0rpx;
  577. }
  578. .scroll-view {
  579. transition: max-height 1s ease-out;
  580. max-height: 0;
  581. overflow: hidden;
  582. }
  583. .is-fold {
  584. max-height: 600rpx;
  585. }
  586. .card_item_option {
  587. display: flex;
  588. justify-content: space-between;
  589. align-items: center;
  590. padding: 20rpx;
  591. }
  592. .nomatchingData {
  593. display: flex;
  594. justify-content: center;
  595. align-items: center;
  596. padding: 20rpx;
  597. color: #c8c9cc;
  598. }
  599. .card_frequency {
  600. display: flex;
  601. flex-wrap: wrap;
  602. }
  603. .swept_card {
  604. padding: 0rpx 20rpx;
  605. width: calc(100% - 40rpx);
  606. max-height: 600rpx;
  607. // overflow-y: auto;
  608. }
  609. .card_high {
  610. margin-bottom: 20rpx;
  611. }
  612. .card_frequency_title {
  613. font-size: 32rpx;
  614. }
  615. .card_bottle {
  616. font-size: 30rpx;
  617. span {
  618. color: red;
  619. }
  620. }
  621. .item_coding {
  622. display: flex;
  623. justify-content: space-between;
  624. align-items: center;
  625. width: 100%;
  626. padding: 20rpx 0rpx;
  627. }
  628. .num_index {
  629. font-size: 30rpx;
  630. margin-right: 10rpx;
  631. }
  632. .title_coding {
  633. font-size: 30rpx;
  634. }
  635. .card_search_gray {
  636. display: flex;
  637. flex-direction: row;
  638. align-items: center;
  639. justify-content: space-between;
  640. flex: 1;
  641. padding: 12rpx 18rpx;
  642. border-radius: 8rpx;
  643. line-height: 48rpx;
  644. }
  645. .title_gray {
  646. font-size: 30rpx;
  647. color: #c8c9cc;
  648. }
  649. // 伪元素1rpx边框
  650. .frame {
  651. position: relative; //重要
  652. }
  653. .frame::after {
  654. position: absolute;
  655. content: '';
  656. border: 2rpx solid #e7e6e4;
  657. border-radius: 16rpx;
  658. width: 200%;
  659. height: 200%;
  660. top: 0;
  661. left: 0;
  662. transform: scale(0.5);
  663. transform-origin: 0 0;
  664. pointer-events: none;
  665. /* 使伪元素不会阻止鼠标事件 */
  666. }
  667. </style>