sendOutGoods.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. replenishBillSn: _this.replenishBillSn,
  120. shelfSn: getQueryString('&'+qrCode, 'shelfSn'),
  121. shelfPlaceSn: getQueryString('&'+qrCode, 'shelfPlaceSn'),
  122. productSn: getQueryString('&'+qrCode, 'productSn')
  123. }).then(res => {
  124. console.log(res)
  125. if(res.status == 200){
  126. _this.toashMsg("扫码成功!")
  127. _this.getPartList()
  128. if(res.data && res.data.totalConfirmQty && res.data.totalScanQty && res.data.totalConfirmQty == res.data.totalScanQty){
  129. _this.isAll = true
  130. _this.handleOutGoods()
  131. }
  132. }else{
  133. this.contModal = res.message
  134. this.confirmModal = true
  135. }
  136. })
  137. },
  138. modalConfirm(){
  139. this.confirmModal = false
  140. this.barcode.start()
  141. },
  142. init(){
  143. const _this = this
  144. // 初始化
  145. this.barcode = plus.barcode.create('barcode', [], {
  146. top:'0px',
  147. left:'0px',
  148. width: '100%',
  149. height: '28%',
  150. position: 'static',
  151. frameColor: '#00aaff',
  152. scanbarColor: '#00aaff'
  153. })
  154. // 设置高度
  155. const query = uni.createSelectorQuery().in(this);
  156. query.select('#barcode').boundingClientRect(data => {
  157. this.barcode.setStyle({
  158. height: data.height + 'px' // 调整扫码控件的位置
  159. })
  160. }).exec()
  161. // 扫码成功后
  162. this.barcode.onmarked = function(type, result) {
  163. _this.scanResult(result)
  164. }
  165. // 扫码识别出错
  166. this.barcode.onerror = function(error){
  167. console.log(error)
  168. _this.toashMsg("条形码错误!")
  169. _this.barcode.start()
  170. }
  171. const currentWebview = this.$mp.page.$getAppWebview()
  172. currentWebview.append(this.barcode)
  173. this.barcode.start()
  174. }
  175. }
  176. }
  177. </script>
  178. <style lang="less">
  179. page{
  180. height: 100vh;
  181. }
  182. .sendOutGoods-wrap{
  183. position: relative;
  184. width: 100%;
  185. height: 100%;
  186. overflow: hidden;
  187. padding-bottom: 136upx;
  188. .sendOutGoods-con{
  189. width: 100%;
  190. height: 100%;
  191. overflow: auto;
  192. .barCode{
  193. height: 30%;
  194. }
  195. .info-body{
  196. flex-flow: 1;
  197. overflow: auto;
  198. height: 70%;
  199. }
  200. .info{
  201. background-color: #FFFFFF;
  202. padding: 10rpx 30upx;
  203. font-size: 32rpx;
  204. margin-top: 20rpx;
  205. }
  206. }
  207. .sendOutGoods-footer{
  208. padding: 26upx 32upx 30upx;
  209. background-color: #fff;
  210. position: fixed;
  211. left: 0;
  212. bottom: 0;
  213. width: 100%;
  214. box-shadow: 3px 1px 7px #eee;
  215. }
  216. }
  217. </style>