展杰
2024-07-03 db16c0207818437ddd711bcc0778667ba8d9fcc4
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
<template>
    <view>
        <view>
            <uni-card>
                <u-row customStyle="margin-bottom: 10px">
                    <u-col span="2">
                        <label>点检计划单:</label>
                    </u-col>
                    <u-col span="4">
                        <label>{{item.PLAN_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.PLAN_DATE}}</label>
                    </u-col>
                </u-row>
                <u-row customStyle="margin-bottom: 10px">
                    <u-col span="2">
                        <label>点检设备:</label>
                    </u-col>
                    <u-col>
                        <label>{{item.EQ_NO}} - - - {{item.EQ_NAME}}</label>
                    </u-col>
                </u-row>
                <u-row customStyle="margin-bottom: 10px">
                    <u-col span="2">
                        <label>设备型号:</label>
                    </u-col>
                    <u-col>
                        <label>{{item.EQ_MODEL}}</label>
                    </u-col>
                </u-row>
                <u-row customStyle="margin-bottom: 10px">
                    <u-col span="2">
                        <label>放置地点:</label>
                    </u-col>
                    <u-col>
                        <label>{{item.DEPARTMENT}} - - - {{item.PLACE}}</label>
                    </u-col>
                </u-row>
                <u-row>
                    <u-col span="2">
                        <label>点检方案:</label>
                    </u-col>
                    <u-col span="4">
                        <label>{{item.WAYS}}</label>
                    </u-col>
                </u-row>
 
            </uni-card>
        </view>
 
        <view>
            <uni-table border stripe emptyText="暂无更多数据" style="margin-left: 5px;margin-right: 5px;">
                <!-- 表头行 -->
                <uni-tr>
                    <uni-th align="center" width="100">点检部位</uni-th>
                    <uni-th align="center" width="100">点检内容</uni-th>
                    <uni-th align="center" width="50">点检方式</uni-th>
                    <uni-th align="center" width="30">检验值</uni-th>
                    <uni-th align="center" width="30">检验结果</uni-th>
                    <uni-th align="center" width="80">备注</uni-th>
                </uni-tr>
                <!-- 表格数据行 -->
                <uni-tr v-for="(item,index) in table">
                    <uni-td>{{item.eqDepartment}}</uni-td>
                    <uni-td>{{item.eqMain}}</uni-td>
                    <uni-td>{{item.eqWay}}</uni-td>
                    <uni-td>
                        <u-switch v-model="item.VALUE === '合格'" size="20" @change="changeSwitch(item)"></u-switch>
                    </uni-td>
                    <uni-td>
                        <u-tag
                            v-if="item.VALUE == '合格'"
                            text="合格" type="success"></u-tag>
                        <u-tag v-else text="不合格" type="error"></u-tag>
                    </uni-td>
                    <uni-td>
                        <u--textarea height="40px" v-model="item.remark" 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>
        <u-button text="提交" type="primary" style="margin-top: 10px;" @click="submit()"></u-button>
        <u-toast ref="uToast" />
    </view>
</template>
 
<script>
    import {
        getSpotItemResult,
        saveSpotInfo
    } from '../../api/spotCheck';
    import {
        baseUrl
    } from '../../config.js'
    export default {
        data() {
            return {
                item: {},
                table: [],
                name: '',
                remeke: '',
                //show: false
                chooseValue: "",
                list: []
            }
        },
        onLoad(option) {
            let item = JSON.parse(decodeURIComponent(option.item));
            this.item = item
            this.loadmore(item.PLAN_NO)
            this.name = uni.getStorageSync('userInfo').username
        },
        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: {
            loadmore(planNo) {
                getSpotItemResult(planNo).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)
                        // }
                        item.VALUE = '合格'
                        this.table.push(item)
                    }
                    console.log(this.table)
                })
            },
            changeSwitch(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()) {
                        saveSpotInfo(this.item.PLAN_NO, this.table, this.remeke).then(res => {
                            console.log(this.item.PLAN_NO, this.table, this.remeke);
                            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
                }
            },
            check() {
                for (let item of this.table) {
                    if (item.VALUE === null) {
                        return false
                    }
                }
                return true
            }
        }
    }
</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;
    }
</style>