sendOutGoods.vue 8.6 KB

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