dispatching.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. <template>
  2. <!-- 选择配送信息 -->
  3. <view>
  4. <u-navbar title="" autoBack placeholder></u-navbar>
  5. <view class="card_incubator_anti_fake">
  6. <view class="title_fake">保温箱/冰排</view>
  7. <view class="card_input_send">
  8. <view class="incubator_title"><span>*</span>保温箱</view>
  9. <view class="card_search_gray frame" @click="focus(false)">
  10. <span v-if="incubator.name">{{incubator.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. </view>
  15. <view class="card_input_send">
  16. <view class="incubator_title"><span>*</span>冰排编号</view>
  17. <u-input placeholder="请输入冰排编号" border="surround" v-model="iceNumber" @blur="iceRaftBlur">
  18. <template slot="suffix">
  19. <u-icon name="scan" size="24" @click="sweep"></u-icon>
  20. </template>
  21. </u-input>
  22. <view class="add_card center_in" @click="addIce">
  23. <u-icon name="plus" size="18"></u-icon>
  24. </view>
  25. </view>
  26. <view class="card_frequency">
  27. <view class="card_high space_between">
  28. <view class="card_frequency_title">已扫冰排编号</view>
  29. <view class="card_bottle">已扫<span>{{iceList.length}}</span></view>
  30. </view>
  31. <scroll-view :scroll-top="scrollTop" scroll-y="true" class="swept_card">
  32. <view class="scrollView" style="width: 100%;" v-if="iceList.length > 0">
  33. <view class="item_coding" v-for="(item,index) in iceList" :key="index">
  34. <view style="display: flex;align-items: center;">
  35. <view class="num_index">{{index + 1}}</view>
  36. <view class="title_coding">{{item}}</view>
  37. </view>
  38. <u-icon name="close-circle-fill" color="#c0c4cc" size="20"
  39. @click="removeWaybill(item)"></u-icon>
  40. </view>
  41. </view>
  42. <view v-else>
  43. <u-empty mode="list"></u-empty>
  44. </view>
  45. </scroll-view>
  46. </view>
  47. </view>
  48. <view class="card_incubator_anti_fake1">
  49. <view class="title_fake" style="margin-left: 20rpx;">防拆标签</view>
  50. <x-form ref="goods" :list="goodsList" :model="goodsModel" :rules="goodsRules"></x-form>
  51. </view>
  52. <view class="btn_print" @click="getDispatching()">
  53. <u-button type="primary" :loading="loading" text="确定"></u-button>
  54. </view>
  55. <u-modal :show="logoutShow" showCancelButton :title="title" :content='content' @cancel="cancel"
  56. @confirm="confirm"></u-modal>
  57. </view>
  58. </template>
  59. <script>
  60. import {
  61. formRules,
  62. } from "../../components/waybill.js";
  63. export default {
  64. data() {
  65. return {
  66. goodsList: formRules(),
  67. goodsModel: {
  68. tamperProofLabel: '',
  69. tamperProofLabelImg: '',
  70. },
  71. goodsRules: {
  72. tamperProofLabel: {
  73. required: false,
  74. message: '请输入防拆标签码',
  75. trigger: ['blur', 'change']
  76. },
  77. tamperProofLabelImg: {
  78. required: false,
  79. message: '请上传防拆标签图片',
  80. trigger: ['blur', 'change']
  81. },
  82. },
  83. incubator: {
  84. id: null,
  85. name: '',
  86. },
  87. iceNumber: '',
  88. iceList: [],
  89. scrollTop: null,
  90. waybillId: null,
  91. deliveryId: null,
  92. loading: false,
  93. logoutShow: false,
  94. title: '是否继续出库配送?',
  95. content: '',
  96. userInfo: {},
  97. }
  98. },
  99. onUnload() {
  100. // console.log('页面销毁')
  101. uni.removeStorageSync('incubatorValue');
  102. this.getempty()
  103. },
  104. onLoad() {
  105. let orderList = uni.getStorageSync('orderValue')
  106. if (orderList) {
  107. let arr = JSON.parse(orderList)
  108. this.waybillId = arr.id
  109. this.deliveryId = arr.deliveryId
  110. this.goodsModel.tamperProofLabel = arr.tamperProofLabel
  111. this.goodsModel.tamperProofLabelImg = arr.tamperProofLabelImg
  112. if (arr.tamperProofLabelImg) {
  113. let arrImg = arr.tamperProofLabelImg.split(',')
  114. let arrImgList = []
  115. arrImg.forEach((item) => {
  116. const arr = {
  117. url: item,
  118. }
  119. arrImgList.push(arr)
  120. })
  121. this.$nextTick(() => {
  122. this.$refs.goods.fileList1 = arrImgList
  123. })
  124. }
  125. }
  126. },
  127. onShow() {
  128. let incubator = uni.getStorageSync('incubatorValue')
  129. if (incubator) {
  130. if (incubator.id != this.incubator.id) {
  131. this.incubator.id = incubator.id
  132. this.incubator.name = incubator.name
  133. this.getIceList(incubator.id)
  134. }
  135. }
  136. var userInfo = this.$cache.getCache('userInfo')
  137. this.userInfo = userInfo
  138. },
  139. methods: {
  140. getempty() {
  141. this.iceList = []
  142. this.incubator.id = ''
  143. this.incubator.name = ''
  144. this.iceNumber = ''
  145. uni.removeStorageSync('incubatorValue');
  146. },
  147. // 确定配送
  148. async getDispatching() {
  149. if (this.incubator.id) {
  150. if (this.iceList.length > 0) {
  151. let flag2 = await this.$refs['goods'].validateForm();
  152. if (flag2) {
  153. this.$api.post('/api/ice-raft/isoutstorage', {
  154. code: this.iceList,
  155. }).then(res => {
  156. if (res.code == 200) {
  157. this.content = res.msg
  158. this.logoutShow = true
  159. } else if (res.code == 1201) {
  160. this.confirm()
  161. } else {
  162. uni.$u.toast(res.msg)
  163. }
  164. })
  165. }
  166. } else {
  167. uni.$u.toast('请先扫描冰排')
  168. }
  169. } else {
  170. uni.$u.toast('请先选择保温箱')
  171. }
  172. },
  173. // 确定
  174. confirm() {
  175. if (this.userInfo.dept) {
  176. if (!this.userInfo.dept.isOutStorage) {
  177. const arr = []
  178. arr.push(this.waybillId)
  179. this.$api.post('/api/waybill/delivery', {
  180. waybillIds: arr,
  181. deliveryId: Number(this.deliveryId),
  182. coolerBoxId: this.incubator.id,
  183. iceRaftCode: this.iceList,
  184. tamperProofLabel: this.goodsModel.tamperProofLabel,
  185. tamperProofLabelImg: this.goodsModel.tamperProofLabelImg,
  186. status: 4,
  187. }).then(res => {
  188. if (res.code == 200) {
  189. uni.$u.toast('操作成功')
  190. uni.$emit('send', '成功');
  191. uni.navigateBack({
  192. delta: 1
  193. });
  194. } else if (res.code == 2000) {
  195. let arrTitle = res.data
  196. let title = ' ,请将冰排' + arrTitle.toString() + '重新入库'
  197. uni.$u.toast(res.msg + title)
  198. } else {
  199. uni.$u.toast(res.msg)
  200. }
  201. })
  202. } else {
  203. uni.$u.toast('冰排暂未到达冷冻要求')
  204. }
  205. } else {
  206. uni.$u.toast('当前账户无公司信息')
  207. }
  208. },
  209. // 取消
  210. cancel() {
  211. this.logoutShow = false
  212. },
  213. // 获取保温箱存在冰排
  214. getIceList(iceId) {
  215. this.$api.get('/api/ice-raft/cooler-box', {
  216. coolerBoxId: iceId,
  217. }).then(res => {
  218. if (res.code == 200) {
  219. this.iceList = res.data
  220. }
  221. })
  222. },
  223. // 移除错误运单号
  224. removeWaybill(value) {
  225. if (this.iceNumber == value) {
  226. this.iceNumber = ''
  227. }
  228. const arr = deleteElementById(this.iceList, value)
  229. this.iceList = arr
  230. function deleteElementById(arr, key) {
  231. return arr.filter((item) => item !== key);
  232. }
  233. },
  234. // 添加冰排
  235. addIce() {
  236. if (this.iceNumber) {
  237. this.iceList.push(this.iceNumber)
  238. this.iceList = this.uniqueArray(this.iceList)
  239. this.$nextTick(() => {
  240. // 获取scroll-view的高度
  241. const query = uni.createSelectorQuery().in(this);
  242. query.select('.scrollView').boundingClientRect(data => {
  243. this.scrollTop = data.height;
  244. }).exec();
  245. });
  246. this.iceNumber = ''
  247. }
  248. },
  249. // 冰排失去焦点
  250. iceRaftBlur(value) {
  251. if (value) {
  252. this.iceList.push(value)
  253. this.iceList = this.uniqueArray(this.iceList)
  254. }
  255. },
  256. // 去重
  257. uniqueArray(arr) {
  258. return [...new Set(arr)];
  259. },
  260. // 扫一扫
  261. sweep() {
  262. // 允许从相机和相册扫码
  263. uni.scanCode({
  264. scanType: ['barCode'],
  265. // scanType: ['qrCode'],
  266. autoZoom: false,
  267. success: (res) => {
  268. console.log(res);
  269. if (res.result) {
  270. let url = res.result;
  271. this.iceNumber = url
  272. this.iceList.push(url)
  273. function methods1(arr) {
  274. return Array.from(new Set(arr));
  275. }
  276. this.iceList = methods1(this.iceList)
  277. } else {
  278. console.log('请重新扫描');
  279. return false;
  280. }
  281. },
  282. fail: (res) => {
  283. console.log('未识别到二维码');
  284. }
  285. })
  286. },
  287. // 鼠标聚焦
  288. focus() {
  289. uni.navigateTo({
  290. url: '/pages/order/Incubator'
  291. });
  292. }
  293. }
  294. }
  295. </script>
  296. <style lang="scss">
  297. .card_send {
  298. padding: 20rpx;
  299. min-height: 600rpx;
  300. }
  301. .send_title {
  302. text-align: center;
  303. margin: 10px;
  304. }
  305. .card_input_send {
  306. position: relative;
  307. display: flex;
  308. align-items: center;
  309. margin-bottom: 20rpx;
  310. }
  311. .incubator_title {
  312. width: 150rpx;
  313. margin-right: 10rpx;
  314. font-size: 30rpx;
  315. span {
  316. color: red;
  317. }
  318. }
  319. .add_card {
  320. margin-left: 10rpx;
  321. width: 50rpx;
  322. height: 46rpx;
  323. border-radius: 8rpx;
  324. padding: 6px 9px;
  325. border: 1px solid #dadbde;
  326. }
  327. .scroll-view {
  328. transition: max-height 1s ease-out;
  329. max-height: 0;
  330. overflow: hidden;
  331. }
  332. .card_frequency {
  333. display: flex;
  334. flex-wrap: wrap;
  335. }
  336. .swept_card {
  337. padding: 0rpx 20rpx;
  338. width: calc(100% - 40rpx);
  339. max-height: 600rpx;
  340. // overflow-y: auto;
  341. }
  342. .card_high {
  343. margin-bottom: 20rpx;
  344. }
  345. .card_frequency_title {
  346. font-size: 30rpx;
  347. }
  348. .card_bottle {
  349. font-size: 30rpx;
  350. span {
  351. color: red;
  352. }
  353. }
  354. .item_coding {
  355. display: flex;
  356. justify-content: space-between;
  357. align-items: center;
  358. width: 100%;
  359. padding: 20rpx 0rpx;
  360. }
  361. .num_index {
  362. font-size: 30rpx;
  363. margin-right: 10rpx;
  364. }
  365. .title_coding {
  366. font-size: 30rpx;
  367. }
  368. .card_search_gray {
  369. display: flex;
  370. flex-direction: row;
  371. align-items: center;
  372. justify-content: space-between;
  373. flex: 1;
  374. padding: 12rpx 18rpx;
  375. border-radius: 8rpx;
  376. line-height: 48rpx;
  377. }
  378. .title_gray {
  379. font-size: 30rpx;
  380. color: #c8c9cc;
  381. }
  382. // 伪元素1rpx边框
  383. .frame {
  384. position: relative; //重要
  385. }
  386. .frame::after {
  387. position: absolute;
  388. content: '';
  389. border: 2rpx solid #e7e6e4;
  390. border-radius: 16rpx;
  391. width: 200%;
  392. height: 200%;
  393. top: 0;
  394. left: 0;
  395. transform: scale(0.5);
  396. transform-origin: 0 0;
  397. pointer-events: none;
  398. /* 使伪元素不会阻止鼠标事件 */
  399. }
  400. .card_incubator_anti_fake {
  401. padding: 20rpx;
  402. width: calc(100% - 80rpx);
  403. margin: 20rpx 20rpx;
  404. border-radius: 10rpx;
  405. background-color: #fff;
  406. }
  407. .card_incubator_anti_fake1 {
  408. padding: 20rpx 0rpx;
  409. width: calc(100% - 40rpx);
  410. margin: 20rpx 20rpx;
  411. border-radius: 10rpx;
  412. background-color: #fff;
  413. }
  414. .title_fake {
  415. margin-bottom: 10rpx;
  416. font-size: 32rpx;
  417. font-weight: bold;
  418. }
  419. .btn_confirm_ching {
  420. position: absolute;
  421. bottom: 0;
  422. left: 0;
  423. right: 0;
  424. height: 120rpx;
  425. background-color: #fff;
  426. }
  427. </style>