record.vue
11.4 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
<template>
<view>
<view class="lz-status_bar" :style="{ height: menuButtonInfo + 'px' }">
<view class="lz-top_view"></view>
</view>
<!--#ifdef MP-WEIXIN-->
<view class="index-head">
<view class="index-head-top">
<!-- <view class="index-head-l" @tap="$navigateBack">
<view class="iconfont icon-youjiantou"></view>
</view> -->
<view class="index-head-m">巡检记录</view>
</view>
</view>
<!--#endif-->
<mescroll-body height="auto" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
:down="downOption" :up="upOption">
<view class="shenpi-list-flex">
<view class="shenpi-list" v-for="(item,index) in dataList" :key="index" @tap="gotoDetail(item)">
<view class="shenpi-flex">
<view class="shenpi-title shenpi-title-top">
<view class="shenpi-title-l">
<view>{{item.site_name}}</view>
<view v-if="item.status==2" class="shenpi-title-t">已跳过巡检</view>
</view>
<view v-if="item.status==1" class="shenpi-list-button" hover-class="navigator-hover">巡检详情
</view>
</view>
<view style="display: flex;align-items: center;justify-content: space-between;">
<view>
<view v-if="item.status==1" class="shenpi-title">
<view>巡检时间:</view>
<view class="shenpi-list-r">{{item.checktime}}</view>
</view>
<view v-else class="shenpi-title">
<view>跳过时间:</view>
<view class="shenpi-list-r">{{item.jumptime}}</view>
</view>
<!-- <view class="shenpi-title">
<view>结束时间:</view>
<view class="shenpi-list-r">
{{item.endtime}}
</view>
</view> -->
</view>
</view>
</view>
</view>
</view>
</mescroll-body>
</view>
</template>
<script>
import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
import MescrollBody from "@/components/mescroll-uni/mescroll-body.vue"; // 注意.vue后缀不能省
import {mapState} from 'vuex';
import util from '@/lib/utils/index.js'
import WucTab from '@/components/wuc-tab/wuc-tab.vue';
import noRecode from "@/components/no-recode.vue";
export default {
mixins: [MescrollMixin], // 使用mixin
data() {
return {
is_recode: false,
xunjianList: {
list: [],
// 请求参数
requestParams: {
page: 1,
limit: 10
}
},
list: [],
mescroll: null, //mescroll实例对象 (此行可删,mixins已默认)
// 下拉刷新的常用配置
downOption: {
use: true, // 是否启用下拉刷新; 默认true
auto: false, // 是否在初始化完毕之后自动执行下拉刷新的回调; 默认true
native: false // 启用系统自带的下拉组件,默认false;仅mescroll-body生效,mescroll-uni无效(native: true, 则需在pages.json中配置"enablePullDownRefresh":true)
},
// 上拉加载的常用配置
upOption: {
use: true, // 是否启用上拉加载; 默认true
auto: true, // 是否在初始化完毕之后自动执行上拉加载的回调; 默认true
page: {
num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
size: 10 // 每页数据的数量,默认10
},
noMoreSize: 5, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
empty: {
tip: '暂无相关数据'
}
},
// 列表数据
dataList: []
}
},
computed: {
...mapState([
"userInfo","menuButtonInfo"
])
},
onLoad() {
},
onShow() {
if (this.userInfo.token == undefined) {
this.loginOut();
} else {
this.canReset && this.mescroll.resetUpScroll() // 自行实现的刷新指定一条数据
this.canReset = true // 过滤第一次的onShow事件,避免初始化界面时重复触发upCallback, 无需配置auto:false
}
},
components: {
WucTab,
MescrollBody,
noRecode
},
methods: {
loginOut() {
this.$lib.$store.commit('clearUserInfo')
uni.reLaunch({
url: '/pages/login/index'
})
},
async upCallback(page) {
// console.log(page)
let pageNum = page.num; // 页码, 默认从1开始
let pageSize = page.size; // 页长, 默认每页10条
let res = await this.$lib.$http.post({
url: this.$lib.$urlMap.xunjianRecord,
data: {
status: this.status,
page: pageNum,
limit: pageSize
},
needLogin: true
})
if (res.code == 1) {
// 接口返回的当前页数据列表 (数组)
let curPageData = res.data.data;
// 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
let curPageLen = curPageData.length;
// 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
// let totalPage =Math.ceil(totalSize/pageSize);
// 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
let totalSize = res.data.count;
// 接口返回的是否有下一页 (true/false)
// let hasNext = data.xxx;
//设置列表数据
if (page.num == 1) this.dataList = []; //如果是第一页需手动置空列表
for (let i = 0, leng = curPageData.length; i < leng; i++) {
var timestamp = Date.parse(new Date()).toString();
timestamp = timestamp.substr(0, 10);
let item = curPageData[i]
curPageData[i].area_name = item.area_name;
curPageData[i].jumptime = util.timestampToTime(item.jumptime);
curPageData[i].checktime = util.timestampToTime(item.checktime);
curPageData[i].begintime = util.timestampToTime(item.begintime);
curPageData[i].endtime = util.timestampToTime(item.endtime);
curPageData[i].id = item.id;
curPageData[i].status = item.status;
curPageData[i].uid = item.uid;
}
this.dataList = this.dataList.concat(curPageData); //追加新数据
this.mescroll.endBySize(curPageLen, totalSize);
this.$nextTick(() => {
this.mescroll.endSuccess(curPageLen)
})
}
},
filter_xunjian_list() {
if (this.xunjianList.list) {
let arr = [];
for (let i = 0, leng = this.xunjianList.list.length; i < leng; i++) {
if (this.status == 2) {
this.xunjianList.list[i].delay = 0 //1 超时 0 未超时
}
if (this.xunjianList.list[i].status == this.status) {
arr.push(this.xunjianList.list[i]);
}
}
this.list = arr;
}
if (this.list.length == 0) {
this.is_recode = true
}
// console.log(this.list)
},
resetData() {
this.upOption = {
use: true, // 是否启用上拉加载; 默认true
auto: true, // 是否在初始化完毕之后自动执行上拉加载的回调; 默认true
page: {
num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
size: 10 // 每页数据的数量,默认10
},
noMoreSize: 5, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
empty: {
tip: '暂无相关数据'
}
};
},
gotoDetail(item) {
if (item.status == 2) return
this.$lib.$utils.Router.navigateTo({
url: '/pages/xunjian/detail',
params: {
id: item.id
}
})
},
}
}
</script>
<style>
page {
background: #f5f5f5;
}
.shenpi-list-flex {
font-size: 16px;
padding-top: 14px;
}
.shenpi-list {
padding: 16px 0;
display: flex;
justify-content: space-between;
align-items: center;
background: #fff;
border-radius: 5px;
box-shadow: 1px 2px 4px rgb(2 2 2 / 5%);
width: 93%;
margin: 0 auto;
margin-bottom: 14px;
}
.shenpi-list-flex .shenpi-list:last-child {
margin-bottom: none;
}
.shenpi-flex {
display: flex;
flex-direction: column;
justify-content: space-between;
font-size: 16px;
flex: 1;
}
.shenpi-title {
display: flex;
align-items: center;
padding: 0 14px;
font-size: 14px;
}
.shenpi-title-top {
border-bottom: solid 1px #f3f3f3;
margin-bottom: 14px;
padding-bottom: 14px;
font-size: 16px;
}
.shenpi-title-l {
flex: 1;
display: flex;
align-items: center;
}
.shenpi-list-button {
padding: 7px 14px;
background: #4d72ff;
color: #fff;
border-radius: 5px;
font-size: 12px;
}
.shenpi-list-r {
color: #9f9f9f;
margin-left: 7px;
}
.shenpi-title-t {
border: solid 1px #f00;
font-size: 12px;
color: red;
padding: 4px 8px;
margin-left: 8px;
border-radius: 5px;
}
</style>