delivery.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  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. submit() {
  233. 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. getEntering() {
  293. if (this.frequencyCoding) {
  294. this.list.push(this.frequencyCoding)
  295. function methods1(arr) {
  296. return Array.from(new Set(arr));
  297. }
  298. this.list = methods1(this.list)
  299. }
  300. },
  301. // 扫一扫
  302. sweep() {
  303. // 允许从相机和相册扫码
  304. uni.scanCode({
  305. scanType: ['barCode'],
  306. // scanType: ['qrCode'],
  307. autoZoom: false,
  308. success: (res) => {
  309. console.log(res);
  310. if (res.result) {
  311. let url = res.result;
  312. this.frequencyCoding = url
  313. this.list.push(url)
  314. function methods1(arr) {
  315. return Array.from(new Set(arr));
  316. }
  317. this.list = methods1(this.list)
  318. } else {
  319. console.log('请重新扫描');
  320. return false;
  321. }
  322. },
  323. fail: (res) => {
  324. console.log('未识别到二维码');
  325. }
  326. })
  327. },
  328. // 添加冰排
  329. addIce() {
  330. if (this.frequencyCoding) {
  331. this.list.push(this.frequencyCoding)
  332. this.list = this.uniqueArray(this.list)
  333. }
  334. },
  335. // 去重
  336. uniqueArray(arr) {
  337. return [...new Set(arr)];
  338. },
  339. // 移除错误运单号
  340. removeWaybill(value) {
  341. if (this.frequencyCoding == value) {
  342. this.frequencyCoding = ''
  343. }
  344. const arr = deleteElementById(this.list, value)
  345. this.list = arr
  346. function deleteElementById(arr, key) {
  347. return arr.filter((item) => item !== key);
  348. }
  349. },
  350. }
  351. }
  352. </script>
  353. <style lang="scss">
  354. page {
  355. background-color: #fff !important;
  356. }
  357. .card_order_details {
  358. margin: 10rpx 30rpx 30rpx 30rpx;
  359. }
  360. .details_title {
  361. width: 150rpx;
  362. flex: none;
  363. color: #333;
  364. font-size: 32rpx;
  365. font-weight: 500;
  366. margin-bottom: 10rpx;
  367. // margin-right: 15rpx;
  368. }
  369. .title_hour {
  370. flex: none;
  371. font-size: 30rpx;
  372. margin-left: 15rpx;
  373. }
  374. .card_time {
  375. width: 100%;
  376. border: 1rpx solid #dadbde;
  377. border-radius: 10rpx;
  378. padding: 6px 9px;
  379. margin-left: 10rpx;
  380. line-height: 48rpx;
  381. }
  382. .card_search {
  383. display: flex;
  384. align-items: center;
  385. margin: 20rpx 0rpx;
  386. }
  387. .card_sign_in {
  388. margin-top: 30rpx;
  389. display: flex;
  390. }
  391. .scan_title {
  392. font-size: 20rpx;
  393. }
  394. .card_sweep {
  395. display: flex;
  396. flex-direction: column;
  397. align-items: center;
  398. flex: none;
  399. }
  400. .card_input {
  401. width: 100%;
  402. margin-left: 30rpx;
  403. }
  404. .line_title {
  405. color: red;
  406. }
  407. .card_high {
  408. margin-top: 20rpx;
  409. }
  410. .card_frequency {
  411. display: flex;
  412. flex-wrap: wrap;
  413. }
  414. .card_frequency_title {
  415. font-size: 32rpx;
  416. }
  417. .card_bottle {
  418. font-size: 30rpx;
  419. span {
  420. color: red;
  421. }
  422. }
  423. .item_coding {
  424. display: flex;
  425. justify-content: space-between;
  426. align-items: center;
  427. width: 100%;
  428. margin-top: 10px;
  429. padding: 25rpx 0rpx;
  430. border-bottom: 2rpx solid #dfdfdf;
  431. }
  432. .title_coding {
  433. font-size: 30rpx;
  434. }
  435. .card_empty {
  436. width: 100%;
  437. margin-top: 50rpx;
  438. display: flex;
  439. align-items: center;
  440. justify-content: center;
  441. }
  442. .card_btn {
  443. position: fixed;
  444. left: 0;
  445. right: 0;
  446. bottom: 0;
  447. padding-left: 30rpx;
  448. padding-right: 30rpx;
  449. padding-top: 20rpx;
  450. background-color: #fff;
  451. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  452. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  453. }
  454. .deleteCurrent {
  455. display: flex;
  456. align-items: center;
  457. flex-direction: column;
  458. justify-content: center;
  459. border: 1px solid #e5e5e5;
  460. padding: 5rpx 0rpx 5rpx 5rpx;
  461. margin-left: 10rpx;
  462. border-radius: 8rpx;
  463. height: 66rpx;
  464. .icon_current {
  465. height: 15px;
  466. }
  467. .title_nape {
  468. margin: 0rpx 10rpx;
  469. display: flex;
  470. font-size: 20rpx;
  471. width: 40rpx;
  472. }
  473. }
  474. .add_card {
  475. margin-left: 10rpx;
  476. width: 50rpx;
  477. height: 46rpx;
  478. border-radius: 8rpx;
  479. padding: 6px 9px;
  480. border: 1px solid #dadbde;
  481. }
  482. ::v-deep .u-border {
  483. border-width: 1px !important;
  484. border-color: #e5e5e5 !important;
  485. border-style: solid;
  486. }
  487. .card_courier {
  488. min-height: 600rpx;
  489. padding-bottom: 20rpx;
  490. }
  491. .scroll-view {
  492. max-height: 60vh;
  493. overflow: hidden;
  494. }
  495. .headline {
  496. padding: 30rpx 30rpx 0rpx 30rpx;
  497. display: flex;
  498. align-items: center;
  499. justify-content: center;
  500. padding-bottom: 30rpx;
  501. font-size: 32rpx;
  502. font-weight: 600;
  503. }
  504. .search_card {
  505. padding: 0rpx 30rpx 10rpx 30rpx;
  506. }
  507. .courier_item {
  508. margin: 20rpx 20rpx;
  509. width: calc(100% - 80rpx);
  510. padding: 20rpx;
  511. border-radius: 20rpx;
  512. box-shadow: 0 2rpx 10rpx 0 rgba(0, 0, 0, .1);
  513. }
  514. .courier_name {
  515. display: flex;
  516. flex-direction: column;
  517. }
  518. .title_name {
  519. font-weight: 600;
  520. font-size: 32rpx;
  521. margin-bottom: 10rpx;
  522. }
  523. .title_phone {
  524. font-size: 28rpx;
  525. }
  526. .xd_title {
  527. width: auto;
  528. font-size: 28rpx;
  529. font-weight: 500;
  530. padding: 10rpx 20rpx;
  531. border-radius: 35rpx;
  532. border: 3rpx solid #82848a;
  533. }
  534. .card_search_gray {
  535. display: flex;
  536. flex-direction: row;
  537. align-items: center;
  538. justify-content: space-between;
  539. flex: 1;
  540. padding: 12rpx 18rpx;
  541. border-radius: 8rpx;
  542. line-height: 48rpx;
  543. }
  544. .title_gray {
  545. font-size: 30rpx;
  546. color: #c8c9cc;
  547. }
  548. // 伪元素1rpx边框
  549. .frame {
  550. position: relative; //重要
  551. }
  552. .frame::after {
  553. position: absolute;
  554. content: '';
  555. border: 2rpx solid #e7e6e4;
  556. border-radius: 16rpx;
  557. width: 200%;
  558. height: 200%;
  559. top: 0;
  560. left: 0;
  561. transform: scale(0.5);
  562. transform-origin: 0 0;
  563. pointer-events: none;
  564. /* 使伪元素不会阻止鼠标事件 */
  565. }
  566. </style>