delivery.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  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. if (this.typeFlag) {
  164. // 入库
  165. this.$api.post('/api/ice-raft/in-storage', {
  166. code: this.list,
  167. iceLockerId: this.coldCupboard.id,
  168. freezeClaim: Number(this.freezingDuration),
  169. }).then(res => {
  170. if (res.code == 200) {
  171. this.list = []
  172. this.freezingDuration = ''
  173. this.frequencyCoding = ''
  174. this.coldCupboard.id = null
  175. this.coldCupboard.name = ''
  176. uni.showToast({
  177. icon: 'none',
  178. title: res.msg,
  179. duration: 3000
  180. });
  181. } else {
  182. uni.showToast({
  183. icon: 'none',
  184. title: res.msg,
  185. duration: 3000
  186. });
  187. }
  188. this.loading = false
  189. })
  190. } else {
  191. this.loading = false
  192. this.$api.post('/api/ice-raft/isoutstorage', {
  193. code: this.list,
  194. }).then(res => {
  195. if (res.code == 200) {
  196. this.content = res.msg
  197. this.logoutShow = true
  198. } else if (res.code == 1201) {
  199. this.confirm(1201)
  200. } else {
  201. uni.$u.toast(res.msg)
  202. }
  203. })
  204. }
  205. } else {
  206. uni.$u.toast('请先录入冰排编号')
  207. }
  208. },
  209. // 确定
  210. confirm(event) {
  211. if (this.userInfo.dept) {
  212. if (!this.userInfo.dept.isOutStorage) {
  213. this.getOutStorage()
  214. } else {
  215. if (event == 200) {
  216. this.$message.error('冰排暂未到达冷冻要求');
  217. } else if (event == 1201) {
  218. this.getOutStorage()
  219. }
  220. }
  221. } else {
  222. this.$message.error('当前账户无公司信息');
  223. }
  224. },
  225. getOutStorage() {
  226. this.logoutShow = false
  227. this.loading = true
  228. // 出库
  229. this.$api.post('/api/ice-raft/out-storage', {
  230. code: this.list,
  231. coolerBoxId: this.incubator.id,
  232. suitableForCold: Number(this.suitableForCold),
  233. }).then(res => {
  234. if (res.code == 200) {
  235. this.list = []
  236. this.suitableForCold = null
  237. this.frequencyCoding = ''
  238. this.incubator.id = null
  239. this.incubator.name = ''
  240. uni.showToast({
  241. icon: 'none',
  242. title: res.msg,
  243. duration: 3000
  244. });
  245. } else {
  246. uni.showToast({
  247. icon: 'none',
  248. title: res.msg,
  249. duration: 3000
  250. });
  251. }
  252. this.loading = false
  253. })
  254. },
  255. // 取消
  256. cancel() {
  257. this.logoutShow = false
  258. },
  259. // 扫码录入
  260. async getEntering() {
  261. if (this.frequencyCoding) {
  262. await this.$api.get('/api/ice-raft/code/' + this.frequencyCoding).then(res => {
  263. if (res.code == 200) {
  264. this.list.push(this.frequencyCoding)
  265. function methods1(arr) {
  266. return Array.from(new Set(arr));
  267. }
  268. this.list = methods1(this.list)
  269. } else {
  270. uni.showToast({
  271. icon: 'none',
  272. title: res.msg,
  273. duration: 3000
  274. });
  275. }
  276. })
  277. }
  278. },
  279. // 扫一扫
  280. sweep() {
  281. // 允许从相机和相册扫码
  282. uni.scanCode({
  283. scanType: ['barCode'],
  284. // scanType: ['qrCode'],
  285. autoZoom: false,
  286. success: (res) => {
  287. console.log(res);
  288. if (res.result) {
  289. let url = res.result;
  290. this.frequencyCoding = url
  291. this.$api.get('/api/ice-raft/code/' + this.frequencyCoding).then(res => {
  292. if (res.code == 200) {
  293. this.list.push(url)
  294. function methods1(arr) {
  295. return Array.from(new Set(arr));
  296. }
  297. this.list = methods1(this.list)
  298. } else {
  299. uni.showToast({
  300. icon: 'none',
  301. title: res.msg,
  302. duration: 3000
  303. });
  304. }
  305. })
  306. } else {
  307. console.log('请重新扫描');
  308. return false;
  309. }
  310. },
  311. fail: (res) => {
  312. console.log('未识别到二维码');
  313. }
  314. })
  315. },
  316. // 添加冰排
  317. addIce() {
  318. if (this.frequencyCoding) {
  319. this.$api.get('/api/ice-raft/code/' + this.frequencyCoding).then(res => {
  320. if (res.code == 200) {
  321. this.list.push(this.frequencyCoding)
  322. this.list = this.uniqueArray(this.list)
  323. this.frequencyCoding = ''
  324. } else {
  325. uni.showToast({
  326. icon: 'none',
  327. title: res.msg,
  328. duration: 3000
  329. });
  330. }
  331. })
  332. }
  333. },
  334. // 去重
  335. uniqueArray(arr) {
  336. return [...new Set(arr)];
  337. },
  338. // 移除错误运单号
  339. removeWaybill(value) {
  340. if (this.frequencyCoding == value) {
  341. this.frequencyCoding = ''
  342. }
  343. const arr = deleteElementById(this.list, value)
  344. this.list = arr
  345. function deleteElementById(arr, key) {
  346. return arr.filter((item) => item !== key);
  347. }
  348. },
  349. }
  350. }
  351. </script>
  352. <style lang="scss">
  353. page {
  354. background-color: #fff !important;
  355. }
  356. .card_order_details {
  357. margin: 10rpx 30rpx 30rpx 30rpx;
  358. }
  359. .details_title {
  360. width: 150rpx;
  361. flex: none;
  362. color: #333;
  363. font-size: 32rpx;
  364. font-weight: 500;
  365. margin-bottom: 10rpx;
  366. // margin-right: 15rpx;
  367. }
  368. .title_hour {
  369. flex: none;
  370. font-size: 30rpx;
  371. margin-left: 15rpx;
  372. }
  373. .card_time {
  374. width: 100%;
  375. border: 1rpx solid #dadbde;
  376. border-radius: 10rpx;
  377. padding: 6px 9px;
  378. margin-left: 10rpx;
  379. line-height: 48rpx;
  380. }
  381. .card_search {
  382. display: flex;
  383. align-items: center;
  384. margin: 20rpx 0rpx;
  385. }
  386. .card_sign_in {
  387. margin-top: 30rpx;
  388. display: flex;
  389. }
  390. .scan_title {
  391. font-size: 20rpx;
  392. }
  393. .card_sweep {
  394. display: flex;
  395. flex-direction: column;
  396. align-items: center;
  397. flex: none;
  398. }
  399. .card_input {
  400. width: 100%;
  401. margin-left: 30rpx;
  402. }
  403. .line_title {
  404. color: red;
  405. }
  406. .card_high {
  407. margin-top: 20rpx;
  408. }
  409. .card_frequency {
  410. display: flex;
  411. flex-wrap: wrap;
  412. }
  413. .card_frequency_title {
  414. font-size: 32rpx;
  415. }
  416. .card_bottle {
  417. font-size: 30rpx;
  418. span {
  419. color: red;
  420. }
  421. }
  422. .item_coding {
  423. display: flex;
  424. justify-content: space-between;
  425. align-items: center;
  426. width: 100%;
  427. margin-top: 10px;
  428. padding: 25rpx 0rpx;
  429. border-bottom: 2rpx solid #dfdfdf;
  430. }
  431. .title_coding {
  432. font-size: 30rpx;
  433. }
  434. .card_empty {
  435. width: 100%;
  436. margin-top: 50rpx;
  437. display: flex;
  438. align-items: center;
  439. justify-content: center;
  440. }
  441. .card_btn {
  442. position: fixed;
  443. left: 0;
  444. right: 0;
  445. bottom: 0;
  446. padding-left: 30rpx;
  447. padding-right: 30rpx;
  448. padding-top: 20rpx;
  449. background-color: #fff;
  450. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  451. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  452. border-top: 1rpx solid #E4E7ED;
  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_search_gray {
  488. display: flex;
  489. flex-direction: row;
  490. align-items: center;
  491. justify-content: space-between;
  492. flex: 1;
  493. padding: 12rpx 18rpx;
  494. border-radius: 8rpx;
  495. line-height: 48rpx;
  496. }
  497. .title_gray {
  498. font-size: 30rpx;
  499. color: #c8c9cc;
  500. }
  501. // 伪元素1rpx边框
  502. .frame {
  503. position: relative; //重要
  504. }
  505. .frame::after {
  506. position: absolute;
  507. content: '';
  508. border: 4rpx solid #e7e6e4;
  509. border-radius: 16rpx;
  510. width: 200%;
  511. height: 200%;
  512. top: 0;
  513. left: 0;
  514. transform: scale(0.5);
  515. transform-origin: 0 0;
  516. pointer-events: none;
  517. /* 使伪元素不会阻止鼠标事件 */
  518. }
  519. </style>