Xjtj.vue 5.78 KB
Newer Older
耿迪迪's avatar
耿迪迪 committed
1 2 3 4
<!--
 * @Author: 纪泽龙 jizelong@qq.com
 * @Date: 2022-09-06 13:42:45
 * @LastEditors: 纪泽龙 jizelong@qq.com
5
 * @LastEditTime: 2022-10-22 11:36:35
耿迪迪's avatar
耿迪迪 committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
 * @FilePath: /danger-manage-web/src/views/indexComponents/leftComponents/deviceYx.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="first-wrapper flex">
    <Title text="巡检统计" />
    <div class="two flex">
      <div class="top">
        <div class="time">
          <span
            v-for="item in ['日', '月', '年']"
            :key="item"
            @click="timeChange(item)"
            :class="{ active: item == yearActive }"
          >
            {{ item }}
          </span>
        </div>

        <div class="countNumbe flex">
          <div
            v-for="item in numData"
            :key="item.name"
            class="countNumbe-item flex"
          >
            <div class="img">
              <img :src="item.icon" alt="" />
            </div>
            <div class="text">
              <div class="name">{{ item.name }}</div>
              <div class="num">{{ item.num }}</div>
            </div>
          </div>
        </div>
      </div>

      <div class="bottom">
        <Chars :options="options" />
      </div>
    </div>
  </div>
</template>

<script>
import Title from "@/views/indexComponents/allComponents/Title";
import Chars from "@/components/allCharsCom/Chars";
import rimg1 from "@/assets/indexImages/rimg1.png";
import rimg2 from "@/assets/indexImages/rimg2.png";
54
import { getxjtjYMD } from "@/api/indexChars/chars";
耿迪迪's avatar
耿迪迪 committed
55 56 57 58 59 60 61 62 63 64 65

export default {
  name: "",
  components: {
    Title,
    Chars,
  },
  data() {
    return {
      yearActive: "年",
      numData: [
66 67
        // { icon: rimg1, name: "发现隐患数量", num: 2 },
        // { icon: rimg2, name: "整改隐患数量", num: 1 },
耿迪迪's avatar
耿迪迪 committed
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 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
      ],
      options: {
        xAxis: {
          type: "category",
          data: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"],
          axisLine: {
            show: true,
            lineStyle: {
              color: "rgba(19, 135, 167, 1)",
            },
          },
          axisLabel: {
            color: "#ffffff",
          },
        },
        yAxis: {
          type: "value",
          name: "月度巡检统计图",
          nameTextStyle: {
            color: "#ffffff",
            padding: [0, 0, 0, 40],
            fontSize: 15,
          },
          nameGap: 10,
          min: 0,
          max: 250,
          axisLine: {
            show: true,
            lineStyle: {
              color: "rgba(19, 135, 167, 1)",
            },
          },
          axisLabel: {
            color: "#ffffff",
          },
          splitLine: {
            show: true,
            lineStyle: {
              color: "rgba(19, 135, 167, .5)",
              type: "dashed",
            },
          },
        },
        grid: {
          left: "10%",
          right: "5%",
          top: "20%",
          bottom: "10%",
        },
        series: [
          {
            data: [120, 200, 150, 80, 70, 110, 130, 200, 210, 140, 190, 120],
            type: "bar",
            barWidth: 10,

            itemStyle: {
              color: "rgba(45, 207, 255, 1)",
              borderRadius: [0, 3, 3, 0],
            },
          },
        ],
      },
    };
  },
132 133 134
  created() {
    this.getxjtjYMD({ type: "year" });
  },
耿迪迪's avatar
耿迪迪 committed
135
  methods: {
136 137 138 139 140 141 142 143 144 145 146
    getxjtjYMD(query) {
      getxjtjYMD(query).then((res) => {
        if (res.code == 200) {
          const { faxian, zhenggai } = res.data;
          this.numData = [
            { icon: rimg1, name: "发现隐患数量", num: faxian },
            { icon: rimg2, name: "整改隐患数量", num: zhenggai },
          ];
        }
      });
    },
耿迪迪's avatar
耿迪迪 committed
147 148 149 150
    timeChange(e) {
      if (this.yearActive == e) return;
      this.yearActive = e;
      if (this.yearActive == "日") {
151 152 153 154 155 156
        this.getxjtjYMD({ type: "day" });

        // this.numData = [
        //   { icon: rimg1, name: "发现隐患数量", num: 3 },
        //   { icon: rimg2, name: "整改隐患数量", num: 2 },
        // ];
耿迪迪's avatar
耿迪迪 committed
157
      } else if (this.yearActive == "月") {
158 159 160 161 162 163
        this.getxjtjYMD({ type: "month" });

        // this.numData = [
        //   { icon: rimg1, name: "发现隐患数量", num: 6 },
        //   { icon: rimg2, name: "整改隐患数量", num: 10 },
        // ];
耿迪迪's avatar
耿迪迪 committed
164
      } else {
165 166 167 168 169 170
        this.getxjtjYMD({ type: "year" });

        // this.numData = [
        //   { icon: rimg1, name: "发现隐患数量", num: 56 },
        //   { icon: rimg2, name: "整改隐患数量", num: 50 },
        // ];
耿迪迪's avatar
耿迪迪 committed
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.first-wrapper {
  width: 100%;
  height: 40%;
  // background: blue;
  flex-direction: column;
  > div {
    // width: 100%;
  }
  .two {
    position: relative;
    flex: 1;
    flex-direction: column;

    // background: wheat;
    .top {
      height: 22%;
      width: 100%;
      // background: red;
      position: relative;
      .time {
        position: absolute;
        top: -43px;
        right: 0;
        font-size: 14px;
        font-weight: 400;
        color: #1387a7;
        > span {
          display: inline-block;
          margin-left: 10px;
          cursor: pointer;
          &.active {
            color: #75e7f8;
          }
        }
      }
      .countNumbe {
        justify-content: space-between;
        align-items: center;
        padding: 0 17px;
        .img {
          margin-right: 11px;
        }
        .text {
          .name {
            color: #2ffae0;
            font-weight: 400;
            font-size: 16px;
          }
          .num {
            font-size: 21px;
            color: #ffffff;
          }
        }
      }
    }
    .bottom {
      flex: 1;
    }
  }
}
</style>