index.vue 15 KB

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