<template>
|
<view>
|
<scroll-view scroll-y catch:touchmove="touchmove">
|
|
<!-- 站点编号 -->
|
<view class="square-2">
|
<view class="square-title">
|
<view class="title-sign"><view class="sign"></view></view>
|
<view class="title-text"><text>站点编号</text></view>
|
</view>
|
<view class="square-content">
|
<view class="content-combox">
|
<uni-combox
|
emptyTips="暂无数据"
|
:candidates="floorList"
|
v-model="staNo"
|
placeholder="站点编号">
|
</uni-combox>
|
</view>
|
</view>
|
</view>
|
|
<!-- 条码 -->
|
<view class="square-2">
|
<view class="square-title">
|
<view class="title-sign"><view class="sign"></view></view>
|
<view class="title-text"><text>条码值</text></view>
|
</view>
|
<view class="square-content">
|
<view class="content-input">
|
<input
|
ref="barcodeInput"
|
v-model="barcode"
|
type="text"
|
:focus="barcodeFocus"
|
placeholder="扫码 / 输入"
|
placeholder-style="line-height: 85rpx;"
|
@confirm="submit"
|
/>
|
</view>
|
</view>
|
</view>
|
|
</scroll-view>
|
|
<!-- 底部按钮 -->
|
<view class="footer flex justify-around">
|
<label class="label-btn flex justify-center align-center">
|
<button class="cu-btn" @click="reset">重置</button>
|
</label>
|
<label class="label-btn flex justify-center align-center">
|
<button class="cu-btn bg-blue" :disabled="submitting" @click="submit">
|
{{ submitting ? '提交中...' : '启动' }}
|
</button>
|
</label>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
export default {
|
data() {
|
return {
|
barcode: '',
|
staNo: '',
|
floorList: ['2102', '2105', '2112', '2115'],
|
|
apiUrl: 'http://10.10.10.235:9090/jshdwcs/open/hd/task/cs/barcode/default/v1',
|
|
// ✅ 防重复提交锁
|
submitting: false,
|
|
// ✅ 扫码框自动聚焦
|
barcodeFocus: true
|
}
|
},
|
|
mounted() {
|
this.refocus()
|
},
|
|
methods: {
|
// ✅ 强制重新聚焦扫码框
|
refocus() {
|
this.barcodeFocus = false
|
this.$nextTick(() => {
|
this.barcodeFocus = true
|
})
|
},
|
|
// ✅ 重置
|
reset() {
|
this.barcode = ''
|
this.refocus()
|
uni.vibrateShort()
|
},
|
|
// ✅ 提交(防重复 + 自动回焦)
|
submit() {
|
// 防重复点击
|
if (this.submitting) return
|
|
if (!this.barcode || !this.staNo) {
|
uni.showToast({
|
title: '请先选择站点并扫码',
|
icon: 'none',
|
position: 'top'
|
})
|
return
|
}
|
|
this.submitting = true
|
uni.showLoading({ title: '提交中...' })
|
|
uni.request({
|
url: this.apiUrl,
|
method: 'POST',
|
data: {
|
barcode: this.barcode,
|
siteId: this.staNo
|
},
|
header: {
|
'token': uni.getStorageSync('token'),
|
'appkey': 'ea1f0459efc02a79f046f982767939ae'
|
},
|
|
success: res => {
|
uni.hideLoading()
|
|
if (res.data.code === 200) {
|
uni.showToast({
|
title: '成功',
|
icon: 'success',
|
position: 'bottom'
|
})
|
|
// ✅ 成功 → 清空条码 → 自动回焦
|
this.barcode = ''
|
this.refocus()
|
} else {
|
uni.showToast({
|
title: res.data.msg || '失败',
|
icon: 'none',
|
position: 'top'
|
})
|
}
|
},
|
|
fail: () => {
|
uni.hideLoading()
|
uni.showToast({
|
title: '网络异常',
|
icon: 'none',
|
position: 'top'
|
})
|
},
|
|
complete: () => {
|
// ✅ 成功 / 失败 都释放锁
|
this.submitting = false
|
}
|
})
|
}
|
}
|
}
|
</script>
|
|
<style>
|
/* ✅ 完整保留你原来的 style,不做任何破坏 */
|
|
.item-text {
|
display: inline-block;
|
width: 500rpx;
|
line-height: 55rpx;
|
font-size: 30rpx;
|
}
|
|
.item-sign {
|
float: left;
|
width: 2em;
|
height: 50rpx;
|
}
|
|
.revise-box {
|
position: relative;
|
width: 500rpx;
|
height: 470rpx;
|
border-radius: 15px;
|
background-color: #FFFFFF;
|
}
|
|
.revise-box-top {
|
width: 400rpx;
|
height: 120rpx;
|
border-radius: 25px;
|
}
|
|
.changeBox {
|
width: 400rpx;
|
height: 100rpx;
|
}
|
|
.num-box {
|
margin-left: 100rpx;
|
}
|
|
.revise-box-buttom {
|
margin-left: 190rpx;
|
}
|
|
.pak-seach-box {
|
background-color: #FFFFFF;
|
margin: 15rpx 15rpx 0rpx 15rpx;
|
width: 96%;
|
height: 150rpx;
|
border-radius: 20rpx;
|
}
|
|
.box-top {
|
display: block;
|
height: 60rpx;
|
width: 720rpx;
|
}
|
|
.color-block-blue {
|
background-color: #1E9FFF;
|
display: inline-block;
|
float: left;
|
margin: 15rpx 15rpx 0 15rpx;
|
width: 12rpx;
|
height: 40rpx;
|
border: 5rpx solid #1E9FFF;
|
border-radius: 20rpx;
|
}
|
|
.title {
|
display: inline-block;
|
float: left;
|
font-size: 34rpx;
|
font-weight: 700;
|
height: 50rpx;
|
line-height: 50rpx;
|
margin-top: 10rpx;
|
}
|
|
.box-buttom {
|
display: inline-block;
|
background-color: #ededed;
|
width: 65%;
|
height: 60rpx;
|
border-radius: 20rpx;
|
margin: 15rpx 15rpx 0rpx 15rpx;
|
}
|
|
.box-buttom input {
|
width: 75%;
|
float: left;
|
margin: 8rpx 10rpx 0rpx 25rpx;
|
}
|
|
.box-buttom .search-icon {
|
width: 60rpx;
|
height: 60rpx;
|
float: right;
|
margin-top: 5rpx;
|
margin-right: 10rpx;
|
}
|
|
.pak-data-box {
|
background-color: #F1F1F1;
|
margin: 15rpx;
|
width: 96%;
|
height: 70rpx;
|
border-radius: 20rpx;
|
}
|
|
.bg-false {
|
background-color: #FFFFFF;
|
}
|
|
.bg-true {
|
background-color: #ebebeb;
|
}
|
|
.data-list {
|
border-bottom: 1px solid #d8d8d8;
|
margin: 15rpx;
|
border-radius: 20rpx;
|
}
|
|
.footer {
|
position: fixed;
|
bottom: 0;
|
left: 0;
|
right: 0;
|
display: flex;
|
justify-content: space-around;
|
background: #fff;
|
padding: 20rpx;
|
}
|
|
.bg-blue {
|
background-color: #1E9FFF;
|
color: #fff;
|
}
|
</style>
|