sendOutGoods.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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="chooseModal=false" />
  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 } 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. },
  58. methods: {
  59. // 立即出库
  60. handleOutGoods(){
  61. if(this.isAll){
  62. this.confirmOutModal = true
  63. }else{
  64. this.toashMsg("请全部扫描完成后,再进行出库操作")
  65. }
  66. },
  67. // 选择配送方式
  68. modalChooseType(data){
  69. const _this = this
  70. const arr = []
  71. _this.partList.map((item, index) => {
  72. arr.push({
  73. productSn: item.productSn,
  74. confirmQty: item.confirmQty,
  75. replenishBillDetailSn: item.replenishBillDetailSn
  76. })
  77. })
  78. const params = {
  79. replenishBillSn: _this.replenishBillSn,
  80. detailList: arr,
  81. dispatchType: data.dispatchType,
  82. remarks: data.remarks,
  83. shelfSn: _this.shelfSn
  84. }
  85. console.log(params)
  86. shelfReplenishOutStock(params).then(res => {
  87. console.log(res)
  88. if (res.status == 200) {
  89. _this.toashMsg(res.message)
  90. _this.chooseModal = false
  91. uni.navigateTo({ url: '/pages/replenishmentManage/replenishmentList?billState=WAIT_OUT_STOCK' })
  92. }else{
  93. _this.toashMsg(res.message)
  94. }
  95. })
  96. },
  97. // 确认出库
  98. modalOutConfirm(){
  99. this.chooseModal = true
  100. },
  101. // 查询列表
  102. getPartList(){
  103. const _this = this
  104. shelfReplenishDetailList({ replenishBillSn: this.replenishBillSn }).then(res => {
  105. if(res.status == 200 && res.data){
  106. res.data.map(item =>{
  107. item.confirmQty = item.confirmQty ? Number(item.confirmQty) : 0
  108. })
  109. this.partList = res.data || []
  110. }else{
  111. this.partList = []
  112. }
  113. })
  114. },
  115. // 扫码结果
  116. scanResult(qrCode){
  117. const _this = this
  118. shelfReplenishDetailOutScan({
  119. productSn: getQueryString('&'+qrCode, 'productSn'),
  120. replenishBillDetailSn: getQueryString('&'+qrCode, 'replenishBillDetailSn')
  121. }).then(res => {
  122. console.log(res)
  123. if(res.status == 200){
  124. _this.toashMsg("扫码成功!")
  125. _this.getPartList()
  126. if(res.data && res.data.totalConfirmQty && res.data.totalScanQty && res.data.totalConfirmQty == res.data.totalScanQty){
  127. _this.isAll = true
  128. _this.handleOutGoods()
  129. }
  130. }else{
  131. this.contModal = res.message
  132. this.confirmModal = true
  133. }
  134. })
  135. },
  136. modalConfirm(){
  137. this.confirmModal = false
  138. this.barcode.start()
  139. },
  140. init(){
  141. const _this = this
  142. // 初始化
  143. this.barcode = plus.barcode.create('barcode', [], {
  144. top:'0px',
  145. left:'0px',
  146. width: '100%',
  147. height: '28%',
  148. position: 'static',
  149. frameColor: '#00aaff',
  150. scanbarColor: '#00aaff'
  151. })
  152. // 设置高度
  153. const query = uni.createSelectorQuery().in(this);
  154. query.select('#barcode').boundingClientRect(data => {
  155. this.barcode.setStyle({
  156. height: data.height + 'px' // 调整扫码控件的位置
  157. })
  158. }).exec()
  159. // 扫码成功后
  160. this.barcode.onmarked = function(type, result) {
  161. _this.scanResult(result)
  162. }
  163. // 扫码识别出错
  164. this.barcode.onerror = function(error){
  165. console.log(error)
  166. _this.toashMsg("条形码错误!")
  167. _this.barcode.start()
  168. }
  169. const currentWebview = this.$mp.page.$getAppWebview()
  170. currentWebview.append(this.barcode)
  171. this.barcode.start()
  172. }
  173. }
  174. }
  175. </script>
  176. <style lang="less">
  177. page{
  178. height: 100vh;
  179. }
  180. .sendOutGoods-wrap{
  181. position: relative;
  182. width: 100%;
  183. height: 100%;
  184. overflow: hidden;
  185. padding-bottom: 136upx;
  186. .sendOutGoods-con{
  187. width: 100%;
  188. height: 100%;
  189. overflow: auto;
  190. .barCode{
  191. height: 30%;
  192. }
  193. .info-body{
  194. flex-flow: 1;
  195. overflow: auto;
  196. height: 70%;
  197. }
  198. .info{
  199. background-color: #FFFFFF;
  200. padding: 10rpx 30upx;
  201. font-size: 32rpx;
  202. margin-top: 20rpx;
  203. }
  204. }
  205. .sendOutGoods-footer{
  206. padding: 26upx 32upx 30upx;
  207. background-color: #fff;
  208. position: fixed;
  209. left: 0;
  210. bottom: 0;
  211. width: 100%;
  212. box-shadow: 3px 1px 7px #eee;
  213. }
  214. }
  215. </style>