sendOutGoods.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <view class="sendOutGoods-wrap">
  3. <view class="sendOutGoods-con">
  4. <view class="barCode" id="barcode"></view>
  5. <view class="info-body">
  6. <view class="info partList">
  7. <!-- 补货产品 -->
  8. <partList :list="partList" title="补货产品" model="view" fromPage="sendOutGoods" ref="partList" noDataText="暂无产品"></partList>
  9. </view>
  10. </view>
  11. </view>
  12. <view class="sendOutGoods-footer">
  13. <u-button @click="handleOutGoods" type="success" :custom-style="customStyle" hover-class="none" shape="circle">立即出库</u-button>
  14. </view>
  15. <!-- 确认弹框 -->
  16. <common-modal v-if="confirmModal" :openModal="confirmModal" title="扫码失败" :content="contModal" confirmText="好的" :isCancel="false" @confirm="modalConfirm" @close="confirmModal=false" />
  17. <!-- 出库确认弹框 -->
  18. <common-modal v-if="confirmOutModal" :openModal="confirmOutModal" title="出库" content="此补货单产品已经全部扫描完成,确认出库吗?" confirmText="确认出库" @confirm="modalOutConfirm" @close="confirmOutModal=false" />
  19. <!-- 选择配送方式弹框 -->
  20. <choose-type-modal v-if="chooseModal" :openModal="chooseModal" @confirm="modalChooseType" @close="closeChooseType" />
  21. </view>
  22. </template>
  23. <script>
  24. import partList from '@/pages/common/partList.vue'
  25. import chooseTypeModal from './chooseTypeModal.vue'
  26. import commonModal from '@/pages/common/commonModal.vue'
  27. import { getQueryString } from '@/libs/tools'
  28. import { shelfReplenishDetailList, shelfReplenishDetailOutScan, shelfReplenishOutStock, shelfReplenishDetail } from '@/api/shelfReplenish'
  29. export default {
  30. components: { partList, commonModal, chooseTypeModal },
  31. data() {
  32. return {
  33. barcode:null,
  34. replenishBillSn: null,
  35. shelfSn: null,
  36. partList: [],
  37. confirmModal: false,
  38. customStyle: {
  39. borderRadius:'100rpx',
  40. fontSize:'30rpx',
  41. background: this.$config('primaryColor')
  42. },
  43. isAll: false,
  44. contModal: '',
  45. confirmOutModal: false,
  46. chooseModal: false
  47. }
  48. },
  49. onReady() {
  50. // 初始化摄像头
  51. this.init()
  52. },
  53. onLoad(options) {
  54. this.replenishBillSn = options.sn
  55. this.shelfSn = options.shelfSn
  56. this.getPartList()
  57. this.getDetail()
  58. },
  59. methods: {
  60. // 详情
  61. getDetail(){
  62. shelfReplenishDetail({ sn: this.replenishBillSn }).then(res => {
  63. console.log(res)
  64. if(res.status == 200 && res.data){
  65. if(res.data.totalConfirmQty && res.data.totalScanQty && res.data.totalConfirmQty == res.data.totalScanQty){
  66. this.isAll = true
  67. }else{
  68. this.isAll = false
  69. }
  70. }else{
  71. this.isAll = false
  72. }
  73. })
  74. },
  75. // 立即出库
  76. handleOutGoods(){
  77. if(this.isAll){
  78. this.confirmOutModal = true
  79. }else{
  80. this.toashMsg("请全部扫描完成后,再进行出库操作")
  81. }
  82. },
  83. // 选择配送方式
  84. modalChooseType(data){
  85. const _this = this
  86. const arr = []
  87. _this.partList.map((item, index) => {
  88. arr.push({
  89. productSn: item.productSn,
  90. confirmQty: item.confirmQty,
  91. replenishBillDetailSn: item.replenishBillDetailSn
  92. })
  93. })
  94. const params = {
  95. replenishBillSn: _this.replenishBillSn,
  96. detailList: arr,
  97. dispatchType: data.dispatchType,
  98. remarks: data.remarks,
  99. shelfSn: _this.shelfSn
  100. }
  101. console.log(params)
  102. shelfReplenishOutStock(params).then(res => {
  103. console.log(res)
  104. if (res.status == 200) {
  105. _this.toashMsg(res.message)
  106. _this.chooseModal = false
  107. uni.$emit('refreshBL')
  108. uni.$emit("refreshBhList",'WAIT_CHECK')
  109. uni.navigateBack({
  110. delta:2
  111. })
  112. }else{
  113. _this.toashMsg(res.message)
  114. }
  115. })
  116. },
  117. // 确认出库
  118. modalOutConfirm(){
  119. this.chooseModal = true
  120. },
  121. closeChooseType(){
  122. this.confirmOutModal = false
  123. this.chooseModal = false
  124. },
  125. // 查询列表
  126. getPartList(){
  127. const _this = this
  128. shelfReplenishDetailList({ replenishBillSn: this.replenishBillSn }).then(res => {
  129. if(res.status == 200 && res.data){
  130. res.data.map(item =>{
  131. item.confirmQty = item.confirmQty ? Number(item.confirmQty) : 0
  132. })
  133. this.partList = res.data || []
  134. }else{
  135. this.partList = []
  136. }
  137. })
  138. },
  139. // 扫码结果
  140. scanResult(qrCode){
  141. const _this = this
  142. const pa = qrCode.split("&")
  143. console.log(qrCode,pa)
  144. shelfReplenishDetailOutScan({
  145. replenishBillSn: _this.replenishBillSn,
  146. // shelfSn: getQueryString('&'+qrCode, 'shelfSn'),
  147. // shelfPlaceSn: getQueryString('&'+qrCode, 'shelfPlaceSn'),
  148. // productSn: getQueryString('&'+qrCode, 'productSn')
  149. shelfSn: pa[0],
  150. shelfPlaceSn: pa[3],
  151. productSn: pa[2]
  152. }).then(res => {
  153. console.log(res)
  154. if(res.status == 200){
  155. _this.toashMsg("扫码成功!")
  156. setTimeout(()=>{
  157. _this.barcode.start()
  158. // 刷新列表
  159. _this.getPartList()
  160. },2000)
  161. if(res.data && res.data.totalConfirmQty && res.data.totalScanQty && res.data.totalConfirmQty == res.data.totalScanQty){
  162. _this.isAll = true
  163. _this.handleOutGoods()
  164. }
  165. }else{
  166. this.contModal = res.message
  167. this.confirmModal = true
  168. }
  169. })
  170. },
  171. modalConfirm(){
  172. this.confirmModal = false
  173. this.barcode.start()
  174. },
  175. init(){
  176. const _this = this
  177. // 初始化
  178. this.barcode = plus.barcode.create('barcode', [], {
  179. top:'0px',
  180. left:'0px',
  181. width: '100%',
  182. height: '28%',
  183. position: 'static',
  184. frameColor: '#00aaff',
  185. scanbarColor: '#00aaff'
  186. })
  187. // 设置高度
  188. const query = uni.createSelectorQuery().in(this);
  189. query.select('#barcode').boundingClientRect(data => {
  190. this.barcode.setStyle({
  191. height: data.height + 'px' // 调整扫码控件的位置
  192. })
  193. }).exec()
  194. // 扫码成功后
  195. this.barcode.onmarked = function(type, result) {
  196. console.log(type,result)
  197. _this.scanResult(result)
  198. }
  199. // 扫码识别出错
  200. this.barcode.onerror = function(error){
  201. console.log(error)
  202. _this.toashMsg("条形码错误!")
  203. _this.barcode.start()
  204. }
  205. const currentWebview = this.$mp.page.$getAppWebview()
  206. currentWebview.append(this.barcode)
  207. this.barcode.start()
  208. }
  209. }
  210. }
  211. </script>
  212. <style lang="less">
  213. page{
  214. height: 100vh;
  215. }
  216. .sendOutGoods-wrap{
  217. position: relative;
  218. width: 100%;
  219. height: 100%;
  220. overflow: hidden;
  221. padding-bottom: 136upx;
  222. .sendOutGoods-con{
  223. width: 100%;
  224. height: 100%;
  225. overflow: auto;
  226. display: flex;
  227. flex-direction: column;
  228. .barCode{
  229. height: 33%;
  230. margin-bottom: 10%;
  231. }
  232. .info-body{
  233. flex-flow: 1;
  234. overflow: auto;
  235. height: 57%;
  236. }
  237. .info{
  238. background-color: #FFFFFF;
  239. padding: 10rpx 30upx;
  240. font-size: 32rpx;
  241. margin-top: 20rpx;
  242. }
  243. }
  244. .sendOutGoods-footer{
  245. padding: 26upx 32upx 30upx;
  246. background-color: #fff;
  247. position: fixed;
  248. left: 0;
  249. bottom: 0;
  250. width: 100%;
  251. box-shadow: 3px 1px 7px #eee;
  252. }
  253. }
  254. </style>