wangxinhui
2025-01-11 e9f11eec6cbb720dcb456edaf5af6db715b131e9
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
273
274
275
<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 style="margin-left: 2%;margin-top: 20px;" label-width="180">
                        <uni-forms-item :label="label" style="margin-top: -20px;"></uni-forms-item>
                        <!-- <uni-forms-item label="单据类型:生产领料单" style="margin-top: -20px;"></uni-forms-item> -->
                        <uni-forms-item label="物料码:" style="margin-top: -20px;">
                            <uni-easyinput type="text" placeholder="请扫描物料码" ref='midInput' :focus="focus"
                                v-model="innerCode" @input="snInput" />
                        </uni-forms-item>
                        <!-- <uni-forms-item :label="PurchaseOrderNo" style="margin-top: -20px;"></uni-forms-item>
                        <uni-forms-item :label="matCode" style="margin-top: -20px;"></uni-forms-item>
                        <uni-forms-item :label="LotNo" style="margin-top: -20px;"></uni-forms-item>
                        <uni-forms-item :label="ProductionDate" style="margin-top: -20px;"></uni-forms-item>
                        <uni-forms-item :label="EffectiveDate" style="margin-top: -20px;"></uni-forms-item>
                        <uni-forms-item :label="orderQty" style="margin-top: -20px;"></uni-forms-item>
                        <uni-forms-item :label="remaindQty" style="margin-top: -20px;"> -->
                        <uni-list>
                            <uni-list-item direction="column" v-for="item in matInfos" :key="item.palletCode">
                                <template v-slot:body>
                                    <view class="uni-content">
                                        <view>单据编号:{{item.orderNo}}</view>
                                        <view>托盘编号:{{item.palletCode}}</view>
                                        <view>物料批次:{{item.batchNo}}</view>
                                        <view>物料编码:{{item.materielCode}}</view>
                                        <view>物料名称:{{item.materielName}}</view>
                                        <view>单据数量:{{item.orderQuantity}}</view>
                                        <view>原始库存:{{item.originalQuantity}}</view>
                                        <view>分配库存:{{item.assignQuantity}}</view>
                                        <view>剩余库存:{{item.originalQuantity-item.assignQuantity}}</view>
                                    </view>
                                </template>
                            </uni-list-item>
                        </uni-list>
                        <uni-forms-item label="出库数量:" style="margin-top: -20px;">
                            <uni-easyinput type="text" placeholder="请输入出库数量" ref='midInput' :focus="focus"
                                v-model="outQty" />
                        </uni-forms-item>
                        </uni-forms-item>
                    </uni-forms>
                    <uni-forms-item>
                        <button @click="submit" type="primary" size="default" style="margin-top: 2%;">确认出库</button>
                    </uni-forms-item>
                </view>
            </view>
            <view v-if="current === 1" class="headerstyle">
                <view class="itemstyle">
                    <uni-list :border="true">
                        <uni-list-item direction="column" v-for="(item,index) in orderInfo" :key="index">
                            <template v-slot:body>
                                <view class="uni-list-box">
                                    <view class="uni-content">
                                        <view>单据号:{{orderNo}}</view>
                                        <view>物料编码:{{item.materielCode}}</view>
                                        <view>物料名称:{{item.materielName}}</view>
                                        <view>数量:{{item.orderQuantity+item.unit}}</view>
                                        <view>出库数量:{{item.orderQuantity}}</view>
                                        <view>已出数量:{{item.overOutQuantity}}</view>
                                    </view>
                                </view>
                            </template>
                        </uni-list-item>
                    </uni-list>
                </view>
            </view>
        </view>
        <u-toast ref="uToast" />
    </view>
</template>
 
<script>
    const innerAudioContext = uni.createInnerAudioContext();
    export default {
        data() {
            return {
                items: ['物料信息', '单据信息'],
                current: 0,
                matTotal: [],
                matInfos: [],
                orderNo: "",
                label: "",
                outQty: "",
                orderInfo: [],
                focus: false,
                pkfocus: false,
                barcode: "",
                materSn: "",
                Initiallife: 1000,
                sns: [],
                pksns: [],
                addressFocus: false,
                inboundBarcode: "",
                address: "",
                check: true,
                value: "",
                matInfo: [],
                value2: "",
                matTotals: [],
                warehouseId: "",
                Test: false,
                Testlabel: "",
                Testplaceholder: "",
                Testcheck: false,
                pkmaterSn: "",
                pkmatInfos: []
            }
        },
        onShow() {},
        onLoad(res) {
            this.focus = false;
            this.addressFocus = false;
            this.orderNo = res.orderNo;
            this.warehouseId = res.warehouseId;
            this.label = "单据编号:" + this.orderNo;
            this.getData();
        },
        methods: {
            voiceSpeech(src) {
                innerAudioContext.src = src; // '../../static/success.mp3';
                innerAudioContext.play();
            },
            getData() {
                var postData = {
                    MainData: {
                        orderNo: this.orderNo
                    },
                }
                this.$u.post('/api/OutboundOrderDetail/GetOutboundOrderDetails', postData).then((res) => {
                    if (res.status) {
                        this.orderInfo = res.data;
                        if (this.orderInfo.length > 3) {
                            this.loadVisible = true;
                        }
                    }
                })
            },
            onClickItem(e) {
                this.focus = false;
                this.addressFocus = false;
                if (this.current !== e.currentIndex) {
                    this.current = e.currentIndex;
                    if (this.current == 2) {
                        this.getData();
                    }
                }
            },
            //扫码
            snInput() {
                this.$nextTick(() => {
                    if (this.materSn != "") {
                        this.focus = false;
                        var matSn = this.materSn;
                        setTimeout(() => {
                            this.materSn = "";
                        }, 10);
                        this.$u.post('/api/MaterielInfo/CodeAnalysis?serNum=' + matSn, {}).then((res) => {
                            this.Testcheck = false;
                            if (res.status) {
                                this.sns.push(res.data.serialNumber);
 
                                this.matInfos.push(res.data);
                                if (res.message) {
                                    this.$refs.uToast.show({
                                        title: res.message,
                                        type: "error"
                                    })
                                    setTimeout(() => {
                                        this.voiceSpeech('../../static/fail.mp3');
                                    }, 100);
                                    return;
                                }
                                setTimeout(() => {
                                    this.voiceSpeech('../../static/success.mp3');
                                }, 100);
                            } else {
                                this.$refs.uToast.show({
                                    title: res.message,
                                    type: "error"
                                })
                                setTimeout(() => {
                                    this.voiceSpeech('../../static/fail.mp3');
                                }, 100);
                            }
                        })
                    }
                })
            },
            deleteList(res) {
                this.matInfos.splice(res, 1);
                this.sns.splice(res, 1);
            },
            submit() {
                if (this.barcode == "") {
                    this.$refs.uToast.show({
                        title: "请扫描托盘条码",
                        type: 'error'
                    })
                    return;
                }
                if (this.matInfos.length == 0) {
                    this.$refs.uToast.show({
                        title: "请扫描内箱标签",
                        type: 'error'
                    })
                    return;
                }
                if (this.Test) {
                    if (!this.Testcheck) {
                        this.Testcheck = true;
                        this.$refs.uToast.show({
                            title: "请确认初始寿命",
                            type: 'error'
                        })
                        return;
                    }
                }
                this.$u.post('/api/InboundOrder/MaterielGroup', {
                    MainData: {
                        "palletCode": this.barcode,
                        "orderNo": this.orderNo,
                        "initiallife": this.Initiallife,
                        // "isFull": this.check
                        "warehouseId": this.warehouseId
                    },
                    DelKeys: this.sns
                }).then(res => {
                    this.Testcheck = false;
                    if (res.status) {
                        this.$refs.uToast.show({
                            title: "出库成功",
                            type: "success"
                        })
                        this.focus = false;
                        this.barcode = "";
                        this.matInfos = [];
                        this.sns = [];
                        this.matTotal = [];
                    } else {
                        this.$refs.uToast.show({
                            title: res.message,
                            type: "error"
                        })
                    }
                })
            }
        }
    }
</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>