sendOutGoods.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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.totalQty && res.data.totalScanQty && res.data.totalQty == 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.qty,
  135. replenishBillDetailSn: item.replenishBillDetailSn,
  136. id:item.id
  137. })
  138. })
  139. const params = {
  140. replenishBillSn: _this.replenishBillSn,
  141. detailList: arr,
  142. dispatchType: data.dispatchType,
  143. remarks: data.remarks,
  144. shelfSn: _this.shelfSn
  145. }
  146. console.log(params)
  147. this.loading = true
  148. shelfReplenishOutStock(params).then(res => {
  149. console.log(res)
  150. if (res.status == 200) {
  151. _this.toashMsg(res.message)
  152. _this.chooseModal = false
  153. uni.$emit('refreshBL')
  154. uni.$emit("refreshBhList",'WAIT_CHECK')
  155. uni.navigateBack({
  156. delta:2
  157. })
  158. }else{
  159. _this.toashMsg(res.message)
  160. }
  161. this.loading = false
  162. })
  163. },
  164. // 确认出库
  165. modalOutConfirm(){
  166. this.confirmOutModal = false
  167. this.chooseModal = true
  168. },
  169. closeChooseType(){
  170. this.confirmOutModal = false
  171. this.chooseModal = false
  172. },
  173. // 查询列表
  174. getPartList(){
  175. const _this = this
  176. shelfReplenishDetailList({ replenishBillSn: this.replenishBillSn }).then(res => {
  177. if(res.status == 200 && res.data){
  178. res.data.map(item =>{
  179. item.confirmQty = item.confirmQty ? Number(item.confirmQty) : 0
  180. })
  181. this.partList = res.data || []
  182. }else{
  183. this.partList = []
  184. }
  185. })
  186. },
  187. // 扫码结果
  188. scanResult(qrCode){
  189. const _this = this
  190. const pa = qrCode.split("&")
  191. console.log(qrCode,pa)
  192. shelfReplenishDetailOutScan({
  193. replenishBillSn: _this.replenishBillSn,
  194. shelfSn: pa[0],
  195. shelfPlaceSn: pa[3],
  196. productSn: pa[2]
  197. }).then(res => {
  198. console.log(res)
  199. if(res.status == 200){
  200. // 刷新列表
  201. _this.getPartList()
  202. if(res.data && res.data.totalQty && res.data.totalScanQty && res.data.totalQty == res.data.totalScanQty){
  203. _this.isAll = true
  204. _this.handleOutGoods()
  205. }else{
  206. this.contTitle = 1
  207. this.contModal = '是否继续扫码'
  208. this.confirmModal = true
  209. }
  210. }else{
  211. this.contTitle = 0
  212. this.contModal = res.message
  213. this.confirmModal = true
  214. }
  215. })
  216. },
  217. modalConfirm(){
  218. this.confirmModal = false
  219. this.scanCode()
  220. },
  221. init(){
  222. // const _this = this
  223. // // 初始化
  224. // this.barcode = plus.barcode.create('barcode', [], {
  225. // top:'0px',
  226. // left:'0px',
  227. // width: '100%',
  228. // height: '28%',
  229. // position: 'static',
  230. // frameColor: '#00aaff',
  231. // scanbarColor: '#00aaff'
  232. // })
  233. // // 设置高度
  234. // const query = uni.createSelectorQuery().in(this);
  235. // query.select('#barcode').boundingClientRect(data => {
  236. // this.barcode.setStyle({
  237. // height: data.height + 'px' // 调整扫码控件的位置
  238. // })
  239. // }).exec()
  240. // // 扫码成功后
  241. // this.barcode.onmarked = function(type, result) {
  242. // console.log(type,result)
  243. // _this.scanResult(result)
  244. // }
  245. // // 扫码识别出错
  246. // this.barcode.onerror = function(error){
  247. // console.log(error)
  248. // _this.toashMsg("条形码错误!")
  249. // _this.barcode.start()
  250. // }
  251. // const currentWebview = this.$scope.$getAppWebview()
  252. // currentWebview.append(this.barcode)
  253. // this.barcode.start()
  254. }
  255. }
  256. }
  257. </script>
  258. <style lang="less">
  259. page{
  260. height: 100vh;
  261. }
  262. .sendOutGoods-wrap{
  263. position: relative;
  264. width: 100%;
  265. height: 100%;
  266. overflow: hidden;
  267. padding-bottom: 136upx;
  268. .sendOutGoods-con{
  269. width: 100%;
  270. height: 100%;
  271. overflow: auto;
  272. display: flex;
  273. flex-direction: column;
  274. .barCode{
  275. height: 33%;
  276. margin-bottom: 10%;
  277. }
  278. .info-body{
  279. flex-flow: 1;
  280. overflow: auto;
  281. height: 100%;
  282. }
  283. .info{
  284. background-color: #FFFFFF;
  285. padding: 10rpx 30upx;
  286. font-size: 32rpx;
  287. margin-top: 20rpx;
  288. }
  289. }
  290. .sendOutGoods-footer{
  291. padding: 26upx 32upx 30upx;
  292. background-color: #fff;
  293. position: fixed;
  294. left: 0;
  295. bottom: 0;
  296. width: 100%;
  297. box-shadow: 3px 1px 7px #eee;
  298. }
  299. }
  300. </style>