kyy
2025-02-11 bb05da47c66341aa5d65c965528271d03f37a1e1
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
<template>
  <view>
    <view class="nav_item form-container">
      <form :modelValue="scanFormData">
        <view class="form-group">
          <label class="form-label">移入库位:</label>
         <input class="form-input" placeholder="请扫描库位" type="text"
                v-model="scanFormData.sectionCode"  :focus="focus1"  @confirm="checkKw"  @focus="getFocus(1)"/>
        </view>
        <view class="form-group">
          <label class="form-label">物料条码:</label>
          <input class="form-input" placeholder="请扫描物料条码" type="text"
                 v-model="scanFormData.barcode" :focus="focus2" @confirm="checkWl" @focus="getFocus(2)"/>
        </view>
        <view class="form-group">
          <label class="form-label">物料编码:</label>
          <input class="form-input" disabled="true" type="text" v-model="scanFormData.itemNo"/>
        </view>
        <view class="form-group">
          <label class="form-label">数量:</label>
          <input class="form-input" type="text" v-model="scanFormData.quantity"/>
        </view>
      </form>
    </view>
    <view class="text" v-if="Message">
      <text v-text="Message"></text>
    </view>
</view>
    
</template>
 
<script>
import {
  broadcastScan
} from '@/utils/scanCode.js';
 
export default {
  data() {
    return {
      focus1: true,
      focus2: false,
      scanFormData: {sectionCode:"",barcode:""},
      itemOutNoList: [],
      Message: '',
    }
  },
  methods: {
      // onLoad 是在页面加载时触发,用于页面的初始化操作,只执行一次
      onLoad() {
        // init传入一个回调函数做参数,在扫描时候会将数据传入此方法里,然后处理此方法的自定义业务逻辑
        broadcastScan.init(this.getScanCode);
        this.getFocus(1);
      },
      onUnload() {
        broadcastScan.stop();
      },
      // 在页面展示时触发,用于处理页面显示相关的逻辑,可能会多次执行,包括页面首次展示和从后台切换到前台时
      onShow() {
        broadcastScan.start();
      },
      onHide() {
        broadcastScan.stop();
      },
      // 自定义扫描的结果回调函数
      getScanCode(code) {
         let parseData = code.trim();
        if (this.focus2) {
          this.scanFormData.barcode = parseData;
          //库位检查
          this.checkWl();
        } else {
          this.scanFormData.sectionCode = parseData;
          //物料检查
          this.checkKw();
        }
      },
      // 主动触发扫描
      openScan() {
        broadcastScan.triggerScan();
      },
      //移动焦点
      getFocus(f) {
          switch(f){
              case 1:
              this.focus1 = true;
              this.focus2 = false;
              this.scanFormData.sectionCode = "";
              break;
              case 2:
              this.focus1 = false;
              this.focus2 = true;
              this.scanFormData.barcode = "";
              default:
              break;
          }
      },
      //检查库位
        checkKw() {
              var that=this;
              if (!this.scanFormData.barcode) {
              }
              let userName = this.$loginInfo.account;
              this.$post({
                url: "/MesDepotSections/ScanInDepotSectionsName",
                data: {
                  sectionCode:that.scanFormData.sectionCode,
                }
              }).then(res => {
                  that.getFocus(2);
              });    
          },
         //移位
        checkWl(){
                var that=this;
                let userName = this.$loginInfo.account;
                 that.$post({
                   url: "/MesInvItemMoves/ScanInBarcode",
                   data: {
                     userName: userName,
                     sectionCode:that.scanFormData.sectionCode,
                     barcode:that.scanFormData.barcode,
                   }
                 }).then(res => {
                     //待赋值
                      that.scanFormData.itemNo="";
                      that.scanFormData.quantity="";
                      that.getFocus(2);
                 });
            },
  }
}
</script>
 
<style>
.pdmg0{padding: 0px !important;margin: 0px !important;}
.form-group {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #c9c9c9;
}
 
.form-label {
  margin-bottom: 0;
  padding: 5px;
}
 
.form-input {
  flex: 1;
  margin-bottom: 0;
  padding: 5px;
}
 
.picker {
  flex: 1;
  margin-bottom: 0;
  padding: 5px;
  font-size: 12px;
}
 
.uni-form-item {
  display: flex;
  border-bottom: 1px solid #c9c9c9;
}
 
.edit {
  background-color: white;
}
 
/* 默认样式 */
.list-container {
  height: 60vh;
  /* 设置列表容器的高度为剩余空间,并减去表单容器的高度 */
  overflow-y: auto;
  /* 允许列表容器垂直滚动 */
  padding: 10px;
  /* 可选:添加一些内边距,使列表内容更美观 */
}
 
/* 在小屏幕设备上,重置高度为适应屏幕 */
@media (max-width: 768px) {
  .list-container {
    height: calc(100vh - 500px);
    /* 适当调整高度 */
  }
}
 
 
.form-container {
  padding: 10px;
  /* 可选:添加一些内边距,使表单内容更美观 */
}
 
.th {
  background-color: lightskyblue;
  color: #FFFFFF;
}
 
.text {
  background-color: #ffee6f;
}
 
.plus-button {
  line-height: 59px;
  font-size: 24px;
  cursor: pointer;
  z-index: 1000;
  margin-bottom: 10px;
}
 
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
}
 
.popup {
  background-color: #fff;
  padding: 20px;
  border: 1px solid #ccc;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  width: 68vw;
  /* 设置宽度为视口宽度的80% */
  height: 25vh;
  /* 设置高度为视口高度的80% */
}
 
.container {
  display: flex;
  flex-direction: column;
}
 
.tab-bar {
  display: flex;
  justify-content: space-around;
  background-color: #f5f5f5;
  padding: 10px;
  border-bottom: 1px solid #ccc;
}
 
.tab-item {
  flex: 1;
  text-align: center;
  padding: 10px;
  border-radius: 5px;
  background-color: #fff;
  color: #007aff;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.3s, color 0.3s;
}
 
.tab-item.active {
  background-color: #007aff;
  color: #fff;
  font-weight: bold;
}
 
.content {
  flex: 1;
  padding: 10px;
}
 
.tab-content {
  padding: 10px;
}
</style>