<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      v-show="showSearch"
      label-width="100px"
    >
      <!-- <el-form-item label="开始时间" prop="beginDate">
      <el-input
        v-model="queryParams.beginDate"
        placeholder="请输入开始时间"
        clearable
        size="small"
        @keyup.enter.native="handleQuery"
      />
    </el-form-item>

      <el-form-item label="结束时间" prop="endDate">
        <el-input
          v-model="queryParams.endDate"
          placeholder="请输入结束时间"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->

      <el-form-item label="对比周期" >
        <el-date-picker
          v-model="appDate1"
          type="monthrange"
          @input="appDateInput1"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          format="yyyy-MM"
          value-format="yyyy-MM"
        />
        和
        <el-date-picker
          v-model="appDate2"
          type="monthrange"
          @input="appDateInput2"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          format="yyyy-MM"
          value-format="yyyy-MM"
        />
      </el-form-item>

      <el-form-item label="对比数据" prop="month">
        <el-select
          v-model="queryParams.cpData"
          placeholder="请选择对比数据"
        >
          <el-option label="有效" value="act"></el-option>
          <el-option label="授权" value="auth"></el-option>
          <el-option label="高价值" value="hv"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="对比内容">
        <el-checkbox-group v-model="queryParams.cpContentArr">
          <el-checkbox v-for="t in cpContentList" :label="t.id" :key="t.id">{{
            t.name
          }}</el-checkbox>
        </el-checkbox-group>
      </el-form-item>

      <el-form-item label="地区级别" prop="province">
        <el-select
          v-model="queryParams.province"
          placeholder="请选择省份"
        >
          <el-option label="云南省" value="53" ></el-option>
        </el-select>

        <el-select
          v-model="queryParams.appliCity"
          placeholder="请选择州市"
          @change="search"
        >
          <el-option label="不选择" value="null"></el-option>
          <el-option label="全部州市" value="all"></el-option>
          <el-option
            v-for="region in regionOptions"
            :key="region.cityShortName"
            :label="region.cityShortName"
            :value="region.code"
          />
        </el-select>
        <el-select
          v-model="queryParams.appliCounty"
          placeholder="请选择区县"
          :disabled="opensb"
        >
          <el-option label="不选择" value="null"></el-option>
          <el-option label="全部区县" value="all"></el-option>
          <!--
          <el-option
            v-for="item in ysDistrictCounty"
            :key="item.cityShortName"
            :label="item.cityShortName"
            :value="item.name"
          />-->
        </el-select>
      </el-form-item>

      <el-form-item style="margin-left: 30px;">
        <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>

    <div id="scrollTable">
      <el-table
        v-loading="loading"
        :data="patentListAll"
        :max-height="maxHeight"
        :header-cell-style="{ background: '#2a8eed', color: '#fafcfe' }"
        v-show="(cpData == 'act' || cpData == 'auth') && cpContentArr.length == 2"
      >
        <el-table-column
          label="对比地区"
          align="center"
          width="100"
          fixed="left"
        >
          <template slot-scope="scope">
            <span>{{ scope.row["areaName"] }}</span>
          </template>
        </el-table-column>
        <el-table-column label="对比数据" align="center">
          <el-table-column label="对比周期" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row["timeReg"] }}</span>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="有效" align="center" v-if="cpData == 'act'">
          <el-table-column label="总计" align="center">
            <template slot-scope="scope">
              <span>
                {{ scope.row['all_total_cnt'] }}
              </span>
            </template>
          </el-table-column>
        </el-table-column>

        <el-table-column label="授权" align="center" v-if="cpData == 'auth'">
          <el-table-column label="总计" align="center">
            <template slot-scope="scope">
              <span>
                {{ scope.row['all_total_cnt'] }}
              </span>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column
          v-for="p in patentTypes"
          :label="p.name"
          :key="p.id"
          align="center"
        >
          <el-table-column label="合计" align="center">
            <template slot-scope="scope">
              <span> {{ scope.row[p.code + "_total_cnt"] }}</span>
            </template>
          </el-table-column>
          <el-table-column
            v-for="t in applicantTypes"
            :label="t.name"
            :key="t.id"
            align="center"
          >
            <template slot-scope="scope">
              <span>
                {{ scope.row[p.code + "_" + t.code2] }}
              </span>
            </template>
          </el-table-column>
        </el-table-column>
      </el-table>

      <el-table
        v-loading="loading"
        :data="patentListPatent"
        :max-height="maxHeight"
        :header-cell-style="{ background: '#2a8eed', color: '#fafcfe' }"
        v-show="
          (cpData == 'act' || cpData == 'auth') &&
          cpContentArr.length == 1 &&
          cpContentArr[0] == '1'
        "
      >
        <el-table-column
          label="对比地区"
          align="center"
          width="100"
          fixed="left"
        >
          <template slot-scope="scope">
            <span>{{ scope.row["areaName"] }}</span>
          </template>
        </el-table-column>
        <el-table-column label="对比数据" align="center">
          <el-table-column label="对比周期" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row["timeReg"] }}</span>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="有效" align="center" v-if="cpData == 'act'">
          <el-table-column label="总计" align="center">
           <template slot-scope="scope">
              <span>
                {{ scope.row['total_cnt'] }}
              </span>
            </template>
          </el-table-column>
        </el-table-column>

        <el-table-column label="授权" align="center" v-if="cpData == 'auth'">
          <el-table-column label="总计" align="center">
           <template slot-scope="scope">
              <span>
                {{ scope.row['total_cnt'] }}
              </span>
            </template>
          </el-table-column>
        </el-table-column>

        <el-table-column label="" align="center">
          <el-table-column
            v-for="t in patentTypes"
            :label="t.name"
            :key="t.id"
            align="center"
          >
          <template slot-scope="scope">
              <span>
                {{ scope.row[t.code + "_cnt"] }}
              </span>
            </template>
          </el-table-column>
        </el-table-column>
      </el-table>

      <el-table
        v-loading="loading"
        :data="patentListAppli"
        :max-height="maxHeight"
        :header-cell-style="{ background: '#2a8eed', color: '#fafcfe' }"
        v-show="
          (cpData == 'act' || cpData == 'auth') &&
          cpContentArr.length == 1 &&
          cpContentArr[0] == '2'
        "
      >
        <el-table-column
          label="对比地区"
          align="center"
          width="100"
          fixed="left"
        >
          <template slot-scope="scope">
            <span>{{ scope.row["areaName"] }}</span>
          </template>
        </el-table-column>
        <el-table-column label="对比数据" align="center">
          <el-table-column label="对比周期" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row["timeReg"] }}</span>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="有效" align="center" v-if="cpData == 'act'">
          <el-table-column label="总计" align="center">
             <template slot-scope="scope">
              <span>
                {{ scope.row['total_cnt'] }}
              </span>
            </template>
          </el-table-column>
        </el-table-column>

        <el-table-column label="授权" align="center" v-if="cpData == 'auth'">
          <el-table-column label="总计" align="center">
             <template slot-scope="scope">
              <span>
                {{ scope.row['total_cnt'] }}
              </span>
            </template>
          </el-table-column>
        </el-table-column>

        <el-table-column label="" align="center">
          <el-table-column
            v-for="t in applicantTypes"
            :label="t.name"
            :key="t.id"
            align="center"
          >
          <template slot-scope="scope">
              <span>
                {{ scope.row[t.code2] }}
              </span>
            </template>
          </el-table-column>
        </el-table-column>
      </el-table>

      <!-- 高价值 -->
      <el-table
        v-loading="loading"
        :data="hvListPatent"
        :max-height="maxHeight"
        :header-cell-style="{ background: '#2a8eed', color: '#fafcfe' }"
        v-show="
          cpData == 'hv' && cpContentArr.length == 1 && cpContentArr[0] == '1'
        "
      >
        <el-table-column
          label="对比地区"
          align="center"
          width="100px"
          fixed="left"
        >
          <template slot-scope="scope">
            <span>{{ scope.row["areaName"] }}</span>
          </template>
        </el-table-column>
        <el-table-column label="对比数据" align="center">
          <el-table-column label="对比周期" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row["timeReg"] }}</span>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="高价值" align="center">
          <el-table-column label="总计" align="center">
            <template slot-scope="scope">
              <span>
                {{ scope.row['total_cnt'] }}
              </span>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="发明" align="center">
          <el-table-column
            v-for="t in highValueTypes"
            :label="t.name"
            :key="t.id"
            align="center"
          >
          <template slot-scope="scope">
              <span>
                {{ scope.row[t.code2] }}
              </span>
            </template>
          </el-table-column>
          </el-table-column>
        <el-table-column label="实用新型" align="center">
          <el-table-column label="/" align="center">
            <span>
                /
              </span>
          </el-table-column>
        </el-table-column>
        <el-table-column label="外观设计" align="center">
          <el-table-column label="/" align="center">
            <span>
                /
              </span>
          </el-table-column>
        </el-table-column>
      </el-table>

      <el-table
        v-loading="loading"
        :data="hvListAppli"
        :max-height="maxHeight"
        :header-cell-style="{ background: '#2a8eed', color: '#fafcfe' }"
        v-show="
          cpData == 'hv' && cpContentArr.length == 1 && cpContentArr[0] == '2'
        "
      >
        <el-table-column
          label="对比地区"
          align="center"
          width="100"
          fixed="left"
        >
          <template slot-scope="scope">
            <span>{{ scope.row["areaName"] }}</span>
          </template>
        </el-table-column>
        <el-table-column label="对比数据" align="center">
          <el-table-column label="对比周期" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row["timeReg"] }}</span>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="高价值" align="center">
          <el-table-column label="总计" align="center">
            <template slot-scope="scope">
              <span>
                {{ scope.row['all_total_cnt'] }}
              </span>
            </template>
          </el-table-column>
          </el-table-column>
        <el-table-column
          v-for="t in applicantTypes"
          :label="t.name"
          :key="t.id"
          align="center"
        >

        <el-table-column label="合计" align="center">
            <template slot-scope="scope">
              <span> {{ scope.row[t.code + "_total_cnt"] }}</span>
            </template>
          </el-table-column>

          <el-table-column
            v-for="p in highValueTypes"
            :label="p.name"
            :key="p.id"
            align="center"
          >
          <template slot-scope="scope">
              <span>
                {{ scope.row[t.code+'_'+p.code2] }}
              </span>
            </template>
          </el-table-column>
        </el-table-column>
      </el-table>

      <el-table
        v-loading="loading"
        :data="hvListAll"
        :max-height="maxHeight"
        :header-cell-style="{ background: '#2a8eed', color: '#fafcfe' }"
        v-show="cpData == 'hv' && cpContentArr.length == 2"
      >
        <el-table-column
          label="对比地区"
          align="center"
          width="100"
          fixed="left"
        >
          <template slot-scope="scope">
            <span>{{ scope.row["areaName"] }}</span>
          </template>
        </el-table-column>
        <el-table-column label="对比数据" align="center">
          <el-table-column label="对比周期" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row["timeReg"] }}</span>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="高价值" align="center">
          <el-table-column label="总计" align="center">
            <template slot-scope="scope">
              <span>
                {{ scope.row['all_total_cnt'] }}
              </span>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="发明" align="center">
          <el-table-column
            v-for="v in highValueTypes"
            :label="v.name"
            :key="v.id"
            align="center"
          >
            <el-table-column
              v-for="t in applicantTypes"
              :label="t.name"
              :key="t.id"
              align="center"
            >
            <template slot-scope="scope">
              <span>
                {{ scope.row[v.code2+'_'+t.code] }}
              </span>
            </template>
          </el-table-column>
            </el-table-column>
          </el-table-column>

        <el-table-column label="实用新型" align="center">
          <el-table-column label="/" align="center">
            <el-table-column label="/" align="center">
              <span>
                /
              </span>
            </el-table-column>
          </el-table-column>
        </el-table-column>

        <el-table-column label="外观设计" align="center">
          <el-table-column label="/" align="center">
            <el-table-column label="/" align="center">
              <span>
                /
              </span>
            </el-table-column>
          </el-table-column>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import {
  listDAgentAuthInfo,
  getDAgentAuthInfo,
  delDAgentAuthInfo,
  addDAgentAuthInfo,
  updateDAgentAuthInfo,
} from "@/api/agentrep/dAgentAuthInfo";
import {
  listUrPatentValid,
  getHeaderList,
  getRegionList,
} from "@/api/system/urPatentValid";
import {
  getPatentType,
  getPatentTypes,
  getApplicantTypes,
  getHighValues,
  getAllPatentTypeIdStr,
  getAllApplicantTypeIdStr,
} from "@/api/staticdata";

import { getGrowthrateList } from "@/api/growthrate/patentgrowthrate";

import chinaSSQ from "./chinaSSQ";
export default {
  name: "DAgentAuthInfo",
  data() {
    return {
      maxHeight: 0,
      zbc: "",
      // 遮罩层
      loading: false,
      //对比内容
      cpContentList: [
        { id: "1", name: "专利类型" },
        { id: "2", name: "申请人类型" },
      ],
      activeList: [],
      // 需要只选择云南把chinaSSQ换成[]，选择全部设置成chinaSSQ
      activeList2: [],
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 代理机构报表格数据
      dAgentAuthInfoList: [],
      rzlClassStatisticsInfoList: [],

      patentListAll: [],
      patentListPatent: [],
      patentListAppli: [],

      hvListAll: [],
      hvListPatent: [],
      hvListAppli: [],

      applicantTypes: [],
      highValueTypes: [],
      patentTypes: [],
      // 弹出层标题
      title: "",
      appDate1: ['2021-12','2021-12'],
      appDate2: ['2022-12','2022-12'],
      // 是否显示弹出层
      open: false,
      regionOptions: {},
      ysDistrictCounty: [],
      opensb: true,
      cpData: "act",
      cpContentArr: ["1", "2"],
      // 查询参数
      queryParams: {
        cpData: "act",
        cpContentArr: ["1", "2"],
        cpContents: null,
        province: "53",
        appliCity: 'null',
        appliCounty: 'null',
        beginDate: null,

        endDate: null,
        beginDate2: null,
        endDate2: null,
        pageNum: 1,
        pageSize: 100,
        agencyName: null,
        pubTotal: null,
        authTotal: null,
        inventionCnt: null,
        modelUtilityCnt: null,
        appearanceCnt: null,
        status: null,
        beginTime1:'202112',
        endTime1:'202112',
        beginTime2:'202212',
        endTime2:'202212',

      },
      // 表单参数
      form: {},
      activityRegs: [],
      activityRegs2: ['2022-12','2022-12'],
      activityRegs1: ['2021-12','2021-12'],
      // 表单校验
      rules: {},
    };
  },
  created() {
    this.getRegion();
    this.cascaderSSQChange();
    this.getList();
    this.gettable();
    this.applicantTypes = getApplicantTypes();
    this.patentTypes = getPatentTypes();
    this.highValueTypes = getHighValues();
    this.$nextTick(() => {
      this.maxHeight = window.innerHeight - 200; //300是页面中除了表格外其他组件的高度
    });
  },
  methods: {
    //刷新表头
    refreshHeader() {
      this.cpData = this.queryParams.cpData;
      this.cpContentArr = this.queryParams.cpContentArr;
    },

    search(q) {
      console.log(q);
      if (q == null || q == "" || q == "null"|| q == "all") {
        this.opensb = true;
        //this.queryParams.appliCounty = null;
        this.queryParams.appliCounty='null';
      } else {
        this.opensb = false;
        this.queryParams.appliCounty = "null";
        this.regionOptions.forEach((item) => {
          if (q == item.cityName) {
            this.ysDistrictCounty = item.areaList;
            this.opensb = false;
          }
        });
      }
    },
    /** 获取省市列表 */
    getRegion() {
      let params = {};
      getRegionList(params).then((response) => {
        console.log(response.data);
        let citys = [];
        for (let i = 0; i < response.data.length; i++) {
          if (response.data[i].code != "53") {
            citys.push(response.data[i]);
          }
        }
        this.regionOptions = citys;
      });
    },
    iscityChange(val) {
      let arr = this.regionOptions.find(
        (item) => item.name == "云南省"
      ).areaList;
      console.log(obj);
    },

    gettable() {
      console.log(this.activityRegs2, "this.activityRegs2");

      if (this.activityRegs2.length > 0) {
        this.zbc =
          "统计时期" + this.activityRegs2[0] + "到" + this.activityRegs2[1];
      } else {
        this.zbc = "统计时期";
      }
    },
    appDateInput1(e) {
      console.log(e,'appDateInput1');
      this.$nextTick(() => {
        if (e == null) {
          this.queryParams.beginTime1 = null;
          this.queryParams.endTime1 = null;
        } else {
          console.log(this.activityRegs1);
          this.$set(this, "activityRegs1", [e[0], e[1]]);
          this.queryParams.beginTime1 = this.activityRegs1[0].replaceAll("-", "");
          this.queryParams.endTime1 = this.activityRegs1[1].replaceAll("-", "");
        }
      });
    },

    appDateInput2(e) {
      console.log(e,'appDateInput2');
      this.$nextTick(() => {
        if (e == null) {
          this.queryParams.beginTime2 = null;
          this.queryParams.endTime2 = null;
        } else {
          console.log(this.activityRegs2);
          this.$set(this, "activityRegs2", [e[0], e[1]]);
          this.queryParams.beginTime2 = this.activityRegs2[0].replaceAll(
            "-",
            ""
          );
          this.queryParams.endTime2 = this.activityRegs2[1].replaceAll("-", "");
        }
      });
    },
    cascaderSSQChange(val) {
      chinaSSQ.forEach((item) => {
        if (item.code == 530000) {
          this.activeList = item.areaList;
        }
      });
      let activeb = [
        {
          code: "530000",
          level: 0,
          name: "云南省",
          areaList: this.activeList,
        },
      ];
      //this.activeList2 = [...this.activeList2, ...activeb];
      console.log(this.activeList2, "this.activeList2");
    },
    /** 查询代理机构报列表 */
    getList() {
      this.refreshHeader();
      this.loading = true;

      let cpData2 = this.cpData;
      let cpContentArr2 = this.cpContentArr;

      let cpContents = "";
      if (cpContentArr2.length > 0) {
        for (let i = 0; i < cpContentArr2.length; i++) {
          if (i > 0) {
            cpContents = cpContents + ",";
          }
          cpContents = cpContents + cpContentArr2[i];
        }
      }
      this.queryParams.cpContents = cpContents;

      getGrowthrateList(this.queryParams).then((response) => {
        if (
          (cpData2 == "act" || cpData2 == "auth") &&
          cpContentArr2.length == 2
        ) {
          //this.patentListAll = response.data;
          let temp = [];
          response.data.forEach((item) => {
            let r1 = {};
            r1.areaName = item.areaName;
            r1 = { ...r1, ...item.item1 };
            let r2 = {};
            r2.areaName = "";
            r2 = { ...r2, ...item.item2 };
            let r3 = {};
            r3 = { ...item.growth };
            temp.push(r1);
            temp.push(r2);
            temp.push(r3);
          });
          this.patentListAll = temp;
        }
        if (
          (cpData2 == "act" || cpData2 == "auth") &&
          cpContentArr2.length == 1 &&
          cpContentArr2[0] == "1"
        ) {
          // this.patentListPatent = response.data;
          let temp = [];
          response.data.forEach((item) => {
            let r1 = {};
            r1.areaName = item.areaName;
            r1 = { ...r1, ...item.item1 };
            let r2 = {};
            r2.areaName = "";
            r2 = { ...r2, ...item.item2 };
            let r3 = {};
            r3 = { ...item.growth };
            temp.push(r1);
            temp.push(r2);
            temp.push(r3);
          });
          this.patentListPatent = temp;
        }
        if (
          (cpData2 == "act" || cpData2 == "auth") &&
          cpContentArr2.length == 1 &&
          cpContentArr2[0] == "2"
        ) {
          // this.patentListAppli = response.data;
          let temp = [];
          response.data.forEach((item) => {
            let r1 = {};
            r1.areaName = item.areaName;
            r1 = { ...r1, ...item.item1 };
            let r2 = {};
            r2.areaName = "";
            r2 = { ...r2, ...item.item2 };
            let r3 = {};
            r3 = { ...item.growth };
            temp.push(r1);
            temp.push(r2);
            temp.push(r3);
          });
          this.patentListAppli = temp;
        }
        if (cpData2 == "hv" && cpContentArr2.length == 2) {
          // this.hvListAll = response.data;
          let temp = [];
          response.data.forEach((item) => {
            let r1 = {};
            r1.areaName = item.areaName;
            r1 = { ...r1, ...item.item1 };
            let r2 = {};
            r2.areaName = "";
            r2 = { ...r2, ...item.item2 };
            let r3 = {};
            r3 = { ...item.growth };
            temp.push(r1);
            temp.push(r2);
            temp.push(r3);
          });
          this.hvListAll = temp;
        }
        if (
          cpData2 == "hv" &&
          cpContentArr2.length == 1 &&
          cpContentArr2[0] == "1"
        ) {
          // this.hvListPatent = response.data;
           let temp = [];
          response.data.forEach((item) => {
            let r1 = {};
            r1.areaName = item.areaName;
            r1 = { ...r1, ...item.item1 };
            let r2 = {};
            r2.areaName = "";
            r2 = { ...r2, ...item.item2 };
            let r3 = {};
            r3 = { ...item.growth };
            temp.push(r1);
            temp.push(r2);
            temp.push(r3);
          });
          this.hvListPatent = temp;
        }
        if (
          cpData2 == "hv" &&
          cpContentArr2.length == 1 &&
          cpContentArr2[0] == "2"
        ) {
          // this.hvListAppli = response.data;
          let temp = [];
          response.data.forEach((item) => {
            let r1 = {};
            r1.areaName = item.areaName;
            r1 = { ...r1, ...item.item1 };
            let r2 = {};
            r2.areaName = "";
            r2 = { ...r2, ...item.item2 };
            let r3 = {};
            r3 = { ...item.growth };
            temp.push(r1);
            temp.push(r2);
            temp.push(r3);
          });
          this.hvListAppli = temp;
        }
        this.total = 0;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        agencyName: null,
        pubTotal: null,
        authTotal: null,
        inventionCnt: null,
        modelUtilityCnt: null,
        appearanceCnt: null,
        status: "0",
        remark: null,
        delFlag: null,
        createTime: null,
        createBy: null,
        updateTime: null,
        updateBy: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
      this.gettable();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.appDate1 = null;
      this.appDate2 = null;
      this.queryParams.beginTime1 = null;
      this.queryParams.beginTime2 = null;
      this.queryParams.endTime1 = null;
      this.queryParams.endTime2 = null;
      this.activityRegs1 = [];
      this.activityRegs2 = [];
      this.resetForm("queryForm");
      this.handleQuery();
      this.gettable();
    },
    // 多选框选中数据
    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;
      getDAgentAuthInfo(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) {
            updateDAgentAuthInfo(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addDAgentAuthInfo(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 delDAgentAuthInfo(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "growthrate/patentGrowthrate/export",
        {
          ...this.queryParams,
        },
        `patentGrowthrate_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
