dispatching.vue 9.4 KB

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