delivery.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  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" :loading="loading" @click="submit">提交</u-button>
  77. </view>
  78. </view>
  79. <u-modal :show="logoutShow" showCancelButton :title="title" :content='content' @cancel="cancel"
  80. @confirm="confirm(200)"></u-modal>
  81. </view>
  82. </template>
  83. <script>
  84. const ENV = require('@/.env.js')
  85. export default {
  86. data() {
  87. return {
  88. loading: false,
  89. frequencyCoding: '',
  90. navTitle: '',
  91. selectiveType: '',
  92. cmpCode: '',
  93. list: [],
  94. orderId: '',
  95. freezingDuration: '',
  96. suitableForCold: null,
  97. typeFlag: true,
  98. coldCupboard: {
  99. id: null,
  100. name: '',
  101. },
  102. incubator: {
  103. id: null,
  104. name: '',
  105. },
  106. logoutShow: false,
  107. title: '是否继续出库?',
  108. content: '',
  109. userInfo: {},
  110. }
  111. },
  112. onUnload() {
  113. uni.removeStorageSync('incubatorValue');
  114. uni.removeStorageSync('freezerValue');
  115. },
  116. onLoad(receive) {
  117. this.navTitle = receive.title
  118. this.selectiveType = receive.id
  119. if (receive.id == 'enter') {
  120. this.typeFlag = true
  121. } else {
  122. this.typeFlag = false
  123. }
  124. },
  125. onShow() {
  126. let incubator = uni.getStorageSync('incubatorValue')
  127. if (incubator) {
  128. if (incubator.id != this.incubator.id) {
  129. this.incubator.id = incubator.id
  130. this.incubator.name = incubator.name
  131. }
  132. }
  133. let freezer = uni.getStorageSync('freezerValue')
  134. if (freezer) {
  135. if (freezer.id != this.coldCupboard.id) {
  136. this.coldCupboard.id = freezer.id
  137. this.coldCupboard.name = freezer.name
  138. }
  139. }
  140. var userInfo = this.$cache.getCache('userInfo')
  141. this.userInfo = userInfo
  142. },
  143. methods: {
  144. focus(flag) {
  145. this.typeFlag = flag
  146. if (flag) {
  147. uni.navigateTo({
  148. url: '/pages/order/iceCold'
  149. });
  150. } else {
  151. uni.navigateTo({
  152. url: '/pages/order/Incubator'
  153. });
  154. }
  155. },
  156. leftClick() {
  157. uni.$emit('refresh');
  158. },
  159. async submit() {
  160. await this.getEntering()
  161. if (this.list.length > 0) {
  162. this.loading = true
  163. uni.showLoading({
  164. mask: true
  165. });
  166. if (this.typeFlag) {
  167. // 入库
  168. this.$api.post('/api/ice-raft/in-storage', {
  169. code: this.list,
  170. iceLockerId: this.coldCupboard.id,
  171. freezeClaim: Number(this.freezingDuration),
  172. }).then(res => {
  173. if (res.code == 200) {
  174. this.list = []
  175. this.freezingDuration = ''
  176. this.frequencyCoding = ''
  177. this.coldCupboard.id = null
  178. this.coldCupboard.name = ''
  179. uni.showToast({
  180. icon: 'none',
  181. title: res.msg,
  182. duration: 3000
  183. });
  184. } else {
  185. uni.showToast({
  186. icon: 'none',
  187. title: res.msg,
  188. duration: 3000
  189. });
  190. }
  191. this.loading = false
  192. this.getIncubator()
  193. }).catch(() => {
  194. uni.hideLoading();
  195. })
  196. } else {
  197. this.loading = false
  198. this.$api.post('/api/ice-raft/isoutstorage', {
  199. code: this.list,
  200. }).then(res => {
  201. if (res.code == 200) {
  202. this.content = res.msg
  203. this.logoutShow = true
  204. } else if (res.code == 1201) {
  205. this.confirm(1201)
  206. } else {
  207. uni.$u.toast(res.msg)
  208. }
  209. this.getIncubator()
  210. }).catch(() => {
  211. uni.hideLoading();
  212. })
  213. }
  214. } else {
  215. uni.$u.toast('请先录入冰排编号')
  216. }
  217. },
  218. // 确定
  219. confirm(event) {
  220. if (this.userInfo.dept) {
  221. if (!this.userInfo.dept.isOutStorage) {
  222. this.getOutStorage()
  223. } else {
  224. if (event == 200) {
  225. this.$message.error('冰排暂未到达冷冻要求');
  226. } else if (event == 1201) {
  227. this.getOutStorage()
  228. }
  229. }
  230. } else {
  231. this.$message.error('当前账户无公司信息');
  232. }
  233. },
  234. getOutStorage() {
  235. this.logoutShow = false
  236. this.loading = true
  237. // 出库
  238. this.$api.post('/api/ice-raft/out-storage', {
  239. code: this.list,
  240. coolerBoxId: this.incubator.id,
  241. // suitableForCold: Number(this.suitableForCold),
  242. }).then(res => {
  243. if (res.code == 200) {
  244. this.list = []
  245. // this.suitableForCold = null
  246. this.frequencyCoding = ''
  247. this.incubator.id = null
  248. this.incubator.name = ''
  249. uni.showToast({
  250. icon: 'none',
  251. title: res.msg,
  252. duration: 3000
  253. });
  254. } else {
  255. uni.showToast({
  256. icon: 'none',
  257. title: res.msg,
  258. duration: 3000
  259. });
  260. }
  261. this.loading = false
  262. })
  263. },
  264. // 取消
  265. cancel() {
  266. this.logoutShow = false
  267. },
  268. // 扫码录入
  269. async getEntering() {
  270. if (this.frequencyCoding) {
  271. await this.$api.get('/api/ice-raft/code/' + this.frequencyCoding).then(res => {
  272. if (res.code == 200) {
  273. this.list.push(this.frequencyCoding)
  274. function methods1(arr) {
  275. return Array.from(new Set(arr));
  276. }
  277. this.list = methods1(this.list)
  278. } else {
  279. uni.showToast({
  280. icon: 'none',
  281. title: res.msg,
  282. duration: 3000
  283. });
  284. }
  285. })
  286. }
  287. },
  288. // 扫一扫
  289. sweep() {
  290. // 允许从相机和相册扫码
  291. uni.scanCode({
  292. scanType: ['barCode'],
  293. // scanType: ['qrCode'],
  294. autoZoom: false,
  295. success: (res) => {
  296. console.log(res);
  297. if (res.result) {
  298. let url = res.result;
  299. this.frequencyCoding = url
  300. this.$api.get('/api/ice-raft/code/' + this.frequencyCoding).then(res => {
  301. if (res.code == 200) {
  302. this.list.push(url)
  303. function methods1(arr) {
  304. return Array.from(new Set(arr));
  305. }
  306. this.list = methods1(this.list)
  307. } else {
  308. uni.showToast({
  309. icon: 'none',
  310. title: res.msg,
  311. duration: 3000
  312. });
  313. }
  314. })
  315. } else {
  316. console.log('请重新扫描');
  317. return false;
  318. }
  319. },
  320. fail: (res) => {
  321. console.log('未识别到二维码');
  322. }
  323. })
  324. },
  325. // 添加冰排
  326. addIce() {
  327. if (this.frequencyCoding) {
  328. this.$api.get('/api/ice-raft/code/' + this.frequencyCoding).then(res => {
  329. if (res.code == 200) {
  330. this.list.push(this.frequencyCoding)
  331. this.list = this.uniqueArray(this.list)
  332. this.frequencyCoding = ''
  333. } else {
  334. uni.showToast({
  335. icon: 'none',
  336. title: res.msg,
  337. duration: 3000
  338. });
  339. }
  340. })
  341. }
  342. },
  343. // 去重
  344. uniqueArray(arr) {
  345. return [...new Set(arr)];
  346. },
  347. // 移除错误运单号
  348. removeWaybill(value) {
  349. if (this.frequencyCoding == value) {
  350. this.frequencyCoding = ''
  351. }
  352. const arr = deleteElementById(this.list, value)
  353. this.list = arr
  354. function deleteElementById(arr, key) {
  355. return arr.filter((item) => item !== key);
  356. }
  357. },
  358. }
  359. }
  360. </script>
  361. <style lang="scss">
  362. page {
  363. background-color: #fff !important;
  364. }
  365. .card_order_details {
  366. margin: 10rpx 30rpx 30rpx 30rpx;
  367. }
  368. .details_title {
  369. width: 150rpx;
  370. flex: none;
  371. color: #333;
  372. font-size: 32rpx;
  373. font-weight: 500;
  374. margin-bottom: 10rpx;
  375. // margin-right: 15rpx;
  376. }
  377. .title_hour {
  378. flex: none;
  379. font-size: 30rpx;
  380. margin-left: 15rpx;
  381. }
  382. .card_time {
  383. width: 100%;
  384. border: 1rpx solid #dadbde;
  385. border-radius: 10rpx;
  386. padding: 6px 9px;
  387. margin-left: 10rpx;
  388. line-height: 48rpx;
  389. }
  390. .card_search {
  391. display: flex;
  392. align-items: center;
  393. margin: 20rpx 0rpx;
  394. }
  395. .card_sign_in {
  396. margin-top: 30rpx;
  397. display: flex;
  398. }
  399. .scan_title {
  400. font-size: 20rpx;
  401. }
  402. .card_sweep {
  403. display: flex;
  404. flex-direction: column;
  405. align-items: center;
  406. flex: none;
  407. }
  408. .card_input {
  409. width: 100%;
  410. margin-left: 30rpx;
  411. }
  412. .line_title {
  413. color: red;
  414. }
  415. .card_high {
  416. margin-top: 20rpx;
  417. }
  418. .card_frequency {
  419. display: flex;
  420. flex-wrap: wrap;
  421. }
  422. .card_frequency_title {
  423. font-size: 32rpx;
  424. }
  425. .card_bottle {
  426. font-size: 30rpx;
  427. span {
  428. color: red;
  429. }
  430. }
  431. .item_coding {
  432. display: flex;
  433. justify-content: space-between;
  434. align-items: center;
  435. width: 100%;
  436. margin-top: 10px;
  437. padding: 25rpx 0rpx;
  438. border-bottom: 2rpx solid #dfdfdf;
  439. }
  440. .title_coding {
  441. font-size: 30rpx;
  442. }
  443. .card_empty {
  444. width: 100%;
  445. margin-top: 50rpx;
  446. display: flex;
  447. align-items: center;
  448. justify-content: center;
  449. }
  450. .card_btn {
  451. position: fixed;
  452. left: 0;
  453. right: 0;
  454. bottom: 0;
  455. padding-left: 30rpx;
  456. padding-right: 30rpx;
  457. padding-top: 20rpx;
  458. background-color: #fff;
  459. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  460. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  461. border-top: 1rpx solid #E4E7ED;
  462. }
  463. .deleteCurrent {
  464. display: flex;
  465. align-items: center;
  466. flex-direction: column;
  467. justify-content: center;
  468. border: 1px solid #e5e5e5;
  469. padding: 5rpx 0rpx 5rpx 5rpx;
  470. margin-left: 10rpx;
  471. border-radius: 8rpx;
  472. height: 66rpx;
  473. .icon_current {
  474. height: 15px;
  475. }
  476. .title_nape {
  477. margin: 0rpx 10rpx;
  478. display: flex;
  479. font-size: 20rpx;
  480. width: 40rpx;
  481. }
  482. }
  483. .add_card {
  484. margin-left: 10rpx;
  485. width: 50rpx;
  486. height: 46rpx;
  487. border-radius: 8rpx;
  488. padding: 6px 9px;
  489. border: 1px solid #dadbde;
  490. }
  491. ::v-deep .u-border {
  492. border-width: 1px !important;
  493. border-color: #e5e5e5 !important;
  494. border-style: solid;
  495. }
  496. .card_search_gray {
  497. display: flex;
  498. flex-direction: row;
  499. align-items: center;
  500. justify-content: space-between;
  501. flex: 1;
  502. padding: 12rpx 18rpx;
  503. border-radius: 8rpx;
  504. line-height: 48rpx;
  505. }
  506. .title_gray {
  507. font-size: 30rpx;
  508. color: #c8c9cc;
  509. }
  510. // 伪元素1rpx边框
  511. .frame {
  512. position: relative; //重要
  513. }
  514. .frame::after {
  515. position: absolute;
  516. content: '';
  517. border: 4rpx solid #e7e6e4;
  518. border-radius: 16rpx;
  519. width: 200%;
  520. height: 200%;
  521. top: 0;
  522. left: 0;
  523. transform: scale(0.5);
  524. transform-origin: 0 0;
  525. pointer-events: none;
  526. /* 使伪元素不会阻止鼠标事件 */
  527. }
  528. </style>