delivery.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. <template>
  2. <!-- 出入库 -->
  3. <view>
  4. <u-navbar :title="navTitle" autoBack placeholder @leftClick="leftClick"></u-navbar>
  5. <view class="card_order_details">
  6. <view class="card_search" v-if="selectiveType == 'enter'">
  7. <view class="details_title">冷冻柜 <span class="line_title">*</span></view>
  8. <view class="card_input">
  9. <view class="card_search_gray frame" @click="focus(true)">
  10. <span v-if="coldCupboard.name">{{coldCupboard.name}}</span>
  11. <span class="title_gray" v-else>请选择冷冻柜</span>
  12. <u-icon name="arrow-down" color="#c8c9cc" size="18"></u-icon>
  13. </view>
  14. <!-- <u-input placeholder="请选择" border="surround" v-model="coldCupboard.name" suffixIcon="arrow-down"
  15. @focus="focus(true)"></u-input> -->
  16. </view>
  17. </view>
  18. <view class="card_search" v-if="selectiveType == 'out'">
  19. <view class="details_title">保温箱 <span class="line_title">*</span></view>
  20. <view class="card_input">
  21. <view class="card_search_gray frame" @click="focus(false)">
  22. <span v-if="incubator.name">{{incubator.name}}</span>
  23. <span class="title_gray" v-else>请选择保温箱</span>
  24. <u-icon name="arrow-down" color="#c8c9cc" size="18"></u-icon>
  25. </view>
  26. <!-- <u-input placeholder="请选择" border="surround" v-model="incubator.name" suffixIcon="arrow-down"
  27. @focus="focus(false)"></u-input> -->
  28. </view>
  29. </view>
  30. <!-- <view class="card_search" v-if="selectiveType == 'out'">
  31. <view class="details_title">冰排适冷温度 <span class="line_title">*</span></view>
  32. <view class="card_input">
  33. <u-input placeholder="请输入冰排适冷温度" border="surround" v-model="suitableForCold"></u-input>
  34. </view>
  35. <view class="title_hour"> ℃ </view>
  36. </view> -->
  37. <!-- <view class="card_search" v-if="selectiveType == 'enter'">
  38. <view class="details_title">冷冻要求 <span class="line_title">*</span></view>
  39. <view class="card_input">
  40. <u-input placeholder="请输入冷冻要求" border="surround" v-model="freezingDuration"></u-input>
  41. </view>
  42. <view class="title_hour">小时</view>
  43. </view> -->
  44. <view class="card_search">
  45. <view class="details_title">冰排编号 <span class="line_title">*</span></view>
  46. <view class="card_input">
  47. <u-input border="surround" v-model="frequencyCoding">
  48. <template slot="suffix">
  49. <u-icon name="scan" size="24" @click="sweep"></u-icon>
  50. </template>
  51. </u-input>
  52. </view>
  53. <view class="add_card center_in" @click="addIce">
  54. <u-icon name="plus" size="18"></u-icon>
  55. </view>
  56. <!-- <view class="deleteCurrent" @click="removeWaybill(frequencyCoding)">
  57. <u-icon class="icon_current" name="backspace" height="10" size="20"></u-icon>
  58. <view class="title_nape">删除</view>
  59. </view> -->
  60. </view>
  61. <view class="card_frequency">
  62. <view class="card_high space_between">
  63. <view class="card_frequency_title">已录入冰排编号</view>
  64. <view class="card_bottle">已扫<span>{{list.length}}</span></view>
  65. </view>
  66. <view style="width: 100%;" v-if="list.length > 0">
  67. <view class="item_coding" v-for="(item,index) in list" :key="index">
  68. <view class="title_coding">{{item}}</view>
  69. <u-icon name="close-circle-fill" color="#c0c4cc" size="20"
  70. @click="removeWaybill(item)"></u-icon>
  71. </view>
  72. </view>
  73. </view>
  74. <view style="width: 100%;height: 120rpx;"></view>
  75. <view class="card_btn">
  76. <u-button style="margin-bottom: 20rpx;" type="primary" @click="submit">提交</u-button>
  77. </view>
  78. </view>
  79. <u-popup :show="courierShow" mode="bottom" closeable :round="10" :closeOnClickOverlay="false" @close="close">
  80. <view class="card_courier">
  81. <view class="headline">{{courierHeadline}}</view>
  82. <view class="search_card">
  83. <u-search :showAction="false" v-model="keyword" @change="searchChange"
  84. placeholder="输入关键字快速查找"></u-search>
  85. </view>
  86. <scroll-view class="scroll-view" scroll-y="true" @scrolltolower="loadMore">
  87. <view class="courier" v-if="courieList.length > 0">
  88. <view class="courier_item space_between" v-for="(item,index) in courieList" :key="index"
  89. @click="bindingDistributor(item)">
  90. <view class="courier_name">
  91. <view class="title_name">{{item.name}}</view>
  92. </view>
  93. <view class="xd_title center_in">选择</view>
  94. </view>
  95. </view>
  96. <view style="margin-top: 30rpx;" v-else>
  97. <u-empty mode="list" :text="textEmpty"></u-empty>
  98. </view>
  99. </scroll-view>
  100. </view>
  101. </u-popup>
  102. </view>
  103. </template>
  104. <script>
  105. const ENV = require('@/.env.js')
  106. export default {
  107. data() {
  108. return {
  109. frequencyCoding: '',
  110. navTitle: '',
  111. selectiveType: '',
  112. cmpCode: '',
  113. list: [],
  114. orderId: '',
  115. freezingDuration: '',
  116. suitableForCold: null,
  117. keyword: '',
  118. courierHeadline: '选择冷冻柜',
  119. textEmpty: '暂无冷冻柜',
  120. courieList: [],
  121. courierShow: false,
  122. iceLockerId: '',
  123. freezeClaim: '',
  124. typeFlag: true,
  125. incubatorMore: true,
  126. Pagination: 1,
  127. pageSize: 10,
  128. coldCupboard: {
  129. id: null,
  130. name: '',
  131. },
  132. incubator: {
  133. id: null,
  134. name: '',
  135. },
  136. }
  137. },
  138. onUnload() {
  139. uni.removeStorageSync('incubatorValue');
  140. },
  141. onLoad(receive) {
  142. this.navTitle = receive.title
  143. this.selectiveType = receive.id
  144. },
  145. onShow() {
  146. let incubator = uni.getStorageSync('incubatorValue')
  147. if (incubator) {
  148. if (incubator.id != this.incubator.id) {
  149. this.incubator.id = incubator.id
  150. this.incubator.name = incubator.name
  151. }
  152. }
  153. },
  154. methods: {
  155. focus(flag) {
  156. this.typeFlag = flag
  157. this.courieList = []
  158. this.Pagination = 1
  159. this.incubatorMore = true
  160. if (flag) {
  161. this.courierHeadline = '选择冷冻柜'
  162. this.textEmpty = '暂无冷冻柜'
  163. this.getFreezer()
  164. this.courierShow = true
  165. } else {
  166. uni.navigateTo({
  167. url: '/pages/order/Incubator'
  168. });
  169. // this.courierHeadline = '选择保温箱'
  170. // this.textEmpty = '暂无保温箱'
  171. // this.getIncubator()
  172. }
  173. },
  174. // 关键字搜索
  175. searchChange(value) {
  176. this.Pagination = 1
  177. this.incubatorMore = true
  178. this.courieList = []
  179. if (this.typeFlag) {
  180. this.getFreezer()
  181. } else {
  182. this.getIncubator()
  183. }
  184. },
  185. // 获取冷冻柜
  186. getFreezer() {
  187. this.$api.get('/api/ice-locker', {
  188. page: this.Pagination,
  189. pageSize: this.pageSize,
  190. name: this.keyword,
  191. status: '2',
  192. }).then(res => {
  193. if (res.code == 200) {
  194. const data = res.data.list
  195. if (this.incubatorMore == true) {
  196. this.courieList = this.courieList.concat(data);
  197. }
  198. if (data.length < this.pageSize) {
  199. this.incubatorMore = false
  200. } else {
  201. this.incubatorMore = true
  202. }
  203. }
  204. })
  205. },
  206. // 获取保温箱
  207. getIncubator() {
  208. this.$api.get('/api/cooler-box', {
  209. page: this.Pagination,
  210. pageSize: this.pageSize,
  211. name: this.keyword,
  212. status: '2',
  213. }).then(res => {
  214. if (res.code == 200) {
  215. const data = res.data.list
  216. if (this.incubatorMore == true) {
  217. this.courieList = this.courieList.concat(data);
  218. }
  219. if (data.length < this.pageSize) {
  220. this.incubatorMore = false
  221. } else {
  222. this.incubatorMore = true
  223. }
  224. }
  225. })
  226. },
  227. // 选择保温箱.冷冻柜
  228. bindingDistributor(value) {
  229. if (this.typeFlag) {
  230. this.coldCupboard.id = value.id
  231. this.coldCupboard.name = value.name
  232. } else {
  233. this.incubator.id = value.id
  234. this.incubator.name = value.name
  235. }
  236. this.courierShow = false
  237. },
  238. // 滚动加载更多
  239. loadMore() {
  240. if (this.incubatorMore) {
  241. this.Pagination++
  242. if (this.typeFlag) {
  243. this.getFreezer()
  244. } else {
  245. this.getIncubator()
  246. }
  247. }
  248. },
  249. close() {
  250. this.courierShow = false
  251. },
  252. leftClick() {
  253. uni.$emit('refresh');
  254. },
  255. async submit() {
  256. await this.getEntering()
  257. if (this.list.length > 0) {
  258. if (this.typeFlag) {
  259. // 入库
  260. this.$api.post('/api/ice-raft/in-storage', {
  261. code: this.list,
  262. iceLockerId: this.coldCupboard.id,
  263. freezeClaim: Number(this.freezingDuration),
  264. }).then(res => {
  265. if (res.code == 200) {
  266. this.list = []
  267. this.freezingDuration = ''
  268. this.frequencyCoding = ''
  269. this.coldCupboard.id = null
  270. this.coldCupboard.name = ''
  271. uni.showToast({
  272. icon: 'none',
  273. title: res.msg,
  274. duration: 3000
  275. });
  276. } else {
  277. uni.showToast({
  278. icon: 'none',
  279. title: res.msg,
  280. duration: 3000
  281. });
  282. }
  283. })
  284. } else {
  285. // 出库
  286. this.$api.post('/api/ice-raft/out-storage', {
  287. code: this.list,
  288. coolerBoxId: this.incubator.id,
  289. suitableForCold: Number(this.suitableForCold),
  290. }).then(res => {
  291. if (res.code == 200) {
  292. this.list = []
  293. this.suitableForCold = null
  294. this.frequencyCoding = ''
  295. this.incubator.id = null
  296. this.incubator.name = ''
  297. uni.showToast({
  298. icon: 'none',
  299. title: res.msg,
  300. duration: 3000
  301. });
  302. } else {
  303. uni.showToast({
  304. icon: 'none',
  305. title: res.msg,
  306. duration: 3000
  307. });
  308. }
  309. })
  310. }
  311. } else {
  312. uni.$u.toast('请先录入冰排编号')
  313. }
  314. },
  315. // 扫码录入
  316. async getEntering() {
  317. if (this.frequencyCoding) {
  318. await this.$api.get('/api/ice-raft/code/' + this.frequencyCoding).then(res => {
  319. if (res.code == 200) {
  320. this.list.push(this.frequencyCoding)
  321. function methods1(arr) {
  322. return Array.from(new Set(arr));
  323. }
  324. this.list = methods1(this.list)
  325. } else {
  326. uni.showToast({
  327. icon: 'none',
  328. title: res.msg,
  329. duration: 3000
  330. });
  331. }
  332. })
  333. }
  334. },
  335. // 扫一扫
  336. sweep() {
  337. // 允许从相机和相册扫码
  338. uni.scanCode({
  339. scanType: ['barCode'],
  340. // scanType: ['qrCode'],
  341. autoZoom: false,
  342. success: (res) => {
  343. console.log(res);
  344. if (res.result) {
  345. let url = res.result;
  346. this.frequencyCoding = url
  347. this.$api.get('/api/ice-raft/code/' + this.frequencyCoding).then(res => {
  348. if (res.code == 200) {
  349. this.list.push(url)
  350. function methods1(arr) {
  351. return Array.from(new Set(arr));
  352. }
  353. this.list = methods1(this.list)
  354. } else {
  355. uni.showToast({
  356. icon: 'none',
  357. title: res.msg,
  358. duration: 3000
  359. });
  360. }
  361. })
  362. } else {
  363. console.log('请重新扫描');
  364. return false;
  365. }
  366. },
  367. fail: (res) => {
  368. console.log('未识别到二维码');
  369. }
  370. })
  371. },
  372. // 添加冰排
  373. addIce() {
  374. if (this.frequencyCoding) {
  375. this.$api.get('/api/ice-raft/code/' + this.frequencyCoding).then(res => {
  376. if (res.code == 200) {
  377. this.list.push(this.frequencyCoding)
  378. this.list = this.uniqueArray(this.list)
  379. this.frequencyCoding = ''
  380. } else {
  381. uni.showToast({
  382. icon: 'none',
  383. title: res.msg,
  384. duration: 3000
  385. });
  386. }
  387. })
  388. }
  389. },
  390. // 去重
  391. uniqueArray(arr) {
  392. return [...new Set(arr)];
  393. },
  394. // 移除错误运单号
  395. removeWaybill(value) {
  396. if (this.frequencyCoding == value) {
  397. this.frequencyCoding = ''
  398. }
  399. const arr = deleteElementById(this.list, value)
  400. this.list = arr
  401. function deleteElementById(arr, key) {
  402. return arr.filter((item) => item !== key);
  403. }
  404. },
  405. }
  406. }
  407. </script>
  408. <style lang="scss">
  409. page {
  410. background-color: #fff !important;
  411. }
  412. .card_order_details {
  413. margin: 10rpx 30rpx 30rpx 30rpx;
  414. }
  415. .details_title {
  416. width: 150rpx;
  417. flex: none;
  418. color: #333;
  419. font-size: 32rpx;
  420. font-weight: 500;
  421. margin-bottom: 10rpx;
  422. // margin-right: 15rpx;
  423. }
  424. .title_hour {
  425. flex: none;
  426. font-size: 30rpx;
  427. margin-left: 15rpx;
  428. }
  429. .card_time {
  430. width: 100%;
  431. border: 1rpx solid #dadbde;
  432. border-radius: 10rpx;
  433. padding: 6px 9px;
  434. margin-left: 10rpx;
  435. line-height: 48rpx;
  436. }
  437. .card_search {
  438. display: flex;
  439. align-items: center;
  440. margin: 20rpx 0rpx;
  441. }
  442. .card_sign_in {
  443. margin-top: 30rpx;
  444. display: flex;
  445. }
  446. .scan_title {
  447. font-size: 20rpx;
  448. }
  449. .card_sweep {
  450. display: flex;
  451. flex-direction: column;
  452. align-items: center;
  453. flex: none;
  454. }
  455. .card_input {
  456. width: 100%;
  457. margin-left: 30rpx;
  458. }
  459. .line_title {
  460. color: red;
  461. }
  462. .card_high {
  463. margin-top: 20rpx;
  464. }
  465. .card_frequency {
  466. display: flex;
  467. flex-wrap: wrap;
  468. }
  469. .card_frequency_title {
  470. font-size: 32rpx;
  471. }
  472. .card_bottle {
  473. font-size: 30rpx;
  474. span {
  475. color: red;
  476. }
  477. }
  478. .item_coding {
  479. display: flex;
  480. justify-content: space-between;
  481. align-items: center;
  482. width: 100%;
  483. margin-top: 10px;
  484. padding: 25rpx 0rpx;
  485. border-bottom: 2rpx solid #dfdfdf;
  486. }
  487. .title_coding {
  488. font-size: 30rpx;
  489. }
  490. .card_empty {
  491. width: 100%;
  492. margin-top: 50rpx;
  493. display: flex;
  494. align-items: center;
  495. justify-content: center;
  496. }
  497. .card_btn {
  498. position: fixed;
  499. left: 0;
  500. right: 0;
  501. bottom: 0;
  502. padding-left: 30rpx;
  503. padding-right: 30rpx;
  504. padding-top: 20rpx;
  505. background-color: #fff;
  506. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  507. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  508. border-top: 1rpx solid #E4E7ED;
  509. }
  510. .deleteCurrent {
  511. display: flex;
  512. align-items: center;
  513. flex-direction: column;
  514. justify-content: center;
  515. border: 1px solid #e5e5e5;
  516. padding: 5rpx 0rpx 5rpx 5rpx;
  517. margin-left: 10rpx;
  518. border-radius: 8rpx;
  519. height: 66rpx;
  520. .icon_current {
  521. height: 15px;
  522. }
  523. .title_nape {
  524. margin: 0rpx 10rpx;
  525. display: flex;
  526. font-size: 20rpx;
  527. width: 40rpx;
  528. }
  529. }
  530. .add_card {
  531. margin-left: 10rpx;
  532. width: 50rpx;
  533. height: 46rpx;
  534. border-radius: 8rpx;
  535. padding: 6px 9px;
  536. border: 1px solid #dadbde;
  537. }
  538. ::v-deep .u-border {
  539. border-width: 1px !important;
  540. border-color: #e5e5e5 !important;
  541. border-style: solid;
  542. }
  543. .card_courier {
  544. min-height: 600rpx;
  545. padding-bottom: 20rpx;
  546. }
  547. .scroll-view {
  548. max-height: 60vh;
  549. overflow: hidden;
  550. }
  551. .headline {
  552. padding: 30rpx 30rpx 0rpx 30rpx;
  553. display: flex;
  554. align-items: center;
  555. justify-content: center;
  556. padding-bottom: 30rpx;
  557. font-size: 32rpx;
  558. font-weight: 600;
  559. }
  560. .search_card {
  561. padding: 0rpx 30rpx 10rpx 30rpx;
  562. }
  563. .courier_item {
  564. margin: 20rpx 20rpx;
  565. width: calc(100% - 80rpx);
  566. padding: 20rpx;
  567. border-radius: 16rpx;
  568. border: 1rpx solid #e7e6e4;
  569. // box-shadow: 0 2rpx 10rpx 0 rgba(0, 0, 0, .1);
  570. }
  571. .courier_name {
  572. display: flex;
  573. flex-direction: column;
  574. }
  575. .title_name {
  576. font-weight: 600;
  577. font-size: 32rpx;
  578. margin-bottom: 10rpx;
  579. }
  580. .title_phone {
  581. font-size: 28rpx;
  582. }
  583. .xd_title {
  584. width: auto;
  585. font-size: 28rpx;
  586. font-weight: 500;
  587. padding: 15rpx 30rpx;
  588. border-radius: 35rpx;
  589. // border: 3rpx solid #82848a;
  590. background-color: #E4E7ED;
  591. }
  592. .card_search_gray {
  593. display: flex;
  594. flex-direction: row;
  595. align-items: center;
  596. justify-content: space-between;
  597. flex: 1;
  598. padding: 12rpx 18rpx;
  599. border-radius: 8rpx;
  600. line-height: 48rpx;
  601. }
  602. .title_gray {
  603. font-size: 30rpx;
  604. color: #c8c9cc;
  605. }
  606. // 伪元素1rpx边框
  607. .frame {
  608. position: relative; //重要
  609. }
  610. .frame::after {
  611. position: absolute;
  612. content: '';
  613. border: 4rpx solid #e7e6e4;
  614. border-radius: 16rpx;
  615. width: 200%;
  616. height: 200%;
  617. top: 0;
  618. left: 0;
  619. transform: scale(0.5);
  620. transform-origin: 0 0;
  621. pointer-events: none;
  622. /* 使伪元素不会阻止鼠标事件 */
  623. }
  624. </style>