delivery.vue 14 KB

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