JuHua-app/pagesB/user/scada/indeScada.vue
2024-12-09 14:16:57 +08:00

184 lines
5.0 KiB
Vue

<template>
<view class="inde-scada">
<u-sticky zIndex="98" bgColor="#eef3f7">
<view class="nav-bar">
<view v-if="!isSearch" style="margin-right: 20rpx;">
<u-icon name="search" size="23" @click="isSearch = true"></u-icon>
</view>
<view v-else style="width: 100%;">
<!-- #ifndef APP-NVUE -->
<u-input :customStyle="{ padding: '6rpx 18rpx'}" v-model="queryParams.pageName"
:placeholder="$tt('indeScada.inputScada')" shape="circle" @clear="handleClearSearch" clearable>
<!-- #endif -->
<!-- #ifdef APP-NVUE -->
<u--input :customStyle="{ padding: '6rpx 18rpx'}" v-model="queryParams.pageName"
:placeholder="$tt('indeScada.inputScada')" shape="circle" @clear="handleClearSearch"
clearable>
<!-- #endif -->
<template slot="prefix">
<u-icon name="search" size="22" @click="isSearch = false"></u-icon>
</template>
<template slot="suffix">
<u-button :text="$tt('indeScada.search')" type="primary" shape="circle" size="mini"
@click="handleSearch"></u-button>
</template>
<!-- #ifndef APP-NVUE -->
</u-input>
<!-- #endif -->
<!-- #ifdef APP-NVUE -->
</u--input>
<!-- #endif -->
</view>
</view>
</u-sticky>
<view class="content-wrap">
<view class="item-wrap" v-for="(item, index) in scadaList" :key="index">
<view class="card"
:style="{margin:(index % 2 === 0 ?'15rpx 15rpx 15rpx 30rpx':'15rpx 30rpx 15rpx 15rpx')}"
@tap="handleScadaDetail(item.guid,item.pageName)">
<view class="img-wrap">
<u--image :src="baseUrl + item.pageImage" radius="10" mode="aspectFill" width="100" height="70">
</u--image>
</view>
<view class="title">{{item.pageName}}</view>
</view>
</view>
<u-loadmore :status="loadStatus" v-if="total > queryParams.pageSize"
:loading-text="$tt('indeScada.tryingToLoad')" :loadmoreText="$tt('indeScada.gentlyPullUp')"
:nomoreText="$tt('indeScada.emptyData')" marginTop="15" />
</view>
<u-empty mode="data" :show="total === 0" marginTop="60" :text="$tt('indeScada.emptyData')"></u-empty>
</view>
</template>
<script>
import projectConfig from '@/env.config.js';
import { getIndeScadaList } from '@/apis/modules/scada';
export default {
data () {
return {
isSearch: true,
baseUrl: projectConfig.baseUrl,
loadStatus: 'loadmore', // 加载更多
queryParams: {
pageNum: 1,
pageSize: 10,
pageName: '',
type: 3,
},
scadaList: [],
total: 0,
};
},
mounted () {
this.getList();
},
methods: {
getList () {
getIndeScadaList(this.queryParams).then(res => {
if (this.queryParams.pageNum == 1) {
this.scadaList = res.rows;
} else {
this.scadaList = this.scadaList.concat(res.rows);
}
this.total = res.total;
const { pageNum, pageSize } = this.queryParams;
this.loadStatus = this.total > pageNum * pageSize ? 'loadmore' : 'nomore';
uni.stopPullDownRefresh();
}).catch(errors => {
console.log(res.msg);
})
},
// 搜索
handleSearch () {
this.queryParams.pageNum = 1;
this.getList();
},
handleClearSearch () {
this.handleSearch();
},
//组态详情
handleScadaDetail (guid, pageName) {
const title = pageName;
if (projectConfig.baseUrl.includes('prod-api')) {
// 去掉 '/prod-api/' 部分
projectConfig.baseUrl = projectConfig.baseUrl.replace('/prod-api/', '/');
}
const token = uni.getStorageSync('token');
const url = projectConfig.baseUrl + `${'scada/topo/fullscreen'}?guid=${guid}&type=3&share=${token}`;
//测试使用的
// let url =
// `${'http://localhost:81/scada/topo/fullscreen'}?share=${encodeURIComponent(this.token)}&guid=${encodeURIComponent(guid)}`;
uni.navigateTo({
url: `/pages/common/webview/index?title=${title}&url=${encodeURIComponent(url)}`
})
},
// 下拉刷新
onPullDownRefresh () {
this.dataList = [];
this.queryParams.pageNum = 1;
this.getList();
},
// 上拉加载
onReachBottom () {
this.queryParams.pageNum = this.queryParams.pageNum + 1;
if ((this.queryParams.pageNum - 1) * this.queryParams.pageSize > this.total) {
this.loadStatus = 'nomore';
} else {
this.getList();
this.loadStatus = 'loading';
}
}
}
};
</script>
<style>
page {
height: 100%;
background: #eef3f7;
}
</style>
<style lang="scss" scoped>
.inde-scada {
.nav-bar {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
padding: 26rpx 30rpx 0;
height: 74rpx;
}
.content-wrap {
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-content: flex-start;
width: 100%;
margin-top: 10rpx;
padding-bottom: 120rpx;
.item-wrap {
width: 50%;
.card {
box-shadow: 0 2rpx 0 0 rgba(0, 0, 0, .1);
padding: 20rpx;
background-color: #fff;
border-radius: 20rpx;
.title {
margin-top: 10px;
font-size: 14px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
}
}
}
</style>