<template>
  <div class="page">
    <div class="left">
      <div class="left_top">
        <div class="title">
          部门绩效总分排名TOP10
          <div class="button_box">
            <span>今年</span>
            <span class="check">本月</span>
            <span>今日</span>
          </div>
        </div>
        <dv-scroll-ranking-board
          :config="config"
          style="width:100%;height:75%"
        />
      </div>
      <div class="left_mid">
        <div class="button_box">
          <span>今年</span>
          <span class="check">本月</span>
          <span>今日</span>
        </div>
        <div id="leida" style="width: 100%;height: 100%;"></div>
      </div>
      <div class="left_down">
        <div id="rulePie" style="width: 100%;height: 100%;"></div>
      </div>
    </div>
    <div class="mid">
      <div class="mid_top">
        <div class="top_box one">
          <div class="title">今年分值情况</div>
          <div class="mid_content">
            <div class="content_top">
              <p class="content_text">
                <span class="txt">初始扣分</span
                ><span class="txt_num">9856241</span>
              </p>
              <p class="content_text">
                <span class="txt">核查扣分</span
                ><span class="txt_num">9856241</span>
                <span class="txt_small">占比：87.21%</span>
              </p>
              <p class="content_text">
                <span class="txt">申诉分值</span
                ><span class="txt_num">9856241</span>
                <span class="txt_small">占比：87.21%</span>
              </p>
              <p class="content_text">
                <span class="txt">累计扣分</span
                ><span class="txt_num">9856241</span>
              </p>
            </div>
            <div class="content_down">
              <div class="down_left">
                <div class="num">+65.32%</div>
                <p class="down_text">环比增长率</p>
              </div>
              <div class="down_right">
                <div class="num">+65.32%</div>
                <p class="down_text">同比增长率</p>
              </div>
            </div>
          </div>
        </div>
        <div class="top_box two">
          <div class="title">本月分值情况</div>
          <div class="mid_content">
            <div class="content_top">
              <p class="content_text">
                <span class="txt">初始扣分</span
                ><span class="txt_num">9856241</span>
              </p>
              <p class="content_text">
                <span class="txt">核查扣分</span
                ><span class="txt_num">9856241</span>
                <span class="txt_small">占比：87.21%</span>
              </p>
              <p class="content_text">
                <span class="txt">申诉分值</span
                ><span class="txt_num">9856241</span>
                <span class="txt_small">占比：87.21%</span>
              </p>
              <p class="content_text">
                <span class="txt">累计扣分</span
                ><span class="txt_num">9856241</span>
              </p>
            </div>
            <div class="content_down">
              <div class="down_left">
                <div class="num">+65.32%</div>
                <p class="down_text">环比增长率</p>
              </div>
              <div class="down_right">
                <div class="num">+65.32%</div>
                <p class="down_text">同比增长率</p>
              </div>
            </div>
          </div>
        </div>
        <div class="top_box three">
          <div class="title">今日分值情况</div>
          <div class="mid_content">
            <div class="content_top">
              <p class="content_text">
                <span class="txt">初始扣分</span
                ><span class="txt_num">9856241</span>
              </p>
              <p class="content_text">
                <span class="txt">核查扣分</span
                ><span class="txt_num">9856241</span>
                <span class="txt_small">占比：87.21%</span>
              </p>
              <p class="content_text">
                <span class="txt">申诉分值</span
                ><span class="txt_num">9856241</span>
                <span class="txt_small">占比：87.21%</span>
              </p>
              <p class="content_text">
                <span class="txt">累计扣分</span
                ><span class="txt_num">9856241</span>
              </p>
            </div>
            <div class="content_down">
              <div class="down_left">
                <div class="num">+65.32%</div>
                <p class="down_text">环比增长率</p>
              </div>
              <div class="down_right">
                <div class="num">+65.32%</div>
                <p class="down_text">同比增长率</p>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="mid_down">
        <div class="down_content">
          <img class="content_title" src="../../../assets/images/title.png" />
          <div style="margin: 20px 0;">
            <el-radio-group v-model="type" border>
              <el-radio-button label="1">部门评估</el-radio-button>
              <el-radio-button label="2">个人评估</el-radio-button>
            </el-radio-group>
          </div>
          <div class="form">
            <el-form ref="form" :model="form" label-width="100px">
              <el-form-item label="请选择部门：">
                <el-select
                  v-model="form.region"
                  placeholder="请选择部门"
                  style="width: 100%;"
                >
                  <el-option label="区域一" value="shanghai"></el-option>
                  <el-option label="区域二" value="beijing"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="请选择时间：">
                <el-date-picker
                  type="date"
                  placeholder="选择日期"
                  v-model="form.date1"
                  style="width: 100%;"
                ></el-date-picker>
              </el-form-item>
              <el-form-item label="请选择类型：" style="text-align: left;">
                <el-radio-group v-model="form.resource">
                  <el-radio label="0">按年</el-radio>
                  <el-radio label="1">按月</el-radio>
                  <el-radio label="2">按天</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item>
                <el-button
                  type="primary"
                  @click="onSubmit"
                  style="margin-top: 20px;transform: translateX(-50%);"
                  >立即创建</el-button
                >
              </el-form-item>
            </el-form>
          </div>
        </div>
      </div>
    </div>
    <div class="right">
      <div class="right_top">
        <div class="button_box">
          <span>今年</span>
          <span class="check">本月</span>
          <span>今日</span>
        </div>
        <div class="title">
          个人绩效总分排名TOP10
        </div>
        <dv-scroll-ranking-board
          :config="personConfig"
          style="width:100%;height:75%"
        />
      </div>
      <div class="right_mid">
        <div class="button_box">
          <span>今年</span>
          <span class="check">本月</span>
          <span>今日</span>
        </div>
        <div id="shensuPie" style="width: 100%;height: 100%;"></div>
      </div>
      <div class="right_down">
        <div id="recordPie" style="width: 100%;height: 100%;"></div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      type: "1",
      form: {
        date1: "",
        type: [],
        resource: "",
      },
      config: {
        data: [
          {
            name: "部门1",
            value: 95,
          },
          {
            name: "部门2",
            value: 90,
          },
          {
            name: "部门3",
            value: 98,
          },
          {
            name: "部门4",
            value: 91,
          },
          {
            name: "部门5",
            value: 80,
          },
          {
            name: "部门6",
            value: 92,
          },
          {
            name: "部门7",
            value: 93,
          },
          {
            name: "部门8",
            value: 94,
          },
          {
            name: "部门9",
            value: 90,
          },
          {
            name: "部门10",
            value: 100,
          },
        ],
      },
      personConfig: {
        data: [
          {
            name: "个人1",
            value: 95,
          },
          {
            name: "个人2",
            value: 90,
          },
          {
            name: "个人3",
            value: 98,
          },
          {
            name: "个人4",
            value: 91,
          },
          {
            name: "个人5",
            value: 80,
          },
          {
            name: "个人6",
            value: 92,
          },
          {
            name: "个人7",
            value: 93,
          },
          {
            name: "个人8",
            value: 94,
          },
          {
            name: "个人9",
            value: 90,
          },
          {
            name: "个人10",
            value: 100,
          },
        ],
      },
      cricleData: [
        { value: 756, name: "考勤绩效" },
        { value: 690, name: "评价绩效" },
        { value: 559, name: "办件绩效" },
        { value: 1278, name: "效能绩效" },
      ],
    };
  },

  mounted() {
    this.drawLeiDa();
    this.drawRulePie();
    this.drawCorePie();
    this.drawRecordPie();
  },

  methods: {
    drawLeiDa() {
      // 基于dom，初始化echarts实例
      let myChart = this.$echarts.init(document.getElementById("leida"));
      // 绘制图表
      myChart.setOption({
        title: {
          text: "异常分值分布情况",
          left: "left",
          textStyle: {
            fontSize: 18,
          },
        },
        color: ["#56A3F1", "#FF917C"],
        tooltip: {},
        legend: {
          data: ["加分", "扣分"],
          right: 0,
          bottom: "50px",
          orient: "vertical",
        },
        radar: [
          {
            center: ["25%", "50%"],
            radius: 120,
            startAngle: 90,
            splitNumber: 4,
            shape: "circle",
            axisName: {
              formatter: "【{value}】",
              color: "#428BD4",
            },

            axisLine: {
              lineStyle: {
                color: "rgba(211, 253, 250, 0.8)",
              },
            },
            splitLine: {
              lineStyle: {
                color: "rgba(211, 253, 250, 0.8)",
              },
            },
          },
          {
            indicator: [
              { text: "考勤绩效", max: 150 },
              { text: "办件绩效", max: 150 },
              { text: "评价绩效", max: 150 },
              { text: "效能绩效", max: 120 },
              { text: "其他绩效", max: 108 },
            ],
            center: ["45%", "60%"],
            radius: 80,
            axisName: {
              color: "#fff",
              backgroundColor: "#666",
              borderRadius: 10,
              padding: [0, 1],
            },
          },
        ],
        series: [
          {
            type: "radar",
            radarIndex: 1,
            data: [
              {
                value: [120, 118, 130, 100, 99, 70],
                name: "加分",
                symbol: "rect",
                symbolSize: 12,
                areaStyle: { color: "#56A3F1" }, //雷达覆盖区域背景颜色
                label: {
                  show: true,
                  formatter: function(params) {
                    return params.value;
                  },
                },
              },
              {
                value: [100, 93, 50, 90, 70, 60],
                areaStyle: { color: "#FF917C" }, //雷达覆盖区域背景颜色
                name: "扣分",
              },
            ],
          },
        ],
      });
    },
    drawRulePie() {
      // 基于dom，初始化echarts实例
      let myChart = this.$echarts.init(document.getElementById("rulePie"));
      myChart.setOption({
        title: {
          text: "绩效规则分布情况",
          textStyle: {
            fontSize: 18,
          },
        },
        tooltip: {
          trigger: "item",
        },
        legend: {
          bottom: "0%",
          right: "5%",
          orient: "vertical",
          textStyle: {
            // 文字的样式
            fontSize: 24, // 可控制每个legend项的间距
            color: "#828282",
            rich: {
              // 通过富文本rich给每个项设置样式，下面的oneone、twotwo、threethree可以理解为"每一列"的样式
              oneone: {
                // 设置文字、数学、英语这一列的样式
                width: 50,
                color: "#000000",
                fontSize: 12,
                fontWeight: "bolder",
              },
              twotwo: {
                // 设置10分、20分、30分这一列的样式
                width: 35,
                color: "#333",
                fontSize: 12,
                fontWeight: 600,
              },
              threethree: {
                // 设置百分比这一列的样式
                width: 20,
                color: "#333",
                fontSize: 12,
              },
            },
          },
          formatter: (name) => {
            // formatter格式化函数动态呈现数据
            console.log(name);
            var total = 0; // 用于计算总数
            var target; // 遍历拿到数据
            for (var i = 0; i < this.cricleData.length; i++) {
              total += this.cricleData[i].value;
              if (this.cricleData[i].name == name) {
                target = this.cricleData[i].value;
              }
            }
            var v = ((target / total) * 100).toFixed(2);
            return `{oneone|${name}}  {twotwo|${target}分}   {threethree|${v}%}`;
            //     富文本第一列样式应用    富文本第二列样式应用      富文本第三列样式应用
          },
        },
        series: [
          {
            type: "pie",
            radius: ["40%", "70%"],
            // avoidLabelOverlap: false,
            left: "-50%",
            top: "10%",
            label: {
              position: "center",
              fontSize: 16,
              formatter: () => {
                let str = "总" + "\n" + `${756 + 690 + 559 + 1278}`;
                return str;
              },
            },
            labelLine: {
              show: false,
            },
            data: this.cricleData,
          },
        ],
      });
    },
    drawCorePie() {
      // 基于dom，初始化echarts实例
      let myChart = this.$echarts.init(document.getElementById("shensuPie"));
      myChart.setOption({
        title: {
          text: "绩效规则分布情况",
          textStyle: {
            fontSize: 18,
          },
        },
        tooltip: {
          trigger: "item",
        },
        legend: {
          bottom: "0%",
          right: "5%",
          orient: "vertical",
          textStyle: {
            // 文字的样式
            fontSize: 24, // 可控制每个legend项的间距
            color: "#828282",
            rich: {
              // 通过富文本rich给每个项设置样式，下面的oneone、twotwo、threethree可以理解为"每一列"的样式
              oneone: {
                width: 50,
                color: "#000000",
                fontSize: 12,
                fontWeight: "bolder",
              },
              twotwo: {
                width: 35,
                color: "#333",
                fontSize: 12,
                fontWeight: 600,
              },
              threethree: {
                // 设置百分比这一列的样式
                width: 20,
                color: "#333",
                fontSize: 12,
              },
            },
          },
          formatter: (name) => {
            // formatter格式化函数动态呈现数据
            var total = 0; // 用于计算总数
            var target; // 遍历拿到数据
            for (var i = 0; i < this.cricleData.length; i++) {
              total += this.cricleData[i].value;
              if (this.cricleData[i].name == name) {
                target = this.cricleData[i].value;
              }
            }
            var v = ((target / total) * 100).toFixed(2);
            return `{oneone|${name}}`;
            //     富文本第一列样式应用    富文本第二列样式应用      富文本第三列样式应用
          },
        },
        series: [
          {
            type: "pie",
            // avoidLabelOverlap: false,
            left: "-25%",
            top: "10%",
            label: {
              normal: {
                show: true,
                position: "outside",
                rich: {
                  // 通过富文本rich给每个项设置样式，下面的oneone、twotwo、threethree可以理解为"每一列"的样式
                  async: {
                    width: 50,
                    color: "#000000",
                    fontSize: 12,
                    fontWeight: "bolder",
                  },
                  hr: {
                    width: 35,
                    color: "#333",
                    fontSize: 12,
                    fontWeight: 600,
                  },
                  per: {
                    // 设置百分比这一列的样式
                    width: 20,
                    color: "#333",
                    fontSize: 12,
                  },
                },
                formatter: "{per|{d}%}",
              },
            },
            labelLine: {
              show: true,
            },
            data: this.cricleData,
          },
        ],
      });
    },

    drawRecordPie() {
      let xData = ["未开始", "进行中", "已完结", "全部问卷"];
      let yData = [2, 8, 116, 126];
      let colorList = ["#97e7ff", "#75f5ff", "#00deff", "#0093ff", "#2a5fcf"];
      let visualMapPiecesData = [];
      // visualMap: {
      //   pieces: [
      //     { value: 123, label: '123（自定义特殊颜色）', color: 'grey' }
      //   ]
      // }
      for (var i = 0; i < xData.length; i++) {
        visualMapPiecesData.push({
          value: yData[i],
          label: xData[i],
          color: colorList[i],
        });
      }
      // 基于dom，初始化echarts实例
      let myChart = this.$echarts.init(document.getElementById("recordPie"));
      myChart.setOption({
        title: {
          text: "绩效规则分布情况",
          textStyle: {
            fontSize: 18,
          },
        },
        tooltip: {
          trigger: "item",
        },

        polar: {
          radius: [0, "90%"],
          center: ["50%", "55%"],
        },
        angleAxis: {
          show: false, // 隐藏刻度
          max: 180,
          startAngle: 90,
        },
        radiusAxis: {
          show: true,
          type: "category",
          data: xData,
        },

        visualMap: {
          top: 40,
          x: "left",
          orient: "vertical",
          textStyle: {
            color: "#000",
          },
          pieces: visualMapPiecesData,
          outOfRange: {
            color: "#999",
          },
        },
        series: [
          {
            type: "bar",
            data: yData,
            coordinateSystem: "polar",
            itemStyle: {
              normal: {
                // 定制显示（按顺序）
                color: function(params) {
                  return colorList[params.dataIndex];
                },
              },
            },
          },
        ],
      });
    },
  },
};
</script>

<style lang="less" scoped>
.page {
  width: 100%;
  height: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  overflow: hidden;
  background: unset;
  font-family: "微软雅黑 Bold", "微软雅黑 Regular", "微软雅黑", sans-serif;

  .left,
  .mid,
  .right {
    width: 24%;
    height: 100%;
    display: flex;
    flex-direction: column;
  }
  .mid {
    flex: 1;
    justify-content: space-between;
    .mid_top,
    .mid_down {
      width: 100%;
    }
    .mid_top {
      padding: 0 10px;
      height: 40%;
      display: flex;
      justify-content: space-around;
      .top_box {
        width: 31%;
        height: 100%;
        border-width: 2px;
        padding: 12px;
        border-style: solid;
        border-color: rgba(255, 255, 255, 1);
        border-radius: 8px;
        -moz-box-shadow: none;
        -webkit-box-shadow: none;
        box-shadow: none;
        .title {
          font-weight: 700;
          font-style: normal;
          font-size: 14px;
        }
        .mid_content {
          width: 100%;
          height: 100%;
          color: #fff;
          overflow: hidden;
          .content_top {
            width: 100%;
            height: 70%;
            display: flex;
            justify-content: space-evenly;
            flex-direction: column;
            border-bottom: 2px solid rgb(240, 240, 240);
            .content_text {
              position: relative;
              margin-bottom: 5px;
              font-size: 14px;
              .txt {
                display: inline-block;
                width: 30%;
              }
              .txt_num {
                display: inline-block;
                width: 70%;
                text-align: right;
                font-weight: 600;
              }
              .txt_small {
                position: absolute;
                right: 0;
                top: 20px;
                font-size: 12px;
              }
            }
          }
          .content_down {
            width: 100%;
            height: auto;
            display: flex;
            justify-content: space-between;
            padding: 10px 0;
            .down_left,
            .down_right {
              padding: 8px 0;
              width: 50%;
              height: 100%;
              text-align: center;
              .down_text {
                font-size: 12px;
              }
              .num {
                font-weight: 700;
                font-style: normal;
                font-size: 18px;
                color: #ffffff;
              }
            }
            .down_left {
              border-right: 2px solid rgb(240, 240, 240);
            }
          }
        }
      }
      .one {
        background: linear-gradient(
          180deg,
          rgba(241, 189, 76, 1) 0%,
          rgba(237, 133, 77, 1) 100%
        );
        .title {
          color: #7d2d00;
        }
      }
      .two {
        background: linear-gradient(
          180deg,
          rgba(96, 155, 248, 1) 0%,
          rgba(102, 135, 244, 1) 100%
        );
        .title {
          color: #001c80;
        }
      }
      .three {
        background: linear-gradient(
          180deg,
          rgba(76, 201, 245, 1) 0%,
          rgba(19, 149, 235, 1) 100%
        );
        .title {
          color: #004679;
        }
      }
    }
    .mid_down {
      width: 96%;
      height: 58%;
      border-radius: 8px;
      -moz-box-shadow: none;
      -webkit-box-shadow: none;
      box-shadow: none;
      margin: 0 auto;
      background: url(../../../assets/images/u10938.svg) no-repeat;
      background-size: cover;
      overflow: hidden;
      .down_content {
        width: 100%;
        height: 100%;
        text-align: center;
        padding: 40px 30px 10px 30px;
        /deep/.el-radio-button {
          width: 150px;
          text-align: center;
          border: 1px solid #eee;
        }
        /deep/.el-radio-button__inner {
          width: 150px;
        }
        /deep/.el-radio-button__orig-radio:checked + .el-radio-button__inner {
          width: 150px;
          border: none;
          background: #1890ff;
          color: #fff;
          border: 1px solid #eee;
        }
        .form {
          width: 70%;
          margin: 0 auto;
        }
      }
    }
  }
  .left_top,
  .left_mid,
  .left_down,
  .right_top,
  .right_mid,
  .right_down {
    position: relative;
    width: 100%;
    height: 33%;
    background: #fff;
    border-radius: 8px;
    padding: 10px;
    overflow: hidden;
    .title {
      font-weight: 600;
      margin-bottom: 5px;
    }
    /deep/.info-name,
    /deep/.ranking-value {
      color: #000;
    }
  }
  .left_mid,
  .right_mid {
    width: 100%;
    height: 30%;
    margin: 15px 0;
  }
  .button_box {
    position: absolute;
    top: 8px;
    right: 10px;
    display: flex;
    span {
      border-width: 0px;
      width: 40px;
      height: 24px;
      display: flex;
      font-family: "微软雅黑", sans-serif;
      font-weight: 400;
      font-style: normal;
      font-size: 12px;
      color: #797979;
      background-color: rgba(28, 117, 221, 0.0980392156862745);
      border: none;
      border-radius: 4px;
      justify-content: center;
      align-items: center;
      margin-right: 5px;
      cursor: pointer;
    }
    .check {
      background: linear-gradient(
        90deg,
        rgba(23, 67, 198, 1) 0%,
        rgba(31, 116, 223, 1) 50%,
        rgba(44, 140, 240, 1) 99%
      );
      font-size: 12px;
      color: #ffffff;
    }
  }
}
</style>
