张晓波
2023-09-19 164694c47c35d6654df69b533e8dbf8b5423efc5
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
<template>
    <view class="check_index">
        <view class="check_titles">
            <view class="check_title_left">{{bigDeviceName}}</view>
            <view class="check_title_right">规格型号:{{bigDeviceModel}}</view>
        </view>
        <view class="check_select">
            <view @click="startClick()">
                <u--input placeholder="起始时间" disabled disabledColor="#FFFFFF" placeholderStyle="color:#999999;padding-left:10px"  v-model="search.strTime" border="none" suffixIcon="calendar" suffixIconStyle="color: #666666;font-size:30px;"></u--input>
            </view>
            <view @click="endClick()">
                <u--input placeholder="截止时间" disabled disabledColor="#FFFFFF"  placeholderStyle="color:#999999;padding-left:10px" v-model="search.endTime" border="none" suffixIcon="calendar" suffixIconStyle="color: #666666;font-size:30px;"></u--input>
            </view>
            <view style="width:60px">
                <u-button type="primary" color="#1977FF" text="查询" @click="searchCheckList(bigDeviceId)"></u-button>
            </view>
        </view>
        <view class="check_main">
            <scroll-view
                scroll-y="true"
                class="check_index_scroll"
                :scroll-top="scrollTop" 
                refresher-enabled="true" 
                refresher-background="#EAEAEA"
                :refresher-triggered="triggered" 
                @refresherpulling="refresherrefresh"
                @scrolltolower="scrolltoLower">
                <view class="check_card_index" v-for="(item,index) in checkDatas" :key="index">
                    <view class="check_card_header">
                        <view class="check_header_times">{{item.inspectTime}}</view>
                        <view class="check_header_names">{{item.realName}}</view>
                    </view>
                    <view class="check_card_main">
                        <view class="check_main_items">
                            <view class="check_main_items_titles">设备编号</view>
                            <view class="check_main_items_datas">{{item.bigNumber}}</view>
                        </view>
                        <view class="check_main_items">
                            <view class="check_main_items_titles">设备类型</view>
                            <view class="check_main_items_datas">{{item.dictName}}</view>
                        </view>
                        <view class="check_main_items">
                            <view class="check_main_items_titles">安装位置</view>
                            <view class="check_main_items_datas">{{item.bigPosition}}</view>
                        </view>
                        <view class="check_main_items">
                            <view class="check_main_items_titles">检查类型</view>
                            <view class="check_main_items_datas">{{showTypes(item.inspectTypes)}}</view>
                        </view>
                        <view class="check_main_items">
                            <view class="check_main_items_titles">检查结果</view>
                            <view class="check_main_items_datas"  @click="showResults(item.inspectResult)">{{item.inspectResult === null?'':item.inspectResult}}</view>
                        </view>
                    </view>
                </view>
                <u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" />
            </scroll-view>
        </view>
        <u-datetime-picker
            :show="showStart"
            v-model="startTime"
            mode="date"
            @confirm="changeStart"
            @cancel="showStart = false"
        ></u-datetime-picker>
        <u-datetime-picker
            :show="showEnd"
            v-model="endTime"
            mode="date"
            @confirm="changeEnd"
            @cancel="showEnd = false"
        ></u-datetime-picker>
        <u-popup :show="showResult" @close="closeResult" mode="center" :round="6" :closeable="true">
            <view class="result_main_style">
                {{resultContent===null?'':resultContent}}
            </view>
        </u-popup>
    </view>
</template>
 
<script>
    import {changeTime,throttle} from '@/plugins/public.js'
    export default{
        data(){
            return{
                showResult:false,//是否展示检查结果弹框
                resultContent:"",//检查结果内容
                search:{},//查询条件
                showStart:false,//是否显示起始时间
                showEnd:false,//是否展示截止时间弹框
                startTime:Number(new Date()),//起始时间默认当天
                endTime:Number(new Date()),//截止时间默认当天
                checkDatas:[],//列表数据
                pageNum: 1,
                pageSize: 10,
                loadPage: 0,
                scrollTop: 0,
                triggered: true,
                status: 'loading',
                loadText: {
                    loading: '努力加载中',
                    nomore: '没有更多数据了'
                },
                bigDeviceId:null,
                bigDeviceModel:null,//规格型号
                bigDeviceName:null,//设备名称
            }
        },
        onLoad(options) {
            this.bigDeviceName = options.bigDeviceName
            this.bigDeviceModel = options.bigDeviceModel
            this.bigDeviceId = options.bigDeviceId
            this.searchCheckList(options.bigDeviceId)
        },
        methods:{
            //展示检查结果
            showResults(value){
                this.showResult = true
                this.resultContent =value
            },
            //关闭弹框
            closeResult(){
                this.showResult = false
            },
            //展示检查类型
            showTypes(val){
                let str=''
                let str1 = ''
                if(val.length===1){
                    str = val[0].typeName
                }else{
                    val.forEach(item=>{
                        str+=item.typeName+','
                    })
                    str1 = str.lastIndexOf(',')
                    str = str.substring(0,str1)
                }
                return str
            },
            //查询列表
            searchCheckList(val){
                this.triggered = true;
                this.checkDatas = [];
                let params =Object.assign({},this.search,{
                    pageNum: this.pageNum,
                    pageSize:this.pageSize,
                    bigDeviceId:val,
                })
                this.$api.reboSystem.getCheckDeviceLists(params).then(res=>{
                    if(res.statusMsg === 'ok'){
                        this.checkDatas = res.data.list
                        this.loadPage = res.data.pages;
                        this.triggered = false;
                        this.status = 'nomore';
                    }else{
                        uni.$u.toast(res.statusMsg);
                    }
                }).catch((err) => {
                    uni.$u.toast('请检查网络服务或联系管理员!')
                })
            },
            //自定义下拉刷新
            refresherrefresh: throttle(function() {
                this.status = 'loading';
                this.pageNum = 1;
                this.searchCheckList(this.bigDeviceId);
                uni.$u.toast('刷新成功');
            }, 500),
            //触底刷新
            scrolltoLower: throttle(function() {
                this.status = 'loading';
                if(this.pageNum >= this.loadPage) {
                    setTimeout(() => {
                        this.status = 'nomore'
                        uni.$u.toast('没有更多数据了');
                    },1000)
                    return
                } else {
                    this.pageNum+=1
                    let params =Object.assign({},this.search,{
                        pageNum: this.pageNum,
                        pageSize:this.pageSize,
                        bigDeviceId:this.bigDeviceId
                    })
                    this.$api.reboSystem.getCheckDeviceLists(params).then(res=>{
                        if(res.statusMsg === 'ok'){
                            this.checkDatas.push(...res.data.list)
                            this.loadPage = res.data.pages;
                            this.triggered = false;
                            this.status = 'nomore';
                        }else{
                            uni.$u.toast(res.statusMsg);
                        }
                    }).catch((err) => {
                        uni.$u.toast('请检查网络服务或联系管理员!')
                    })
                }
            }, 1500),
            //点击弹出选择起始时间
            startClick(){
                this.showStart = true
                this.$set(this.search,'strTime','')
            },
            //确定选择的起始时间
            changeStart({value}){
                this.showStart = false
                this.$set(this.search,'strTime',changeTime(value))
            },
            //点击弹出选择截止时间
            endClick(){
                this.showEnd = true
                this.$set(this.search,'endTime','')
            },
            //确定选择的起始时间
            changeEnd({value}){
                this.showEnd = false
                this.$set(this.search,'endTime',changeTime(value))
            }
        }
    }
</script>
 
<style scoped lang="scss">
    .check_index{
        height: 100vh;
        background-color: #F6F6F6;
        padding: 10px 15px;
        .check_titles{
            line-height: 36px;
            // display: flex;
            justify-content: space-between;
            background-color: #EDF1F6;
            border-radius: 4px;
            margin-bottom: 20px;
            .check_title_left{
                color: #1977FF;
                font-size: 17px;
                padding-left: 10px;
                position: relative;
                &::before{
                    width: 2px;
                    height: 17px;
                    background-color: #1977FF;
                    content: "";
                    position: absolute;
                    top: 11px;
                    left: 0px;
                }
            }
            .check_title_right{
                padding-left: 10px;
                color: #333333;
                font-size: 17px;
                padding-right: 5px;
            }
        }
        .check_select{
            display: flex;
            margin-bottom: 20px;
        }
        .check_main{
            height: calc(100% - 135px);
            .check_index_scroll{
                height: 90%;
                
                .check_card_index{
                    height: 200px;
                    background-color: #FFFFFF;
                    border-radius: 6px;
                    margin-bottom: 10px;
                    .check_card_header{
                        line-height: 40px;
                        border-bottom: 1px solid #F2F2F2;
                        display: flex;
                        justify-content: space-between;
                        align-items: center;
                        .check_header_times{
                            font-size: 15px;
                            padding-left: 28px;
                            color: #333333;
                            position: relative;
                            &::before{
                                width: 15px;
                                height: 15px;
                                content: "";
                                background: url('../../static/times.png') no-repeat;
                                position: absolute;
                                top: 13px;
                                left: 10px;
                            }
                        }
                        .check_header_names{
                            padding-right: 15px;
                            font-size: 17px;
                            color: #1977FF;
                        }
                    }
                    .check_card_main{
                        display: flex;
                        flex-direction: column;
                        justify-content: space-around;
                        .check_main_items{
                            display: flex;
                            line-height: 30px;
                            .check_main_items_titles{
                                padding-left: 15px;
                                width: 100px;
                                flex: none;
                                color: #999999;
                                font-size: 15px;
                            }
                            .check_main_items_datas{
                                padding-right: 10px;
                                color: #333333;
                                font-size: 15px;
                                flex: 1;
                                text-align: right;
                                overflow: hidden;
                                text-overflow: ellipsis;
                                white-space: nowrap;
                            }
                        }
                    }
                }
            }
        }
    }
    ::v-deep .u-input {
        margin-right: 10px!important;
        background-color: #FFFFFF;
        border-radius: 0px;
        height: 40px;
    }
    .result_main_style{
        width: 200px;
        height: 200px;
        padding: 30px 15px 15px;
        overflow: auto;
        margin-right: 15px;
    }
</style>