展杰
2024-07-03 e6044ce7c9513de2733ffbfb76cc953bcf7bd5d3
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
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
<template>
    <view>
        <view>
            <uni-card>
                <view :class="new Date().getTime()-new Date(item.BEGIN_TIME).getTime()>7200000?'red':''">
                    <u-row customStyle="margin-bottom: 10px">
                        <u-col span="2">
                            <label>检验单号:</label>
                        </u-col>
                        <u-col span="4">
                            <label>{{item.TASK_NO}}</label>
                        </u-col>
                    </u-row>
                    <u-row customStyle="margin-bottom: 10px" v-if="item.LOT_NO">
                        <u-col span="2">
                            <label>销售单号:</label>
                        </u-col>
                        <u-col span="4">
                            <label>{{item.LOT_NO}}</label>
                        </u-col>
                    </u-row>
                    <u-row customStyle="margin-bottom: 10px">
                        <u-col span="2">
                            <label>工单数量:</label>
                        </u-col>
                        <u-col span="4">
                            <label>{{item.DAA008}}</label>
                        </u-col>
                    </u-row>
                    <u-row customStyle="margin-bottom: 10px">
                        <u-col span="2">
                            <label>机台 / 产线:</label>
                        </u-col>
                        <u-col span="4">
                            <label>{{item.MACHINE_NO}}</label>
                        </u-col>
                    </u-row>
                    <u-row customStyle="margin-bottom: 10px" v-if="item.PROC_NAME">
                        <u-col span="2">
                            <label>工序名称:</label>
                        </u-col>
                        <u-col span="4">
                            <label>{{item.PROC_NAME}}</label>
                        </u-col>
                    </u-row>
                    <u-row customStyle="margin-bottom: 10px">
                        <u-col span="2">
                            <label>产品名称:</label>
                        </u-col>
                        <u-col span="4">
                            <label>{{item.ITEM_NO}} | {{item.ITEM_NAME}}</label>
                        </u-col>
                    </u-row>
                    <u-row customStyle="margin-bottom: 10px">
                        <u-col span="2">
                            <label>图号颜色:</label>
                        </u-col>
                        <u-col>
                            <label>{{item.ENGINEERING_NO}} / {{item.COLOR_NAME}}</label>
                        </u-col>
                    </u-row>
                    <u-row customStyle="margin-bottom: 10px">
                        <u-col span="2">
                            <label>规格材质:</label>
                        </u-col>
                        <u-col>
                            <label>{{item.MODEL}} / {{item.MATERIAL}}</label>
                        </u-col>
                    </u-row>
                    <u-row customStyle="margin-bottom: 10px">
                        <u-col span="2">
                            <label>检验员/检验类型:</label>
                        </u-col>
                        <u-col span="4">
                            <label>{{item.OPERATE_MAN}} / {{item.FTYPE}}</label>
                        </u-col>
                    </u-row>
                    <u-button text="生成检验资料" type="primary" :plain="true"
                        style="width: 200px;height: 100px;position: absolute;top: 30%;right: 10%;"
                        @click="generate()"></u-button>
                </view>
 
                <view class="container">
                    <button @click="fetchDrawingNumber">查看图号</button>
 
                    
                </view>
 
            </uni-card>
        </view>
 
        <view>
            <uni-table border stripe emptyText="暂无更多数据" style="margin-left: 5px;margin-right: 5px;">
                <!-- 表头行 -->
                <uni-tr>
                    <uni-th align="center" width="60">检验项目</uni-th>
                    <uni-th align="center" width="60">检验工具</uni-th>
                    <uni-th align="center" width="140">规格</uni-th>
                    <uni-th align="center" width="80" v-if="item.DEPARTMENT_NO=='HS0202'">组件名称</uni-th>
                    <uni-th align="center" width="40">数量</uni-th>
                    <uni-th align="center" width="60">上限值</uni-th>
                    <uni-th align="center" width="60">下限值</uni-th>
                    <uni-th align="center" width="70">检验值</uni-th>
                    <uni-th align="center" width="78">结果</uni-th>
                    <uni-th align="center" width="80">不良原因</uni-th>
                    <uni-th align="center" width="80">备注</uni-th>
                </uni-tr>
                <!-- 表格数据行 -->
                <uni-tr v-for="(item,index) in table">
                    <uni-td>{{item.CHECK_ITEM}}</uni-td>
                    <uni-td>{{item.CHECK_TOOL}}</uni-td>
                    <uni-td>{{item.SPECIFICATION}}</uni-td>
                    <uni-td v-if="item.FTEXT_TYPE">{{item.FTEXT_TYPE}}</uni-td>
                    <uni-td>{{item.CHECK_NUM}}</uni-td>
                    <uni-td>{{item.UP_ALLOW}}</uni-td>
                    <uni-td>{{item.DOWN_ALLOW}}</uni-td>
                    <uni-td>
                        <u--input v-model="item.VALUE" v-if="item.UP_ALLOW"></u--input>
                        <u-switch v-model="item.VALUE === '合格'" size="20" v-if="!item.UP_ALLOW"
                            @change="changeSwitch(item)"></u-switch>
                    </uni-td>
                    <uni-td>
                        <u-tag
                            v-if="item.UP_ALLOW && (parseFloat(item.VALUE) <= parseFloat(item.UP_ALLOW) && parseFloat(item.VALUE) >= parseFloat(item.DOWN_ALLOW)) || (!item.UP_ALLOW && item.VALUE == '合格')"
                            text="合格" type="success"></u-tag>
                        <u-tag v-else text="不合格" type="error"></u-tag>
                    </uni-td>
                    <uni-td>
                        <!--                         <view class="content" @click="useOutClickSide">
                            <easy-select ref="easySelect" size="medium" :value="item.BAD_REASON" @selectOne="selectOne($event,index)"></easy-select>
                        </view> -->
                        <view class="login">
                            <w-select style="margin-left: 20rpx;" v-model='chooseValue' defaultValue="请选择" :list='list'
                                valueName='CONTENT' keyName="ID" @change='change(index)'>
                            </w-select>
                        </view>
                    </uni-td>
                    <uni-td>
                        <u--textarea height="40px" v-model="item.MEMO" placeholder="请输入内容"></u--textarea>
                    </uni-td>
                </uni-tr>
            </uni-table>
        </view>
        <view style="margin-top: 10px;">
            <u-row style="margin-bottom: 5px;">
                <u--text type="info" text="备注"></u--text>
            </u-row>
            <u-row>
                <u--textarea v-model="remeke" placeholder="请输入内容"></u--textarea>
            </u-row>
        </view>
        <!-- 弹出窗口 -->
        <view v-if="pdfVisible" class="modal">
            <view class="modal-content">
                <view class="modal-header">
                    <text>PDF预览</text>
                    <button @click="closeModal">关闭</button>
                </view>
                <!--             <web-view v-if="pdfLink" :src="pdfLink" class="pdf-view"></web-view> -->
                <view class="pdf-view">
                    <!-- 在此处显示 PDF 内容 -->
                    <iframe :src="pdfLink" width="100%" height="100%"></iframe>
                </view>
            </view>
        </view>
        
        <u-button text="提交" type="primary" style="margin-top: 10px;" @click="submit()"></u-button>
        <u-toast ref="uToast" />
    </view>
</template>
 
<script>
    import {
        getInspectionInfo,
        saveInspectionInfo,
        getBadReason,
        generateInfoc
    } from '../../api/inspection';
    import {
        baseUrl
    } from '../../config.js'
    export default {
        data() {
            return {
                item: {},
                table: [],
                name: '',
                remeke: '',
                pdfVisible: false, // 在这里声明 pdfVisible
                pdfLink: '', // 也声明 pdfLink,确保它们是响应式的
                //show: false
                chooseValue: "",
                list: []
            }
        },
        onLoad(option) {
            let item = JSON.parse(decodeURIComponent(option.item));
            this.item = item
            this.getInspection(item.CHECK_NO)
            this.name = uni.getStorageSync('userInfo').username
            this.getBadReason()
        },
        onNavigationBarButtonTap(e) {
            let that = this
            uni.chooseImage({
                count: 1,
                sizeType: ['original', 'compressed'],
                sourceType: ['camera'],
                success: chooseImage => {
                    const tempFilePaths = chooseImage.tempFilePaths;
                    uni.uploadFile({
                        url: 'http://183.249.77.50:8008' + '/hkFile/upload?mid=' + that.item.CHECK_NO +
                            '&username=' + uni.getStorageSync('userInfo').code,
                        filePath: tempFilePaths[0],
                        name: 'file',
                        success: (uploadFileRes) => {
                            console.log(uploadFileRes.data);
 
                        },
                        fail: (res) => {
                            console.log(res)
                        }
                    });
                }
            })
        },
        methods: {
            getInspection(chenkNo) {
                getInspectionInfo(chenkNo).then(res => {
                    for (let item of res.data) {
                        // for (let i = 0; i < parseInt(item.CHECK_NUM); i++) {
                        //     let insert = JSON.parse(JSON.stringify(item))
 
                        //     insert.CHECK_ITEM = insert.CHECK_ITEM + '-' + i
                        //     if (!insert.UP_ALLOW) {
                        //         insert.VALUE = '合格'
                        //     } else {
                        //         insert.VALUE = null
                        //     }
                        //     this.table.push(insert)
                        // }
                        if (!item.UP_ALLOW) {
                            item.VALUE = '合格'
                        } else {
                            item.VALUE = null
                        }
 
                        this.table.push(item)
                    }
                    console.log(this.table)
                })
            },
            // selectOne(options,index) {
            //     this.table[index].BAD_REASON = options.label
            //     console.log(options.label);
            // },
            // useOutClickSide() {
            //     this.$refs.easySelect.hideOptions && this.$refs.easySelect.hideOptions()
            // },
            change(index) {
                this.table[index].BAD_REASON = this.chooseValue;
            },
            changeSwitch(item) {
                console.log(item)
                if (item.VALUE == '合格') {
                    item.VALUE = '不合格'
                } else {
                    item.VALUE = '合格'
                }
            },
            submit() {
                if (this.table.length == 0) {
                    this.$refs.uToast.show({
                        message: "提交失败,请维护检验项目",
                        type: 'error'
                    })
                    return
                } else {
                    if (this.check()) {
                        saveInspectionInfo(this.item.CHECK_NO, this.table, this.remeke).then(res => {
                            if (!res.result) {
                                this.$refs.uToast.show({
                                    message: res.msg,
                                    type: 'error'
                                })
                                return
                            } else {
                                // this.$refs.uToast.show({
                                //     message: "提交成功",
                                //     type: 'success'
                                // })
                                let pages = getCurrentPages();
                                let beforePage = pages[pages.length - 2];
                                uni.navigateBack({
                                    delta: 1, //返回的页面数,如果为1表示返回上一页
                                    success: (event) => {
                                        console.log('提交成功');
                                        beforePage.$vm.reload()
                                    }
                                });
                            }
                        })
                        return
                    }
                    this.$refs.uToast.show({
                        message: '有检验项目未录入完整测试结果!',
                        type: 'error'
                    })
                    return
                }
            },
            generate() {
                generateInfo(this.item.CHECK_NO).then(res => {
                    if (!res.result) {
                        this.$refs.uToast.show({
                            message: res.msg,
                            type: 'error'
                        })
                        return
                    } else {
                        this.$refs.uToast.show({
                            message: "更新成功",
                            type: 'success'
                        })
                        this.table.splice(0, this.table.length)
                        this.getInspection(this.item.CHECK_NO)
                    }
                })
            },
            getBadReason() {
 
                getBadReason().then(res => {
                    console.log(res)
                    if (!res.result) {
                        this.$refs.uToast.show({
                            message: res.msg,
                            type: 'error'
                        })
                        return
                    }
                    this.list = res.data
                })
            },
            check() {
                for (let item of this.table) {
                    if (item.VALUE === null) {
                        return false
                    }
                }
                return true
 
            },
            fetchDrawingNumber() {
                let lb = 0;
                if (this.item.ITEM_NO.startsWith('A') || this.item.ITEM_NO.startsWith('B')) {
                    lb = 1;
                } else if (this.item.ITEM_NO.startsWith('C')) {
                    lb = 2;
                }
                const id = this.item.ENGINEERING_NO;
                // lb = 2;
                // const id = 'A3-A010';
                const url = "http://192.168.0.98:808/deviceMessage.ashx?lb='"+lb+"'&id='"+id+"'";
                //const url = `/api/deviceMessage.ashx?lb=${lb}&id=${id}`; // 使用代理路径
 
                // 打印 URL 进行调试
                console.log("Request URL:", url);
                uni.request({
                    url: url,
                    method: 'POST',
                    success: (response) => {
                        const respData = response.data;
                        if (respData != "") {
                            this.pdfLink = respData;
                            this.pdfVisible = true;
                        } else {
                            uni.showToast({
                                title: respData.msg,
                                icon: 'none'
                            });
                        }
                    },
                    fail: (error) => {
                        uni.showToast({
                            title: '请求图号链接失败',
                            icon: 'none'
                        });
                    }
                });
            },
            closeModal() {
                this.pdfVisible = false;
            }
        },
    }
</script>
 
<style>
    .wrap {
        padding: 12px;
    }
 
    .demo-layout {
        height: 25px;
        border-radius: 4px;
    }
 
    .bg-purple {
        background: #CED7E1;
    }
 
    .bg-purple-light {
        background: #e5e9f2;
    }
 
    .bg-purple-dark {
        background: #99a9bf;
    }
 
    .text {
        font-size: x-large;
    }
 
    .red {
        color: red;
    }
 
 
    .modal {
        display: flex;
        justify-content: center;
        align-items: center;
        position: absolute;
        top: 10%;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1000;
    }
 
    .modal-content {
        background-color: white;
        padding: 20px;
        border-radius: 10px;
        width: 80%;
        height: 80%;
    }
 
    .pdf-view {
        width: 100%;
        height: 100%;
    }
 
    button {
        background-color: #4CAF50;
        color: white;
        border: none;
        padding: 10px 20px;
        text-align: center;
        text-decoration: none;
        display: inline-block;
        font-size: 16px;
        margin: 4px 2px;
        cursor: pointer;
    }
 
    button:hover {
        background-color: #45a049;
    }
</style>