<template>
  <div class="personnel-portrait">
    <Tabs v-model="resultType" :list="resultTypeList" @changeVal="resultTypeChange"/>
    <div class="screen">
      <div class="txt">不满意人员画像</div>
      <el-select v-model="typeCondition" @change="getData" placeholder="请选择" class="select" popper-class="selectPopClass">
        <el-option
            v-for="item in typeConditionList"
            :key="item.value"
            :label="item.label"
            :value="item.value">
        </el-option>
      </el-select>
    </div>

    <div class="portrait">
      <div class="tag yellow">
        <div class="text">{{ gridName }}</div>
      </div>
      <div class="tag blue">
        <div class="text">{{ ageClassification }}</div>
      </div>
      <div class="tag red">
        <div class="text">{{ residentTagName }}</div>
      </div>
      <div class="tag light">
        <div class="text">{{ monthIncomeLevel }}</div>
      </div>
      <div class="tag green">
        <div class="text">{{ cultureLevel }}</div>
      </div>
      <div class="tag orange">
        <div class="text">{{ marriageName }}</div>
      </div>
      <div class="tag purple">
        <div class="text">{{ gender==='1'?'男':gender==='2'?'女':gender==='0'?'未知':'' }}</div>
      </div>
    </div>

    <div class="btn" @click="$router.push('/dataBoard/satisfactionEval/dissatisfiedPersonnel')">
      <div>按画像匹配到同类：<span> <b>{{matchPeopleNum?matchPeopleNum:0}}</b>人</span></div>
      <i class="el-icon-arrow-right"></i>
    </div>
  </div>
</template>

<script>
import Tabs from "@/views/dataBoard/satisfactionEval/components/Tabs/index.vue";

export default {
  name: "PersonnelPortrait",
  components: {Tabs},
  data() {
    return {
      resultType: 'provinceAndSelf',
      resultTypeList: [{
        label: ' 按省调查/社区自查结果',
        value: 'provinceAndSelf'

      }, {
        label: '按12345热线投诉结果',
        value: '12345'
      }],
      typeCondition: 1,
      typeConditionList: [],
      gender: "",
      marriageName: "",
      ageClassification: "",
      cultureLevel: "",
      gridName: "",
      monthIncomeLevel: "",
      residentTagName: "",
      matchPeopleNum: 0
    }
  },
  watch: {
    "$store.state.chooseArea.chooseName"(val) {
      if (val.orgId) {
        this.getDisKey()
      }
    }
  },
  mounted() {
    if (this.$store.state.chooseArea.chooseName.orgId) {
      this.getDisKey()
    }
  },
  methods: {
    resultTypeChange(val) {
      this.resultType = val
      this.getData()
    },
    getDisKey() {
      this.$http.post('/sys/dict/data/dictlist', {'dictType': 'satisfaction_category'}).then(({data: {data}}) => {
        this.typeCondition = data[0].value
        this.typeConditionList = data
        this.getData();
      })
    },
    getData() {
      let params = {
        level: this.$store.state.chooseArea.chooseName.level,
        orgId: this.$store.state.chooseArea.chooseName.orgId,
        queryType: this.resultType,
        category: this.typeCondition,
      }
      this.$http.get('/governance/satisfactionOverview/satisfactionCrowdPortrait?' + this.$paramsFormat(params)).then(({data: {data}}) => {
        this.gender = data.gender;
        this.marriageName = data.marriageName;
        this.ageClassification = data.ageClassification;
        this.cultureLevel = data.cultureLevel;
        this.gridName = data.gridName;
        this.monthIncomeLevel = data.monthIncomeLevel;
        this.residentTagName = data.residentTagName;
        this.matchPeopleNum = data.matchPeopleNum;
      })
    }
  }
}
</script>

<style scoped lang="scss">
$yellow: #ef9700;
$blue: #1a95ff;
$red: #ee3030;
$light: #2ab6be;
$green: #1b7d47;
$orange: #f95619;
$purple: #6642fd;
.personnel-portrait {
  padding: 16px 16px 40px;
}

.screen {
  display: flex;
  align-items: center;
  margin: 25px 0 47px;

  .txt {
    font-size: 16px;
    font-weight: 500;
    color: #FFFFFF;
    line-height: 22px;
    margin-right: 25px;
  }

  /deep/ .el-input__inner {
    width: 110px !important;
    height: 24px !important;
    background: #021C49 !important;
    border: 1px solid #125AAA !important;
    border-radius: 12px !important;
    color: #A0CDFF;
  }

  /deep/ .el-input__icon {
    line-height: 24px !important;
    color: #A0CDFF;
  }
}

.portrait {
  width: 388px;
  height: 345px;
  position: relative;
  background: url("@/assets/images/manyidu/hx_bg.png") no-repeat center;
  margin: 0 auto;
  cursor: pointer;

  .tag {
    position: absolute;
    width: 76px;
    height: 76px;
    display: flex;
    align-items: center;
    justify-content: center;

    .text {
      width: 60px;
      height: 60px;
      top: 0;
      left: 0;
      color: #fff;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 50%;
    }

    &:after {
      content: "";
      opacity: .3;
      display: block;
      width: 76px;
      height: 76px;
      position: absolute;
      border-radius: 50%;

    }

    &:nth-of-type(1) {
      left: 162px;
      top: 0;
    }

    &:nth-of-type(2) {
      left: 297px;
      top: 73px;
    }

    &:nth-of-type(3) {
      left: 316px;
      top: 203px;
    }

    &:nth-of-type(4) {
      left: 228px;
      top: 269px;
    }

    &:nth-of-type(5) {
      left: 77px;
      top: 257px;
    }

    &:nth-of-type(6) {
      left: 0px;
      top: 158px;
    }

    &:nth-of-type(7) {
      left: 48px;
      top: 57px;
    }
  }

  .yellow {
    .text {
      background: $yellow;
    }

    &:after {
      background: $yellow;
    }
  }

  .blue {
    .text {
      background: $blue;
    }

    &:after {
      background: $blue;
    }
  }

  .red {
    .text {
      background: $red;
    }

    &:after {
      background: $red;
    }
  }

  .light {
    .text {
      background: $light;
    }

    &:after {
      background: $light;
    }
  }

  .green {
    .text {
      background: $green;
    }

    &:after {
      background: $green;
    }
  }

  .orange {
    .text {
      background: $orange;
    }

    &:after {
      background: $orange;
    }
  }

  .purple {
    .text {
      background: $purple;
    }

    &:after {
      background: $purple;
    }
  }
}

.btn {
  width: 240px;
  height: 46px;
  border: 1px solid #125AAA;
  border-radius: 23px;
  font-size: 14px;
  font-weight: 400;
  color: #FFFFFF;
  line-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  margin: 33px auto 0;
  cursor: pointer;

  span {
    font-size: 18px;
  }
}

</style>