ykzz-app/pages/homeIndex/index.vue

536 lines
11 KiB
Vue

<template>
<view class="container">
<!-- 个人信息 -->
<view class="info">
<div class="left">
<div class="icon">
<image
style="width: 100%; height: 100%; border-radius: 50%"
:src="default_src"
mode="aspectFill"
>
</image>
</div>
<div class="info_name">
<div v-if="userList.userName">{{ userList.nickName }}</div>
<div v-if="userList.dept">
{{ userList.dept.deptName || "" }}
</div>
</div>
</div>
</view>
<!-- nav -->
<view class="navBar" style="display: flex; flex-wrap: wrap">
<div class="navList" v-for="(item, index) in getNavList" :key="index">
<div
@click="myNavigateTo(item.url, item.value)"
style="display: flex; flex-direction: column; align-items: center"
>
<div class="navIcon">
<image
style="width: 100%; height: 100%"
:src="item.icon"
mode="aspectFit"
></image>
<div class="readStatus" v-show="warnStatus && item.key == 2"></div>
</div>
<div class="navTxt">{{ item.value }}</div>
</div>
</div>
</view>
<view class="info_rain">
<div class="heart" style="display: flex">
<p class="title">
<image
:style="{ width: '20px', height: '20px', marginRight: '10px' }"
src="../../static/tabs/rain.svg"
></image
><span class="h4">雨情</span>
</p>
<div class="time" style="width: 50%; color: #000" v-if="timeList">
<uni-data-select
v-model="selValue"
:localdata="timeList"
@change="changeTime"
:clear="false"
>
</uni-data-select>
</div>
</div>
<div
class="info_icon"
style="height: 260px; width: 100%"
v-if="rainList.length"
>
<qiun-data-charts
:chartData="chartData.chartData"
:echartsApp="true"
:eopts="chartData.eopts"
/>
</div>
<image
:src="showImg"
style="width: 60%; height: 220px; margin: 5% 10% 0 20%;"
v-else
></image>
</view>
<view
class="info_24"
:style="{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
padding: '5px 0',
margin: '0',
}"
>
<image
:style="{ width: '20px', height: '20px', marginRight: '10px' }"
src="../../static/logoc.png"
></image>
<div>技术支持: 湖北鲧石物联科技有限公司</div>
</view>
</view>
</template>
<script>
import moment from "moment";
import drpOption from './chartOption';
const warnStm = moment().subtract(1, "days").format("YYYY-MM-DD HH:mm:ss");
const warnetm = moment().format("YYYY-MM-DD HH:mm:ss");
const stm = moment()
.subtract(1, "days")
.startOf("day")
.set({ hour: 8, minute: 0 });
const etm = moment().startOf("day").set({ hour: 8, minute: 0 });
export default {
data() {
return {
userList: uni.getStorageSync("value"),
default_src: uni.getStorageSync("avatar"),
stm,
etm,
timeList: [
{ text: "昨天08:00~当前时间", value: 1 },
{ text: "今天08:00~当前时间", value: 2 },
{ text: "昨天08:00~今天08:00", value: 3 },
{ text: "最近1小时", value: 4 },
{ text: "最近3小时", value: 5 },
{ text: "最近6小时", value: 6 },
{ text: "最近12小时", value: 7 },
{ text: "最近24小时", value: 8 },
],
selValue: 3,
showImg: "../../static/empty.png",
rainList:[],
warnStatus: false, //预警
};
},
onPullDownRefresh() {
this.getAllList();
uni.$showMsg("刷新成功");
setTimeout(function () {
uni.stopPullDownRefresh();
}, 1000);
},
computed: {
getNavList() {
return [
{
value: "工程概况",
key: 1,
icon: "../../static/tabs/wxyh.png",
url: "/pages/gcgk/index",
},
{
value: "巡查任务",
key: 5,
icon: "../../static/tabs/xcrw.png",
url: "/pages/xcrw/index",
},
{
value: "安全监测",
key: 4,
icon: "../../static/tabs/aqjc.png",
url: "/pages/aqjc/index",
},
{
value: "预(报)警",
key: 2,
icon: "../../static/tabs/yujing_icon@2x2.png",
url: "/pages/yj/index",
},
{
value: "视频监控",
key: 3,
icon: "../../static/tabs/spjk.png",
url: "/pages/spjk/index",
},
{
value: "水雨情",
key: 6,
icon: "../../static/tabs/xingzhuang2.png",
url: "/pages/syq/index",
},
];
},
},
methods: {
changeTime(params) {
switch (params) {
case 1:
this.stm = moment()
.subtract(1, "days")
.startOf("day")
.set({ hour: 8, minute: 0 });
this.etm = moment();
break;
case 2:
this.stm = moment().startOf("day").set({ hour: 8, minute: 0 });
this.etm = moment();
break;
case 3:
this.stm = stm;
this.etm = etm;
break;
case 4:
this.stm = moment().subtract(1, "hours");
this.etm = moment();
break;
case 5:
this.stm = moment().subtract(3, "hours");
this.etm = moment();
break;
case 6:
this.stm = moment().subtract(6, "hours");
this.etm = moment();
break;
case 7:
this.stm = moment().subtract(12, "hours");
this.etm = moment();
break;
case 8:
this.stm = moment().subtract(24, "hours");
this.etm = moment();
break;
default:
break;
}
this.getRainData();
console.log("params", params);
},
// 雨量数据
getRainData() {
const params = {
pageSo: {
pageSize: 999,
pageNumber: 1,
},
dateTimeRangeSo: {
start: moment(this.stm).format("YYYY-MM-DD HH:mm:ss"),
end: moment(this.etm).format("YYYY-MM-DD HH:mm:ss"),
},
type: 3,
};
uni.$http
.post("/gunshiApp/ykz/stPptnRReal/his/data", params)
.then((res) => {
if (res.data.code == 200) {
const result = res.data.data;
this.rainList = result;
this.chartData = {...drpOption(result)};
}
});
},
async setInsert(menu2) {
try {
const params = {
createId: uni.getStorageSync("value").userId,
loginType: 1,
menu1: "首页",
menu2: menu2 || "首页",
};
const { data } = await uni.$http.post(
"/gunshiApp/ykz/visitMenuLog/insert",
params
);
} catch (error) {}
},
myNavigateTo(url, menu2) {
uni.navigateTo({
url: url, // 跳转到对应路径的页面
});
// this.setInsert(menu2);
},
// 闸前
getZqList() {
return uni.$http.post("/gunshiApp/ykz/warnRecord/page", {
pageSo: {
pageSize: 999,
pageNumber: 1,
},
dateTimeRangeSo: {
start: warnStm,
end: warnetm,
},
});
},
// 安全类型
getAqList() {
return uni.$http.post("/gunshiApp/ykz/osmoticWarnRecord/page", {
pageSo: {
pageSize: 999,
pageNumber: 1,
},
dateTimeRangeSo: {
start: warnStm,
end: warnetm,
},
});
},
getAllList() {
Promise.all([this.getZqList(), this.getAqList()]).then((res) => {
const result = res.map((item) => item.data?.data?.records).flat();
if (result.length > 0) {
this.warnStatus = true;
}
});
},
},
onShow() {
// this.setInsert();
this.getAllList();
this.getRainData();
},
};
</script>
<style lang="scss" scoped>
.container {
position: relative;
font-size: 14px;
line-height: 24px;
background-color: #f3f5f8;
height: 100%;
overflow: auto;
.info_rain {
padding: 10px;
background-color: #fff;
.heart {
display: flex;
align-items: center;
justify-content: space-between;
}
.title {
display: flex;
align-items: center;
}
}
}
.info {
height: 100rpx;
background-color: #007afd;
display: flex;
align-items: center;
justify-content: space-between;
padding: 20px;
color: #fff;
}
.left {
display: flex;
justify-content: space-around;
align-items: center;
}
.icon {
width: 50px;
height: 50px;
border-radius: 50%;
background-color: #fff;
text-align: center;
color: #007afd;
line-height: 50px;
}
.info_name {
margin-left: 16rpx;
}
.right {
text-align: center;
}
.navBar {
padding: 13px;
padding-bottom: 0;
/* text-align: center; */
display: flex;
background-color: #fff;
// justify-content: center;
margin-bottom: 10px;
}
.navList {
text-align: center;
margin-right: 0px;
margin-bottom: 10px;
}
.navIcon {
position: relative;
width: 82px;
height: 50px;
}
.readStatus {
position: absolute;
top: 0;
right: 17px;
width: 10px;
height: 10px;
border-radius: 50%;
background: #de2433;
}
.warn {
padding: 18rpx 20rpx;
text-align: left;
margin-bottom: 12rpx;
background: #fff;
}
.warn1 {
padding: 18rpx 20rpx;
text-align: left;
margin-bottom: 5px;
background: #fff;
}
.info_24 {
width: 100%;
// position: fixed;
// padding: 15px;
background-color: #fff;
// margin-bottom: 12rpx;
// height: 100px;
}
.title .line {
border: 2px solid #3380ff;
border-radius: 3rpx;
margin-right: 20rpx;
}
.title .h4 {
font-weight: 400;
font-size: 32rpx;
color: #121b3d;
}
.time {
font-weight: 400;
font-size: 24rpx;
color: #a2a2a2;
}
.g1 {
color: #545556;
}
.ye {
color: #ff1717;
/* font-weight: 600; */
}
.b1 {
color: #3380ff;
padding: 0 2px;
}
.uni-group {
display: flex;
align-items: center;
}
/* 表格 */
.tableBox {
width: 100%;
position: relative;
}
.leftTab {
width: 80px;
/* border-bottom: 1px solid #ccc; */
}
.rightTab {
width: 80px;
/* border: 1px solid #ccc;
border-radius: 0 3px 3px 0;
border-left: 0; */
}
.activetextTypeTab,
.activetextTypeTab:hover {
border-bottom: 3rpx solid #2286f6;
color: #026be0;
}
.table_div {
widows: 100%;
height: 100%;
max-width: calc(100% - 0px);
max-height: calc(100vh - 24px);
flex: 1;
padding-top: 30px;
overflow-x: scroll;
}
/*table样式*/
.table_cur {
width: 100%;
empty-cells: show;
border-collapse: collapse;
font-size: 14px;
}
.table_cur tr {
display: flex;
line-height: 56rpx;
}
.table_cur th {
height: 56rpx;
color: #2f4056;
background: #f5f6f8;
font-size: 14px;
font-weight: bold;
padding: 0 10px;
box-sizing: border-box;
white-space: nowrap;
text-align: center !important;
}
.table_cur td {
height: 56rpx;
border-bottom: 1px solid #e5e9f2;
font-size: 14px;
color: #2f4056;
padding: 0 10px;
box-sizing: border-box;
white-space: nowrap;
text-align: center !important;
}
/*table样式 end*/
.noData {
width: 100px;
}
</style>