<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <!-- <el-form-item label="申请日" prop="appDate">
        <el-input
          v-model="queryParams.appDate"
          placeholder="请输入申请日"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="高价值数据年份" prop="year" label-width="150px">
        <el-select
          v-model="queryParams.year"
          placeholder="请选择年份"
          clearable
        >
          <el-option
            v-for="year in yearList"
            :key="year"
            :label="year"
            :value="year"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
        <el-button type="primary" size="mini" @click="handleExport"
            >导出列表</el-button
          >
      </el-form-item>
    </el-form>
    <el-table
      v-loading="loading"
      :data="dHeightValuePatentCompareList"
      @selection-change="handleSelectionChange"
      :header-cell-style="{ background: '#2a8eed', color: '#fafcfe' }"
      border
    >
      <el-table-column type="selection" width="55" align="center" />

      <!--
      <el-table-column label="id" align="center" prop="id" />

      <el-table-column label="申请日" align="center" prop="appDate" />-->

      <el-table-column label="ID" align="center" prop="id" />
      <el-table-column label="省份" align="center" prop="provinceName" />
      <el-table-column label="地址" align="center" prop="address" />
      <el-table-column label="申请人" align="center" prop="appli" >
        <template slot-scope="scope">
          <table>
            <tr v-for="item in scope.row.appliPubList"><td>{{item}}</td></tr>
          </table>

        </template>

      </el-table-column>
      <!--
      <el-table-column label="州市" align="center" prop="appliCity" />
      <el-table-column label="区县" align="center" prop="appliCounty" />
      <el-table-column label="省份" align="center" prop="modifyAppliProvince" />
      <el-table-column label="州市" align="center" prop="modifyAppliCity" />
      <el-table-column label="区县" align="center" prop="modifyAppliCounty" />
      <el-table-column label="当前权利状态" align="center" prop="status" />
      <el-table-column label="高价值" align="center" prop="heightValuePress" />
      -->
      <el-table-column
        label="战略性新兴产业"
        align="center"
        prop="industryEmergIndustry"
      />
      <el-table-column
        label="在海外有同族专利"
        align="center"
        prop="overseasCongenerPatent"
      />
      <el-table-column
        label="维持年限超十年"
        align="center"
        prop="maintenanceTenYear"
      />
      <el-table-column
        label="存在质押记录"
        align="center"
        prop="pledgeRecord"
      />
      <el-table-column
        label="获得国家科技奖或者中国专利奖"
        align="center"
        prop="nationalScienceAward"
      />
      <el-table-column
        label="高价值专利拥有量"
        align="center"
        prop="inventionPatentNumber"
      />
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import {
  listDHeightValuePatentCompare,
  getDHeightValuePatentCompare,
  delDHeightValuePatentCompare,
  addDHeightValuePatentCompare,
  updateDHeightValuePatentCompare,
} from "@/api/heightval/dHeightValuePatentCompare";

import {
  listDHighValueInfo
} from "@/api/dimp/dHighValueInfo";

import { getYearList } from "@/api/report/rzlViewStatisticsInfo";
export default {
  name: "DHeightValuePatentCompare",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 查询年份数据
      yearList: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 高价值专利对照表格数据
      dHeightValuePatentCompareList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        year: "2022",
        pageSize: 10,
        pubId: null,
        dataType: null,
        appNumber: null,
        appDate: null,
        appli: null,
        appliAddress: null,
        preCounts: null,
        highValue: null,
        appliProvince: null,
        appliCity: null,
        appliCounty: null,
        modifyAppliProvince: null,
        modifyAppliCity: null,
        modifyAppliCounty: null,
        status: null,
        heightValuePress: null,
        hvSeisPress: null,
        hvHaveOverseasPress: null,
        hvKeep10Press: null,
        hvHighPledgePress: null,
        hvTechnologyAwardPress: null,
        title: null,
        pubNumber: null,
        patentType: null,
        appliType: null,
        queryPub: '1'
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
    };
  },
  created() {
    this.getList();
    this.getYear();
  },
  methods: {
    /** 获取查询年份列表 */
    getYear() {
      getYearList().then((response) => {
        //this.hasYearList=response.data;
        this.yearList = response.data;
      });
    },
    /** 查询高价值专利对照列表 */
    getList() {
      this.loading = true;
      listDHighValueInfo(this.queryParams).then((response) => {
        this.dHeightValuePatentCompareList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        pubId: null,
        dataType: null,
        appNumber: null,
        appDate: null,
        appli: null,
        appliAddress: null,
        preCounts: null,
        highValue: null,
        appliProvince: null,
        appliCity: null,
        appliCounty: null,
        modifyAppliProvince: null,
        modifyAppliCity: null,
        modifyAppliCounty: null,
        status: "0",
        heightValuePress: null,
        hvSeisPress: null,
        hvHaveOverseasPress: null,
        hvKeep10Press: null,
        hvHighPledgePress: null,
        hvTechnologyAwardPress: null,
        title: null,
        pubNumber: null,
        patentType: null,
        appliType: null,
        remark: null,
        delFlag: null,
        createTime: null,
        createBy: null,
        updateTime: null,
        updateBy: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加高价值专利对照";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getDHeightValuePatentCompare(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改高价值专利对照";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updateDHeightValuePatentCompare(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addDHeightValuePatentCompare(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除高价值专利对照编号为"' + ids + '"的数据项？')
        .then(function () {
          return delDHeightValuePatentCompare(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "heightval/dHeightValuePatentCompare/export",
        {
          ...this.queryParams,
        },
        `dHeightValuePatentCompare_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
<style lang="scss" scoped>
  .derived-list {
  height: 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #f8f8f8;
  padding: 0 10px 0 20px;
  margin: 20px 0;

  div {
    span {
      color: #616161;
      font-size: 14px;
      margin-left: 5px;
    }
  }
}
</style>