RightBototmData.vue 7.74 KB
Newer Older
1 2 3
<template>
  <div class="wrapper">
    <div class="left">
纪泽龙's avatar
纪泽龙 committed
4 5
      <div class="top">
        <span>设备报警最新记录</span>
纪泽龙's avatar
纪泽龙 committed
6
        <span @click="repeatClick" class="repeat">刷新</span>
纪泽龙's avatar
纪泽龙 committed
7 8 9 10 11

        <transition name="fade">
          <span v-show="repeatFinshed" class="repeat2"> 数据刷新成功</span>
        </transition>

纪泽龙's avatar
纪泽龙 committed
12
        <span @click="moreClick" class="more">更多>></span>
纪泽龙's avatar
纪泽龙 committed
13
      </div>
14

15 16 17 18 19 20 21 22 23 24
      <div class="bottom right-bottom-data-left">
        <!-- <div class="table-top">
          <div>编号</div>
          <div>名称</div>
          <div>类型</div>
          <div>内容</div>
          <div>事件</div>
        </div> -->
        <!-- <div class="one">设备编号:<span>1123123123</span></div>
        <div class="two">报警时间:<span>34523452345</span></div> -->
纪泽龙's avatar
纪泽龙 committed
25 26 27 28 29 30
        <el-table
          size="mini"
          :data="tableData"
          style="width: 100%"
          height="170"
        >
31 32
        
          <el-table-column prop="deviceCode" label="设备编号" width="100">
33
          </el-table-column>
34
          <el-table-column prop="deviceName" label="设备名称" width="">
35
          </el-table-column>
纪泽龙's avatar
纪泽龙 committed
36
          <el-table-column prop="alarmType" label="报警类型" width="80">
37
          </el-table-column>
纪泽龙's avatar
纪泽龙 committed
38
          <el-table-column prop="createTime" label="报警开始时间" width="170">
39
          </el-table-column>
纪泽龙's avatar
纪泽龙 committed
40
          <el-table-column prop="alarmValue" label="报警内容" width="100">
41 42
          </el-table-column>
        </el-table>
43 44
      </div>
    </div>
45
    
46
    <div class="right">
47 48 49 50 51 52
      <template v-for="(item, index) in list">
        <div
          class="right-content"
          :class="{ three: index == 2 }"
          :key="item.type"
        >
53
          <div class="text-icon">
54 55 56 57
            <i
              class="iconfont"
              :class="[iconClass(item), { iconFontSize: item.type == 4 }]"
            ></i>
58 59
          </div>
          <div class="text">
纪泽龙's avatar
纪泽龙 committed
60 61
            <div class="top">{{ typeName[item.type] }}</div>
            <div class="bottom">
纪泽龙's avatar
纪泽龙 committed
62
              {{ item.number }}{{ item.type == 99 ? "M" : "个" }}
纪泽龙's avatar
纪泽龙 committed
63
            </div>
64 65 66 67 68 69 70 71
          </div>
        </div>
      </template>
    </div>
  </div>
</template>

<script>
纪泽龙's avatar
纪泽龙 committed
72 73
import { listDeviceAlarm } from "@/api/dataMonitoring/deviceAlarm";

74 75 76 77 78 79
export default {
  props: {
    list: {
      type: Array,
    },
  },
纪泽龙's avatar
纪泽龙 committed
80
  data() {
81
    return {
纪泽龙's avatar
纪泽龙 committed
82 83
      timer: null,
      repeatFinshed: false,
纪泽龙's avatar
纪泽龙 committed
84 85 86 87 88 89
      typeName: {
        1: "调压箱",
        2: "阀门井",
        3: "流量计",
        4: "压力表",
        99: "管道",
90
      },
纪泽龙's avatar
纪泽龙 committed
91
      iconList: {
纪泽龙's avatar
纪泽龙 committed
92 93 94 95
        1: "icon-tyxgs",
        2: "icon-fmjgs",
        3: "icon-lljgs",
        4: "icon-ylbgs",
纪泽龙's avatar
纪泽龙 committed
96 97
        99: "icon-gdcd",
      },
98 99
      tableData: [
        {
纪泽龙's avatar
纪泽龙 committed
100
          deviceCode: "2016-05-03",
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路",
        },
        {
          date: "2016-05-02",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "2016-05-04",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "2016-05-01",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "2016-05-08",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "2016-05-06",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "2016-05-07",
          name: "王小虎",
          province: "上海",
          city: "普陀区",
          address: "上海市普陀区金沙江路 1518 弄",
        },
      ],
纪泽龙's avatar
纪泽龙 committed
149
    };
150 151 152
  },
  created() {
    console.log("list", this.list);
纪泽龙's avatar
纪泽龙 committed
153
    this.getList();
154
  },
纪泽龙's avatar
纪泽龙 committed
155

纪泽龙's avatar
纪泽龙 committed
156 157
  methods: {
    iconClass(item) {
158
      return this.iconList[item.type];
纪泽龙's avatar
纪泽龙 committed
159
    },
纪泽龙's avatar
纪泽龙 committed
160 161 162 163
    moreClick() {
      this.$router.push("/dataMonitoring/deviceAlarm");
      // route.push(`dataMonitoring/deviceAlarm`)
    },
纪泽龙's avatar
纪泽龙 committed
164 165 166 167
    repeatClick() {
      // this.tableData=[];
      if(this.repeatFinshed) return;
      this.getList(true);
纪泽龙's avatar
纪泽龙 committed
168
    },
纪泽龙's avatar
纪泽龙 committed
169
    getList(bool) {
纪泽龙's avatar
纪泽龙 committed
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
      this.loading = true;
      listDeviceAlarm({ pageNum: 1, pageSize: 10 }).then((res) => {
        if (res.code == 200) {
          const arr = res.rows.map((item) => {
            const {
              deviceCode,
              deviceName,
              alarmType,
              createTime,
              alarmValue,
            } = item;
            return {
              deviceCode,
              deviceName,
              alarmType,
              createTime,
              alarmValue,
            };
          });
纪泽龙's avatar
纪泽龙 committed
189 190 191 192 193 194 195 196
          this.tableData = arr;
          if (bool) {
            this.timer = null;
            this.repeatFinshed = true;
            this.timer = setTimeout(() => {
              this.repeatFinshed = false;
            }, 1000);
          }
纪泽龙's avatar
纪泽龙 committed
197 198 199
        }
      });
    },
纪泽龙's avatar
纪泽龙 committed
200
  },
201 202 203 204 205
};
</script>

<style lang="scss"  scoped>
.wrapper {
206 207
  // width: 978px;
  height: 200px;
208
  position: fixed;
209 210
  right: 10px;
  bottom: 10px;
纪泽龙's avatar
纪泽龙 committed
211
  overflow: hidden;
212 213 214 215 216 217
  // background-color: #fff;
  display: flex;
  justify-content: space-between;
  & > div {
  }
  .left {
纪泽龙's avatar
纪泽龙 committed
218
    width: 680px;
219 220
    margin-right: 12px;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.16);
221 222
    // background-color: #fff;
    // color: #fff;
223 224 225 226 227
    font-size: 14px;
    font-weight: 400;
    .top {
      height: 32px;
      background-color: #053b6a;
228
      color: #fff;
229 230
      line-height: 32px;
      padding-left: 12px;
纪泽龙's avatar
纪泽龙 committed
231
      // position: relative;
纪泽龙's avatar
纪泽龙 committed
232

纪泽龙's avatar
纪泽龙 committed
233 234 235 236 237 238 239 240 241 242
      span {
        display: inline-block;
      }
      .repeat {
        margin-left: 20px;
        cursor: pointer;
        &:hover {
          color: #2788ea;
        }
      }
纪泽龙's avatar
纪泽龙 committed
243 244 245 246
      .repeat2 {
        margin-left: 20px;
        color:#67c23a;
      }
纪泽龙's avatar
纪泽龙 committed
247 248 249 250 251 252 253 254
      .more {
        float: right;
        margin-right: 20px;
        cursor: pointer;
        &:hover {
          color: #2788ea;
        }
      }
255 256
    }
    .bottom {
257 258 259 260 261 262 263 264
      .table-top {
        // background-color: red;
        // display: flex;
        // justify-content: space-between;
        // div {
        //   width: 100%;
        //   text-align: center;
        // }
265 266 267 268
      }
    }
  }
  .right {
269
    width: 740px;
270 271
    display: flex;
    flex-wrap: wrap;
272
    // justify-content: space-between;
273
    align-content: flex-start;
274
    // margin-top: 7px;
275 276 277 278 279 280
    & > .right-content {
      background-color: #fff;
      width: 238px;
      height: 82px;
      margin-bottom: 29px;
      box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.16);
281
      margin-right: 10px;
282
      display: flex;
283 284 285
      &.three {
        margin-right: 0px;
      }
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
      // align-items: center;
      .text-icon {
        line-height: 82px;
        padding-left: 22px;
        margin-right: 22px;
        i {
          color: #053b6a;
          font-size: 60px;
        }
      }
      .text {
        font-size: 14px;
        padding-top: 16px;
        .top {
          color: #000;
          margin-bottom: 10px;
          font-weight: 600;
        }
        .bottom {
          color: #2788ea;
        }
      }
    }
  }
纪泽龙's avatar
纪泽龙 committed
310
  // 单独调整下最后一个icon的大小
311
  .iconFontSize {
纪泽龙's avatar
纪泽龙 committed
312 313
    font-size: 50px !important;
  }
纪泽龙's avatar
纪泽龙 committed
314 315 316 317 318 319 320 321 322 323 324 325 326
  .fade-enter-to,
  .fade-leave {
    opacity: 1;
  }
  .fade-leave-active {
    transition: opacity 0.5s;
  }
  .fade-enter-active {
    transition: opacity 0s;
  }
  .fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
    opacity: 0;
  }
327 328
}
</style>