delivery.vue 11 KB

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