<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="申请号" prop="appNumber">
        <el-input
          v-model="queryParams.appNumber"
          placeholder="请输入申请号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <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="appli">
        <el-input
          v-model="queryParams.appli"
          placeholder="请输入第一申请人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="申请人类型" prop="appliTypeSrc">
        <el-input
          v-model="queryParams.appliTypeSrc"
          placeholder="请输入申请人类型"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="申请人地址" prop="appliAddress">
        <el-input
          v-model="queryParams.appliAddress"
          placeholder="请输入申请人地址"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="省份" prop="appliProvince">
        <el-input
          v-model="queryParams.appliProvince"
          placeholder="请输入省份"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="州市" prop="appliCity">
        <el-input
          v-model="queryParams.appliCity"
          placeholder="请输入州市"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="区县" prop="appliCounty">
        <el-input
          v-model="queryParams.appliCounty"
          placeholder="请输入区县"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="省份" prop="modifyAppliProvince">
        <el-input
          v-model="queryParams.modifyAppliProvince"
          placeholder="请输入省份"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="州市" prop="modifyAppliCity">
        <el-input
          v-model="queryParams.modifyAppliCity"
          placeholder="请输入州市"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="区县" prop="modifyAppliCounty">
        <el-input
          v-model="queryParams.modifyAppliCounty"
          placeholder="请输入区县"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="高价值类型" prop="highValue">
        <el-input
          v-model="queryParams.highValue"
          placeholder="请输入高价值类型"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="入库时间" prop="inboundDate">
        <el-input
          v-model="queryParams.inboundDate"
          placeholder="请输入入库时间"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="地址调整时间" prop="addressAdjustmentTime">
        <el-input
          v-model="queryParams.addressAdjustmentTime"
          placeholder="请输入地址调整时间"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="申请人调整时间" prop="applyAdjustmentTime">
        <el-input
          v-model="queryParams.applyAdjustmentTime"
          placeholder="请输入申请人调整时间"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="专利名称" prop="title">
        <el-input
          v-model="queryParams.title"
          placeholder="请输入专利名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="公开号" prop="pubNumber">
        <el-input
          v-model="queryParams.pubNumber"
          placeholder="请输入公开号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="当前专利人" prop="currPatentHolder">
        <el-input
          v-model="queryParams.currPatentHolder"
          placeholder="请输入当前专利人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="分类号" prop="ipcMain">
        <el-input
          v-model="queryParams.ipcMain"
          placeholder="请输入分类号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="分类号" prop="locStr">
        <el-input
          v-model="queryParams.locStr"
          placeholder="请输入分类号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="国民经济行业分类" prop="nationalEcoStr">
        <el-input
          v-model="queryParams.nationalEcoStr"
          placeholder="请输入国民经济行业分类"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="专利转移次数" prop="patTranCounts">
        <el-input
          v-model="queryParams.patTranCounts"
          placeholder="请输入专利转移次数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="申请权转移次数" prop="appTranCounts">
        <el-input
          v-model="queryParams.appTranCounts"
          placeholder="请输入申请权转移次数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="许可发生次数" prop="licCounts">
        <el-input
          v-model="queryParams.licCounts"
          placeholder="请输入许可发生次数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="质押发生次数" prop="pleCounts">
        <el-input
          v-model="queryParams.pleCounts"
          placeholder="请输入质押发生次数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="保全发生次数" prop="preCounts">
        <el-input
          v-model="queryParams.preCounts"
          placeholder="请输入保全发生次数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="法院判决发生次数" prop="curtCounts">
        <el-input
          v-model="queryParams.curtCounts"
          placeholder="请输入法院判决发生次数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="代理机构" prop="agencyName">
        <el-input
          v-model="queryParams.agencyName"
          placeholder="请输入代理机构"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </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-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['adjust:dPatentDataCollationLog:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['adjust:dPatentDataCollationLog:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['adjust:dPatentDataCollationLog:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['adjust:dPatentDataCollationLog:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="dPatentDataCollationLogList" @selection-change="handleSelectionChange">
      <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="appNumber" />
      <el-table-column label="申请日" align="center" prop="appDate" />
      <el-table-column label="第一申请人" align="center" prop="appli" />
      <el-table-column label="申请人类型" align="center" prop="appliTypeSrc" />
      <el-table-column label="申请人类型" align="center" prop="appliType" />
      <el-table-column label="申请人地址" align="center" prop="appliAddress" />
      <el-table-column label="省份" align="center" prop="appliProvince" />
      <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="highValue" />
      <el-table-column label="入库时间" align="center" prop="inboundDate" />
      <el-table-column label="地址调整时间" align="center" prop="addressAdjustmentTime" />
      <el-table-column label="申请人调整时间" align="center" prop="applyAdjustmentTime" />
      <el-table-column label="专利名称" align="center" prop="title" />
      <el-table-column label="公开号" align="center" prop="pubNumber" />
      <el-table-column label="当前专利状态" align="center" prop="currPatentStatus" />
      <el-table-column label="当前专利人" align="center" prop="currPatentHolder" />
      <el-table-column label="专利类型" align="center" prop="patentType" />
      <el-table-column label="分类号" align="center" prop="ipcMain" />
      <el-table-column label="分类号" align="center" prop="locStr" />
      <el-table-column label="国民经济行业分类" align="center" prop="nationalEcoStr" />
      <el-table-column label="专利转移次数" align="center" prop="patTranCounts" />
      <el-table-column label="申请权转移次数" align="center" prop="appTranCounts" />
      <el-table-column label="许可发生次数" align="center" prop="licCounts" />
      <el-table-column label="质押发生次数" align="center" prop="pleCounts" />
      <el-table-column label="保全发生次数" align="center" prop="preCounts" />
      <el-table-column label="法院判决发生次数" align="center" prop="curtCounts" />
      <el-table-column label="代理机构" align="center" prop="agencyName" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="状态" align="center" prop="status" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['adjust:dPatentDataCollationLog:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['adjust:dPatentDataCollationLog:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改专利数据整理历史对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="申请号" prop="appNumber">
          <el-input v-model="form.appNumber" placeholder="请输入申请号" />
        </el-form-item>
        <el-form-item label="申请日" prop="appDate">
          <el-input v-model="form.appDate" placeholder="请输入申请日" />
        </el-form-item>
        <el-form-item label="第一申请人" prop="appli">
          <el-input v-model="form.appli" placeholder="请输入第一申请人" />
        </el-form-item>
        <el-form-item label="申请人类型" prop="appliTypeSrc">
          <el-input v-model="form.appliTypeSrc" placeholder="请输入申请人类型" />
        </el-form-item>
        <el-form-item label="申请人地址" prop="appliAddress">
          <el-input v-model="form.appliAddress" placeholder="请输入申请人地址" />
        </el-form-item>
        <el-form-item label="省份" prop="appliProvince">
          <el-input v-model="form.appliProvince" placeholder="请输入省份" />
        </el-form-item>
        <el-form-item label="州市" prop="appliCity">
          <el-input v-model="form.appliCity" placeholder="请输入州市" />
        </el-form-item>
        <el-form-item label="区县" prop="appliCounty">
          <el-input v-model="form.appliCounty" placeholder="请输入区县" />
        </el-form-item>
        <el-form-item label="省份" prop="modifyAppliProvince">
          <el-input v-model="form.modifyAppliProvince" placeholder="请输入省份" />
        </el-form-item>
        <el-form-item label="州市" prop="modifyAppliCity">
          <el-input v-model="form.modifyAppliCity" placeholder="请输入州市" />
        </el-form-item>
        <el-form-item label="区县" prop="modifyAppliCounty">
          <el-input v-model="form.modifyAppliCounty" placeholder="请输入区县" />
        </el-form-item>
        <el-form-item label="高价值类型" prop="highValue">
          <el-input v-model="form.highValue" placeholder="请输入高价值类型" />
        </el-form-item>
        <el-form-item label="入库时间" prop="inboundDate">
          <el-input v-model="form.inboundDate" placeholder="请输入入库时间" />
        </el-form-item>
        <el-form-item label="地址调整时间" prop="addressAdjustmentTime">
          <el-input v-model="form.addressAdjustmentTime" placeholder="请输入地址调整时间" />
        </el-form-item>
        <el-form-item label="申请人调整时间" prop="applyAdjustmentTime">
          <el-input v-model="form.applyAdjustmentTime" placeholder="请输入申请人调整时间" />
        </el-form-item>
        <el-form-item label="专利名称" prop="title">
          <el-input v-model="form.title" placeholder="请输入专利名称" />
        </el-form-item>
        <el-form-item label="公开号" prop="pubNumber">
          <el-input v-model="form.pubNumber" placeholder="请输入公开号" />
        </el-form-item>
        <el-form-item label="当前专利人" prop="currPatentHolder">
          <el-input v-model="form.currPatentHolder" placeholder="请输入当前专利人" />
        </el-form-item>
        <el-form-item label="分类号" prop="ipcMain">
          <el-input v-model="form.ipcMain" placeholder="请输入分类号" />
        </el-form-item>
        <el-form-item label="分类号" prop="locStr">
          <el-input v-model="form.locStr" placeholder="请输入分类号" />
        </el-form-item>
        <el-form-item label="国民经济行业分类" prop="nationalEcoStr">
          <el-input v-model="form.nationalEcoStr" placeholder="请输入国民经济行业分类" />
        </el-form-item>
        <el-form-item label="专利转移次数" prop="patTranCounts">
          <el-input v-model="form.patTranCounts" placeholder="请输入专利转移次数" />
        </el-form-item>
        <el-form-item label="申请权转移次数" prop="appTranCounts">
          <el-input v-model="form.appTranCounts" placeholder="请输入申请权转移次数" />
        </el-form-item>
        <el-form-item label="许可发生次数" prop="licCounts">
          <el-input v-model="form.licCounts" placeholder="请输入许可发生次数" />
        </el-form-item>
        <el-form-item label="质押发生次数" prop="pleCounts">
          <el-input v-model="form.pleCounts" placeholder="请输入质押发生次数" />
        </el-form-item>
        <el-form-item label="保全发生次数" prop="preCounts">
          <el-input v-model="form.preCounts" placeholder="请输入保全发生次数" />
        </el-form-item>
        <el-form-item label="法院判决发生次数" prop="curtCounts">
          <el-input v-model="form.curtCounts" placeholder="请输入法院判决发生次数" />
        </el-form-item>
        <el-form-item label="代理机构" prop="agencyName">
          <el-input v-model="form.agencyName" placeholder="请输入代理机构" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注" />
        </el-form-item>
        <el-form-item label="删除标识" prop="delFlag">
          <el-input v-model="form.delFlag" placeholder="请输入删除标识" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listDPatentDataCollationLog, getDPatentDataCollationLog, delDPatentDataCollationLog, addDPatentDataCollationLog, updateDPatentDataCollationLog } from "@/api/adjust/dPatentDataCollationLog";

export default {
  name: "DPatentDataCollationLog",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 专利数据整理历史表格数据
      dPatentDataCollationLogList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
          pageNum: 1,
          pageSize: 10,
        appNumber: null,
        appDate: null,
        appli: null,
        appliTypeSrc: null,
        appliType: null,
        appliAddress: null,
        appliProvince: null,
        appliCity: null,
        appliCounty: null,
        modifyAppliProvince: null,
        modifyAppliCity: null,
        modifyAppliCounty: null,
        highValue: null,
        inboundDate: null,
        addressAdjustmentTime: null,
        applyAdjustmentTime: null,
        title: null,
        pubNumber: null,
        currPatentStatus: null,
        currPatentHolder: null,
        patentType: null,
        ipcMain: null,
        locStr: null,
        nationalEcoStr: null,
        patTranCounts: null,
        appTranCounts: null,
        licCounts: null,
        pleCounts: null,
        preCounts: null,
        curtCounts: null,
        agencyName: null,
        status: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询专利数据整理历史列表 */
    getList() {
      this.loading = true;
      listDPatentDataCollationLog(this.queryParams).then(response => {
        this.dPatentDataCollationLogList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        dataType: null,
        appNumber: null,
        appDate: null,
        appli: null,
        appliTypeSrc: null,
        appliType: null,
        appliAddress: null,
        appliProvince: null,
        appliCity: null,
        appliCounty: null,
        modifyAppliProvince: null,
        modifyAppliCity: null,
        modifyAppliCounty: null,
        highValue: null,
        inboundDate: null,
        addressAdjustmentTime: null,
        applyAdjustmentTime: null,
        title: null,
        pubNumber: null,
        currPatentStatus: "0",
        currPatentHolder: null,
        patentType: null,
        ipcMain: null,
        locStr: null,
        nationalEcoStr: null,
        patTranCounts: null,
        appTranCounts: null,
        licCounts: null,
        pleCounts: null,
        preCounts: null,
        curtCounts: null,
        agencyName: null,
        remark: null,
        delFlag: null,
        status: 0,
        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
      getDPatentDataCollationLog(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) {
            updateDPatentDataCollationLog(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addDPatentDataCollationLog(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 delDPatentDataCollationLog(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('adjust/dPatentDataCollationLog/export', {
        ...this.queryParams
      }, `dPatentDataCollationLog_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
