delivery.vue 16 KB

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