<template>
|
<view>
|
<view class="itemstyle">
|
<uni-forms label-width="180">
|
<uni-forms-item label="托盘条码:">
|
<uni-easyinput type="text" placeholder="请扫描托盘条码" ref='midInput' :focus="!focus" v-model="barcode"
|
@input="barcodeInput" />
|
</uni-forms-item>
|
<uni-forms-item label="起点位置:">
|
<uni-easyinput type="text" placeholder="请扫描起点位置" ref='midInput' :focus="focusStart" v-model="address"
|
@input="addressInput" />
|
</uni-forms-item>
|
<uni-forms-item>
|
<!-- 空框回库按钮添加禁用状态和文字提示 -->
|
<button
|
@click="InEmpty"
|
type="primary"
|
size="default"
|
style="margin-top: 2%;"
|
:disabled="isSubmitting"
|
>
|
{{ isSubmitting ? '提交中...' : '空框回库' }}
|
</button>
|
</uni-forms-item>
|
</uni-forms>
|
</view>
|
<u-toast ref="uToast" />
|
</view>
|
</template>
|
|
<script>
|
const innerAudioContext = uni.createInnerAudioContext();
|
export default {
|
data() {
|
return {
|
focus: false,
|
focusStart: false,
|
barcode: "",
|
address: "",
|
WarehouseId: "",
|
// 新增:防重复点击状态变量
|
isSubmitting: false
|
}
|
},
|
onShow() {},
|
onLoad(res) {
|
|
},
|
methods: {
|
barcodeInput() {
|
this.$nextTick(function(x) {
|
if (this.barcode.length > 0) {
|
this.focus = true;
|
this.focusStart = true;
|
}
|
})
|
},
|
addressInput() {
|
this.$nextTick(function(x) {
|
if (this.address.length > 0) {
|
this.focusStart = false;
|
}
|
})
|
},
|
InEmpty() {
|
// 1. 前置校验
|
if (this.barcode == "") {
|
this.$refs.uToast.show({
|
title: "请扫描托盘码",
|
type: 'error'
|
})
|
return;
|
}
|
if (this.address == "") {
|
this.$refs.uToast.show({
|
title: "请扫描起点",
|
type: 'error'
|
})
|
return;
|
}
|
|
// 2. 防止重复点击:请求中则直接返回
|
if (this.isSubmitting) return;
|
|
// 3. 标记为请求中,禁用按钮
|
this.isSubmitting = true;
|
|
this.$u.post('/api/Task/EmptyBackTask?barcode=' + this.barcode + '&startPoint=' + this.address).then(
|
res => {
|
if (res.status) {
|
this.$refs.uToast.show({
|
title: "成功",
|
type: "success"
|
})
|
this.barcode = "";
|
this.address = "";
|
} else {
|
this.$refs.uToast.show({
|
title: res.message,
|
type: "error"
|
})
|
}
|
}).catch(err => {
|
// 捕获请求异常,提示错误
|
this.$refs.uToast.show({
|
title: err.message || "请求失败",
|
type: "error"
|
})
|
}).finally(() => {
|
// 4. 请求完成(成功/失败/异常)恢复按钮状态
|
this.isSubmitting = false;
|
})
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss">
|
@import '@/common/uni-ui.scss';
|
|
.content {
|
display: flex;
|
height: 150px;
|
}
|
|
.content-text {
|
font-size: 14px;
|
color: #666;
|
}
|
|
.itemstyle {
|
margin-top: 30px;
|
margin-left: 5%;
|
}
|
|
.headerstyle {
|
width: 90%;
|
}
|
</style>
|