|
|
@@ -0,0 +1,223 @@
|
|
|
+
|
|
|
+<template>
|
|
|
+ <div class="box-return">
|
|
|
+ <van-nav-bar
|
|
|
+ title="容器-绑定/解绑" left-arrow fixed placeholder @click-left="goBack" @click-right="onConfirm()">
|
|
|
+ <template #left>
|
|
|
+ <van-icon name="arrow-left" size="25" />
|
|
|
+ <div style="color: #fff">返回</div>
|
|
|
+ </template>
|
|
|
+ <template #right>
|
|
|
+ <div style="color: #fff">确认</div>
|
|
|
+ </template>
|
|
|
+ </van-nav-bar>
|
|
|
+ <div class="box-return-content">
|
|
|
+ <div class="content-tips">
|
|
|
+ <div style="flex: 1"><van-notice-bar left-icon="volume-o">{{ tips }}</van-notice-bar></div>
|
|
|
+ </div>
|
|
|
+ <van-tabs v-model:active="active" type="card" @change="activeChange">
|
|
|
+ <van-tab title="绑定" name="1"></van-tab>
|
|
|
+ <van-tab title="解绑" name="2" ></van-tab>
|
|
|
+ </van-tabs>
|
|
|
+ <div class="content-code">
|
|
|
+ <div class="barcode-input" v-if="active==1">
|
|
|
+ <van-search
|
|
|
+ ref="boxRef"
|
|
|
+ v-model.lazy="locationNo"
|
|
|
+ placeholder="请扫描库位号"
|
|
|
+ @search="_handlerScan(locationNo)"
|
|
|
+ label="库位号:"
|
|
|
+ left-icon=""
|
|
|
+ :class="[scanType===1?'search-input-barcode':'','van-hairline--bottom']"
|
|
|
+ @focus="scanType=1"
|
|
|
+ autocomplete="off"
|
|
|
+ >
|
|
|
+ </van-search>
|
|
|
+ </div>
|
|
|
+ <div class="barcode-input">
|
|
|
+ <van-search
|
|
|
+ v-model.lazy="containerNo"
|
|
|
+ placeholder="请扫描容器号"
|
|
|
+ @search="_handlerScan(containerNo)"
|
|
|
+ label="容器号:"
|
|
|
+ left-icon=""
|
|
|
+ :class="[scanType===2?'search-input-barcode':'','van-hairline--bottom']"
|
|
|
+ @focus="scanType=2"
|
|
|
+ autocomplete="off"
|
|
|
+ >
|
|
|
+ </van-search>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script setup lang="ts">
|
|
|
+import { onMounted, onUnmounted, ref } from 'vue'
|
|
|
+import { getHeader, goBack, scanError, scanSuccess } from '@/utils/android'
|
|
|
+import { closeListener, openListener, scanInit } from '@/utils/keydownListener'
|
|
|
+import { barcodeToUpperCase } from '@/utils/dataType'
|
|
|
+import { showConfirmDialog, showNotify } from 'vant'
|
|
|
+import { useStore } from '@/store/modules/user'
|
|
|
+import { closeLoading, showLoading } from '@/utils/loading'
|
|
|
+import { bindContainerLocation, unbindContainerLocation } from '@/api/container'
|
|
|
+const tips=ref('请扫描库位号')
|
|
|
+const scanType = ref(1)
|
|
|
+const locationNo=ref('')
|
|
|
+const containerNo=ref('')
|
|
|
+try {
|
|
|
+ getHeader()
|
|
|
+} catch (error) {
|
|
|
+}
|
|
|
+// 页面初始化
|
|
|
+onMounted(() => {
|
|
|
+ openListener()
|
|
|
+ scanInit(_handlerScan)
|
|
|
+})
|
|
|
+const store = useStore()
|
|
|
+const warehouse = store.warehouse
|
|
|
+const active=ref('1')
|
|
|
+const activeChange=(value)=>{
|
|
|
+ scanType.value=Number(value)
|
|
|
+ locationNo.value=''
|
|
|
+ tips.value=active.value=='1'?'请扫描库位号':'请扫描容器号'
|
|
|
+}
|
|
|
+// 扫描条码监听
|
|
|
+const _handlerScan = (code) => {
|
|
|
+ if(!code) return
|
|
|
+ if (scanType.value == 1) {
|
|
|
+ // const regex = /^HK\d{6}$/;
|
|
|
+ // if(regex.test(barcodeToUpperCase(code))){
|
|
|
+ locationNo.value = barcodeToUpperCase(code)
|
|
|
+ scanType.value=2
|
|
|
+ tips.value='请扫描库位号'
|
|
|
+ // }else {
|
|
|
+ // tips.value=`${code}:料箱条码不匹配`
|
|
|
+ // scanError()
|
|
|
+ // showNotify({ type: 'danger', duration: 3000, message:`${code}:料箱条码不匹配` })
|
|
|
+ // locationNo.value=''
|
|
|
+ // }
|
|
|
+ }else if(scanType.value == 2){
|
|
|
+ if(code){
|
|
|
+ containerNo.value = barcodeToUpperCase(code)
|
|
|
+ onConfirm()
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+const onConfirm=()=>{
|
|
|
+ if(!locationNo.value && active.value!=2){
|
|
|
+ tips.value='请先扫描库位号'
|
|
|
+ scanType.value=1
|
|
|
+ showNotify({ type: 'danger', duration: 3000, message:'请先扫描库位号' })
|
|
|
+ scanError()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(!containerNo.value){
|
|
|
+ tips.value='请先扫描容器号'
|
|
|
+ scanType.value=2
|
|
|
+ showNotify({ type: 'danger', duration: 3000, message:'请先扫描容器号' })
|
|
|
+ scanError()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const message=active.value==1?'您正在进行绑定是否继续':'您正在进行解绑是否继续'
|
|
|
+ showConfirmDialog({
|
|
|
+ title: '温馨提示',
|
|
|
+ message
|
|
|
+ }).then(() => {
|
|
|
+ if(active.value==1){
|
|
|
+ _bindContainerLocation()
|
|
|
+ }else {
|
|
|
+ _unbindContainerLocation()
|
|
|
+ }
|
|
|
+ }).catch(() => {})
|
|
|
+}
|
|
|
+const _bindContainerLocation=()=>{
|
|
|
+ const data={
|
|
|
+ warehouseId:warehouse,
|
|
|
+ dataList:[
|
|
|
+ {
|
|
|
+ containerCode:containerNo.value,
|
|
|
+ locationId:locationNo.value,
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ showLoading()
|
|
|
+ bindContainerLocation(data).then(res=>{
|
|
|
+ if(res.data){
|
|
|
+ tips.value='请继续扫描库位号'
|
|
|
+ scanType.value=1
|
|
|
+ locationNo.value=''
|
|
|
+ containerNo.value=''
|
|
|
+ showNotify({ type: 'success', duration: 3000, message:'容器绑定成功,请继续扫描库位号' })
|
|
|
+ scanSuccess()
|
|
|
+ }
|
|
|
+ }).catch(err=>{
|
|
|
+ tips.value=err.message
|
|
|
+ containerNo.value=''
|
|
|
+ scanError()
|
|
|
+ }).finally(()=>{
|
|
|
+ closeLoading()
|
|
|
+ })
|
|
|
+}
|
|
|
+const _unbindContainerLocation=()=>{
|
|
|
+ const params={
|
|
|
+ warehouseId:warehouse,
|
|
|
+ containerCode:containerNo.value,
|
|
|
+ }
|
|
|
+ showLoading()
|
|
|
+ unbindContainerLocation(params).then(res=>{
|
|
|
+ if(res.data){
|
|
|
+ tips.value='请继续扫描容器'
|
|
|
+ scanType.value=1
|
|
|
+ containerNo.value=''
|
|
|
+ showNotify({ type: 'success', duration: 3000, message:'容器解绑成功,请继续扫描容器号' })
|
|
|
+ scanSuccess()
|
|
|
+ }
|
|
|
+ }).catch(err=>{
|
|
|
+ tips.value=err.message
|
|
|
+ containerNo.value=''
|
|
|
+ scanError()
|
|
|
+ }).finally(()=>{
|
|
|
+ closeLoading()
|
|
|
+ })
|
|
|
+}
|
|
|
+onUnmounted(() => {
|
|
|
+ closeListener()
|
|
|
+})
|
|
|
+// window.onRefresh = loadData
|
|
|
+</script>
|
|
|
+<style scoped lang="sass">
|
|
|
+.box-return
|
|
|
+ .box-return-content
|
|
|
+ .content-code
|
|
|
+ text-align: left
|
|
|
+ background: #FFFFFF
|
|
|
+
|
|
|
+ .barcode-input
|
|
|
+ ::v-deep(.van-search)
|
|
|
+ padding: 0
|
|
|
+ height: 60px
|
|
|
+
|
|
|
+
|
|
|
+ ::v-deep(.van-search__field)
|
|
|
+ border-bottom: 2px solid #ffffff
|
|
|
+
|
|
|
+ ::v-deep(.van-search__content)
|
|
|
+ background: #fff
|
|
|
+ align-items: center
|
|
|
+
|
|
|
+ ::v-deep(.van-field__control)
|
|
|
+ font-size: 15px
|
|
|
+ font-weight: bold
|
|
|
+
|
|
|
+
|
|
|
+ ::v-deep(.van-search__label)
|
|
|
+ font-size: 15px
|
|
|
+ font-weight: bold
|
|
|
+
|
|
|
+ .search-input-barcode
|
|
|
+ ::v-deep(.van-search__field)
|
|
|
+ border-bottom: 2px solid #0077ff
|
|
|
+ z-index: 2
|
|
|
+ line-height: 58px
|
|
|
+ height: 60px
|
|
|
+</style>
|