patrolPlan-detail.vue
7.35 KB
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
<template>
<view class="device-detail-page">
<!-- 公共组件-每个页面必须引入 -->
<public-module></public-module>
<u-sticky :bgColor="bgColor">
<u-tabs :list="list.map(item=>({...item,name:$t(item.name)}))" :current="currentTab" :lineWidth="30" @click=" handleTabClick " :activeStyle="{activeColor}"
:inactiveStyle="inActiveColor" :scrollable="isScrollable" itemStyle="padding: 0 11px;display:flex;flex-direction:row;align-items:center;justify-content:center;height:44px" />
</u-sticky>
<view class="mt-3">
<view class="basic-box" v-show="currentTab == 0">
<view class="basic-header">
<view class="u-flex">
<view class="basic-text text-clip ml-2">
{{ listDetail.code }}
</view>
<view v-if="listDetail.status" class="basic-text-status ml-2" :style="{ color: inspectionType[listDetail.status].color}">
{{ listDetail.status ? inspectionType[listDetail.status].name : '' }}
</view>
</view>
</view>
<view class="detail">
<view class="detail-item">
<view class="detail-label">{{ $t('deviceInspect.preserveCode') }}</view>
<view class="detail-value">{{ listDetail.code}}</view>
</view>
<u-line length="90%" margin="0 auto"></u-line>
<view class="detail-item">
<view class="detail-label">{{ $t('deviceInspect.preserveName') }}</view>
<view class="detail-value">{{ listDetail.name}}</view>
</view>
<u-line length="90%" margin="0 auto"></u-line>
<view class="detail-item">
<view class="detail-label">{{ $t('deviceInspect.startTime') }}</view>
<view class="detail-value">{{ listDetail.startTime }}</view>
</view>
<u-line length="90%" margin="0 auto"></u-line>
<view class="detail-item">
<view class="detail-label">{{ $t('deviceInspect.endTime') }}</view>
<view class="detail-value">{{ listDetail.endTime }}</view>
</view>
</view>
</view>
<view class="record-box" v-show="currentTab == 1">
<!-- 列表分页 -->
<mescroll-body ref="mescrollRef" @init="mescrollInit" :up="upOption" :down="downOption" @down="downCallback"
@up="upCallback">
<page-list :list="listData" @openDeviceDetail="openDeviceDetail"></page-list>
<mescroll-empty v-if="!listData.length" />
</mescroll-body>
</view>
</view>
</view>
</template>
<script>
import fTabbar from "@/components/module/f-tabbar/f-tabbar";
import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js';
import api from '@/api/index.js'
import {planType,preserveType,detailType,inspectionType,inspectionResult} from '@/pages/deviceInspect/enum/index.js'
import { list } from './config/data.js'
import baseUrl from '@/config/baseUrl.js'
import pageList from '@/components/common/page-list'
export default {
mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
components: {
fTabbar,
pageList
},
data() {
return {
bgColor: '#fff',
activeColor: {
fontWeight: 'bold',
color: '#333',
},
inActiveColor: {
color: '#999',
},
listDetail:{},
list,
inspectionType,
preserveType,
currentTab: 0,
detailType,
isScrollable: false,
planType,
downOption: {
auto: false //是否在初始化后,自动执行downCallback; 默认true
},
upOption: {
isBounce: false,
auto: false // 不自动加载
},
page: {
num: 0,
size: 10
},
preservePlanId:'', //保养计划id
listData:[]
};
},
onUnload() {
},
async onLoad(options) {
// 隐藏原生的tabbar
uni.hideTabBar();
if (getApp().getBindNot()) {
return
}
let id = options.id
const res = await api.deviceInspectApi.getPatrolPlanDetail(id)
if (!res) return
this.listDetail = {...res}
},
onShow(){
this.$nextTick(()=>{
uni.setNavigationBarTitle({
title:this.$t('menu.patrolPlanDetail')
})
})
},
watch: {
currentTab: {
immediate: true,
handler(val) {
if(val == 1){
this.page.num = 1
this.loadData(this.page.num);
}
}
},
},
methods: {
handleTabClick({index}) {
this.currentTab = index;
},
formatImage(url) {
return baseUrl.baseImgUrl + url
},
//下拉刷新
downCallback() {
if (getApp().getBindNot()) {
setTimeout(() => {
this.mescroll.endByPage(0, 0)
}, 200)
return
}
this.listData = [];
this.page.num = 1;
this.loadData(this.page.num);
this.resetQuery();
},
//上拉加载
upCallback() {
if (getApp().getBindNot()) {
setTimeout(() => {
this.mescroll.endByPage(0, 0)
}, 200)
return
}
this.page.num += 1;
this.loadData(this.page.num);
},
//获取列表
async loadData(pageNo) {
try {
let httpData = {
page: pageNo,
pageSize: 10,
inspectionPlanId:this.listDetail.id,
inspectorId:'',
startTime:'',
endTime:'',
recordResult:''
};
const {
total,
items
} = await api.deviceInspectApi.getPatrolRecordListApi(httpData)
let data = items
let newList = data.map((item)=>{
return {
id:item.id,
title:item.code,
status:item.recordResult ? inspectionResult[item.recordResult].name : '',
iconUrl:item.recordResult ? inspectionResult[item.recordResult].iconUrl : '',
color:item.recordResult ? inspectionResult[item.recordResult].color : '',
child:[
{
label:'deviceInspect.recordCode',
name:item.code
},
{
label:'deviceInspect.patrolPlan',
name:item.tkInspectionPlanDTO ? item.tkInspectionPlanDTO.name : ''
},
{
label:'deviceInspect.patrolByName',
name:item.userDTO ? item.userDTO.realName : ''
},
{
label:'deviceInspect.checkDate',
name:item.checkDate
},
],
detail:{
...item
}
}
})
uni.stopPullDownRefresh();
this.mescroll.endByPage(items.length); //必传参数(当前页的数据个数, 总页数)
if (pageNo == 1) {
this.listData = newList;
} else {
this.listData = this.listData.concat(newList);
}
} catch {
this.mescroll.endErr();
}
},
},
};
</script>
<style lang="scss" scoped>
.device-detail-page {
min-height: 100vh;
background-color: #f8f9fa;
// padding: 0 30rpx;
.mt-3{
// padding: 0 30rpx;
margin-top: 0;
.basic-box{
margin-top: 30rpx;
padding: 0 30rpx;
}
.record-box{
// padding: 0 30rpx 0 15rpx;
}
}
.basic-header {
display: flex;
justify-content: space-between;
align-items: center;
height: 140rpx;
background-color: #fff;
border-radius: 20rpx;
padding-left: 40rpx;
padding-right:20rpx;
.basic-text {
width: 370rpx;
}
.cu-item {
background: #3388ff;
border-radius: 12px;
width: 120rpx;
height: 48rpx;
text-align: center;
line-height: 40rpx;
text {
font-size: 12px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #ffffff;
}
}
.basic-text-status {
font-size: 14px;
}
}
.detail {
background-color: #fff;
margin-top: 30rpx;
border-radius: 20rpx;
width: 690rpx;
.detail-item {
padding: 30rpx;
display: flex;
align-items: center;
.detail-label {
color: #333;
font-size: 15px;
}
.detail-value {
color: #666;
font-size: 14px;
margin-left: 30rpx;
.detail-img{
width: 60rpx;
height: 60rpx;
}
}
}
}
}
</style>