sendOutGoods.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. shelfReplenishDetailOutScan({
  143. replenishBillSn: _this.replenishBillSn,
  144. shelfSn: getQueryString('&'+qrCode, 'shelfSn'),
  145. shelfPlaceSn: getQueryString('&'+qrCode, 'shelfPlaceSn'),
  146. productSn: getQueryString('&'+qrCode, 'productSn')
  147. }).then(res => {
  148. console.log(res)
  149. if(res.status == 200){
  150. _this.toashMsg("扫码成功!")
  151. _this.getPartList()
  152. if(res.data && res.data.totalConfirmQty && res.data.totalScanQty && res.data.totalConfirmQty == res.data.totalScanQty){
  153. _this.isAll = true
  154. _this.handleOutGoods()
  155. }else{
  156. _this.barcode.start()
  157. }
  158. }else{
  159. this.contModal = res.message
  160. this.confirmModal = true
  161. }
  162. })
  163. },
  164. modalConfirm(){
  165. this.confirmModal = false
  166. this.barcode.start()
  167. },
  168. init(){
  169. const _this = this
  170. // 初始化
  171. this.barcode = plus.barcode.create('barcode', [], {
  172. top:'0px',
  173. left:'0px',
  174. width: '100%',
  175. height: '28%',
  176. position: 'static',
  177. frameColor: '#00aaff',
  178. scanbarColor: '#00aaff'
  179. })
  180. // 设置高度
  181. const query = uni.createSelectorQuery().in(this);
  182. query.select('#barcode').boundingClientRect(data => {
  183. this.barcode.setStyle({
  184. height: data.height + 'px' // 调整扫码控件的位置
  185. })
  186. }).exec()
  187. // 扫码成功后
  188. this.barcode.onmarked = function(type, result) {
  189. _this.scanResult(result)
  190. }
  191. // 扫码识别出错
  192. this.barcode.onerror = function(error){
  193. console.log(error)
  194. _this.toashMsg("条形码错误!")
  195. _this.barcode.start()
  196. }
  197. const currentWebview = this.$mp.page.$getAppWebview()
  198. currentWebview.append(this.barcode)
  199. this.barcode.start()
  200. }
  201. }
  202. }
  203. </script>
  204. <style lang="less">
  205. page{
  206. height: 100vh;
  207. }
  208. .sendOutGoods-wrap{
  209. position: relative;
  210. width: 100%;
  211. height: 100%;
  212. overflow: hidden;
  213. padding-bottom: 136upx;
  214. .sendOutGoods-con{
  215. width: 100%;
  216. height: 100%;
  217. overflow: auto;
  218. display: flex;
  219. flex-direction: column;
  220. .barCode{
  221. height: 33%;
  222. margin-bottom: 10%;
  223. }
  224. .info-body{
  225. flex-flow: 1;
  226. overflow: auto;
  227. height: 57%;
  228. }
  229. .info{
  230. background-color: #FFFFFF;
  231. padding: 10rpx 30upx;
  232. font-size: 32rpx;
  233. margin-top: 20rpx;
  234. }
  235. }
  236. .sendOutGoods-footer{
  237. padding: 26upx 32upx 30upx;
  238. background-color: #fff;
  239. position: fixed;
  240. left: 0;
  241. bottom: 0;
  242. width: 100%;
  243. box-shadow: 3px 1px 7px #eee;
  244. }
  245. }
  246. </style>