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
var vm = new Vue({
    el: '#app',
    data: function () {
        return {
            isLoading: false,
            modeInfo: { deptSectionCode: "", rkDate: "" }, // 入库日期默认空
            scanInfo: { barcode: "", itemNo: "", itemName: "", itemModel: "", depotCode: "", depotName: "", sectionCode: "", sectionName: "", oldqty: "", quantity: "" },
            barInfoList: [],
            selectKW: "",
            tbKWInfo: [],
            tbItemInfo: [],
            actions: [],
            show: false,
            zkChecked: false,
            showDatePicker: false,
            tempDate: new Date(), // 日期选择器默认今天
            itemNo: { barCode: "", itemNo: "" }, // 入库日期默认空
        }
    },
    mounted() {
        var that = this;
        this.userInfo = {
            loginGuid: this.GetLoginInfor().loginGuid,
            loginAccount: this.GetLoginInfor().loginAccount,
        };
    },
    watch: {
        showDatePicker(val) {
            if (val) {
                // 弹窗打开时,重置为当天
                this.tempDate = new Date();
            }
        }
    },
    methods: {
        formatDate(date) {
            const d = new Date(date);
            console.log(d);
            return `${d.getFullYear()}-${(d.getMonth() + 1).toString().padStart(2, '0')}-${d.getDate().toString().padStart(2, '0')}`;
        },
        onDateConfirm(date) {
            this.modeInfo.rkDate = this.formatDate(date);
            this.showDatePicker = false;
            this.getBarInfoListModel();
        },
        getBarInfoListModel() {
            var that = this;
            that.isLoading = true;
            that.AxiosHttp("post", 'MesKwcx/GetBarInfoList', {
                deptSectionCode: that.modeInfo.deptSectionCode,
                rkDate: that.modeInfo.rkDate,
                zkChecked: that.zkChecked
            }, false)
                .then(function (res) {
                    var json = res;
                    if (json.status == 0) {
                        that.barInfoList = json.data.tbBarInfoList;
                    } else {
                        that.barInfoList = [];
                        that.modeInfo.deptSectionCode = '';
                        that.$toast.fail(json.message);
                        that.$playSound('error');
                    }
                    that.isLoading = false;
                })
                .catch(function () {
                    that.isLoading = false;
                    that.$toast.fail("网络错误,请重试!");
                    that.$playSound('error');
                });
        },
        getScan() {
            var that = this;
            that.isLoading = true;
            that.AxiosHttp("post", 'MesKwcx/GetBarInfo', {
                barcode: that.scanInfo.barcode
            }, false)
                .then(function (res) {
                    var json = res;
                    if (json.status == 0) {
                        Object.assign(that.scanInfo, json.data.tbBarInfo);
                    } else {
                        that.scanInfo.barcode = '';
                        that.$toast.fail(json.message);
                        that.$playSound('error');
                    }
                    that.isLoading = false;
                })
                .catch(function () {
                    that.isLoading = false;
                    that.$toast.fail("网络错误,请重试!");
                    that.$playSound('error');
                });
        },
        getKWInfo() {
            var that = this;
            that.show = true;
            that.actions = [];
            that.isLoading = true;
            that.AxiosHttp("post", 'MesKwcx/GetKWList', {
                selectKW: that.selectKW
            }, false)
                .then(function (res) {
                    var json = res;
                    if (json.status == 0 && json.data.tbKWList.length > 0) {
                        that.actions = json.data.tbKWList.map(item => ({ name: item.code }));
                    } else {
                        that.$toast.fail("没有可用的数据");
                        that.$playSound('error');
                    }
                    that.isLoading = false;
                })
                .catch(function () {
                    that.isLoading = false;
                    that.$toast.fail("网络错误,请重试!");
                    that.$playSound('error');
                });
        },
        onSelect(item) {
            var that = this;
            that.show = false;
            that.isLoading = true;
            that.selectKW = item.name;
            that.AxiosHttp("post", 'MesKwcx/GetKWInfo', {
                code: item.name
            }, false)
                .then(function (res) {
                    var json = res;
                    
                    if (json.status == 0) {
                        that.tbKWInfo = json.data.tbKWInfo;
                    } else {
                        that.tbKWInfo = [];
                        that.$toast.fail(json.message);
                        that.$playSound('error');
                    }
                    that.isLoading = false;
                })
                .catch(function () {
                    that.isLoading = false;
                    that.$toast.fail("网络错误,请重试!");
                    that.$playSound('error');
                });
        },
        getItemInfoListModel() {
            var that = this;
            that.isLoading = true;
            that.AxiosHttp("post", 'MesKwcx/GetItemInfoList', {
                barCode: that.itemNo.barCode,
                itemNo: that.itemNo.itemNo
            }, false)
                .then(function (res) {
                    var json = res;
                    if (json.status == 0) {
                        that.tbItemInfo = json.data.tbItemInfo;
                    } else {
                        that.tbItemInfo = [];
                        that.itemNo.barCode = '';
                        that.itemNo.itemNo = '';
                        that.$toast.fail(json.message);
                        that.$playSound('error');
                    }
                    that.isLoading = false;
                })
                .catch(function () {
                    that.isLoading = false;
                    that.$toast.fail("网络错误,请重试!");
                    //that.$playSound('error');
                });
        },
    }
});