<template>
|
<view>
|
<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem">
|
</uni-segmented-control>
|
<view class="content">
|
<view v-if="current === 0" class="headerstyle">
|
<view class="itemstyle">
|
<uni-forms label-width="120">
|
<uni-forms-item label="第一起点缓存架地址">
|
<uni-easyinput
|
type="text"
|
v-model="sourceAddress"
|
placeholder="请扫瞄起点地址"
|
ref='firstInput'
|
:focus="focusState === 'first'"
|
@confirm="jumpToSecond"
|
@input="checkFirstInput"
|
/>
|
</uni-forms-item>
|
<uni-forms-item label="第二起点缓存架地址">
|
<uni-easyinput
|
type="text"
|
v-model="sourceAddress1"
|
placeholder="请扫瞄起点地址"
|
ref='secondInput'
|
:focus="focusState === 'second'"
|
@confirm="jumpToThird"
|
@input="checkSecondInput"
|
/>
|
</uni-forms-item>
|
<uni-forms-item label="终点烘烤机上料地址">
|
<uni-easyinput
|
type="text"
|
v-model="targetAddress"
|
placeholder="请扫描终点地址"
|
ref='thirdInput'
|
:focus="focusState === 'third'"
|
@confirm="handleSubmit"
|
/>
|
</uni-forms-item>
|
<button @click="inbound" type="primary" size="default" style="margin-top: 2%;">搬运确认</button>
|
</uni-forms-item>
|
</uni-forms>
|
</view>
|
</view>
|
</view>
|
<u-toast ref="uToast" />
|
</view>
|
</template>
|
|
<script>
|
const innerAudioContext = uni.createInnerAudioContext();
|
export default {
|
data() {
|
return {
|
items: ['输送线搬运'],
|
current: 0,
|
label: "",
|
focus: false,
|
addressFocus: false,
|
sourceAddress: "",
|
sourceAddress1: "",
|
focusState: 'first',
|
targetAddress: ""
|
}
|
},
|
mounted() {
|
// 页面加载后自动聚焦第一个输入框
|
this.focusState = 'first';
|
},
|
methods: {
|
voiceSpeech(src) {
|
innerAudioContext.src = src; // '../../static/success.mp3';
|
innerAudioContext.play();
|
},
|
// 检查第一个输入框
|
checkFirstInput(value) {
|
if(value && value.trim().length > 0) {
|
this.jumpToSecond();
|
}
|
},
|
|
// 跳转到第二个输入框
|
jumpToSecond() {
|
this.focusState = 'second';
|
// 确保DOM更新后执行聚焦
|
this.$nextTick(() => {
|
this.$refs.secondInput.focus();
|
});
|
},
|
|
// 检查第二个输入框
|
checkSecondInput(value) {
|
if(value && value.trim().length > 0) {
|
this.jumpToThird();
|
}
|
},
|
|
// 跳转到第三个输入框
|
jumpToThird() {
|
this.focusState = 'third';
|
this.$nextTick(() => {
|
this.$refs.thirdInput.focus();
|
});
|
},
|
onClickItem(e) {
|
this.focus = false;
|
this.addressFocus = false;
|
if (this.current !== e.currentIndex) {
|
this.current = e.currentIndex;
|
if (this.current == 2) {
|
this.getData();
|
}
|
}
|
},
|
inbound() {
|
// 提取输入框的值
|
const sourceAddress = this.sourceAddress;
|
const sourceAddress1 = this.sourceAddress1;
|
const targetAddress = this.targetAddress;
|
if (sourceAddress == "") {
|
this.$t.message.toast('请扫描起点位置');
|
return;
|
}
|
if (sourceAddress1 == "") {
|
this.$t.message.toast('请选择起点位置');
|
return;
|
}
|
if (targetAddress == "") {
|
this.$t.message.toast('请扫描终点位置');
|
return;
|
}
|
var PostData = {
|
MainData: {
|
"sourceAddress": this.sourceAddress,
|
"sourceAddress1": this.sourceAddress1,
|
"targetAddress": this.targetAddress,
|
}
|
}
|
// console.log(Exception);
|
this.$u.post('/api/PDA/OutBoundTasks', PostData).then(res => {
|
this.$t.message.closeLoading();
|
if (res.code == 200) {
|
this.$t.message.toast('呼叫成功');
|
this.sourceAddress = "";
|
this.sourceAddress1 = "";
|
this.targetAddress = "";
|
// this.$refs.popup.close();
|
// this.submit();
|
} else {
|
this.$t.message.toast(res.message);
|
}
|
}).catch(err => {
|
this.$refs.uToast.show({
|
title: err.message,
|
type: "error"
|
})
|
})
|
},
|
|
inputChangebarcode() {
|
this.addressFocus = false;
|
this.$nextTick(function(x) {
|
if (this.sourceAddress != '') {
|
this.addressFocus = true;
|
}
|
})
|
},
|
}
|
}
|
</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>
|