delivery.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  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="box_serial_number" v-if="iceRaftData.length > 0">
  62. <view class="card_frequency_title">选择冰排</view>
  63. <view class="card_ice_code">
  64. <view class="item_coding" v-for="(item,index) in iceRaftData" :key="index" @click="selectIce(item)">
  65. <view style="display: flex;align-items: center;">
  66. <span class="iconfont icon-bingpaiguanli iceIcon"></span>
  67. <view class="title_coding">{{item.value}}</view>
  68. </view>
  69. <view class="checked" v-if="item.flag"></view>
  70. </view>
  71. </view>
  72. </view>
  73. <view class="card_frequency">
  74. <view class="card_high space_between">
  75. <view class="card_frequency_title">已录入冰排编号</view>
  76. <view class="card_bottle">已扫<span>{{list.length}}</span></view>
  77. </view>
  78. <view style="width: 100%;" v-if="list.length > 0">
  79. <view class="item_coding" v-for="(item,index) in list" :key="index">
  80. <view style="display: flex;align-items: center;">
  81. <span class="iconfont icon-bingpaiguanli iceIcon"></span>
  82. <view class="title_coding">{{item}}</view>
  83. </view>
  84. <u-icon name="close-circle-fill" color="#c0c4cc" size="20"
  85. @click="removeWaybill(item)"></u-icon>
  86. </view>
  87. </view>
  88. </view>
  89. <view style="width: 100%;height: 120rpx;"></view>
  90. <view class="card_btn">
  91. <u-button style="margin-bottom: 20rpx;" type="primary" :loading="loading" @click="submit">提交</u-button>
  92. </view>
  93. </view>
  94. <u-modal :show="logoutShow" showCancelButton :title="title" :content='content' @cancel="cancel"
  95. @confirm="confirm(200)"></u-modal>
  96. </view>
  97. </template>
  98. <script>
  99. const ENV = require('@/.env.js')
  100. export default {
  101. data() {
  102. return {
  103. loading: false,
  104. frequencyCoding: '',
  105. navTitle: '',
  106. selectiveType: '',
  107. cmpCode: '',
  108. list: [],
  109. orderId: '',
  110. freezingDuration: '',
  111. suitableForCold: null,
  112. typeFlag: true,
  113. coldCupboard: {
  114. id: null,
  115. name: '',
  116. },
  117. incubator: {
  118. id: null,
  119. name: '',
  120. },
  121. logoutShow: false,
  122. title: '是否继续出库?',
  123. content: '',
  124. userInfo: {},
  125. iceRaftData: []
  126. }
  127. },
  128. onUnload() {
  129. uni.removeStorageSync('incubatorValue');
  130. uni.removeStorageSync('freezerValue');
  131. },
  132. onLoad(receive) {
  133. this.navTitle = receive.title
  134. this.selectiveType = receive.id
  135. if (receive.id == 'enter') {
  136. this.typeFlag = true
  137. this.getNotStoredIce()
  138. } else {
  139. this.typeFlag = false
  140. }
  141. },
  142. onShow() {
  143. let incubator = uni.getStorageSync('incubatorValue')
  144. if (incubator) {
  145. if (incubator.id != this.incubator.id) {
  146. this.incubator.id = incubator.id
  147. this.incubator.name = incubator.name
  148. this.list = []
  149. this.getAvailable(incubator.id)
  150. }
  151. }
  152. let freezer = uni.getStorageSync('freezerValue')
  153. if (freezer) {
  154. if (freezer.id != this.coldCupboard.id) {
  155. this.coldCupboard.id = freezer.id
  156. this.coldCupboard.name = freezer.name
  157. }
  158. }
  159. var userInfo = this.$cache.getCache('userInfo')
  160. this.userInfo = userInfo
  161. },
  162. methods: {
  163. // 获取未入库冰排
  164. getNotStoredIce() {
  165. this.$api.get('/api/ice-raft/GetCoolerIceRaft').then(res => {
  166. if (res.code == 200) {
  167. let iceArr = res.data
  168. let iceData = []
  169. iceArr.forEach(item => {
  170. let arrValue = {
  171. flag: false,
  172. value: item.code
  173. }
  174. iceData.push(arrValue)
  175. })
  176. this.iceRaftData = iceData
  177. }
  178. })
  179. },
  180. // 获取保温箱可使用冰排
  181. getAvailable(id) {
  182. this.$api.post('/api/ice-raft/GetCoolerBoxBindCieRaft', {
  183. id: String(id),
  184. }).then(res => {
  185. if (res.code == 200) {
  186. let iceArr = res.data
  187. let iceData = []
  188. iceArr.forEach(item => {
  189. let arrValue = {
  190. flag: false,
  191. value: item
  192. }
  193. iceData.push(arrValue)
  194. })
  195. this.iceRaftData = iceData
  196. }
  197. })
  198. },
  199. focus(flag) {
  200. this.typeFlag = flag
  201. if (flag) {
  202. uni.navigateTo({
  203. url: '/pages/order/iceCold'
  204. });
  205. } else {
  206. uni.navigateTo({
  207. url: '/pages/order/Incubator'
  208. });
  209. }
  210. },
  211. leftClick() {
  212. uni.$emit('refresh');
  213. },
  214. async submit() {
  215. await this.getEntering()
  216. if (this.list.length > 0) {
  217. this.loading = true
  218. uni.showLoading({
  219. mask: true
  220. });
  221. if (this.typeFlag) {
  222. // 入库
  223. if (this.coldCupboard.id) {
  224. this.$api.post('/api/ice-raft/in-storage', {
  225. code: this.list,
  226. iceLockerId: this.coldCupboard.id,
  227. freezeClaim: Number(this.freezingDuration),
  228. }).then(res => {
  229. if (res.code == 200) {
  230. this.list = []
  231. this.freezingDuration = ''
  232. this.frequencyCoding = ''
  233. this.coldCupboard.id = null
  234. this.coldCupboard.name = ''
  235. uni.showToast({
  236. icon: 'none',
  237. title: res.msg,
  238. duration: 3000
  239. });
  240. this.getNotStoredIce()
  241. } else {
  242. uni.showToast({
  243. icon: 'none',
  244. title: res.msg,
  245. duration: 3000
  246. });
  247. }
  248. this.loading = false
  249. this.getIncubator()
  250. }).catch(() => {
  251. uni.hideLoading();
  252. })
  253. } else {
  254. this.loading = false
  255. uni.showToast({
  256. icon: 'none',
  257. title: '请选择入库冷冻柜',
  258. duration: 3000
  259. });
  260. }
  261. } else {
  262. this.loading = false
  263. this.$api.post('/api/ice-raft/isoutstorage', {
  264. code: this.list,
  265. }).then(res => {
  266. if (res.code == 200) {
  267. this.content = res.msg
  268. this.logoutShow = true
  269. } else if (res.code == 1201) {
  270. this.confirm(1201)
  271. } else {
  272. uni.$u.toast(res.msg)
  273. }
  274. this.getIncubator()
  275. }).catch(() => {
  276. uni.hideLoading();
  277. })
  278. }
  279. } else {
  280. uni.$u.toast('请先录入冰排编号')
  281. }
  282. },
  283. // 确定
  284. confirm(event) {
  285. if (this.userInfo.dept) {
  286. if (!this.userInfo.dept.isOutStorage) {
  287. this.getOutStorage()
  288. } else {
  289. if (event == 200) {
  290. this.$message.error('冰排暂未到达冷冻要求');
  291. } else if (event == 1201) {
  292. this.getOutStorage()
  293. }
  294. }
  295. } else {
  296. this.$message.error('当前账户无公司信息');
  297. }
  298. },
  299. getOutStorage() {
  300. this.logoutShow = false
  301. this.loading = true
  302. // 出库
  303. this.$api.post('/api/ice-raft/out-storage', {
  304. code: this.list,
  305. coolerBoxId: this.incubator.id,
  306. // suitableForCold: Number(this.suitableForCold),
  307. }).then(res => {
  308. if (res.code == 200) {
  309. this.list = []
  310. // this.suitableForCold = null
  311. this.frequencyCoding = ''
  312. // this.incubator.id = null
  313. // this.incubator.name = ''
  314. this.list = []
  315. this.getAvailable(this.incubator.id)
  316. uni.showToast({
  317. icon: 'none',
  318. title: res.msg,
  319. duration: 3000
  320. });
  321. } else {
  322. uni.showToast({
  323. icon: 'none',
  324. title: res.msg,
  325. duration: 3000
  326. });
  327. }
  328. this.loading = false
  329. })
  330. },
  331. // 取消
  332. cancel() {
  333. this.logoutShow = false
  334. },
  335. // 扫码录入
  336. async getEntering() {
  337. if (this.frequencyCoding) {
  338. await this.$api.get('/api/ice-raft/code/' + this.frequencyCoding).then(res => {
  339. if (res.code == 200) {
  340. this.list.push(this.frequencyCoding)
  341. function methods1(arr) {
  342. return Array.from(new Set(arr));
  343. }
  344. this.list = methods1(this.list)
  345. } else {
  346. uni.showToast({
  347. icon: 'none',
  348. title: res.msg,
  349. duration: 3000
  350. });
  351. }
  352. })
  353. }
  354. },
  355. // 扫一扫
  356. sweep() {
  357. // 允许从相机和相册扫码
  358. uni.scanCode({
  359. scanType: ['barCode'],
  360. // scanType: ['qrCode'],
  361. autoZoom: false,
  362. success: (res) => {
  363. // console.log(res);
  364. if (res.result) {
  365. let url = res.result;
  366. this.frequencyCoding = url
  367. this.$api.get('/api/ice-raft/code/' + this.frequencyCoding).then(res => {
  368. if (res.code == 200) {
  369. this.list.push(url)
  370. function methods1(arr) {
  371. return Array.from(new Set(arr));
  372. }
  373. this.list = methods1(this.list)
  374. } else {
  375. uni.showToast({
  376. icon: 'none',
  377. title: res.msg,
  378. duration: 3000
  379. });
  380. }
  381. })
  382. } else {
  383. console.log('请重新扫描');
  384. return false;
  385. }
  386. },
  387. fail: (res) => {
  388. console.log('未识别到二维码');
  389. }
  390. })
  391. },
  392. // 添加冰排
  393. addIce() {
  394. if (this.frequencyCoding) {
  395. this.$api.get('/api/ice-raft/code/' + this.frequencyCoding).then(res => {
  396. if (res.code == 200) {
  397. this.list.push(this.frequencyCoding)
  398. this.list = this.uniqueArray(this.list)
  399. this.frequencyCoding = ''
  400. this.iceRaftData.forEach(item => {
  401. item.flag = this.list.includes(item.value)
  402. })
  403. } else {
  404. uni.showToast({
  405. icon: 'none',
  406. title: res.msg,
  407. duration: 3000
  408. });
  409. }
  410. })
  411. }
  412. },
  413. // 选择冰排
  414. selectIce(value) {
  415. this.iceRaftData.forEach(item => {
  416. if (item.value == value.value) {
  417. if (item.flag) {
  418. item.flag = false
  419. let arr = this.list.filter(item1 => item1 !== value.value);
  420. this.list = arr
  421. } else {
  422. item.flag = true
  423. this.list.push(item.value)
  424. this.list = this.uniqueArray(this.list)
  425. }
  426. }
  427. })
  428. },
  429. // 去重
  430. uniqueArray(arr) {
  431. return [...new Set(arr)];
  432. },
  433. // 移除错误运单号
  434. removeWaybill(value) {
  435. if (this.frequencyCoding == value) {
  436. this.frequencyCoding = ''
  437. }
  438. const arr = deleteElementById(this.list, value)
  439. this.list = arr
  440. function deleteElementById(arr, key) {
  441. return arr.filter((item) => item !== key);
  442. }
  443. this.iceRaftData.forEach(item => {
  444. item.flag = this.list.includes(item.value)
  445. })
  446. },
  447. }
  448. }
  449. </script>
  450. <style lang="scss">
  451. page {
  452. background-color: #fff !important;
  453. }
  454. .card_order_details {
  455. margin: 10rpx 30rpx 30rpx 30rpx;
  456. }
  457. .details_title {
  458. width: 150rpx;
  459. flex: none;
  460. color: #333;
  461. font-size: 32rpx;
  462. font-weight: 500;
  463. margin-bottom: 10rpx;
  464. // margin-right: 15rpx;
  465. }
  466. .title_hour {
  467. flex: none;
  468. font-size: 30rpx;
  469. margin-left: 15rpx;
  470. }
  471. .card_time {
  472. width: 100%;
  473. border: 1rpx solid #dadbde;
  474. border-radius: 10rpx;
  475. padding: 6px 9px;
  476. margin-left: 10rpx;
  477. line-height: 48rpx;
  478. }
  479. .card_search {
  480. display: flex;
  481. align-items: center;
  482. margin: 20rpx 0rpx;
  483. }
  484. .card_sign_in {
  485. margin-top: 30rpx;
  486. display: flex;
  487. }
  488. .scan_title {
  489. font-size: 20rpx;
  490. }
  491. .card_sweep {
  492. display: flex;
  493. flex-direction: column;
  494. align-items: center;
  495. flex: none;
  496. }
  497. .card_input {
  498. width: 100%;
  499. margin-left: 30rpx;
  500. }
  501. .line_title {
  502. color: red;
  503. }
  504. .card_high {
  505. margin-top: 20rpx;
  506. }
  507. .box_serial_number {
  508. display: flex;
  509. flex-direction: column;
  510. }
  511. .card_ice_code {
  512. padding: 10rpx 0rpx;
  513. max-height: 25vh;
  514. overflow-y: auto;
  515. }
  516. .item_code_box {
  517. padding: 10rpx 0rpx;
  518. }
  519. .card_frequency {
  520. display: flex;
  521. flex-wrap: wrap;
  522. }
  523. .card_frequency_title {
  524. font-size: 32rpx;
  525. }
  526. .card_bottle {
  527. font-size: 30rpx;
  528. span {
  529. color: red;
  530. margin-left: 5rpx;
  531. font-size: 32rpx;
  532. }
  533. }
  534. .item_coding {
  535. display: flex;
  536. justify-content: space-between;
  537. align-items: center;
  538. width: 100%;
  539. // margin-top: 10px;
  540. padding: 25rpx 0rpx;
  541. border-bottom: 2rpx solid #E4E7ED;
  542. }
  543. .iceIcon {
  544. color: #19be6b;
  545. margin-right: 10rpx;
  546. font-size: 36rpx;
  547. }
  548. .title_coding {
  549. font-size: 30rpx;
  550. }
  551. .checked {
  552. position: relative;
  553. width: 40rpx;
  554. height: 40rpx;
  555. }
  556. .checked::after {
  557. content: "";
  558. background-color: #19be6b;
  559. width: 20rpx;
  560. height: 4rpx;
  561. position: absolute;
  562. top: 30rpx;
  563. left: 0rpx;
  564. transform: rotate(30deg);
  565. border-radius: 8rpx;
  566. }
  567. .checked::before {
  568. content: "";
  569. background-color: #19be6b;
  570. width: 30rpx;
  571. height: 4rpx;
  572. position: absolute;
  573. top: 22rpx;
  574. left: 12rpx;
  575. transform: rotate(-50deg);
  576. border-radius: 8rpx;
  577. }
  578. .card_empty {
  579. width: 100%;
  580. margin-top: 50rpx;
  581. display: flex;
  582. align-items: center;
  583. justify-content: center;
  584. }
  585. .card_btn {
  586. position: fixed;
  587. left: 0;
  588. right: 0;
  589. bottom: 0;
  590. padding-left: 30rpx;
  591. padding-right: 30rpx;
  592. padding-top: 20rpx;
  593. background-color: #fff;
  594. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  595. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  596. border-top: 1rpx solid #E4E7ED;
  597. }
  598. .deleteCurrent {
  599. display: flex;
  600. align-items: center;
  601. flex-direction: column;
  602. justify-content: center;
  603. border: 1px solid #e5e5e5;
  604. padding: 5rpx 0rpx 5rpx 5rpx;
  605. margin-left: 10rpx;
  606. border-radius: 8rpx;
  607. height: 66rpx;
  608. .icon_current {
  609. height: 15px;
  610. }
  611. .title_nape {
  612. margin: 0rpx 10rpx;
  613. display: flex;
  614. font-size: 20rpx;
  615. width: 40rpx;
  616. }
  617. }
  618. .add_card {
  619. margin-left: 10rpx;
  620. width: 50rpx;
  621. height: 46rpx;
  622. border-radius: 8rpx;
  623. padding: 6px 9px;
  624. border: 1px solid #dadbde;
  625. }
  626. ::v-deep .u-border {
  627. border-width: 1px !important;
  628. border-color: #e5e5e5 !important;
  629. border-style: solid;
  630. }
  631. .card_search_gray {
  632. display: flex;
  633. flex-direction: row;
  634. align-items: center;
  635. justify-content: space-between;
  636. flex: 1;
  637. padding: 12rpx 18rpx;
  638. border-radius: 8rpx;
  639. line-height: 48rpx;
  640. }
  641. .title_gray {
  642. font-size: 30rpx;
  643. color: #c8c9cc;
  644. }
  645. // 伪元素1rpx边框
  646. .frame {
  647. position: relative; //重要
  648. }
  649. .frame::after {
  650. position: absolute;
  651. content: '';
  652. border: 4rpx solid #e7e6e4;
  653. border-radius: 16rpx;
  654. width: 200%;
  655. height: 200%;
  656. top: 0;
  657. left: 0;
  658. transform: scale(0.5);
  659. transform-origin: 0 0;
  660. pointer-events: none;
  661. /* 使伪元素不会阻止鼠标事件 */
  662. }
  663. </style>