delivery.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. <template>
  2. <!-- 确认送达 -->
  3. <view>
  4. <u-navbar :title="navTitle" autoBack placeholder @leftClick="leftClick"></u-navbar>
  5. <view class="card_order_details">
  6. <view style="display: flex;align-items: center;margin-bottom: 10rpx;">
  7. <view class="details_title">{{getTitle(navTitle)}} <span class="line_title">*</span></view>
  8. <uni-datetime-picker type="datetime" :start="start" :end="end" v-model="valueTime" />
  9. </view>
  10. <view class="card_search" v-if="navTitle == '扫码装箱'">
  11. <view class="details_title">保温箱 <span class="line_title">*</span></view>
  12. <view class="card_form_item_selectil frameil" @click="incubatorChange">
  13. <view class="title_input_selectil" :class="incubatorName ? '' : 'hsColor'">
  14. {{incubatorName || '选择保温箱'}}
  15. </view>
  16. <u-icon name="arrow-down" size="18px"></u-icon>
  17. </view>
  18. </view>
  19. <view class="card_search">
  20. <view class="details_title">运单号 <span class="line_title">*</span></view>
  21. <view class="card_input">
  22. <u-input border="surround" v-model="frequencyCoding">
  23. <template slot="suffix">
  24. <u-icon name="scan" size="26" @click="sweep"></u-icon>
  25. </template>
  26. </u-input>
  27. </view>
  28. <view class="deleteCurrent" @click="removeWaybill(frequencyCoding)">
  29. <u-icon class="icon_current" name="backspace" height="10" size="20"></u-icon>
  30. <view class="title_nape">删除</view>
  31. </view>
  32. </view>
  33. <view v-if="selectiveType != 'signfor'">
  34. <view class="card_frequency">
  35. <view class="card_high space_between">
  36. <view class="card_frequency_title">已录入运单号</view>
  37. <view class="card_bottle">已扫<span>{{list.length}}</span></view>
  38. </view>
  39. <view style="width: 100%;" v-if="list.length > 0">
  40. <view class="item_coding" v-for="(item,index) in list" :key="index">
  41. <view class="title_coding">{{item}}</view>
  42. <u-icon name="close-circle-fill" color="#c0c4cc" size="20"
  43. @click="removeWaybill(item)"></u-icon>
  44. </view>
  45. </view>
  46. <view class="card_empty" v-else>
  47. <u-empty mode="list"></u-empty>
  48. </view>
  49. </view>
  50. </view>
  51. <view v-else>
  52. <view style="color: #2979ff;font-size: 30rpx;" @click="examine">查看温湿度记录</view>
  53. <view class="card_sign_in">
  54. <view class="details_title1">运单签收图片 <span class="line_title">*</span></view>
  55. <view>
  56. <u-upload :fileList="fileList1" name="1" :maxCount="1" @afterRead="afterRead"
  57. @delete="deletePic"></u-upload>
  58. </view>
  59. </view>
  60. <view class="card_sign_in">
  61. <view class="details_title1">随货通行单图片 <span class="line_title">*</span></view>
  62. <view>
  63. <u-upload :fileList="fileList2" name="2" :maxCount="1" @afterRead="afterRead"
  64. @delete="deletePic"></u-upload>
  65. </view>
  66. </view>
  67. <view class="card_sign_in">
  68. <view class="details_title1">冷链交接单图片 <span class="line_title">*</span></view>
  69. <view>
  70. <u-upload :fileList="fileList3" name="3" :maxCount="1" @afterRead="afterRead"
  71. @delete="deletePic"></u-upload>
  72. </view>
  73. </view>
  74. </view>
  75. <view style="width: 100%;height: 120rpx;"></view>
  76. <view class="card_btn">
  77. <u-button style="margin-bottom: 20rpx;" type="primary" :disabled="jurisdiction"
  78. @click="submit">提交</u-button>
  79. </view>
  80. </view>
  81. <u-popup :show="incubatorShow" closeable @close="close">
  82. <view class="card_incubator">
  83. <view class="head_place">选择保温箱</view>
  84. <view class="card_search_il">
  85. <u-search placeholder="请输入保温箱名称" v-model="keyword" :showAction="false"
  86. @change="searchChange"></u-search>
  87. </view>
  88. <view style="display: flex;flex-direction: column;" v-if="incubatorData.length > 0">
  89. <view class="card_title_item" :class="item.name == incubatorName ? 'color_blue' : ''"
  90. v-for="(item,index) in incubatorData" :key="index" @click="incubatorClick(item)">
  91. {{item.name}}
  92. </view>
  93. </view>
  94. <view style="margin-bottom: 20px;" v-else>
  95. <u-empty mode="list" text="暂无保温箱" marginTop="50"></u-empty>
  96. </view>
  97. </view>
  98. </u-popup>
  99. </view>
  100. </template>
  101. <script>
  102. const ENV = require('@/.env.js')
  103. export default {
  104. data() {
  105. return {
  106. frequencyCoding: '',
  107. navTitle: '',
  108. selectiveType: '',
  109. cmpCode: '',
  110. list: [],
  111. orderId: '',
  112. valueTime: this.getDateTime(new Date()),
  113. start: Date.now() - 10 * 24 * 3600000,
  114. end: Date.now() + 10 * 24 * 3600000,
  115. fileList1: [],
  116. fileList2: [],
  117. fileList3: [],
  118. keyword: '',
  119. incubatorShow: false,
  120. incubatorData: [],
  121. incubator: null,
  122. incubatorName: '',
  123. }
  124. },
  125. computed: {
  126. jurisdiction() {
  127. if (this.selectiveType == 'signfor') {
  128. if (this.fileList1.length > 0 && this.fileList2.length > 0 && this.fileList3.length > 0) {
  129. if (this.fileList1[0].message == '成功' && this.fileList2[0].message == '成功' && this.fileList3[0]
  130. .message == '成功') {
  131. return false
  132. } else {
  133. return true
  134. }
  135. } else {
  136. return true
  137. }
  138. }
  139. }
  140. },
  141. onLoad(receive) {
  142. this.navTitle = receive.title
  143. this.selectiveType = receive.id
  144. },
  145. methods: {
  146. leftClick() {
  147. uni.$emit('refresh');
  148. },
  149. submit() {
  150. this.getEntering()
  151. if (this.list.length > 0) {
  152. if (this.valueTime) {
  153. if (this.selectiveType == 'put') {
  154. // 扫码入库
  155. this.scanCodes('/api/waybill/warehouse-in')
  156. } else if (this.selectiveType == 'out') {
  157. // 扫码出库
  158. this.scanCodes('/api/waybill/warehouse-out')
  159. } else if (this.selectiveType == 'truck') {
  160. // 扫码装车
  161. this.scanCodes('/api/waybill/car-in')
  162. } else if (this.selectiveType == 'encasement') {
  163. // 扫码装箱
  164. if (this.incubator) {
  165. this.scanCodes('/api/waybill/cooler-box-in')
  166. } else {
  167. uni.$u.toast('请选择保温箱')
  168. }
  169. } else if (this.selectiveType == 'unload') {
  170. // 扫码下车
  171. this.scanCodes('/api/waybill/car-out')
  172. } else if (this.selectiveType == 'signfor') {
  173. if (this.fileList1.length > 0 && this.fileList2.length > 0 && this.fileList3.length > 0) {
  174. // 扫码签收
  175. this.scanCodesSignFor('/api/waybill/receipt')
  176. } else {
  177. uni.$u.toast('请完善表单')
  178. }
  179. }
  180. } else {
  181. const title = this.getTitle(this.navTitle)
  182. uni.$u.toast('请先选择' + title + '时间')
  183. }
  184. } else {
  185. uni.$u.toast('请先录入运单号')
  186. }
  187. },
  188. getTitle(value) {
  189. const title = value.split('扫码')
  190. const headline = title[1] + '时间'
  191. return headline
  192. },
  193. // 提交扫码列表
  194. scanCodes(url) {
  195. uni.showLoading();
  196. this.$api.post(url, {
  197. startTime: this.valueTime,
  198. waybillNoList: this.list,
  199. coolerBoxId: this.incubator,
  200. }).then(res => {
  201. if (res.code == 200) {
  202. this.frequencyCoding = ''
  203. this.list = []
  204. uni.$u.toast(res.msg)
  205. } else {
  206. uni.$u.toast(res.data.msg)
  207. }
  208. uni.hideLoading();
  209. }).catch(() => {
  210. uni.hideLoading();
  211. })
  212. },
  213. // 提交扫码签收列表
  214. scanCodesSignFor(url) {
  215. const signUrl = this.fileList1[0].url + ',' + this.fileList2[0].url + ',' + this.fileList3[0].url
  216. this.$api.post(url, {
  217. startTime: this.valueTime,
  218. waybillNo: this.frequencyCoding,
  219. receiptImg: signUrl,
  220. }).then(res => {
  221. if (res.code == 200) {
  222. this.frequencyCoding = ''
  223. this.fileList1 = []
  224. this.fileList2 = []
  225. this.fileList3 = []
  226. this.list = []
  227. uni.$u.toast(res.msg)
  228. } else {
  229. uni.$u.toast(res.data.msg)
  230. }
  231. })
  232. },
  233. // 扫码录入
  234. getEntering() {
  235. if (this.frequencyCoding) {
  236. this.list.push(this.frequencyCoding)
  237. function methods1(arr) {
  238. return Array.from(new Set(arr));
  239. }
  240. this.list = methods1(this.list)
  241. }
  242. },
  243. // 扫一扫
  244. sweep() {
  245. // 允许从相机和相册扫码
  246. uni.scanCode({
  247. scanType: ['barCode'],
  248. // scanType: ['qrCode'],
  249. autoZoom: false,
  250. success: (res) => {
  251. console.log(res);
  252. if (res.result) {
  253. let url = res.result;
  254. this.frequencyCoding = url
  255. this.list.push(url)
  256. function methods1(arr) {
  257. return Array.from(new Set(arr));
  258. }
  259. this.list = methods1(this.list)
  260. } else {
  261. console.log('请重新扫描');
  262. return false;
  263. }
  264. },
  265. fail: (res) => {
  266. console.log('未识别到二维码');
  267. }
  268. })
  269. },
  270. // 移除错误运单号
  271. removeWaybill(value) {
  272. if (this.frequencyCoding == value) {
  273. this.frequencyCoding = ''
  274. }
  275. const arr = deleteElementById(this.list, value)
  276. this.list = arr
  277. function deleteElementById(arr, key) {
  278. return arr.filter((item) => item !== key);
  279. }
  280. },
  281. // 新增图片
  282. async afterRead(event) {
  283. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  284. let lists = [].concat(event.file)
  285. let fileListLen = this[`fileList${event.name}`].length
  286. lists.map((item) => {
  287. this[`fileList${event.name}`].push({
  288. ...item,
  289. status: 'uploading',
  290. message: '上传中'
  291. })
  292. })
  293. for (let i = 0; i < lists.length; i++) {
  294. const result = await this.uploadFilePromise(lists[i].url)
  295. let item = this[`fileList${event.name}`][fileListLen]
  296. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  297. status: 'success',
  298. message: '成功',
  299. url: result
  300. }))
  301. fileListLen++
  302. }
  303. if (event.name == '1') {
  304. var arr = []
  305. this.fileList1.forEach(item1 => {
  306. arr.push(item1.url)
  307. })
  308. } else if (event.name == '2') {
  309. var arr1 = []
  310. this.fileList2.forEach(item2 => {
  311. arr1.push(item2.url)
  312. })
  313. } else if (event.name == '3') {
  314. var arr2 = []
  315. this.fileList3.forEach(item3 => {
  316. arr2.push(item3.url)
  317. })
  318. }
  319. },
  320. // 删除图片
  321. deletePic(event) {
  322. this[`fileList${event.name}`].splice(event.index, 1)
  323. },
  324. uploadFilePromise(url) {
  325. return new Promise((resolve, reject) => {
  326. let a = uni.uploadFile({
  327. url: ENV.APP_DEV_URL + '/api/upload', // 仅为示例,非真实的接口地址
  328. filePath: url,
  329. name: 'file',
  330. // formData: {
  331. // user: 'test'
  332. // },
  333. header: {
  334. 'Authorization': 'Bearer ' + uni.getStorageSync('access_token'),
  335. },
  336. success: (res) => {
  337. let state = JSON.parse(res.data)
  338. setTimeout(() => {
  339. if (state.code == 200) {
  340. resolve(state.data)
  341. }
  342. })
  343. }
  344. });
  345. })
  346. },
  347. getDateTime(date, addZero = true) {
  348. return `${this.getDate(date, addZero)} ${this.getTime(date, addZero)}`
  349. },
  350. getDate(date, addZero = true) {
  351. date = new Date(date)
  352. const year = date.getFullYear()
  353. const month = date.getMonth() + 1
  354. const day = date.getDate()
  355. return `${year}-${addZero ? this.addZero(month) : month}-${addZero ? this.addZero(day) : day}`
  356. },
  357. getTime(date, addZero = true) {
  358. date = new Date(date)
  359. const hour = date.getHours()
  360. const minute = date.getMinutes()
  361. const second = date.getSeconds()
  362. return this.hideSecond ?
  363. `${addZero ? this.addZero(hour) : hour}:${addZero ? this.addZero(minute) : minute}` :
  364. `${addZero ? this.addZero(hour) : hour}:${addZero ? this.addZero(minute) : minute}:${addZero ? this.addZero(second) : second}`
  365. },
  366. addZero(num) {
  367. if (num < 10) {
  368. num = `0${num}`
  369. }
  370. return num
  371. },
  372. // 保温箱选择
  373. incubatorChange() {
  374. this.incubatorShow = true
  375. this.$api.get('/api/cooler-box', {
  376. page: 1,
  377. pageSize: 999,
  378. isBind: true,
  379. name: this.keyword,
  380. }).then(res => {
  381. if (res.code == 200) {
  382. this.incubatorData = res.data.list
  383. }
  384. })
  385. },
  386. // 选择保温箱
  387. incubatorClick(event) {
  388. this.incubator = event.id
  389. this.incubatorName = event.name
  390. this.incubatorShow = false
  391. },
  392. // 搜索
  393. searchChange() {
  394. this.incubatorData = []
  395. this.incubatorChange()
  396. },
  397. // 查看温湿度记录
  398. examine() {
  399. if (this.frequencyCoding) {
  400. uni.navigateTo({
  401. url: '/pages/order/humiture?waybillNo=' + this.frequencyCoding
  402. });
  403. } else {
  404. uni.$u.toast('请先扫描运单号')
  405. }
  406. },
  407. close() {
  408. this.incubatorShow = false
  409. },
  410. }
  411. }
  412. </script>
  413. <style lang="scss">
  414. page {
  415. background-color: #fff !important;
  416. }
  417. .card_order_details {
  418. margin: 10rpx 30rpx 30rpx 30rpx;
  419. }
  420. .details_title {
  421. position: relative;
  422. width: 140rpx;
  423. flex: none;
  424. color: #333;
  425. font-size: 32rpx;
  426. font-weight: 500;
  427. margin-bottom: 10rpx;
  428. margin-right: 15rpx;
  429. padding-left: 15rpx;
  430. }
  431. .card_form_item_selectil {
  432. width: 100%;
  433. display: flex;
  434. flex-direction: row;
  435. align-items: center;
  436. justify-content: space-between;
  437. padding: 6px 9px;
  438. height: 52rpx;
  439. }
  440. .title_input_selectil {
  441. font-size: 30rpx;
  442. // width: 100%;
  443. }
  444. .hsColor {
  445. color: rgb(192, 196, 204);
  446. }
  447. .details_title1 {
  448. position: relative;
  449. width: 140rpx;
  450. text-align: center;
  451. flex: none;
  452. color: #333;
  453. font-size: 32rpx;
  454. font-weight: 500;
  455. margin-bottom: 10rpx;
  456. margin-right: 15rpx;
  457. padding-left: 15rpx;
  458. }
  459. .card_time {
  460. width: 100%;
  461. border: 1rpx solid #dadbde;
  462. border-radius: 10rpx;
  463. padding: 6px 9px;
  464. margin-left: 10rpx;
  465. line-height: 48rpx;
  466. }
  467. .card_search {
  468. display: flex;
  469. align-items: center;
  470. margin: 20rpx 0rpx;
  471. }
  472. .card_sign_in {
  473. margin-top: 30rpx;
  474. display: flex;
  475. }
  476. .scan_title {
  477. font-size: 20rpx;
  478. }
  479. .card_sweep {
  480. display: flex;
  481. flex-direction: column;
  482. align-items: center;
  483. flex: none;
  484. }
  485. .card_input {
  486. width: 100%;
  487. // margin-left: 30rpx;
  488. }
  489. .line_title {
  490. position: absolute;
  491. top: 0rpx;
  492. left: 0rpx;
  493. color: red;
  494. }
  495. .card_high {
  496. margin-top: 30rpx;
  497. }
  498. .card_frequency {
  499. display: flex;
  500. flex-wrap: wrap;
  501. }
  502. .card_frequency_title {
  503. font-size: 32rpx;
  504. }
  505. .card_bottle {
  506. font-size: 30rpx;
  507. span {
  508. color: red;
  509. }
  510. }
  511. .item_coding {
  512. display: flex;
  513. justify-content: space-between;
  514. align-items: center;
  515. width: 100%;
  516. margin-top: 10px;
  517. padding: 25rpx 0rpx;
  518. border-bottom: 2rpx solid #dfdfdf;
  519. }
  520. .title_coding {
  521. font-size: 30rpx;
  522. }
  523. .card_empty {
  524. width: 100%;
  525. margin-top: 50rpx;
  526. display: flex;
  527. align-items: center;
  528. justify-content: center;
  529. }
  530. .card_btn {
  531. position: fixed;
  532. left: 0;
  533. right: 0;
  534. bottom: 0;
  535. padding-left: 30rpx;
  536. padding-right: 30rpx;
  537. padding-top: 20rpx;
  538. background-color: #fff;
  539. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  540. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  541. }
  542. .deleteCurrent {
  543. display: flex;
  544. align-items: center;
  545. flex-direction: column;
  546. justify-content: center;
  547. border: 1px solid #e5e5e5;
  548. padding: 5rpx 0rpx 5rpx 5rpx;
  549. margin-left: 10rpx;
  550. border-radius: 8rpx;
  551. height: 66rpx;
  552. .icon_current {
  553. height: 15px;
  554. }
  555. .title_nape {
  556. margin: 0rpx 10rpx;
  557. display: flex;
  558. font-size: 20rpx;
  559. width: 40rpx;
  560. }
  561. }
  562. ::v-deep .u-border {
  563. border-width: 1px !important;
  564. border-color: #e5e5e5 !important;
  565. border-style: solid;
  566. }
  567. .card_incubator {
  568. min-height: 600rpx;
  569. max-height: 900rpx;
  570. }
  571. .head_place {
  572. display: flex;
  573. justify-content: center;
  574. align-items: center;
  575. padding: 20rpx;
  576. }
  577. .card_search_il {
  578. margin: 20rpx;
  579. }
  580. .card_title_item {
  581. position: relative;
  582. padding: 30rpx;
  583. // border-bottom: 1rpx solid #dadbde;
  584. }
  585. .color_blue {
  586. color: #2979ff;
  587. }
  588. .card_title_item:before {
  589. content: " ";
  590. position: absolute;
  591. left: 0;
  592. bottom: 0;
  593. width: 100%;
  594. height: 1px;
  595. border-top: 1px solid #e7e6e4;
  596. -webkit-transform-origin: 0 0;
  597. transform-origin: 0 0;
  598. -webkit-transform: scaleY(0.5);
  599. transform: scaleY(0.5);
  600. }
  601. // 伪元素1rpx边框
  602. .frameil {
  603. position: relative; //重要
  604. }
  605. .frameil::after {
  606. position: absolute;
  607. content: '';
  608. border: 2rpx solid #dadbde;
  609. width: 200%;
  610. height: 200%;
  611. top: 0;
  612. left: 0;
  613. transform: scale(0.5);
  614. transform-origin: 0 0;
  615. pointer-events: none;
  616. border-radius: 20rpx;
  617. /* 使伪元素不会阻止鼠标事件 */
  618. }
  619. </style>