<template>
  <div class="notice_page p0-100">
    <!-- 搜索部分 -->
    <div class="search">
      <div class="search_input" style="display:flex">
        <span>科技成果检索</span>
        <el-input
          v-model="queryParams.title"
          placeholder="请输入搜索关键字"
          @keyup.enter.native="getList"
        ></el-input>
        <el-button type="warning" @click="getList">搜索</el-button>
      </div>
    </div>
    <!-- 筛选部分 -->
    <div class="screen">
      <div class="screen_l" v-loading="loading">
        <!-- 检索条件 -->
        <div class="screen_l_t">
          <div class="screen_l_t_item">
            <span class="text_col">技术领域：</span>
            <el-radio-group v-model="queryParams.field" size="medium">
              <el-radio-button label="">不限</el-radio-button>
              <el-radio-button
                :label="item.id"
                v-for="item in levelList"
                :key="item.id"
              >
                {{ item.name }}
              </el-radio-button>
            </el-radio-group>
          </div>
          <div class="screen_l_t_item">
            <span class="text_col">成熟度：</span>
            <el-radio-group v-model="queryParams.maturityId" size="medium">
              <el-radio-button label="">不限</el-radio-button>
              <el-radio-button
                :label="item.id"
                v-for="item in maturityList"
                :key="item.id"
              >
                {{ item.name }}
              </el-radio-button>
            </el-radio-group>
          </div>
          <div class="screen_l_t_item">
            <span class="text_col">合作标签：</span>
            <el-radio-group v-model="queryParams.labelId" size="medium">
              <el-radio-button label="">不限</el-radio-button>
              <el-radio-button
                :label="item.id"
                v-for="item in cooperationList"
                :key="item.id"
              >
                {{ item.name }}
              </el-radio-button>
            </el-radio-group>
          </div>
        </div>
        <!-- 检索列表 -->
        <div class="screen_l_b">
          <div v-for="item in listData" :key="item.id">
            <router-link
              target="_blank"
              :to="{
                path: '/result',
                query: { key: 'scienceResult', id: item.id }
              }"
            >
              <div class="screen_item">
                <div class="screen_item_l">
                  <img :src="item.picList[0]" alt="" />
                </div>
                <div class="screen_item_r">
                  <div class="title">{{ item.title }}</div>
                  <div class="text_hidden_two text" v-html="item.text"></div>
                  <div class="tags">
                    <el-tag type="warning" effect="dark">
                      {{ item.fieldName }}
                    </el-tag>
                    <el-tag type="warning" effect="dark">
                      {{ item.maturityName }}
                    </el-tag>
                    <el-tag type="warning" effect="dark">
                      {{ item.labelName }}
                    </el-tag>
                  </div>
                  <div class="time">
                    {{ parseTime(item.createTime, '{y}-{m}-{d}') }}发布
                  </div>
                </div>
              </div>
            </router-link>
          </div>
        </div>
        <div style="text-align: center;margin:30px 0" v-show="!total">
          <div
            style="width:210px;height:210px;display: inline-block;color:#999"
          >
            <img
              style="width:100%;height:100%;"
              src="@/assets/image/empty.png"
              alt=""
            />
            暂无数据
          </div>
        </div>
        <!-- 分页 -->
        <pagination
          v-show="total > 0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </div>
    </div>
  </div>
</template>
<script>
import { mapGetters } from 'vuex';
import { getDictListByStatus } from '@/api/home/info';
import { getScienceResultList } from '@/api/home/demand';
export default {
  data() {
    return {
      loading: true,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        title: '',
        field: '',
        maturityId: '', // 成熟度id
        labelId: '' // 合作标签id
      },
      listData: [],
      total: 0,
      levelList: [], // 技术领域
      maturityList: [], // 成熟度
      cooperationList: [] // 合作标签
    };
  },
  computed: {
    ...mapGetters(['token'])
  },
  watch: {
    'queryParams.field'() {
      this.getList();
    },
    'queryParams.maturityId'() {
      this.getList();
    },
    'queryParams.labelId'() {
      this.getList();
    }
  },
  methods: {
    getList() {
      this.loading = true;
      getScienceResultList(this.queryParams).then(({ data }) => {
        this.listData = data.list;
        this.total = data.total;
        this.loading = false;
      });
    },
    handleClick() {},
    handleSizeChange() {},
    handleCurrentChange() {}
  },
  created() {
    // 技术领域
    getDictListByStatus({ type: 1 }).then(({ data }) => {
      this.levelList = data;
    });
    // 成熟度
    getDictListByStatus({ type: 3 }).then(({ data }) => {
      this.maturityList = data;
    });
    // 合作标签
    getDictListByStatus({ type: 4 }).then(({ data }) => {
      this.cooperationList = data;
    });
    this.getList();
  }
};
</script>
<style lang="scss" scoped>
.notice_page {
  .search {
    padding-top: 52px;
    padding-bottom: 52px;
    text-align: center;
    .search_input {
      display: flex;
      justify-content: center;
      align-items: center;
      /deep/.el-input--medium .el-input__inner {
        height: 40px;
        line-height: 40px;
        border-radius: 6px 0 0 6px;
        border: 1px solid #ffa32c;
        border-right: 0;
      }
      span:nth-child(1) {
        color: #333;
        font-size: 24px;
        margin-right: 21px;
      }
      .el-input {
        width: 304px;
      }
      .el-button {
        border-radius: 0 6px 6px 0;
        background-color: #ffa32c;
        font-size: 18px;
      }
    }
    .tags {
      margin-top: 26px;
      .txt {
        font-size: 18px;
        color: #999;
      }
      .el-tag {
        border-radius: 20px;
        margin-right: 18px;
      }
    }
  }
  .screen {
    display: flex;
    .screen_l {
      flex: 2;
      .screen_l_t {
        border-radius: 6px;
        background-color: #f8f8f8;
        .screen_l_t_item {
          // height: 50px;
          // line-height: 50px;
          display: flex;
          align-items: center;
          padding: 0 20px;
          .text_col {
            min-width: 100px;
            color: #333;
            font-size: 18px;
          }
          .el-radio-group {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            .el-radio-button {
              margin: 10px 0;
            }
          }
        }
      }
      .screen_l_b {
        margin-top: 10px;
        padding: 10px 0;
        // display: flex;
        // flex-wrap: wrap;
        // justify-content: flex-start;
        .screen_item {
          cursor: pointer;
          display: flex;
          border: 1px solid #ffa32c;
          padding: 15px;
          margin-top: 30px;
          .screen_item_l {
            width: 225px;
            img {
              width: 100%;
              height: 100%;
            }
          }
          .screen_item_r {
            width: calc(100% - 225px);
            margin-left: 15px;
            .title {
              font-size: 18px;
              font-weight: bold;
              color: #ffa32c;
              padding: 10px 0;
            }
            .text {
              font-size: 14px;
              line-height: 20px;
              color: #999;
            }
            .tags {
              margin-top: 15px;
              .el-tag {
                margin-right: 15px;
              }
            }
            .time {
              font-size: 14px;
              color: #999;
              text-align: right;
            }
          }
        }
      }
      .el-pagination {
        text-align: right;
      }
    }
    .screen_r {
      flex: 1;
      margin-left: 10px;
      max-width: 310px;
      .title {
        color: #ffffff;
        height: 60px;
        line-height: 60px;
        font-size: 20px;
        text-align: center;
        background: #3394ff;
        border-radius: 6px 6px 0px 0px;
      }
      .tabs {
        height: 551px;
        background: #f8f8f8;
        padding: 0px 14px;
        .tabs_row {
          display: flex;
          align-items: center;
          .span {
            width: 30%;
            min-width: 84px;
          }
          .el-tabs {
            // width: 240px;
            width: 70%;
            /deep/.el-tabs__nav-wrap::after {
              height: 0;
            }
            /deep/.el-tabs__item.is-active {
              font-weight: bold;
              color: #1890ff;
            }
          }
        }
        .tabs_item {
          height: 110px;
          display: flex;
          flex-direction: column;
          justify-content: center;
          border-bottom: 1px solid #e3e3e3;
          div:nth-child(1) {
            font-size: 18px;
            color: #333333;
          }
          div:nth-child(2) {
            margin-top: 16px;
            font-size: 16px;
            color: #999999;
          }
        }
        .more {
          text-align: center;
          .el-button {
            margin-top: 12px;
          }
        }
      }
    }
  }
}
</style>
