sendOutGoods.vue 6.6 KB

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