carriers.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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.details
  104. form.value.carrierCount = res.data.form.carrierCount
  105. console.log(res)
  106. })
  107. }
  108. function checkItem(item) {
  109. // console.log(item)
  110. if (checkedCarriers.value.findIndex(v => item.id === v) >= 0) {
  111. return true
  112. } else {
  113. return false;
  114. }
  115. // return true;
  116. }
  117. function handleScanCode() {
  118. // 引入原生插件
  119. const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  120. // const mpaasScanModule = false
  121. if (mpaasScanModule) {
  122. // 调用插件的 mpaasScan 方法
  123. mpaasScanModule.mpaasScan({
  124. // 扫码识别类型,参数可多选,qrCode、barCode,
  125. // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  126. scanType: ["qrCode", "barCode"],
  127. // 是否隐藏相册,默认false不隐藏
  128. hideAlbum: false,
  129. },
  130. (ret) => {
  131. let vehicleObj = JSON.parse(ret.resp_result);
  132. if (!vehicleObj.carrierId || vehicleObj.carrierId == "") {
  133. message.value = '请扫载具码'
  134. inputDialog.value.open()
  135. return;
  136. }
  137. let checked = false
  138. let allChecked = true
  139. details.value.forEach(l => {
  140. checked = checked || (l.carriers.findIndex(e => e.id === vehicleObj.carrierId) >= 0)
  141. // allChecked = allChecked && (l.carriers.findIndex(e => e.id === vehicleObj.carrierId) >= 0)
  142. if (checked) {
  143. checkedCarriers.value.push(vehicleObj.carrierId)
  144. }
  145. allChecked = allChecked && checkedCarriers.values.includes(l.carriers)
  146. })
  147. if (checked) {
  148. uni.showToast({
  149. icon: 'none',
  150. title: '已扫箱' + vehicleObj.carrierCode
  151. })
  152. if (allChecked) {
  153. debonce(() => {
  154. uni.showToast({
  155. icon: 'none',
  156. title: '已验证所有箱码'
  157. })
  158. }, 700)
  159. } else {
  160. debounce(handleScanCode, 700)
  161. }
  162. } else {
  163. message.value = '该箱号' + vehicleObj.carrierCode + '不在此发出单'
  164. inputDialog.value.open()
  165. return
  166. }
  167. }
  168. );
  169. } else {
  170. // message.value = '测试dialog'
  171. // console.log(message.value)
  172. // inputDialog.value.open()
  173. // if (checkedCarriers.value.length < details.value[0].carriers.length) {
  174. // checkedCarriers.value.push(details.value[0].carriers[checkedCarriers.value.length].id)
  175. // } else {
  176. // checkedCarriers.value.pop()
  177. // }
  178. // debounce(handleScanCode, 700)
  179. }
  180. }
  181. </script>
  182. <style lang="scss">
  183. .container {
  184. height: 100%;
  185. background-color: #f5f5f5;
  186. }
  187. .bottom {
  188. position: fixed;
  189. right: 0;
  190. bottom: 0;
  191. left: 0;
  192. height: 100rpx;
  193. padding: 16rpx 24rpx;
  194. align-items: center;
  195. background-color: #FFFFFF;
  196. justify-content: space-between;
  197. .bottom-btn {
  198. flex: 1;
  199. font-size: 28rpx;
  200. color: #FFFFFF;
  201. &.left-btn {
  202. background-color: rgba(0, 226, 166, 1);
  203. }
  204. &.right-btn {
  205. margin-left: 24rpx;
  206. }
  207. }
  208. }
  209. .content {
  210. width: 90%;
  211. height: calc(100% - 250rpx);
  212. background-color: rgba(255, 255, 255, 1);
  213. margin: 50rpx auto;
  214. padding-bottom: 50rpx;
  215. border-radius: 12rpx;
  216. .vehicleList {
  217. justify-content: baseline;
  218. align-content: flex-start;
  219. flex-wrap: wrap;
  220. width: 100%;
  221. height: 100%;
  222. padding: 0 64rpx;
  223. overflow: auto;
  224. .vehicleNo {
  225. padding: 0 10rpx;
  226. margin: 10rpx;
  227. justify-content: center;
  228. align-items: center;
  229. width: 160rpx;
  230. height: 60rpx;
  231. border: 1px solid rgba(213, 213, 213, 1);
  232. color: rgba(213, 213, 213, 1);
  233. border-radius: 6rpx;
  234. }
  235. .success {
  236. border: 1px solid rgba(44, 112, 213, 1.0);
  237. color: rgba(44, 112, 213, 1.0);
  238. }
  239. }
  240. .disuseList {
  241. border-top: 2rpx solid #e1e1e1;
  242. height: calc(100% - 480rpx - 20rpx);
  243. overflow: auto;
  244. width: 90%;
  245. margin: 0 auto;
  246. padding-top: 20rpx;
  247. }
  248. .title {
  249. display: flex;
  250. width: 100%;
  251. justify-content: space-around;
  252. flex-wrap: wrap;
  253. gap: 10px;
  254. .item-info {
  255. margin-bottom: 8rpx;
  256. width: calc(50% - 20px);
  257. .label {
  258. font-size: 28rpx;
  259. width: 220rpx;
  260. color: #808080;
  261. &.right {
  262. flex: 1;
  263. color: #000000;
  264. }
  265. }
  266. }
  267. }
  268. }
  269. .discardVehicleNo {
  270. padding: 0 10rpx;
  271. margin: 10rpx;
  272. justify-content: space-between;
  273. align-items: center;
  274. width: 150rpx;
  275. height: 60rpx;
  276. border: 1px solid rgba(213, 213, 213, 1);
  277. border-radius: 6rpx;
  278. }
  279. .title {
  280. margin: 30rpx auto;
  281. width: 30%;
  282. font-size: 36rpx;
  283. font-weight: bold;
  284. }
  285. </style>