kyy
6 天以前 dee7ef800f4a695c6c9782ebfe3b40d3d789f457
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
var vm = new Vue({
    el: '#app',
    data: function () {
        return {
            // 加载状态
            isLoading: false,
            
            // 用户信息
            userInfo: {
                loginGuid: '',
                loginAccount: '',
            },
 
            // 库位相关
            sectionCode: "",        // 库位编码
            depotData: {            // 仓库数据
                depotName: "",
                depotCode: ""
            },
 
            // 表单数据
            formData: {
                barcode: "",        // 物料条码
                itemNo: "",         // 物料编码
                itemName: "",       // 物料名称
                itemModel: "",      // 物料规格
                sumQuantity: 0,     // 已入总数
                quantity: 0,        // 到货单数量
                cbillNo: "",        // 到货单号
                paperBillNo:"",     // 到货单号 +送货单号
                dhdQty: 0,          // 到货单数量
                tmsyQty: 0          // 剩余未扫条码张数
  
            },
            // 标签页数据 - 剩余未扫
            unscannedList: [],           
            // 标签页数据 - 剩余未扫(其他物料汇总)
            otherUnscannedList: [],           
            // 标签页数据 - 到货单扫码进度
            scanProgressList: []
        }
    },
    
    mounted() {
        var that = this;
        // 获取登录信息
        this.userInfo = {
            loginGuid: this.GetLoginInfor().loginGuid,
            loginAccount: this.GetLoginInfor().loginAccount,
        };
    },
    
    methods: {
        /**
         * 获取库位信息
         * 触发时机:扫描库位编码后按回车键
         */
        getModel() {
            var that = this;
            
            that.$refs.barcode.focus();
        },
        
        /**
         * 扫描物料条码入库
         * 触发时机:扫描物料条码后按回车键
         */
        getScan() {
            var that = this;
            
            // 输入验证
            if (!that.formData.barcode || that.formData.barcode.trim() === "") {
                that.$toast.fail("物料条码不能为空!");
                that.$playSound('error');
                that.$refs.barcode.focus();
                return;
            }
            
            // if (!that.sectionCode || that.sectionCode.trim() === "") {
            //     that.$toast.fail("库位编码不能为空!");
            //     that.$playSound('error');
            //     that.$refs.sectionCode.focus();
            //     return;
            // }
            
            that.isLoading = true;
            
            that.AxiosHttp("post", 'MesInvItemInCDetails/WcsmBar', {
                sectionCode: that.sectionCode.trim(),
                userName: that.userInfo.loginAccount,
                barcode: that.formData.barcode.trim(),
            }, false)
            .then(function (res) {
                var json = res;
                if (json.status == 0) {                  
                    // 清空条码输入框
 
                    var dab001 = that.formData.barcode
                    that.formData.barcode = "";
                    
                    // 重新聚焦到条码输入框(支持连续扫码)
                    that.$refs.barcode.focus();
         
                    // 提示成功
                    that.$notify({ type: 'success', message: json.message || '扫描成功' });
                    that.$playSound('success');
 
                    //根据条码获取信息
                    that.selectByBarcode(dab001);
                }
                else {
                    // 失败处理
                    that.$toast.fail(json.message || "扫描失败!");
                    that.$playSound('error');
                    
                    // 清空条码输入框
                    that.formData.barcode = "";
                    
                    // 重新聚焦到条码输入框
                    that.$refs.barcode.focus();
                }
                that.isLoading = false;
            })
            .catch(function (error) {
                // 异常处理
                that.isLoading = false;
                that.$toast.fail("网络错误,请重试!");
                that.$playSound('error');
                console.error("getScan error:", error);
                
                // 清空条码输入框
                that.formData.barcode = "";
                
                // 重新聚焦到条码输入框
                that.$refs.barcode.focus();
            });
        },
        
         /**
          * 清除库位编码
          */
         clearSectionCode() {
             this.sectionCode = "";
             this.depotData = {
                 depotName: "",
                 depotCode: ""
             };
             this.$refs.sectionCode.focus();
         },
 
         /// <summary>
         /// 根据条码查询相关信息
         /// </summary>
         selectByBarcode(dab001) {
             var that = this;
 
             if (!dab001 || dab001.length <= 0) {
                 that.$toast.fail("条码不能为空!");
                 that.$playSound('error');
                 that.$refs.barcode.focus();
                 return;
             }
 
             that.isLoading = true;
             that.AxiosHttp("post", 'MesInvItemInCDetails/WcsmDetail', {
                 barcode: dab001
             }, false)
                 .then(function (res) {
                     var json = res;
                     if (json.status == 0) {
                         // 标签页数据赋值
                         that.unscannedList = json.data.tbBillList.unscannedList;
                         that.otherUnscannedList = json.data.tbBillList.otherUnscannedList;
                         that.scanProgressList = json.data.tbBillList.scanProgressList;
                                         
                         // 表单数据赋值(从daaInfo获取)
                         var daaInfo = json.data.tbBillList.daaInfo;
                         if (daaInfo && daaInfo.length > 0) {
                             var info = daaInfo[0];
                             that.formData.itemNo = info.itemNo || '';              // 物料编码
                             that.formData.itemName = info.itemName || '';              // 物料编码
                             that.formData.itemModel = info.itemModel || '';              // 物料编码
                             that.formData.cbillNo = info.cbillNo || '';            // 到货单号
                             that.formData.paperBillNo = info.paperBillNo || '';    // 到货单号+送货单号
                             that.formData.quantity = info.quantity || 0;           // 当前条码数量
                             that.formData.dhdQty = info.dhdQty || 0;               // 到货单数量
                             that.formData.sumQuantity = info.sumQuantity || 0;     // 已入总数
                             that.formData.tmsyQty = info.tmsyQty || 0;             // 剩余未扫条码张数
                         }
                                         
                         that.$refs.barcode.focus();
                     }
                     else {
                         that.$toast.fail(json.message);
                         that.$playSound('error');
                         that.$refs.barcode.focus();
                     }
                     that.isLoading = false;
                 })
                 .catch(function (error) {
                     that.isLoading = false;
                     that.$toast.fail("网络错误,请重试!");
                     that.$playSound('error');
                 });
         },
         
         /**
          * 返回上一页
          */
         GoBack() {
             window.history.back();
         }
     }
 });