123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375 |
- <template>
- <div class="swiperMulti" @mouseenter="mouseenter" @mouseleave="mouseleave">
- <div class="el-toLeft guide" v-show="guideShow" @click.stop="toLeft">
- <i class="el-icon-arrow-right icon"></i>
- </div>
- <div class="el-toRight guide" v-show="guideShow" @click.stop="toRight">
- <i class="el-icon-arrow-left icon"></i>
- </div>
- <ul>
- <li
- v-for="(item, index) in data"
- :key="item.lqid"
- :style="`left:${(index - 1) * itemPositionInterval}px`"
- :ref="'item' + index"
- :data-position-left="(index - 1) * itemPositionInterval"
- >
- <template v-if="item.isQk">
- <h3 class="h3_type_1">{{item.position}}</h3>
- <div class="warp">
- <div class="gutter" @click="openItem(item, 1)">
- <el-row>
- <el-col :span="10" class="temp-line">
- <span >水量:</span>
- </el-col>
- <el-col :span="14" style="text-align: left;">
- <span v-if="item.sl === ''" class="text-red" style="font-size: 16px;">暂无数据</span>
- <span v-else class="text-green" >{{item.sl}}吨</span>
- </el-col>
- </el-row>
- </div>
- <div class="gutter" @click="openItem(item, 2)">
- <el-row>
- <el-col :span="10" class="humidity-line">
- <span >电量:</span>
- </el-col>
- <el-col :span="14" class="gutter_text" style="text-align: left;">
- <span v-if="item.dl === ''" class="text-red" style="font-size: 16px;">暂无数据</span>
- <span v-else class="text-green" >{{item.dl}}kwh</span>
- </el-col>
- </el-row>
- </div>
- <div class="gutter" @click="openItem(item, 3)">
- <el-row>
- <el-col :span="10" class="ammonia-line">
- <span >ph:</span>
- </el-col>
- <el-col :span="14" style="text-align: left;">
- <span v-if="item.ph === '' " class="text-red" style="font-size: 16px;">暂无数据</span>
- <span v-else class="text-green" >{{item.ph}}</span>
- </el-col>
- </el-row>
- </div>
- <div class="gutter" @click="openItem(item, 4)">
- <el-row>
- <el-col :span="10" class="ammonia-line">
- <span >水压:</span>
- </el-col>
- <el-col :span="14" style="text-align: left;">
- <span v-if="item.sy === '' " class="text-red" style="font-size: 16px;">暂无数据</span>
- <span v-else class="text-green" >{{item.sy}}Mpa</span>
- </el-col>
- </el-row>
- </div>
- </div>
- </template>
- <template v-else>
- <!-- {{ item.id }} -->
- <h3 class="h3_type_1">{{item.position}}</h3>
- <div class="warp" @click="onOpen(item)">
- <div class="gutter">
- <el-row>
- <el-col :span="14" class="temp-line">
- <i class="icon_temp"></i>
- <span class="temp_text">温度:</span>
- </el-col>
- <el-col :span="10" style="text-align: left;">
- <span v-if="item.temp === ''" class="text-red" style="font-size: 16px;">暂无数据</span>
- <span v-else :class="item.temp > 35 ? 'text-red' : 'text-green'" >{{item.temp}}℃</span>
- </el-col>
- </el-row>
- </div>
- <div class="gutter" @click="onOpen(item)">
- <el-row>
- <el-col :span="14" class="humidity-line">
- <i class="icon_humidity"></i>
- <span class="humidity_text">湿度:</span>
- </el-col>
- <el-col :span="10" class="gutter_text" style="text-align: left;">
- <span v-if="item.humidity === ''" class="text-red" style="font-size: 16px;">暂无数据</span>
- <span v-else :class="item.humidity > 93 ? 'text-red' : 'text-green'" >{{item.humidity}}RH</span>
- </el-col>
- </el-row>
- </div>
- <div class="gutter" @click="onOpen(item)">
- <el-row>
- <el-col :span="14" class="ammonia-line">
- <i class="icon_ammonia"></i>
- <span class="ammonia_text">氨气:</span>
- </el-col>
- <el-col :span="10" style="text-align: left;">
- <span v-if="item.ammonia === '' " class="text-red" style="font-size: 16px;">暂无数据</span>
- <span v-else :class="item.ammonia > 3 ? 'text-red' : 'text-green'" >{{item.ammonia}}mg/m³</span>
- </el-col>
- </el-row>
- </div>
- </div>
- </template>
- </li>
- </ul>
- </div>
- </template>
- <script>
- let timer, timer1;
- export default {
- data() {
- return {
- active: 1,
- guideShow: false,
- itemPositionInterval: 240, // 定位间隔
- data: [],
- };
- },
- created() {},
- mounted() {
- this.init();
- this.setInit();
- },
- destroyed() {
- clearInterval(timer);
- clearInterval(timer1);
- },
- methods: {
- toRight() {
- let firstItemPositionLift = this.$refs.item0[0].getAttribute("data-position-left");
- if (Number(firstItemPositionLift) <= -this.itemPositionInterval) {
- this.data.unshift(this.data.pop());
- }
- },
- toLeft() {
- let firstItemPositionLift = this.$refs.item0[0].getAttribute("data-position-left");
- if (Number(firstItemPositionLift) >= -this.itemPositionInterval) {
- this.data.push(this.data.shift());
- }
- },
- setInterval() {
- clearInterval(timer)
- let that = this;
- timer = setInterval(() => {
- that.toLeft();
- }, 2000);
- },
- mouseenter(e) {
- this.guideShow = true;
- clearInterval(timer);
- },
- mouseleave() {
- this.guideShow = false;
- this.setInterval()
- },
- onOpen(item) {
- this.$emit('onOpen', item);
- },
- openItem(item, i) {
- this.$emit('openItem', {item: item, index: i});
- },
- init() {
- console.log('++++++++++++++++++++++++++++');
- this.$http.get('/environment/getZsda', {mcid: 39})
- .then(res => {
- // loading.close();
- if(res.code === 10000) {
- // this.data = res.data;
- this.data = [];
- let arr1 = [];
- let arr2 = [];
- res.data.forEach(item => {
- if(item.isQuanKong) {
- this.$http.post('http://122.112.252.100:8088/allDataController/findByZSID', {ZSID: item.zsid, lqid: item.lqid})
- .then(res => {
- let slList = [];
- let dlList = [];
- let phList = [];
- let syList = [];
- Object.values(res.data.sl).forEach(key => {
- slList.push(key);
- });
- let sl = Math.max(...slList);
- Object.values(res.data.dl).forEach(key => {
- dlList.push(key);
- });
- let dl = Math.max(...dlList);
- Object.values(res.data.ph).forEach(key => {
- phList.push(key);
- });
- Object.values(res.data.sy).forEach(key => {
- syList.push(key);
- });
- let ph = Math.max(...phList);
- let sy = Math.max(...syList);
- if(res.data.zsid === item.zsid) {
- arr1.push({
- sl: sl,
- dl: dl,
- ph: ph,
- sy: sy,
- isQk: true,
- position: item.zsmc,
- lqid: res.data.lqid,
- zsid: res.data.zsid,
- dlLists: res.data.dl,
- phLists: res.data.ph,
- slLists: res.data.sl,
- syLists: res.data.sy
- });
- }
- this.data = arr1.concat(arr2);
- })
- } else {
- this.$http.get('/environment/getLastEnvByLq', {lqid: item.lqid})
- .then(res => {
- if(res.data.lqid === item.lqid) {
- res.data.position = item.zsmc;
- res.data.isQk = false;
- }
- arr2.push(res.data);
- this.data = arr1.concat(arr2);
- })
- }
- });
- // 数组排序
- this.data.sort(function(a, b){a.lqid - b.lqid});
- this.setInterval();
- }
- })
- .catch(err => {
- // this.loading = false;
- // loading.close();
- })
- },
- setInit() {
- let that = this;
- timer1 = setInterval(() => {
- that.init();
- }, 1800000)
- }
- },
- // beforeUpdate() {
- // console.log('==========================');
- // clearInterval(timer)
- // }
- };
- </script>
- <style lang="scss" scope>
- .swiperMulti {
- box-sizing: border-box;
- width: 100%;
- height: 100%;
- position: relative;
- cursor: pointer;
- > .guide{
- position: absolute;
- font-size: 60px;
- height: 100%;
- display: flex;
- align-items: center;
- z-index: 1;
- background-color: #4441;
- &:hover{
- background-color: #9991;
- }
- .icon{
- transition: all 1s ease-in-out;
- }
- }
- > .el-toRight {
- left: 0;
- }
- > .el-toLeft {
- right: 0;
- }
- ul {
- width: 100%;
- height: 100%;
- li {
- // border: 1px solid rgb(60, 206, 16);
- background-color: #0D1943;
- width: 220px;
- height: 100%;
- position: absolute;
- transition: all 0.5s ease;
- display: flex;
- flex-direction: column;
- > h3{
- text-align: center;
- font-size: 1.3rem;
- font-weight: normal;
- }
- > .h3_type_1{
- background-color: #207BC4;
- }
- > .h3_type_2{
- background-color: #0E1E51;
- }
- > .warp {
- flex-grow: 1;
- // border: 1px solid rgb(221, 218, 16);
- .gutter {
- padding: 30px 0 20px 0;
- text-align: center;
- font-size: 22px;
- .text-red {
- color: #F56C6C;
- }
- .text-green {
- color: #67C23A;
- }
- .temp-line {
- position: relative;
- .icon_temp {
- display: inline-block;
- width: 28px;
- height: 28px;
- background-image: url("../../assets/icon_T.png");
- background-size: 100% 100%;
- position: absolute;
- top: 0;
- left: 15px;
- }
- .temp_text {
- padding-left: 44px;
- }
- }
- .humidity-line {
- position: relative;
- .icon_humidity {
- display: inline-block;
- width: 28px;
- height: 28px;
- background-image: url("../../assets/icon_humidity.png");
- background-size: 100% 100%;
- position: absolute;
- top: 0;
- left: 15px;
- }
- .humidity_text {
- padding-left: 44px;
- }
- }
- .ammonia-line {
- .icon_ammonia {
- display: inline-block;
- width: 28px;
- height: 28px;
- background-image: url("../../assets/icon_meter.png");
- background-size: 100% 100%;
- position: absolute;
- top: 0;
- left: 15px;
- }
- .ammonia_text {
- padding-left: 44px;
- }
- }
- }
- }
- }
- }
- }
- </style>
|