<template>
  <Dialog
    title="创新创优详情"
    :visible="dialogVisible"
    width="600"
    @change-visible="changeVisible"
    :destroy-on-close="true"
  >
    <div class="project-name">
      <div>
        <img src="@/assets/images/index/project.png" alt="" />
        {{ data.project_name }}
      </div>
      <div>
        创新创优得分：<span class="count">{{ data.excellence_score }}</span>
      </div>
    </div>

    <div class="scores">
      <div class="score-title">
        <div class="title">创新工法</div>
        <div class="got-score">得分：{{ formData.cxgf_score || 0}}/24</div>
      </div>
      <div class="score-detail">
        <div class="w-50">省级以上工法：{{ formData.province_num || 0}}</div>
        <div class="w-50">国家级工法：{{ formData.country_num || 0}}</div>
      </div>
    </div>
    <div class="scores">
      <div class="score-title">
        <div class="title">工程专利</div>
        <div class="got-score">得分：{{ formData.patent_score || 0}}/30</div>
      </div>
      <div class="score-detail">
        <div class="w-50">发明专利数：{{ formData.invention_patent_num || 0}}</div>
        <div class="w-50">
          实用新型专利：{{ formData.practical_patent_num || 0}}
        </div>
      </div>
    </div>
    <div class="scores">
      <div class="score-title">
        <div class="title">优秀质量管理成果</div>
        <div class="got-score">得分：{{ formData.result_score || 0}}/28</div>
      </div>
      <div class="score-detail">
        <div class="w-50">国家级：{{ formData.country_result_num || 0}}</div>
        <div class="w-50">省部级：{{ formData.province_result_num || 0}}</div>
      </div>
    </div>
    <div class="scores">
      <div class="score-title">
        <div class="title">工程质量获奖</div>
        <div class="got-score">得分：{{ formData.city_project_score || 0}}/18</div>
      </div>
      <div class="score-detail">
        <div class="w-50">工程质量获奖：{{ formData.city_project_num || 0}}</div>
      </div>
    </div>
  </Dialog>
</template>
<script>
import { getExcellenceDetail } from "@/api/dataStatis";
export default {
  name: "CXCYDetail",
  props: {
    data: {
      type: Object,
      default: () => {
        return {};
      },
    },
    visible: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      formData: {},
    };
  },
  computed: {
    dialogVisible: {
      get() {
        return this.visible;
      },
      set(val) {
        this.$emit("change-visible", val);
      },
    },
  },
  methods: {
    changeVisible(val) {
      this.dialogVisible = val;
    },
    getData() {
      getExcellenceDetail(this.data.id).then((res) => {
        this.formData = res.data.data[0] ? res.data.data[0] : {};
      });
    },
  },
  mounted() {},
  watch: {
    dialogVisible(val) {
      if (val) {
        this.$nextTick(() => {
          this.getData();
        });
      }
    },
  },
};
</script>
<style lang="less" scoped>
.project-name {
  line-height: 50px;
  padding: 0 10px;
  background: #12407f;
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  color: #60fff6;
  font-size: 14px;
  .count {
    font-size: 20px;
    font-weight: bold;
    vertical-align: top;
  }
  img {
    width: 20px;
    vertical-align: top;
    margin: 15px 10px;
  }
}
.scores {
  margin-bottom: 10px;
}
.score-title {
  background: #16488b;
  padding: 0 24px;
  line-height: 40px;
  display: flex;
  justify-content: space-between;
  .title {
    font-size: 14px;
    color: #60fff6;
    font-weight: bold;
    position: relative;
    &::before {
      position: absolute;
      content: "";
      width: 3px;
      height: 16px;
      background: #60fff6;
      left: -12px;
      top: 50%;
      transform: translateY(-50%);
    }
  }
  .got-score {
    color: #d9d9d9;
    font-size: 14px;
  }
}
.score-detail {
  background: #0c3163;
  border: 1px solid #1f4c89;
  border-top: 0;
  padding: 12px 20px;
  display: flex;
  justify-content: flex-start;
}
.w-50 {
  width: 50%;
  text-align: left;
  color: #d9d9d9;
  font-size: 14px;
}
::v-deep .el-dialog .el-dialog__body {
  min-height: 400px !important;
  height: inherit !important;
}
</style>