<template>
  <div>
    <el-dialog title="合并数据" :visible.sync="visible" width="900px" top="3vh" append-to-body destroy-on-close :before-close="close">
      <el-form :inline="true">
        <el-form-item label="当前名称">
          <el-input v-model="queryParams.name" size="small" placeholder="请输入当前名称"></el-input>
        </el-form-item>
        <el-form-item label="标准名称">
          <el-input v-model="queryParams.shortName" size="small" placeholder="请输入标准名称"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="" size="small" @click="getList">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="loading" :data="tableData" border header-row-class-name="custom-table-header">
        <el-table-column prop="name" label="当前名称" align="center" show-overflow-tooltip></el-table-column>
        <el-table-column prop="shortName" label="标准名称" align="center" show-overflow-tooltip></el-table-column>
        <el-table-column prop="countryName" label="国家" align="center" width="150" show-overflow-tooltip></el-table-column>
        <el-table-column prop="addressStr" label="地址" align="center" show-overflow-tooltip></el-table-column>
        <el-table-column label="操作" width="80" align="center">
          <template slot-scope="scope">
            <el-link type="danger" @click="handleDelete(scope.row)" v-if="$permission('/workspace/folder/merge/applicationMerge/merged/remove')">移除</el-link>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination">
        <el-pagination :current-page.sync="queryParams.current" :page-size="queryParams.size" :total="total" @current-change="handleCurrentChange" layout="total, prev, pager, next, jumper" background></el-pagination>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="visible = false">关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      visible: false,
      loading: false,
      tableData: [],
      total: 0,
      queryParams: {
        name: '',
        country: '',
        address: '',
        size: 10,
        current: 1,
        projectId: 0,
        order: 'desc',
        prop: 'update_time',
        from: 'exist',
        mergeId: 0
      },
    }
  },
  methods: {
    open(row) {
      this.visible = true
      this.queryParams.projectId = row.projectId
      this.queryParams.mergeId = row.id
      this.getList()
    },
    close() {
      this.visible = false
      this.$emit('close')
    },
    getList() {
      this.loading = true
      this.$api.getPatentApplicantList(this.queryParams).then(response => {
        this.tableData = response.data.records
        this.total = response.data.total
        this.loading = false
      }).catch(error => {
        this.loading = false
      })
    },
    handleCurrentChange(val) {
      this.queryParams.current = val;
      this.getList();
    },
    handleDelete(row) {
      this.$confirm('确认删除本条数据吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.loading = true
        this.$api.deletePatentMergeApplicant({ id: row.id, mergeId: this.queryParams.mergeId }).then(response => {
          this.$message.success('删除成功')
          this.loading = false
          this.getList()
        }).catch(error => {
          this.loading = false
        })
      })
    },
  }
}
</script>

<style lang="less">

</style>