chen.lin
昨天 748c5e49a29920ca0a7f9b7d0845c93c81085046
快速拣货-
1个文件已修改
60 ■■■■ 已修改文件
pages/outbound/fastPicking.vue 60 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/outbound/fastPicking.vue
@@ -3,9 +3,8 @@
        <form>
            <view class="cu-form-group" v-show="!isconfirm">
                <view class="title">容器码</view>
                <input placeholder="请扫描容器码" v-model="barcode"  focus></input>
                <input placeholder="请扫描容器码" v-model="barcode"  focus @input="onBarcodeInput"></input>
                <text class='cuIcon-close text-gray margin-right-xs' v-show="barcode!==''" @click="clearCode"></text>
                <text class='cuIcon-search text-blue' @click="search"></text>
            </view>
        </form>
@@ -109,7 +108,9 @@
                        backgroundColor: '#42b983',                        
                        borderColor: '#42b983'
                },
                repeatClick: false
                repeatClick: false,
                searchTimer: null, // 防抖定时器
                isClearing: false // 标记是否正在清空
            }
        },
        computed: {
@@ -118,8 +119,30 @@
                return this.list.reduce((acc, row) => +row.receiptQty + acc, 0)
            }
        },
        watch: {
            // 监听容器码变化,自动查询
            barcode(newVal, oldVal) {
                // 如果正在清空,不触发查询
                if (this.isClearing) {
                    return;
                }
                // 清除之前的定时器
                if (this.searchTimer) {
                    clearTimeout(this.searchTimer);
                }
                // 如果容器码不为空,延迟300ms后自动查询(防抖处理)
                if (newVal && newVal.trim() !== '') {
                    this.searchTimer = setTimeout(() => {
                        this.search();
                    }, 300);
                } else {
                    // 容器码为空时,清空列表
                    this.list = [];
                }
            }
        },
        mounted() {
            this.search()
            // 移除自动查询,改为监听输入自动查询
        },
        methods: {
            clickTaskItem(index){                
@@ -134,9 +157,12 @@
                this.typeSelect = e.value
                this.search()
            },
            onBarcodeInput(e) {
                // 输入事件由watch处理,这里可以添加额外逻辑
            },
            async search() {
                this.list = []
                if(this.barcode === '' || this.barcode ===null){
                if(this.barcode === '' || this.barcode ===null || this.barcode.trim() === ''){
                    return ;
                }
                const {
@@ -198,6 +224,7 @@
                        title: msg,
                        icon: "success"
                    })
                    // 确认后清空,支持再次扫描
                    that.clear()
                    
                }else if(code == 401){
@@ -218,14 +245,25 @@
            
            },
            clearCode() {
                this.barcode = ''
                this.isClearing = true;
                this.barcode = '';
                this.list = [];
                // 清空后重置标记,允许下次扫描
                this.$nextTick(() => {
                    this.isClearing = false;
                });
            },
            remove(index) {
                this.list.splice(index, 1);
            },
            clear() {
                this.list = []
                this.barcode = ''
                this.isClearing = true;
                this.list = [];
                this.barcode = '';
                // 清空后重置标记,允许下次扫描
                this.$nextTick(() => {
                    this.isClearing = false;
                });
            },
            next() {
                if (this.list.length) {
@@ -285,6 +323,12 @@
            DateChange(e, item) {
                item.prodTime = e.detail.value
            }
        },
        beforeDestroy() {
            // 组件销毁前清除定时器
            if (this.searchTimer) {
                clearTimeout(this.searchTimer);
            }
        }
    }
</script>