carriers.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <view class='container'>
  3. <view class='content'>
  4. <view class='title uni-row' style="border-bottom-style: solid; border-bottom-width: 1px;">
  5. <view class="item-info uni-row">
  6. <text class="label">外协单:</text>
  7. <text class="label right">{{ form.formCode }}</text>
  8. </view>
  9. <view class="item-info uni-row">
  10. <text class="label">外协商:</text>
  11. <text class="label right">{{ form.supplierName }}</text>
  12. </view>
  13. <view class="item-info uni-row">
  14. <text class="label">带箱方式:</text>
  15. <text class="label right">{{ form.packagingMethod == '0' ? '原箱' : '新箱' }}</text>
  16. </view>
  17. <view class="item-info uni-row">
  18. <text class="label">箱子数量:</text>
  19. <text class="label right">{{ form.carrierCount }}</text>
  20. </view>
  21. </view>
  22. <view class="vehicleList uni-row" style="padding: 0 2px;">
  23. <view v-for="(ditem, index) in details"
  24. style="border-bottom-style: solid; border-bottom-width: 1px;width: 100%; flex-direction: row; flex-wrap: wrap;">
  25. <view :class="'vehicleNo uni-row' +(checkItem(item) ? ' success' :'')"
  26. v-for="(item,index) in ditem.carriers">
  27. <text>{{item.code}}</text>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class='bottom uni-row'>
  33. <button class='bottom-btn left-btn' @click="handleScanCode">逐箱核对</button>
  34. </view>
  35. <uni-popup ref="inputDialog" type="dialog" style="z-index: 2;">
  36. <view
  37. style="background-color: aliceblue; width: 20rem; height: 10rem; padding-top: 3rem; display: flex; flex-direction: column; justify-content: space-between;">
  38. <view style="display: flex;flex-direction: row;justify-content: center; margin-bottom: 2rem;">
  39. <view></view>
  40. <view>{{ message }}</view>
  41. </view>
  42. <view style="display: flex;flex-direction: row;justify-content: space-between; margin-bottom: 2rem;">
  43. <button @click="cancelConfirm">取消</button>
  44. <button @click="continueScna">继续扫码</button>
  45. </view>
  46. </view>
  47. </uni-popup>
  48. </view>
  49. </template>
  50. <script setup>
  51. import {
  52. ref
  53. } from 'vue'
  54. import {
  55. onMounted,
  56. getCurrentInstance
  57. } from 'vue';
  58. import {
  59. onLoad,
  60. onReady
  61. } from '@dcloudio/uni-app'
  62. import {
  63. store
  64. } from '@/store/index.js'
  65. import {
  66. getOutsourceOrderList,
  67. getOutsourceOrderCarrier
  68. } from '@/api/business/outsource.js'
  69. import {
  70. debounce
  71. } from '@/utils/common.js'
  72. const form = ref({})
  73. // const carriers = ref([])
  74. const details = ref([])
  75. const checkedCarriers = ref([])
  76. const message = ref('')
  77. const showConfirm = ref(false)
  78. const inputDialog = ref(null)
  79. onMounted(() => {
  80. const instance = getCurrentInstance().proxy
  81. const eventChannel = instance.getOpenerEventChannel();
  82. eventChannel.on('acceptDataFromOpenerPage', function(data) {
  83. if (data && data.data) {
  84. form.value = data.data
  85. init()
  86. }
  87. })
  88. })
  89. function init() {
  90. getCarrierList()
  91. }
  92. function cancelConfirm() {
  93. inputDialog.value.close()
  94. }
  95. function continueScna() {
  96. inputDialog.value.close()
  97. handleScanCode()
  98. }
  99. function getCarrierList() {
  100. // 获取该外协单所有关联箱
  101. getOutsourceOrderCarrier(form.value).then(res => {
  102. // console.log(res)
  103. details.value = res.data
  104. })
  105. }
  106. function checkItem(item) {
  107. // console.log(item)
  108. if (checkedCarriers.value.findIndex(v => item.id === v) >= 0) {
  109. return true
  110. } else {
  111. return false;
  112. }
  113. // return true;
  114. }
  115. function handleScanCode() {
  116. // 引入原生插件
  117. const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  118. // const mpaasScanModule = false
  119. if (mpaasScanModule) {
  120. // 调用插件的 mpaasScan 方法
  121. mpaasScanModule.mpaasScan({
  122. // 扫码识别类型,参数可多选,qrCode、barCode,
  123. // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  124. scanType: ["qrCode", "barCode"],
  125. // 是否隐藏相册,默认false不隐藏
  126. hideAlbum: false,
  127. },
  128. (ret) => {
  129. let vehicleObj = JSON.parse(ret.resp_result);
  130. if (!vehicleObj.carrierId || vehicleObj.carrierId == "") {
  131. message.value = '请扫载具码'
  132. inputDialog.value.open()
  133. return;
  134. }
  135. let checked = false
  136. details.value.forEach(l => {
  137. checked = checked || (l.carriers.findIndex(e => e.id === vehicleObj.carrierId) >= 0)
  138. })
  139. if (checked) {
  140. checkedCarriers.value.push(vehicleObj.carrierId)
  141. uni.showToast({
  142. icon: 'none',
  143. title: '已扫箱' + vehicleObj.carrierCode
  144. })
  145. debounce(handleScanCode, 700)
  146. } else {
  147. message.value = '该箱号' + vehicleObj.carrierCode + '不在此发出单'
  148. inputDialog.value.open()
  149. return
  150. }
  151. }
  152. );
  153. } else {
  154. // message.value = '测试dialog'
  155. // console.log(message.value)
  156. // inputDialog.value.open()
  157. // if (checkedCarriers.value.length < details.value[0].carriers.length) {
  158. // checkedCarriers.value.push(details.value[0].carriers[checkedCarriers.value.length].id)
  159. // } else {
  160. // checkedCarriers.value.pop()
  161. // }
  162. // debounce(handleScanCode, 700)
  163. }
  164. }
  165. </script>
  166. <style lang="scss">
  167. .container {
  168. height: 100%;
  169. background-color: #f5f5f5;
  170. }
  171. .bottom {
  172. position: fixed;
  173. right: 0;
  174. bottom: 0;
  175. left: 0;
  176. height: 100rpx;
  177. padding: 16rpx 24rpx;
  178. align-items: center;
  179. background-color: #FFFFFF;
  180. justify-content: space-between;
  181. .bottom-btn {
  182. flex: 1;
  183. font-size: 28rpx;
  184. color: #FFFFFF;
  185. &.left-btn {
  186. background-color: rgba(0, 226, 166, 1);
  187. }
  188. &.right-btn {
  189. margin-left: 24rpx;
  190. }
  191. }
  192. }
  193. .content {
  194. width: 90%;
  195. height: calc(100% - 250rpx);
  196. background-color: rgba(255, 255, 255, 1);
  197. margin: 50rpx auto;
  198. padding-bottom: 50rpx;
  199. border-radius: 12rpx;
  200. .vehicleList {
  201. justify-content: baseline;
  202. align-content: flex-start;
  203. flex-wrap: wrap;
  204. width: 100%;
  205. height: 100%;
  206. padding: 0 64rpx;
  207. overflow: auto;
  208. .vehicleNo {
  209. padding: 0 10rpx;
  210. margin: 10rpx;
  211. justify-content: center;
  212. align-items: center;
  213. width: 160rpx;
  214. height: 60rpx;
  215. border: 1px solid rgba(213, 213, 213, 1);
  216. color: rgba(213, 213, 213, 1);
  217. border-radius: 6rpx;
  218. }
  219. .success {
  220. border: 1px solid rgba(44, 112, 213, 1.0);
  221. color: rgba(44, 112, 213, 1.0);
  222. }
  223. }
  224. .disuseList {
  225. border-top: 2rpx solid #e1e1e1;
  226. height: calc(100% - 480rpx - 20rpx);
  227. overflow: auto;
  228. width: 90%;
  229. margin: 0 auto;
  230. padding-top: 20rpx;
  231. }
  232. .title {
  233. display: flex;
  234. width: 100%;
  235. justify-content: space-around;
  236. flex-wrap: wrap;
  237. gap: 10px;
  238. .item-info {
  239. margin-bottom: 8rpx;
  240. width: calc(50% - 20px);
  241. .label {
  242. font-size: 28rpx;
  243. width: 220rpx;
  244. color: #808080;
  245. &.right {
  246. flex: 1;
  247. color: #000000;
  248. }
  249. }
  250. }
  251. }
  252. }
  253. .discardVehicleNo {
  254. padding: 0 10rpx;
  255. margin: 10rpx;
  256. justify-content: space-between;
  257. align-items: center;
  258. width: 150rpx;
  259. height: 60rpx;
  260. border: 1px solid rgba(213, 213, 213, 1);
  261. border-radius: 6rpx;
  262. }
  263. .title {
  264. margin: 30rpx auto;
  265. width: 30%;
  266. font-size: 36rpx;
  267. font-weight: bold;
  268. }
  269. </style>