sendOutGoods.vue 8.7 KB

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