123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- <template>
- <view class="sendOutGoods-wrap">
- <view class="barCode" id="barcode"></view>
- <view class="info-body">
- <view class="info partList">
- <!-- 补货产品 -->
- <partList :list="partList" title="补货产品" model="view" fromPage="sendOutGoods" ref="partList" noDataText="暂无产品"></partList>
- </view>
- </view>
- <!-- 确认弹框 -->
- <common-modal v-if="confirmModal" :openModal="confirmModal" title="扫码失败" content="确认对该数字货架进行补货吗?" confirmText="好的" :isCancel="false" @confirm="modalConfirm" @close="confirmModal=false" />
- </view>
- </template>
- <script>
- import partList from '@/pages/common/partList.vue'
- import commonModal from '@/pages/common/commonModal.vue'
- import { shelfReplenishDetailList, shelfReplenishQrCode } from '@/api/shelfReplenish'
- export default {
- components: { partList, commonModal },
- data() {
- return {
- barcode:null,
- replenishBillSn: null,
- partList: [],
- confirmModal: false
- }
- },
- onReady() {
- // 初始化摄像头
- // this.init()
- },
- onLoad(options) {
- this.replenishBillSn = options.replenishBillSn
- this.getPartList()
- },
- methods: {
- // 查询列表
- getPartList(){
- const _this = this
- shelfReplenishDetailList({ replenishBillSn: this.replenishBillSn }).then(res => {
- if(res.status == 200 && res.data){
- res.data.map(item =>{
- item.confirmQty = item.confirmQty ? Number(item.confirmQty) : 0
- })
- this.partList = res.data || []
- }else{
- this.partList = []
- }
- })
- },
- // 扫码结果
- scanResult(qrCode){
- const _this = this
- shelfReplenishQrCode({
- qrCode: qrCode,
- replenishBillSn: this.replenishBillSn
- }).then(res => {
- if(res.status == 200){
- _this.toashMsg("扫码成功!")
- uni.navigateTo({ url: "/pages/common/printTag/printTag?sn="+item.replenishBillSn })
- }else{
- this.confirmModal = true
- // clzConfirm({
- // title: '扫码失败',
- // content: res.message,
- // showCancel: false,
- // success: (ret) => {
- // _this.barcode.start()
- // }
- // })
- }
- })
- },
- modalConfirm(){
- this.confirmModal = false
- this.barcode.start()
- },
- init(){
- const _this = this
- // 初始化
- this.barcode = plus.barcode.create('barcode', [], {
- top:'0px',
- left:'0px',
- width: '100%',
- height: '28%',
- position: 'static',
- frameColor: '#00aaff',
- scanbarColor: '#00aaff'
- })
- // 设置高度
- const query = uni.createSelectorQuery().in(this);
- query.select('#barcode').boundingClientRect(data => {
- this.barcode.setStyle({
- height: data.height + 'px' // 调整扫码控件的位置
- })
- }).exec()
-
- // 扫码成功后
- this.barcode.onmarked = function(type, result) {
- _this.scanResult(result)
- }
- // 扫码识别出错
- this.barcode.onerror = function(error){
- console.log(error)
- _this.toashMsg("条形码错误!")
- _this.barcode.start()
- }
-
- const currentWebview = this.$mp.page.$getAppWebview()
- currentWebview.append(this.barcode)
- this.barcode.start()
- }
- }
- }
- </script>
- <style lang="less">
- page{
- height: 100vh;
- }
- .sendOutGoods-wrap{
- width: 100%;
- height: 100%;
- .barCode{
- height: 28%;
- }
- .info-body{
- flex-flow: 1;
- overflow: auto;
- height: 72%;
- }
- .info{
- background-color: #FFFFFF;
- padding: 10rpx 30upx;
- font-size: 32rpx;
- margin-top: 20rpx;
- }
- }
- </style>
|