heyujie
2021-11-03 57094ef66e4afb413c39ecd181e65938315c195c
1
2
3
4
5
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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
132
133
134
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<template>
  <div class="swipe-tabs">
    <swiper :options="swiperOption" ref="swiperTabs">
      <swiper-slide v-for="slide in slides" :key="slide.id">
        <div
          class="slide-tab"
          :class="{ act: actSlide == slide.id }"
          @click="checkSlide(slide)"
        >
          <Pie :options="optOfPie(slide)"></Pie>
          <div class="info">
            <div class="title">违规率</div>
            <div class="num">78%</div>
            <div class="place">中铁一局</div>
          </div>
        </div>
      </swiper-slide>
    </swiper>
    <div class="swiper-scrollbar"></div>
    <div class="swiper-button-next">
      <div class="icon-btn">
        <i class="iconfont iconyou1"></i>
      </div>
    </div>
    <div class="swiper-button-prev">
      <div class="icon-btn">
        <i class="iconfont iconzuo"></i>
      </div>
    </div>
    <div class="swiper-pagination"></div>
  </div>
</template>
 
<script>
import Pie from "./charts/pie";
export default {
  components: { Pie },
  data() {
    return {
      swiperOption: {
        spaceBetween: 0,
        //initialSlide: 0,
        direction: "horizontal",
        navigation: {
          nextEl: ".swiper-button-next",
          prevEl: ".swiper-button-prev",
        },
        slidesPerView: 6,
        observer: true,
        observeParents: true,
      },
      slides: [
        { id: "jlfgs", name: "机量分公司", ratio: 1.5 },
        { id: "ztyj", name: "中铁一局", ratio: 1.6 },
        { id: "ztsj", name: "中铁三局", ratio: 1.2 },
        { id: "ztsij", name: "中铁四局", ratio: 1.3 },
        { id: "jtjw", name: "京铁机务", ratio: 0.2 },
        { id: "ztwj", name: "中铁五局", ratio: 1.2 },
        { id: "jgjw", name: "京高机务", ratio: 0.7 },
      ],
      actSlide: "",
    };
  },
  mounted() {
    this.actSlide = this.slides[0].id;
  },
  methods: {
    optOfPie(slide) {
      return {
        tooltip: {
          trigger: "item",
          formatter: "{a}<br/>{b}:{c} ({d}%)",
        },
        // legend: {
        //   orient: 'vertical',
        //   right: 10,
        //   y: 'center',
        //   data: ['未鸣笛', '未手比', '未呼唤', '运行中睡觉', '未检查', '未应答']
        // },
        series: [
          {
            name: "违规率",
            type: "pie",
            color: ["#2D52D7", " #D9DFE6"],
            radius: ["28%", "35%"],
            center: ["50%", "48%"],
            silent: true,
            tooltip: {
              show: false,
            },
            avoidLabelOverlap: false,
            label: {
              show: false,
              position: "center",
            },
            hoverAnimation: false,
            labelLine: {
              show: false,
            },
            data: [
              { value: slide.ratio, name: "" },
              { value: 3 - slide.ratio, name: "" },
            ],
          },
        ],
      };
    },
    checkSlide(slide) {
      this.actSlide = slide.id;
      this.$emit("checkTab", slide);
    },
  },
};
</script>
 
<style lang="scss">
.swipe-tabs {
  width: 94%;
  position: relative;
  padding: 0 30px;
 
  .swiper-container {
    border-left: 1px solid #eee;
    border-right: 1px solid #eee;
  }
  .slide-tab {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    border-left: 10px solid #f4f6f9;
    cursor: pointer;
    height: 130px;
    background: #f4f6f9;
    opacity: 0.67;
    &.act {
      border-color: #2d52d7;
    }
 
    .info {
      position: absolute;
      top: 39px;
      left: 50%;
      margin-left: -28px;
      text-align: center;
      .title {
        font-size: 12px;
        color: #425277;
        opacity: 0.6;
      }
 
      .num {
        font-size: 20px;
        color: #425277;
      }
 
      .place {
        margin-top: 23px;
        font-size: 14px;
        font-weight: 700;
      }
    }
  }
  .swiper-button-prev,
  .swiper-button-next {
    cursor: pointer;
    // width: 40px;
    // height: 40px;
    position: absolute;
    background: transparent;
    top: 50%;
    margin-top: -20px;
    z-index: 999;
    //border-radius: 4em;
    outline: none;
    .icon-btn {
      font-size: 24px;
      color: #666;
      text-align: center;
      line-height: 38px;
      cursor: pointer;
    }
  }
  .swiper-button-next {
    right: -10px;
  }
  .swiper-button-prev {
    left: -10px;
  }
}
</style>