dispatching.vue 9.4 KB

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