165 lines
4.4 KiB
Vue
165 lines
4.4 KiB
Vue
<template>
|
|
<view class="page">
|
|
<view class="example-body" v-if="listCards.length>0">
|
|
<view v-for="item in listCards" :key="item.id" class="example-box">
|
|
<dev-block :title="item.title" :titleNumber="item.titleNumber" :note="item.note"
|
|
:extra="item.extra" :tagType="item.tagType"
|
|
:contentList="item.contentList"></dev-block>
|
|
</view>
|
|
<uni-load-more :loadingType="loadingType" :contentText="contentText" ></uni-load-more>
|
|
</view>
|
|
<view class="example-body" v-else>
|
|
<no-record ></no-record>
|
|
</view>
|
|
<view class="goHome" @click='goMain()'>
|
|
<img src="../../static/img/gohome.png">
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import devBlock from '@/components/xinsoft-dev-block/xinsoft-dev-block.vue'
|
|
import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
|
|
import noRecord from '@/components/xinsoft-no-record/xinsoft-no-record';
|
|
|
|
export default {
|
|
components: {
|
|
devBlock,uniLoadMore,noRecord
|
|
},
|
|
data() {
|
|
return {
|
|
deviceId:'', //设备id
|
|
pageSize:5, //一页多少条记录
|
|
page:1,
|
|
title: 'list-triplex-row',
|
|
listCards: [],
|
|
//上拉刷新,下拉加载
|
|
loadingText: '加载中...',
|
|
loadingType: 0,//定义加载方式 0---contentdown 1---contentrefresh 2---contentnomore
|
|
contentText: {
|
|
contentdown:'上拉显示更多',
|
|
contentrefresh: '正在加载...',
|
|
contentnomore: '没有更多数据了'
|
|
}
|
|
}
|
|
},
|
|
onLoad(options) {
|
|
this.deviceId = options.deviceId;
|
|
//初始化当前列表。
|
|
this.getAccessorySubEq(this.deviceId);
|
|
},
|
|
onPullDownRefresh: function() {
|
|
// //下拉刷新的时候请求一次数据
|
|
this.getAccessorySubEq(this.deviceId);
|
|
},
|
|
onReachBottom: function() {
|
|
this.getAccessorySubEqMore(this.deviceId);
|
|
},
|
|
methods: {
|
|
getAccessorySubEq(deviceId){
|
|
this.loadingType = 0;
|
|
this.$http.request({
|
|
url: '/apis/deviceChilden/listChild',
|
|
params:{
|
|
pageno: this.page,
|
|
pagesize: this.pageSize,
|
|
id:deviceId
|
|
},
|
|
}).then(res=>{
|
|
if (!res.data.data || res.data.data.length ==0) {//没有数据
|
|
this.listCards= [];
|
|
uni.hideNavigationBarLoading();//关闭加载动画
|
|
return;
|
|
}
|
|
if(res.data.code == 0){
|
|
this.page++;//得到数据之后page+1
|
|
uni.hideNavigationBarLoading();
|
|
uni.stopPullDownRefresh();//得到数据后停止下拉刷新
|
|
if(res.data.data && res.data.data.datas.length>0){
|
|
this.listCards = this.formaterData(res.data.data.datas);
|
|
}
|
|
}
|
|
}).catch(err=>{
|
|
});
|
|
},
|
|
getAccessorySubEqMore(deviceId){
|
|
if (this.loadingType !== 0) {//loadingType!=0;直接返回
|
|
return false;
|
|
}
|
|
this.loadingType = 1;
|
|
uni.showNavigationBarLoading();//显示加载动画
|
|
this.$http.request({
|
|
url: '/apis/deviceChilden/listChild',
|
|
params:{
|
|
pageno: this.page,
|
|
pagesize: this.pageSize,
|
|
id:deviceId
|
|
},
|
|
}).then(res=>{
|
|
if (res.data.code == -1) {//没有数据
|
|
this.loadingType = 2;
|
|
uni.hideNavigationBarLoading();//关闭加载动画
|
|
return;
|
|
}
|
|
if(res.data.code == 0 && res.data.data.datas){
|
|
this.page++;//每触底一次 page +1
|
|
this.loadingType = 0;//将loadingType归0重置
|
|
uni.hideNavigationBarLoading();//关闭加载动画
|
|
var resultData = this.formaterData(res.data.data.datas);
|
|
this.listCards = [...this.listCards,...resultData];
|
|
}
|
|
}).catch(err=>{
|
|
});
|
|
},
|
|
formaterData(data){
|
|
var resData = [];
|
|
data.forEach((vals,index)=>{
|
|
var combineJSON = {
|
|
id: vals.id,
|
|
title: vals.name,
|
|
titleNumber:'['+vals.serialno+']',
|
|
contentList: [
|
|
{
|
|
id:1,
|
|
isDouble:true,
|
|
labelName:'规格型号',
|
|
labelContent:vals.model
|
|
},
|
|
{
|
|
id:2,
|
|
isDouble:true,
|
|
labelName:'设备类型',
|
|
labelContent:vals.typen_dicames
|
|
},
|
|
{
|
|
id:3,
|
|
isDouble:true,
|
|
labelName:'使用部门',
|
|
labelContent:vals.dept_name
|
|
},
|
|
{
|
|
id:4,
|
|
isDouble:true,
|
|
labelName:'负责人',
|
|
labelContent:vals.user_dicname
|
|
},
|
|
{
|
|
id:5,
|
|
isDouble:false,
|
|
labelName:'安装地点',
|
|
labelContent:vals.site
|
|
},
|
|
],
|
|
note: '',
|
|
extra: vals.status_dicname,
|
|
tagType:vals.using_status+''
|
|
}
|
|
resData.push(combineJSON);
|
|
});
|
|
return resData;
|
|
}
|
|
}
|
|
};
|
|
</script>
|