123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385 |
- <template>
- <view class="orderScanCode-digitalShel flex flex_column">
- <view class="info-body">
- <view class="flex align-center orderTj" v-if="info">
- <view>
- <view class="redText">{{ info.totalQty }}</view>
- <view>总数量</view>
- </view>
- <view>
- <view>{{ info.confirmQty }}</view>
- <view>已扫码</view>
- </view>
- </view>
- <view class="info partList" v-if="partList.length">
- <view class="infoList">
- <view class="title">配件列表</view>
- <view>
- {{ partList.length }}款,共
- <text class="redText">{{ totalNums }}</text>
- 件
- </view>
- </view>
- <view v-for="item in partList" :key="item.productSn" class="flex align-center item-list">
- <view><u-image :src="item.images" border-radius="16" width="130" height="130" bg-color="#EBEBEB"></u-image></view>
- <view>
- <view class="item-name">
- <text>{{ item.productName }}</text>
- </view>
- <view class="item-nums">
- <text>{{ item.productCode }}</text>
- </view>
- <view class="item-head">
- <view>
- 数量:
- <text class="redText">{{ item.totalQty }}</text>
- 已扫:
- <text>{{ item.confirmQty }}</text>
- </view>
- <text class="item-no">{{ item.shelfPlaceCode }}</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="footer flex align-center" v-if="info">
- <u-button v-if="!hasScanFinish" :throttle-time="100" @click="scanCode" :style="{ background: '#1283d4', color: '#fff' }" shape="circle" type="info">
- <u-icon name="scan" color="#fff" size="32"></u-icon>
- 点击扫码
- </u-button>
- <u-button v-else :throttle-time="100" @click="outShelfOrder" :style="{ background: '#1283d4', color: '#fff' }" shape="circle" type="info">
- 确认取货
- </u-button>
- </view>
- </view>
- </template>
- <script>
- import { findBySnShelfOrder, outShelfOrder, scanConfirmShelfOrder } from '@/api/shelf.js'
- import { clzConfirm, urlToObj } from '@/libs/tools.js'
- export default {
- data() {
- return {
- barcode:null,
- shelfOrderSn: null,
- info: null,
- partList: [],
- mpaasScanModule: null
- }
- },
- computed: {
- totalNums(){
- let ret = 0
- this.partList.map(item => {
- ret += item.totalQty
- })
- return ret
- },
- hasScanFinish(){
- return this.info.totalQty == this.info.confirmQty
- }
- },
- onReady() {
- // 初始化摄像头
- this.init()
- },
- onLoad(options) {
- this.shelfOrderSn = options.shelfOrderSn
- this.getDetail(0)
- },
- methods: {
- // 扫码
- scanCode(){
- // this.mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
- // this.mpaasScanModule.mpaasScan({
- // // 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
- // 'scanType': ['qrCode','barCode'],
- // // 是否隐藏相册,默认false不隐藏
- // 'hideAlbum': false
- // },
- // (ret) => {
- // // 返回值中,resp_code 表示返回结果值,10:用户取消,11:其他错误,1000:成功
- // // 返回值中,resp_message 表示返回结果信息
- // // 返回值中,resp_result 表示扫码结果,只有成功才会有返回
- // if(ret.resp_code == '1000'){
- // this.scanResult(ret.resp_result)
- // }
- // })
- this.mpaasScanModule = uni.requireNativePlugin("wss-scan")
- this.mpaasScanModule.scan(
- {
- "scanType":["QRCODE","CODE93","CODE128","DATAMATRIX"],
- "scanMode":"Customized",
- "scanStyle":{"scanFrameSizePlus":{"width":200,"height":200},"scanFrameSize":200,"scanLight":"visible","scanText":"对准物品二维码","scanTitle":"扫码取货"}
- },
- (result) => {
- console.log(result)
- if(result.scanStatus == 1){
- this.scanResult(result.scanValue)
- }
- })
- },
- // 获取详情
- getDetail(type){
- findBySnShelfOrder({sn: this.shelfOrderSn}).then(res => {
- console.log(res,'++++++++')
- if(res.status == 200){
- this.info = res.data
- this.partList = res.data.shelfOrderDetailList
- // 此单已全部扫码,是否确认取货
- if(this.hasScanFinish){
- clzConfirm({
- title: '扫码成功',
- content: '此单已全部扫码,是否确认取货?',
- success: (ret) => {
- if(ret.confirm||ret.index==0){
- this.outShelfOrder()
- }
- }
- })
- }else{
- if(type){
- this.confimInfo('是否继续扫码',1)
- }
- }
- }
- })
- },
- // 确认取货
- outShelfOrder(){
- if(this.hasScanFinish){
- outShelfOrder({sn:this.shelfOrderSn}).then(res => {
- console.log(res,'确认取货')
- if(res.status == 200){
- uni.$emit("refreshOrder")
- uni.navigateBack()
- }
- })
- }else{
- this.message("请先扫码取货")
- }
- },
- confimInfo(msg,type){
- const _this = this
- clzConfirm({
- title: type?'扫码成功':'扫码失败',
- content: msg,
- confirmText:'继续扫码',
- success: (ret) => {
- if(ret.index == 0){
- _this.scanCode()
- }
- }
- })
- },
- // 扫码结果
- scanResult(qrCode){
- const _this = this
- console.log(qrCode)
- const params = {
- shelfSn: qrCode.split("&")[0],
- productCode: qrCode.split("&")[1]
- }
- console.log(params)
- if(params.shelfSn != this.info.shelfSn){
- _this.confimInfo('该配件不属于此数字货架',0)
- return
- }
- scanConfirmShelfOrder({
- shelfOrderSn: _this.shelfOrderSn,
- shelfOrderDetailList:[
- {
- "productCode": params.productCode,
- "confirmQty": 1
- }
- ]
- }).then(res => {
- if(res.status == 200){
- // 刷新列表
- _this.getDetail(1)
- }else{
- _this.confimInfo(res.message,0)
- }
- })
- },
- message(title){
- uni.showToast({
- icon:'none',
- title: title
- })
- },
- init(){
- // const _this = this
- // // 初始化
- // this.barcode = plus.barcode.create('barcode', [plus.barcode.QR], {
- // top:'0px',
- // left:'0px',
- // width: '100%',
- // height: '35%',
- // 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.message("二维码错误!")
- // _this.barcode.start()
- // }
- // const currentWebview = this.$mp.page.$getAppWebview();
- // currentWebview.append(this.barcode);
- // this.barcode.start();
- }
- }
- }
- </script>
- <style lang="less">
- page {
- height: 100vh;
- }
- .orderScanCode-digitalShel {
- height: 100%;
- .barCode {
- background-color: #333;
- height: 20%;
- display: flex;
- align-items: center;
- justify-content: center;
- color: #fff;
- }
- > view {
- padding: 20rpx;
- }
- .info-body {
- flex-flow: 1;
- overflow: auto;
- height: 100%;
- }
- .redText {
- color: #fb1e1e;
- }
- .orderTj {
- padding: 20rpx;
- background-color: #fff;
- > view {
- text-align: center;
- border-right: 2rpx solid #eee;
- width: 50%;
- color: #666e75;
- .redText {
- color: #fb1e1e;
- }
- &:last-child {
- border: 0;
- }
- > view {
- color: #666e75;
- &:first-child {
- font-size: 56rpx;
- }
- }
- }
- border-radius: 20rpx;
- }
- .info {
- background-color: #ffffff;
- padding: 10rpx 30upx;
- font-size: 32rpx;
- margin-top: 20rpx;
- .infoList {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 20rpx 0;
- border-bottom: 2rpx solid #f2f2f2;
- .title {
- font-weight: bold;
- }
- > text {
- &:first-child {
- color: #666e75;
- }
- }
- }
- .item-list {
- border-bottom: 2rpx solid #f2f2f2;
- &:last-child {
- border: none;
- }
- > view {
- padding: 20rpx 0;
- &:first-child {
- margin-right: 20rpx;
- margin-top: 18rpx;
- }
- &:last-child {
- flex-grow: 1;
- }
- }
- .item-name {
- word-wrap: break-word;
- font-size: 32rpx;
- color: #333;
- font-weight: bold;
- margin-top: 10rpx;
- }
- .item-nums {
- padding: 10rpx 0;
- text {
- font-size: 32rpx;
- color: #222222;
- }
- }
- .item-head {
- display: flex;
- align-items: center;
- justify-content: space-between;
- color: #666;
- > view {
- &:first-child {
- font-size: 28rpx;
- text {
- margin-right: 30rpx;
- }
- }
- }
- .item-no {
- font-size: 28rpx;
- background: rgba(3, 54, 146, 0.15);
- color: #033692;
- border-radius: 100rpx;
- padding: 2rpx 30rpx;
- margin-right: 20rpx;
- display: block;
- }
- }
- }
- }
- .footer {
- padding: 20upx 40upx;
- background: #ffffff;
- uni-button {
- &:after {
- border: 0;
- }
- width: 90%;
- color: #585858;
- font-size: 32rpx;
- }
- }
- }
- </style>
|