loulijun2021
2024-05-14 9e7bbd1a203c39c74b81624640a5ea8f6e247ba3
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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
<template>
    <view>
        <page-nav title="委外发料"></page-nav>
 
 
        <view v-show="topContent.length===0">
            <div class="sacnBody">
                <div class="scanImg" @click="topScanClick"></div>
                <div class="scanText">扫描任务条码</div>
            </div>
        </view>
 
        <view v-show="topContent.length!==0" class="mainContent">
            <u-gap height="10" bgColor="#eff0f1"></u-gap>
            <view class="head">
                <view class="head_block">
                    <view class="head_left">
                        <view class="head_bar"></view>
                        <view class="head_title" style="font-weight: bolder;">
                            发料信息
                        </view>
                    </view>
                </view>
 
                <view class="marginLeft20 marginRight20" style="height: 360rpx;" v-if="topContent.length!==0">
                    <view class="marginBottom20" style="display: flex;">
                        <!--  v-for="item in purchorderArr"  -->
                        <view class="flex_column titleFont">
                            <view>工单编号:</view>
                            <view>产品编码:</view>
                            <view>产品名称:</view>
                            <view>产品规格:</view>
                            <view>当前工序:</view>
                            <view>任务数量:</view>
                            <view>未发/已发:</view>
                        </view>
                        <view class="flex_column contentFont">
                            <view>{{topContent[0].wo_code}}</view>
                            <view>{{topContent[0].partnumber}}</view>
                            <view>{{topContent[0].partname}}</view>
                            <view>{{topContent[0].partspec?topContent[0].partspec:'/'}}</view>
                            <view>{{topContent[0].stepname}}</view>
                            <view>{{topContent[0].planqty}}</view>
                            <view>{{topContent[0].startqty+'/'+topContent[0].reportqty}}</view>
                        </view>
                    </view>
                </view>
 
            </view>
 
 
            <u-gap height="10" bgColor="#eff0f1"></u-gap>
            <view class="head">
                <view class="head_block" style="justify-content: flex-start;height: 70rpx;padding-bottom: 10rpx;">
                    <view class="head_left">
                        <view class="head_bar"></view>
                        <view class="head_title" style="font-weight: bolder;">
                            外协供方
                        </view>
                    </view>
                    <view style="margin-left: 20rpx;">
                        <view @click='WXSheetClick' class="custominputClass">
                            <view v-show='WXSheetValue===""' style="color: rgb(192, 196, 204);">请选择</view>
                            <view v-show='WXSheetValue!==""' class="ellipsis" style="width: 390rpx;">
                                {{WXSheetValue}}
                            </view>
                            <u-icon :name="!WXSheetShow?'arrow-down-fill':'arrow-up-fill'"></u-icon>
                        </view>
 
                    </view>
                </view>
            </view>
 
 
            <u-gap height="10" bgColor="#eff0f1"></u-gap>
            <view class="head">
                <view class="head_block" style="justify-content: flex-start;height: 70rpx;padding-bottom: 10rpx;">
                    <view class="head_left">
                        <view class="head_bar"></view>
                        <view class="head_title" style="font-weight: bolder;">
                            外协人员
                        </view>
                    </view>
                    <view style="margin-left: 20rpx;">
                        <view @click='userSheetClick' class="custominputClass">
                            <view v-show='userSheetValue===""' style="color: rgb(192, 196, 204);">请选择</view>
                            <view v-show='userSheetValue!==""' class="ellipsis" style="width: 390rpx;">
                                {{userSheetValue}}
                            </view>
                            <u-icon :name="!userSheetShow?'arrow-down-fill':'arrow-up-fill'"></u-icon>
                        </view>
 
                    </view>
                </view>
            </view>
 
            <u-gap height="10" bgColor="#eff0f1"></u-gap>
            <view class="head">
                <view class="head_block" style="justify-content: flex-start;height: 70rpx;padding-bottom: 10rpx;">
                    <view class="head_left">
                        <view class="head_bar"></view>
                        <view class="head_title" style="font-weight: bolder;">
                            发料数量
                        </view>
                    </view>
                    <view style="margin-left: 20rpx;">
                        <view class='inputClass'>
                            <u--input placeholder="请输入" border="surround" type='number' v-model="fqty">
                            </u--input>
                        </view>
 
                    </view>
                </view>
            </view>
 
 
 
            <u-picker v-if="topContent.length!==0" :show="WXSheetShow" :columns="WXColumns" :itemHeight='55'
                :closeOnClickOverlay='true' @close='WXSheetShow=false' @confirm='WXPickerConfirm'
                @cancel='WXSheetShow=false'>
            </u-picker>
 
 
            <u-picker v-if="topContent.length!==0" :show="userSheetShow" :columns="userColumns" :itemHeight='55'
                :closeOnClickOverlay='true' @close='userSheetShow=false' @confirm='userPickerConfirm'
                @cancel='userSheetShow=false'>
            </u-picker>
 
 
        </view>
 
        <u-button size="large" v-show="topContent.length!==0" :loading="isDisabledSubmitButton"
            loadingText="正在提交,请稍等..." type="primary" @click="submit" text="发料">
        </u-button>
 
 
        <!-- 悬浮球 -->
        <!--     <view v-show="topContent.length!==0&&!WXSheetShow&&!userSheetShow" @click="topScanClick">
            <drag-ball :x='$DeviceInformation.screenWidth*0.8' :y="$DeviceInformation.screenHeight*0.7"></drag-ball>
        </view> -->
 
        <!-- <scan-code></scan-code> -->
 
 
    </view>
</template>
 
 
<script>
    import {
        MesOrderStepStart,
        CustomerPermissions,
        PersonPermissions,
        SavaMesOrderStepOut
    } from '../../config/api.js';
    // import scanCode from '@/components/scan-code/scan-code.vue'
 
    export default {
        onLoad(option) {
 
        },
 
        onPullDownRefresh() {
            setTimeout(() => {
                this.init(() => {
                    uni.stopPullDownRefresh();
                })
            }, 1000);
        },
 
        data() {
            return {
                topRightMessageCount: '',
 
                isDisabledSubmitButton: false,
 
                topContent: [],
                // {
                // "wo_code": "MO-2023-06-0003_1",
                // "partnumber": "308",
                // "partname": "电池包",
                // "partspec": "",
                // "seq": "2",
                // "stepcode": "ZSStep03",
                // "stepname": "去毛刺",
                // "nextstepcode": "ZSStep06",
                // "nextstepname": "包装2",
                // "stepdesc": "",
                // "wkshopcode": "ZS001",
                // "wkshopname": "注塑车间",
                // "planqty": 50.00,
                // "startqty": 29.00,
                // "noreportqty": 29.00,
                // "reportqty": 21.00,
                // "noputqty": 0.0,
                // "list": null
                // }, //扫描任务条码所带出来的内容
 
                WXSheetValue: '',
                WXSheetShow: false, //上拉列表是否展开
                WXColumns: [],
                WXSheetList: [],
 
 
                userSheetValue: '',
                userSheetShow: false,
                userColumns: [],
                userSheetList: [],
 
                fqty: null,
 
 
 
 
            }
        },
        created() {
 
        },
        mounted() {
            this.init()
 
 
            // this.getMesOrderStepStart('MO-2023-09-0002_1;106')
 
            this.handleSelectAllApi()
 
 
        },
        methods: {
            init() {
                uni.stopPullDownRefresh();
            },
 
            async handleSelectAllApi() {
                await this.getCustomerPermissions()
                await this.getPersonPermissions()
            },
 
 
            async getPersonPermissions(val) {
                const data = {
                    usercode: val
                }
                const res = await PersonPermissions(this.global.formatData(data))
                this.userSheetList = res.data
                this.userColumns = [res.data.map(i => i.username)]
            },
 
            async getCustomerPermissions(val) {
                const data = {
                    orderstepqrcode: val
                }
                const res = await CustomerPermissions(this.global.formatData(data))
                this.WXSheetList = res.data
                this.WXColumns = [res.data.map(i => i.name)]
            },
 
            async getMesOrderStepStart(val) {
                const data = {
                    OperType: 'WX',
                    SelectType: 'OUT',
                    wocode: val ? val.split(';')[0] : '',
                    stepcode: val ? val.split(';')[1] : ''
                }
 
                const res = await MesOrderStepStart(this.global.formatData(data))
                console.log(res, 3)
 
                if (res.code === '200') {
                    this.WXSheetValue = ''
                    this.userSheetValue = ''
                    this.fqty = null
                    this.topContent = []
                    this.topContent.push(res.data)
                }
 
 
 
            },
 
            //  任务条码  的扫码框点击
            topScanClick() {
                let that = this;
 
                uni.scanCode({
                    onlyFromCamera: true,
                    // scanType: ['barCode', 'qrCode'],
                    scanType: ['qrCode'],
                    success: function(res) {
                        console.log('条码类型:' + res.scanType);
                        console.log('条码内容:' + res.result);
 
                        that.getMesOrderStepStart(res.result)
 
                    },
                    complete: function(res) {
 
                    },
                    fail: function(res) {
                        console.log('条码类型:' + res.scanType);
                        console.log('条码内容:' + res.result);
                    }
 
                });
            },
 
 
            WXSheetClick() {
                this.WXSheetShow = true
            },
 
            WXPickerConfirm(val) {
                this.WXSheetValue = val.value[0]
                this.WXSheetShow = false
            },
 
            userSheetClick() {
                this.userSheetShow = true
            },
 
            userPickerConfirm(val) {
                this.userSheetValue = val.value[0]
                this.userSheetShow = false
            },
 
 
            async submit() {
 
                if (!this.WXSheetValue) {
                    return uni.$u.toast('外协供方不能为空!')
                }
 
                if (!this.userSheetValue) {
                    return uni.$u.toast('外协人员不能为空!')
                }
 
                if (!this.fqty) {
                    return uni.$u.toast('发料数量不能为空!')
                }
 
                if (parseFloat(this.fqty) > parseFloat(this.topContent[0].startqty)) {
                    return uni.$u.toast('发料数量不能大于未发数量!')
                }
 
                // const header = {
                //     'Content-Type': 'application/x-www-form-urlencoded',
                //     'rediskey': uni.getStorageSync('rediskey'),
                //     'admin': uni.getStorageSync('usercode'),
                //     'username': encodeURIComponent(uni.getStorageSync('username')),
                //     'navTabId': uni.getStorageSync('usercode'),
                //     'userid': uni.getStorageSync('userid'),
                //     'guid': uni.getStorageSync('guid'),
                //     'usertype': 'APP'
                // }
 
                const data = {
                    mesordercode: this.topContent[0].wo_code, // 工单编号
                    partcode: this.topContent[0].partnumber, // 产品编码
                    stepseq: this.topContent[0].seq, // 工序序号    
                    stepcode: this.topContent[0].stepcode, // 工序编码
                    wxcode: this.WXSheetList.find(i => i.name === this.WXSheetValue).code, // 外协供应商编码
                    outuser: this.userSheetList.find(i => i.username === this.userSheetValue).usercode, // 发料人员
                    taskqty: this.topContent[0].planqty, // 任务数量
                    fqty: this.fqty // 发料数量
                }
 
                console.log(JSON.stringify(data), 6)
 
                this.isDisabledSubmitButton = true
                const res = await SavaMesOrderStepOut(data)
                if (res.code === '200') {
                    uni.$u.toast('发料成功!')
 
                    this.WXSheetValue = ''
                    this.userSheetValue = ''
                    this.fqty = null
                    this.topContent = []
 
                    this.isDisabledSubmitButton = false
                }
 
                // this.isDisabledSubmitButton = true
                // uni.uploadFile({
                //     url: this.$baseUrl + '/AppProductionManagement/SavaMesOrderStepOut',
                //     files: [{
                //         "uri": "/"
                //     }],
                //     header: header,
                //     formData: data,
                //     success: (res) => {
                //         uni.$u.toast('发料成功!')
 
                //         this.WXSheetValue = ''
                //         this.userSheetValue = ''
                //         this.fqty = null
                //         this.topContent = []
 
                //         this.isDisabledSubmitButton = false
                //     },
                //     fail(res) {
                //         uni.$u.toast('发料失败!')
                //         this.isDisabledSubmitButton = false
                //     },
                // })
 
 
 
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    @import url('@/style/global.css');
 
    ::v-deep .uicon-arrow-left>span {
        display: block;
    }
 
    .custominputClass {
        width: 412rpx;
        display: flex;
        justify-content: space-between;
        border: 3rpx #eff0f1 solid;
        border-radius: 10rpx;
        padding: 0 16rpx;
        line-height: 68rpx;
    }
</style>