wankeda
2025-06-24 6cc35000a6e138cfad96e7b02f8aeddcdb4ba6bf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<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>