dispatching.vue 10 KB

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