<template>
|
<view class="train_index">
|
<scroll-view
|
scroll-y="true"
|
class="incom_index_scroll"
|
:scroll-top="scrollTop"
|
refresher-enabled="true"
|
refresher-background="#EAEAEA"
|
:refresher-triggered="triggered"
|
@refresherpulling="refresherrefresh"
|
@scrolltolower="scrolltoLower">
|
<view class="train_main_list" v-for="(item,index) in safeLists" :key="index">
|
<view class="train_left">
|
<view class="train_left_title">{{item.secureName}}<span v-if="item.stateSafe === 2">未完成</span></view>
|
<view :class="{'train_left_contents':item.stateSafe === 1,'train_left_contents1':item.stateSafe === 2}">{{showContents(item.securePathDtos)}}</view>
|
</view>
|
<view class="train_right">
|
<view @click="startClick(item)" :class="{'train_right_btn':item.stateSafe === 1,'train_right_btn1':item.stateSafe === 2}">{{item.stateSafe === 1?'已完成':'开始培训'}}</view>
|
</view>
|
</view>
|
<u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" />
|
</scroll-view>
|
</view>
|
</template>
|
|
<script>
|
import { throttle } from '../../plugins/public.js';
|
export default {
|
data(){
|
return{
|
pageNum: 1,
|
pageSize: 10,
|
loadPage: 0,
|
scrollTop: 0,
|
triggered: true,
|
status: 'loading',
|
loadText: {
|
loading: '努力加载中',
|
nomore: '没有更多数据了'
|
},
|
safeLists:[],//安全培训列表
|
}
|
},
|
onShow() {
|
this.searchTrainList()
|
},
|
methods:{
|
//点击开始培训
|
startClick(val){
|
uni.navigateTo({
|
url: `./trainDetails?secureId=${val.secureId}&stateSafe=${val.stateSafe}`
|
})
|
},
|
//展示文件名字
|
showContents(value){
|
let nameArr = ''
|
value.forEach(titles =>{
|
let names = titles.securePathVideoName&&titles.securePathVideoName.split('.') || ''
|
nameArr+=names[0]
|
})
|
return nameArr
|
},
|
//查询列表
|
searchTrainList(){
|
this.triggered = true;
|
this.safeLists = [];
|
this.$api.labourSystem.getTrainingLists({}).then(res=>{
|
if(res.statusMsg === 'ok'){
|
let safeArr = []
|
res.data.secureTrainUserDtos.map(item=>{
|
if(res.data.secureIds.length !==0){
|
if(res.data.secureIds.includes(item.secureId)){
|
safeArr.push({
|
stateSafe:1,//按钮状态 1:已完成,2:开始培训
|
secureName:item.secureName,
|
secureId:item.secureId,
|
securePathDtos:item.securePathDtos
|
})
|
}else{
|
safeArr.push({
|
stateSafe:2,
|
secureId:item.secureId,
|
secureName:item.secureName,
|
securePathDtos:item.securePathDtos
|
})
|
}
|
}else{
|
safeArr.push({
|
stateSafe:2,
|
secureId:item.secureId,
|
secureName:item.secureName,
|
securePathDtos:item.securePathDtos
|
})
|
}
|
return safeArr
|
})
|
this.safeLists = safeArr
|
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.searchTrainList();
|
uni.$u.toast('刷新成功');
|
}, 500),
|
//触底刷新
|
scrolltoLower: throttle(function() {
|
this.status = 'loading';
|
this.pageNum = 1;
|
this.searchTrainList();
|
// if(this.pageNum <= this.loadPage) {
|
// setTimeout(() => {
|
// this.status = 'nomore'
|
// uni.$u.toast('没有更多数据了');
|
// },1000)
|
// return
|
// } else {
|
// this.pageNum+=this.pageNum
|
// this.searchTrainList().then((data) => {
|
// this.loadPage = data.pages;
|
// this.platUserList.push(...data.list);
|
// this.status = 'nomore';
|
// })
|
// }
|
}, 1500),
|
}
|
}
|
</script>
|
|
<style scoped lang="scss">
|
.train_index{
|
height: 100vh;
|
background-color: #FFFFFF;
|
|
.incom_index_scroll{
|
height: 90%;
|
.train_main_list{
|
display: flex;
|
justify-content: space-between;
|
padding: 10px 0px;
|
margin: 0 15px;
|
border-bottom: 1px solid #EAEAEA;
|
.train_left{
|
.train_left_title{
|
color: #333333;
|
font-weight: 510;
|
font-size:17px ;
|
span{
|
border-radius: 2px;
|
padding: 2px 5px;
|
margin-left: 15px;
|
margin-top: -10px;
|
font-size: 11px;
|
color: #FFFFFF;
|
background-color: #FC3E3E;
|
}
|
}
|
.train_left_contents{
|
width: 230px;
|
margin-top: 10px;
|
color: #999999;
|
font-size: 13px;
|
white-space: nowrap;
|
overflow: hidden;
|
text-overflow: ellipsis;
|
}
|
.train_left_contents1{
|
width: 230px;
|
margin-top: 10px;
|
color: #FC3E3E;
|
font-size: 13px;
|
white-space: nowrap;
|
overflow: hidden;
|
text-overflow: ellipsis;
|
}
|
}
|
.train_right{
|
margin-top: 15px;
|
.train_right_btn{
|
color: #1977FF;
|
font-size: 14px;
|
padding: 4px 10px;
|
border: 1px solid #EAEAEA;
|
background-color: #EAEAEA;
|
border-top-left-radius: 15px;
|
border-bottom-right-radius: 15px;
|
}
|
.train_right_btn1{
|
color: #FFFFFF;
|
font-size: 14px;
|
padding: 4px 10px;
|
border: 1px solid #1977FF;
|
background-color: #1977FF;
|
border-top-left-radius: 15px;
|
border-bottom-right-radius: 15px;
|
}
|
}
|
}
|
}
|
}
|
</style>
|