carriers.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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 && l.carriers.every(t => checkedCarriers.value.includes(t.id))
  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. let vehicleObj = {
  180. carrierId: "1",
  181. carrierCode: "1"
  182. };
  183. if (!vehicleObj.carrierId || vehicleObj.carrierId == "") {
  184. message.value = '请扫载具码'
  185. inputDialog.value.open()
  186. return;
  187. }
  188. let checked = false
  189. let allChecked = true
  190. details.value.forEach(l => {
  191. checked = checked || (l.carriers.findIndex(e => e.id === vehicleObj.carrierId) >= 0)
  192. // allChecked = allChecked && (l.carriers.findIndex(e => e.id === vehicleObj.carrierId) >= 0)
  193. if (checked) {
  194. checkedCarriers.value.push(vehicleObj.carrierId)
  195. }
  196. allChecked = allChecked && l.carriers.every(t => checkedCarriers.value.includes(t.id))
  197. })
  198. if (checked) {
  199. uni.showToast({
  200. icon: 'none',
  201. title: '已扫箱' + vehicleObj.carrierCode
  202. })
  203. if (allChecked) {
  204. debonce(() => {
  205. uni.showToast({
  206. icon: 'none',
  207. title: '已验证所有箱码'
  208. })
  209. }, 700)
  210. } else {
  211. debounce(handleScanCode, 700)
  212. }
  213. } else {
  214. message.value = '该箱号' + vehicleObj.carrierCode + '不在此发出单'
  215. inputDialog.value.open()
  216. return
  217. }
  218. }
  219. }
  220. </script>
  221. <style lang="scss">
  222. .container {
  223. height: 100%;
  224. background-color: #f5f5f5;
  225. }
  226. .bottom {
  227. position: fixed;
  228. right: 0;
  229. bottom: 0;
  230. left: 0;
  231. height: 100rpx;
  232. padding: 16rpx 24rpx;
  233. align-items: center;
  234. background-color: #FFFFFF;
  235. justify-content: space-between;
  236. .bottom-btn {
  237. flex: 1;
  238. font-size: 28rpx;
  239. color: #FFFFFF;
  240. &.left-btn {
  241. background-color: rgba(0, 226, 166, 1);
  242. }
  243. &.right-btn {
  244. margin-left: 24rpx;
  245. }
  246. }
  247. }
  248. .content {
  249. width: 90%;
  250. height: calc(100% - 250rpx);
  251. background-color: rgba(255, 255, 255, 1);
  252. margin: 50rpx auto;
  253. padding-bottom: 50rpx;
  254. border-radius: 12rpx;
  255. .vehicleList {
  256. justify-content: baseline;
  257. align-content: flex-start;
  258. flex-wrap: wrap;
  259. width: 100%;
  260. height: 100%;
  261. padding: 0 64rpx;
  262. overflow: auto;
  263. .vehicleNo {
  264. padding: 0 10rpx;
  265. margin: 10rpx;
  266. justify-content: center;
  267. align-items: center;
  268. width: 160rpx;
  269. height: 60rpx;
  270. border: 1px solid rgba(213, 213, 213, 1);
  271. color: rgba(213, 213, 213, 1);
  272. border-radius: 6rpx;
  273. }
  274. .success {
  275. border: 1px solid rgba(44, 112, 213, 1.0);
  276. color: rgba(44, 112, 213, 1.0);
  277. }
  278. }
  279. .disuseList {
  280. border-top: 2rpx solid #e1e1e1;
  281. height: calc(100% - 480rpx - 20rpx);
  282. overflow: auto;
  283. width: 90%;
  284. margin: 0 auto;
  285. padding-top: 20rpx;
  286. }
  287. .title {
  288. display: flex;
  289. width: 100%;
  290. justify-content: space-around;
  291. flex-wrap: wrap;
  292. gap: 10px;
  293. .item-info {
  294. margin-bottom: 8rpx;
  295. width: calc(50% - 20px);
  296. .label {
  297. font-size: 28rpx;
  298. width: 220rpx;
  299. color: #808080;
  300. &.right {
  301. flex: 1;
  302. color: #000000;
  303. }
  304. }
  305. }
  306. }
  307. }
  308. .discardVehicleNo {
  309. padding: 0 10rpx;
  310. margin: 10rpx;
  311. justify-content: space-between;
  312. align-items: center;
  313. width: 150rpx;
  314. height: 60rpx;
  315. border: 1px solid rgba(213, 213, 213, 1);
  316. border-radius: 6rpx;
  317. }
  318. .title {
  319. margin: 30rpx auto;
  320. width: 30%;
  321. font-size: 36rpx;
  322. font-weight: bold;
  323. }
  324. </style>