Middle.vue 4.9 KB
Newer Older
纪泽龙's avatar
纪泽龙 committed
1 2 3
<!--
 * @Author: your name
 * @Date: 2022-04-11 15:07:47
纪泽龙's avatar
纪泽龙 committed
4
 * @LastEditTime: 2022-04-20 11:09:34
纪泽龙's avatar
纪泽龙 committed
5 6 7 8 9 10 11 12 13 14
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /gassafety-progress/gassafetyprogress-web/src/views/operationMonitor/xunjianxuncha/topChars/left.vue
-->
<template>
  <div class="charsCom all-flex-h">
    <div class="title">隐患整改</div>
    <div class="two all-flex">
      <div class="left">
        <div class="first">
yaqizhang's avatar
yaqizhang committed
15
          <span class="text">隐患发现情况</span>
yaqizhang's avatar
yaqizhang committed
16
          <span>20次</span>
纪泽龙's avatar
纪泽龙 committed
17 18
        </div>
        <div class="second all-flex">
yaqizhang's avatar
yaqizhang committed
19 20
          <div class="left">隐患总数</div>
          <div class="right">隐患已整改数</div>
纪泽龙's avatar
纪泽龙 committed
21 22
        </div>
        <div class="third all-flex">
yaqizhang's avatar
yaqizhang committed
23 24
          <div class="left">13</div>
          <div class="right">7</div>
纪泽龙's avatar
纪泽龙 committed
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 54 55
        </div>
      </div>
      <div class="right">
        <div class="first">
          <span class="text">隐患整改率</span>
        </div>
        <div class="chars-box">
          <Chars color="#604AFF"></Chars>
        </div>
      </div>
    </div>

    <div class="three all-flex-h">
      <div class="first">隐患原因</div>
      <div ref="myChartWidth" class="chars-box">
        <Chars :options="bottomOptions()" />
      </div>
    </div>
  </div>
</template>

<script>
import Chars from "@/components/allCharsCom/Chars";
export default {
  components: {
    Chars,
  },
  data() {
    return {
      bottomData: [
        [
yaqizhang's avatar
yaqizhang committed
56 57 58 59 60
          { name: "裂缝", value: 8, color: "#604AFF" },
          { name: "管道称重", value: 16, color: "#FFC337" },
          { name: "其他", value: 13, color: "#86FF5B" },
          { name: "腐蚀", value: 7, color: "#03C4F1" },
          { name: "漏气", value: 5, color: "#1F8DF3" },
纪泽龙's avatar
纪泽龙 committed
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
        ],
      ],
    };
  },
  methods: {
    bottomOptions() {
      return {
        series: this.bottomData.map((data, idx) => {
          const rich = {};
          data
            .map((item) => ({
              fontsize: 12,
              color: item.color,
            }))
            .forEach((item, index) => {
              rich[`dataIndex${index}`] = item;
            });
王晓倩's avatar
王晓倩 committed
78

纪泽龙's avatar
纪泽龙 committed
79 80 81 82 83 84 85 86 87 88 89 90 91
          return {
            type: "pie",
            radius: ["68%", "80%"],
            color: data.map((item) => item.color),
            itemStyle: {
              borderWidth: 2,
              borderRadius: 10,
              borderColor: "#fff",
            },
            label: {
              alignTo: "edge",
              // formatter: "{name|{b}}\n{num|{c} 个}",
              formatter: (parm) => {
yaqizhang's avatar
yaqizhang committed
92
                return `{dataIndex${parm.dataIndex}|${parm.data.name}}\n{dataIndex${parm.dataIndex}|${parm.data.value}}`;
纪泽龙's avatar
纪泽龙 committed
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
              },
              minMargin: 5,
              edgeDistance: 10,
              lineHeight: 15,
              rich,
            },
            labelLine: {
              length: 15,
              length2: 0,
              maxSurfaceAngle: 80,
            },
            labelLayout: (params) => {
              const { width } = this.$refs.myChartWidth.getBoundingClientRect();
              const isLeft = params.labelRect.x < width / 2;
              const points = params.labelLinePoints;
纪泽龙's avatar
纪泽龙 committed
108
              console.log("points",points)
纪泽龙's avatar
纪泽龙 committed
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
              // Update the end point.
              points[2][0] = isLeft
                ? params.labelRect.x
                : params.labelRect.x + params.labelRect.width;
              return {
                labelLinePoints: points,
              };
            },
            data: data,
          };
        }),
      };
    },
  },
};
</script>

<style lang="scss" scoped>
.charsCom {
  width: 100%;
  height: 100%;
  color: #333333;
}
.title {
  text-align: center;
王晓倩's avatar
王晓倩 committed
134
  font-size: 24px;
纪泽龙's avatar
纪泽龙 committed
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
  margin-bottom: 7px;
}
.two {
  // flex: 1;
  > .left {
    margin-right: 70px;
    .first {
      margin-bottom: 6px;
    }
    .second {
      width: 213px;
      height: 30px;
      line-height: 30px;
      box-sizing: border-box;
      box-shadow: 0px 0px 3px 1px #dddddd;
      margin-bottom: 19px;
      > div {
        // flex: 1;
        text-align: center;

        &.left {
          color: #1d8cf3;
        }
        &.right {
          color: #00c3f1;
        }
      }
    }
    .third {
      text-align: center;
      width: 213px;
王晓倩's avatar
王晓倩 committed
166
      margin-bottom: 24px;
纪泽龙's avatar
纪泽龙 committed
167 168 169 170 171 172 173 174 175 176 177 178 179
    }
  }
  > .right {
    .first {
      text-align: center !important;
    }
    .chars-box {
      width: 90px;
      height: 90px;
      margin: 0 auto;
    }
  }
  > div {
王晓倩's avatar
王晓倩 committed
180
    font-size: 16px;
纪泽龙's avatar
纪泽龙 committed
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
    flex: 1;
    // display: flex;
    // flex-direction: column;
  }
  .left,
  .right {
    // display: flex;
    // flex-direction: column;
    // justify-content: space-between;
    .first {
      text-align: left;
      .text {
        display: inline-block;
        margin-right: 8px;
      }
    }
  }
}
.three {
王晓倩's avatar
王晓倩 committed
200
  font-size: 16px;
纪泽龙's avatar
纪泽龙 committed
201 202 203 204 205 206
  flex: 1;
  // background: red;
  .chars-box {
    flex: 1;
  }
}
王晓倩's avatar
王晓倩 committed
207
</style>