sendOutGoods.vue 8.0 KB

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