<template>
  <div class="container-box">
    <div class="search-box">
      <el-form
        :inline="true"
        ref="searchForm"
        :model="searchForm"
        class="demo-form-inline"
        label-width="auto"
        size="mini"
      >
        <el-form-item label="养殖场">
          <el-input
            v-model="searchForm.a"
            placeholder="请输入养殖场"
          ></el-input>
        </el-form-item>

        <el-form-item label="标记编号">
          <el-input
            v-model="searchForm.b"
            placeholder="请输入标记编号"
          ></el-input>
        </el-form-item>

        <el-form-item>
          <el-button type="success" icon="el-icon-search" @click="searchClick"
            >搜索</el-button
          >
          <el-button type="warning" icon="el-icon-refresh" @click="resetClick"
            >重置</el-button
          >
        </el-form-item>
      </el-form>
    </div>
    <div class="list-box" v-if="showtable">
      <el-table
        :data="tableData"
        style="width: 100%"
        size="mini"
        border
        :header-cell-style="{ textAlign: 'center', color: '#606266' }"
        :cell-style="cellStyle"
      >
        <el-table-column prop="a" label="养殖场"></el-table-column>
        <el-table-column prop="b" label="标记编号"></el-table-column>
        <el-table-column label="综合育种指数">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              @click="detailClickgo(scope.row)"
              class="detail-btn"
              >{{ scope.row.c }}</el-button
            >
          </template>
        </el-table-column>
        <el-table-column label="系谱分析">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              @click="detailClick(scope.row)"
              class="detail-btn"
              >详情</el-button
            >
          </template>
        </el-table-column>
        <el-table-column label="遗传病风险">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              @click="detailClick1(scope.row)"
              class="detail-btn"
              >{{ scope.row.e }}</el-button
            >
          </template>
        </el-table-column>
        <el-table-column label="详情">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              @click="report(scope.row)"
              class="detail-btn"
              >报告</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <div class="page-box">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :page-sizes="[20, 50, 100]"
          layout="total, sizes, prev, pager, next, jumper"
          :current-page="form.page"
          :page-size="form.pagesize"
          :total="total"
        >
        </el-pagination>
      </div>
    </div>
    <div
      v-loading="loading"
      element-loading-text="加载中"
      v-else
      style="
        width: 100%;
        text-align: center;
        padding: 50px 0px 50px 0px;
        background: white;
      "
    >
      <img
        style="width: 80%"
        src="https://smart-1251449951.cos.ap-guangzhou.myqcloud.com/iot_breed/farm/2024/08/30934b551c5bab2f2727d4dfa9ccd85a69.jpg"
        alt=""
      />
    </div>
    <el-dialog :visible.sync="dialogVisible" width="40%">
      <div style="text-align: center">
        <div class="btmstyle">综合分子育种报告</div>
        <div class="textstyle">
          <div>标记编号:82010000990</div>
          <div>养殖场:若尔盖</div>
          <div>品种信息:牦牛</div>
        </div>
        <div class="textdiv">
          <div style="font-weight: bold; padding: 30px 0px 6px 14px">
            1. 繁育管理的育种值
          </div>
          <div class="pl">综合育种值：225.85</div>
          <div class="pl">性状名称: 外貌评分、生长性状、产奶性状</div>
          <div class="pl">
            分析说明:
            该个体在生长性能上的优异表现，更在经济性能上展现了其潜在的高价值。基于此，我们强烈推荐将此个体作为未来育种计划中的亲本首选，以期望通过其遗传优势，孕育出更多具备优良性状的后代。
          </div>
        </div>
        <div class="textdiv">
          <div style="font-weight: bold; padding: 30px 0px 6px 14px">
            2. 进化分析结果中的近交系数
          </div>
          <div class="pl">近交系数: 0</div>
          <div class="pl">
            分析说明:
            经过精确的遗传评估，该个体和82010001456的近交系数计算结果为零，意味着它们在遗传上不存在亲缘关系。因此，这两个个体可以作为无亲缘关系的育种候选者，进行交配以产生后代。这样的配对有助于避免近交衰退，同时促进遗传多样性的保持，为育种项目带来潜在的遗传增益。
          </div>
        </div>
        <div
          class="textdiv"
          style="border-bottom: 2px solid #ebebeb; padding-bottom: 50px"
        >
          <div style="font-weight: bold; padding: 30px 0px 6px 14px">
            3. 携带遗传基因风险警告
          </div>
          <div class="pl">风险等级:低</div>
          <div class="pl">
            建议措施:
            经过专业的基因检测分析，确认该个体并未携带任何已知的遗传性疾病相关基因。在进行繁育计划时，可以放心地将该个体纳入考虑，以实现遗传改良的目标。
          </div>
        </div>
      </div>
      <div
        class="textdiv"
        style="border-bottom: 2px solid #ebebeb; padding-bottom: 20px"
      >
        <div style="font-weight: bold; padding: 30px 0px 6px 14px">总结</div>
        <div class="pl">
          繁育：经过严格的遗传评估和基因检测，该个体证实具备出色的生长性能和繁殖能力。特别值得注意的是，基因检测结果表明，该个体并未携带任何已知的遗传性疾病相关基因。因此，我们可以放心地选择此个体作为繁育计划中的亲本，以期在维持遗传多样性的同时，促进后代群体生产性能的提升和遗传改良。
          选配：该个体和82010001456的近交系数为0，不存在亲缘关系，可放心进行繁育。
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false" size="mini">关闭</el-button>
        <el-button type="success" size="mini" @click="dialogVisible = false"
          >下载</el-button
        ><el-button type="success" size="mini" @click="dialogVisible = false"
          >打印</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>
  
  <script>
export default {
  data() {
    return {
      loading: false,
      showtable: false,
      dialogVisible: false,
      searchForm: {
        a: '',
        b: '',
        c: '',
        d: '',
        e: '',
        f: ''
      },
      tableData: [
        {
          a: '若尔盖',
          b: '82010000990',
          c: '123',
          d: '详情',
          e: '未携带',
          f: '报告'
        },
        {
          a: '若尔盖',
          b: '82010000991',
          c: '100',
          d: '详情',
          e: '未携带'
        },
        {
          a: '若尔盖',
          b: '82010000992',
          c: '96',
          d: '详情',
          e: '携带'
        },
        {
          a: '若尔盖',
          b: '82010000993',
          c: '85',
          d: '详情',
          e: '携带'
        },
        {
          a: '若尔盖',
          b: '82010000994',
          c: '74',
          d: '详情',
          e: '未携带'
        },
        {
          a: '若尔盖',
          b: '82010000995',
          c: '56',
          d: '详情',
          e: '携带'
        },
        {
          a: '若尔盖',
          b: '82010000996',
          c: '58',
          d: '详情',
          e: '未携带'
        },
        {
          a: '若尔盖',
          b: '82010000997',
          c: '98',
          d: '详情',
          e: '携带'
        }
      ],
      form: {
        page: 1,
        pagesize: 20
      },
      total: 8
    }
  },
  methods: {
    detailClick() {
      this.$router.push('/phylogeneticAnalysis/evolutionaryTree')
    },
    detailClickgo() {
      this.$router.push('/breedMgmt/BLUP')
    },
    detailClick1() {
      this.$router.push('/disease-resistance/disease-resistance')
    },
    report(row) {
      if (row.b == '82010000990') {
        window.open(
          'https://smart-1259258654.cos.ap-guangzhou.myqcloud.com/pdf/82010000990%E7%BB%BC%E5%90%88%E5%88%86%E5%AD%90%E8%82%B2%E7%A7%8D%E6%8A%A5%E5%91%8A.pdf',
          '_blank'
        )
      }
    },
    // 搜索
    searchClick() {
      this.loading = true
      setTimeout(() => {
        this.loading = false
        this.showtable = true
      }, 1500)
    },
    // 重置
    resetClick() {
      for (const key in this.searchForm) {
        this.searchForm[key] = ''
      }
    },
    // 条
    handleSizeChange(val) {
      this.form.pagesize = parseInt(val)
    },
    // 页
    handleCurrentChange(val) {
      this.form.page = parseInt(val)
    },
    // 当监测结果为 已携带 的状态，加上背景色,字体颜色
    cellStyle({ row, column, rowIndex, columnIndex }) {
      // 注意，这里返回的是一个对象
      if (row.result == '携带' && column.label == '监测结果') {
        return 'background:#d9001b;textAlign: center;color:#fff;'
      } else {
        return 'textAlign: center'
      }
    }
  }
}
</script>
  
  <style lang="less" scoped>
.container-box {
  min-height: calc(100vh - 84px);
  padding: 15px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  .search-box {
    background: #fff;
    border-radius: 6px;
    padding: 10px 15px;
    margin-bottom: 25px;
  }
  .list-box {
    flex: 1;
    background: #fff;
    border-radius: 6px;
    padding: 10px 15px;
    .detail-btn {
      color: #67c23a;
    }
    .page-box {
      margin-top: 10px;
    }
  }
}
.el-form-item {
  margin-bottom: 0px;
  margin-right: 20px;
}
.btmstyle {
  border-bottom: 2px solid #ebebeb;
  padding-bottom: 26px;
  font-size: 24px;
  font-weight: bold;
  color: black;
}
.textstyle {
  display: flex;
  padding: 24px;
  border-bottom: 2px solid #ebebeb;
}
.textstyle div {
  margin-right: 10%;
}
.textdiv div {
  text-align: left;
}
.pl {
  padding-left: 14px;
  padding-bottom: 4px;
  line-height: 18px;
}
// table
/deep/.el-table th.el-table__cell {
  background-color: #f5f7fa;
}
/deep/ .cell {
  font-weight: normal;
}
</style>