schangxiang@126.com
2025-09-17 ff43ddf18764629ff875478e4e47a7281cbd230a
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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
<template>
    <view class="overflow">
        <!-- 顶部 -->
        <cu-custom bgColor="bg-white" :isBack="true">
            <block slot="backText"></block>
            <block slot="content">物料补打</block>
        </cu-custom>
        <!-- 遮挡层 -->
        <modal-code ref="resmodal" :rescode='rescode' :resmessage='resmessage' />
        <!-- 物料 -->
        <view>
            <u-form labelPosition="top" :model="warehouse" ref="warehouseRef">
                <u-row class="border_bottom margin_top10rpx padding10" style="background-color: #fff;">
                    <u-col span="12">
                        <u-form-item label="库位编号:" prop="wareLocationCode" required style="font-size: 16px;font-weight: bold;padding: 0 0 10rpx;">
                            <u-input v-model.trim="warehouse.wareLocationCode"   @confirm="materialBlur"  placeholder="请录入或扫码"
                            :focus="true"
                                 class="width padding_left25rpx"
                                style="margin-left: 30rpx;font-size: 36rpx;">
                            </u-input>
                        </u-form-item>
                    </u-col>
                    <!-- <u-col span="2">
                        <u-icon class="iconfont icon-saoma fontSize60rpx" ></u-icon>
                    </u-col> -->
                </u-row>
                <u-row class="border_bottom margin_top10rpx padding10" style="background-color: #fff;">
                    <u-col span="12">
                        <u-form-item label="物料编号:" prop="WarematerialCode"   style="font-size: 16px;font-weight: bold;padding: 0 0 10rpx;">
                            <u-input v-model.trim="warehouse.WarematerialCode"  @confirm="materialBlur" placeholder="请录入或扫码"
                            class="width padding_left25rpx"
                            style="margin-left: 30rpx;font-size: 36rpx;">
                            </u-input>
                        </u-form-item>
                    </u-col>
                    <!-- <u-col span="2">
                        <u-icon class="iconfont icon-saoma fontSize60rpx" ></u-icon> 
                    </u-col> -->
                </u-row>
            </u-form>
            <view style="margin-bottom: 180rpx;" v-show="singlist.length > 0">
                <view v-for="(item, eindex) in singlist" :key="eindex">
                    <u-swipe-action :show="item.show" :index="eindex" @click="longpredel" @open="open" @close="close" :options="options">
                        <view class="title-wrap fontSize32rpx background_fff" :class="Number(item.uncollectedQuantity) > 0 ? 'bg_item' : '' " style="width: 100vw;">
                            <u-row>
                                <u-col span="12" class="flex" style="align-items: flex-start;">
                                    <view style="background-color: #f18202;color: #fff;border-radius: 50%;width: 20px;height: 20px;line-height: 20px;text-align: center;">
                                        {{eindex+1}}
                                    </view>
                                    <view class="color_f18202 padding_left10rpx" style="flex: 1;word-break: break-all;">
                                        {{item.wareMaterialCode}}--{{item.wareMaterialName}}
                                    </view>
                                </u-col>
                            </u-row>
                            <u-row>
                                <u-col span="7">
                                    <view class="" style="padding: 10rpx 0 10rpx 45rpx;color: #808080;">
                                        批次:{{item.itemBatchNo}}
                                    </view>
                                </u-col>
                                <u-col span="5">
                                    <view class="" style="padding: 10rpx 0 10rpx 45rpx;color: #808080;">
                                        库位编号:{{item.wareContainerCode}}
                                    </view>
                                </u-col>
                            </u-row>
                            <u-row>
                                <u-col span="7">
                                    <view class="" style="padding: 10rpx 0 10rpx 45rpx;color: #808080;">
                                        SAP位置:{{item.sap_Location}}
                                    </view>
                                </u-col>
                                <u-col span="5">
                                    <view class="" style="padding: 10rpx 0 10rpx 45rpx;color: #808080;">
                                        数量:{{item.quantity}}
                                    </view>
                                </u-col>
                            </u-row>
                        </view>
                    </u-swipe-action>
                </view>
            </view>
 
            <u-popup v-model="detailshow" border-radius="14" @close="detailshow=false" mode="bottom" v-if="!printflag">
                <!-- <view class="pop "> -->
                <h2 class="text_align_center padding_bottom18 padding15">物料信息</h2>
                <view class="line flex justify-between">
                    <text class="text-gray">打印张数</text>
                    <text>
                        <u-input v-model.trim="contLabel"   placeholder="请输入打印张数"
                                 class="width"
                                 @focus="contLabel=''"
                                style="font-size: 36rpx;text-align: right;">
                            </u-input>
                    </text>
                </view>
                <view class="line flex justify-between">
                    <text class="text-gray">打印物料数量</text>
                    <text>
                        <u-input v-model.trim="ermNum"   placeholder="请输入打印物料数量"
                                 class="width"
                                 @focus="ermNum=''"
                                style="font-size: 36rpx;text-align: right;">
                            </u-input>
                    </text>
                </view>
                <view class="line flex justify-between">
                    <text class="text-gray">本次物料总数</text>
                    <text>{{materlist.quantity}}</text>
                </view>
                <view class="line flex justify-between">
                    <text class="text-gray">PO/行号</text>
                    <text>{{materlist.purchaseNo}}/{{materlist.lineNumber}}</text>
                </view>
                <view class="line flex justify-between">
                    <text class="text-gray">供应商</text>
                    <text>{{materlist.supplierNo}}{{materlist.supplierName}}</text>
                </view>
                 <view class="line flex justify-between">
                    <text class="text-gray">物料编号</text>
                    <text>{{materlist.wareMaterialCode}}</text>
                </view>
                <view class="line flex justify-between">
                    <text class="text-gray">物料名称</text>
                    <text>{{materlist.wareMaterialName}}</text>
                </view>
                <!-- </view> -->
                <view class="margin_top140rpx">
                    <!-- <button-modal :subShow='true' garmenTitle='打印' @submit='init'  /> -->
                    <button-modal :cleaningShow='true' allTitle='蓝牙打印' cleaningTitle='斑马打印' @allsubmit="init(1)" @submit='init(2)'/>
                </view>
            </u-popup>
 
        </view>
    </view>
</template>
 
<script>
    import ButtonModal from '@/components/buttonModal.vue'
    import ModalCode from '@/components/ModalCode.vue'
    import BluePrint from '@/pages/print/bluePrint.js'
    import {addPrintRecord,getMerterialBaseKuwei} from '@/api/print.js'
    import printComp from '@/mixins/printPoLabel.js'
    import printBanma from '@/mixins/printBanma.js'
 
    export default {
        mixins: [printComp,printBanma],
 
        data() {
            return {
                rescode: 0,
                resmessage: "",
                singlist: [], //物料详情
                warehouse: {
                    wareLocationCode: '',
                    WarematerialCode:'',
                    PageSize: 1000,
                    PageNo: 1,
                    PurchaseNo:''
                },
                warehouseRules: {
                    wareLocationCode: [{required: true,message: '单号不能为空',trigger: 'blur'}],
                    // WarematerialCode: [{required: true,message: '物料编号不能为空',trigger: 'blur'}]
                },
                options: [{
                        text: '打印',
                        style: {
                            backgroundColor: '#fc9f35'
                        }
                    }
                ],
                addForm: { //打印记录
                    code: '',
                    name: '',
                    batchNo: '',
                    specificationModel: ''
                },
                contLabel:1, //打印张数
                ermNum:'',
                detailshow: false,
                timer:null,
                materlist:{},
                printflag:false
            };
        },
        components: {
            ButtonModal,
            ModalCode
        },
        onReady() {
            this.$refs.warehouseRef.setRules(this.warehouseRules)
        },
        methods: {
            //获取print date print time
            getCurrentDate() {
                let date = new Date();
                let year = date.getFullYear(); //年
                let month = date.getMonth() + 1; //月
                month = month >= 10 ? month : '0' + month;
                let day = date.getDate(); //日
                day = day >= 10 ? day : '0' + day;
                let hour = date.getHours() //时
                hour = hour >= 10 ? hour : '0' + hour;
                let min = date.getMinutes(); //分
                min = min >= 10 ? min : '0' + min;
                let second = date.getSeconds(); //秒
                second = second >= 10 ? second : '0' + second;
                return {
                    date: `${day}.${month}.${year}`,
                    time: `${hour}:${min}:${second}`,
                    formate:`${year}/${month}/${day}`
                }
            },
            //打印
            init(param) {
                const arr = ['warematerialCode','batchNo','uncollectedQuantity','supplier'];
                Object.keys(this.materlist).forEach(item => {
                    if(arr.includes(item)) {
                        if(!this.materlist[item]) {
                            this.rescode = 400
                            this.resmessage = `${item}为空,不能继续打印`
                            this.$refs.resmodal.show = true
                            return 
                        }
                    }
                })
                // if(this.materlist.uncollectedQuantity<=0){
                //     this.detailshow = false
                //     this.rescode = 400
                //     this.resmessage = `数量需大于0`
                //     this.$refs.resmodal.show = true
                //     return
                // }
                if(!this.contLabel || !this.ermNum){
                    uni.showToast({
                        title: '数量不能为空且大于0',
                        icon: 'none'
                    })
                    return
                }
                // if(this.ermNum > this.materlist.uncollectedQuantity){
                //     uni.showToast({
                //         title: '打印数量大于本次数量',
                //         icon: 'none'
                //     })
                //     return
                // }
                // 没有供应商字段 supplier
                if(param==1){
                    this.printComp('REPRINT')
                }else{
                    this.printBanma('REPRINT')
                }
            },
            //获取物料记录
            materialBlur() {
                this.$refs.warehouseRef.validate(valid => {
                    if (valid) {
                        // this.warehouse
                        getMerterialBaseKuwei({
                            'wareLocationCode':this.warehouse.wareLocationCode,
                            'wareMaterialCode':this.warehouse.WarematerialCode,
 
                        }).then(res => {
                            const result = res.data.rows;
                            if(result.length == 0) {
                                this.rescode = 400;
                                this.resmessage = "此物料无物料记录"
                                this.$refs.resmodal.show = true
                            }
                            this.singlist = result;
                        })
                    }
                })
            },
            //删除详情
            longpredel(index, eindex) {
                this.singlist[index].cardNum = true
                this.printflag = false
                if (eindex == 1) {
                    this.singlist.splice(index, 1)
                } else {
                    this.materlist = this.singlist[index]
                    this.detailshow = true
                }
            },
            // 如果打开一个的时候,不需要关闭其他,则无需实现本方法
            open(index) {
                this.singlist[index].show = true;
                this.singlist.map((val, idx) => {
                    if (index != idx) this.singlist[idx].show = false;
                })
            },
            close(index) {
                // this.singlist[index].show = false;
                // this.singlist[index].cardNum = false;
                // this.$forceUpdate()
            },
            beforeDestroy() {
                // 销毁定时器
                if(this.timer){
                    clearTimeout(this.timer)
                    this.timer = null
                }
                
            }
        }
    }
</script>
 
<style lang="scss">
.bg_item {
    background: #FFEBCD !important;
}
</style>