<template>
  <div>
    <el-button type="primary" size="mini" @click="click">复制指标</el-button>
    <el-dialog title="历史绩效" :visible.sync="open" width="1000px" :close-on-click-modal="false">
      复制操作将覆盖当前绩效明细
      <el-table size="mini" height="500px" v-loading="loading" :data="listData" @row-dblclick="btnCopy">
        <el-table-column label="员工" align="center" prop="staffName" />
        <el-table-column label="评估周期" align="center" prop="name" />
        <el-table-column label="月度" align="center" prop="month" />
        <el-table-column label="创建时间" align="center" prop="createTime" />
        <el-table-column label="操作" fixed="right" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-document-copy"
                @click="btnCopy(scope.row)"
              >复制</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div>
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
    </el-dialog>
  </div>
</template>

<script>
import { listPerformance} from "@/api/business/ehr/pm/performance";
export default {
  name: "CopyItemDialog",
  props: ["id"],
  data() {
    return {
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        staff: null,
        params:{
          neId: null,
        },
      },
      // 总条数
      total: 0,
      // 表格数据
      listData: [],
      // 遮罩层
      loading: true,
      // 是否显示弹出层
      open: false,
    };
  },
  methods: {
    /** 查询绩效列表 */
    getList() {
      this.loading = true;
      listPerformance(this.queryParams).then(response => {
        this.listData = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    //点击了当前按钮
    click() {
      this.queryParams.staff = this.$store.state.user.name;
      this.open = true;
      this.getList();
    },
    //复制
    async btnCopy(row){
      this.$emit('setItems',row.id);
      this.open = false;
    },
  },
  created() {
    this.queryParams.params.neId = this.id;
  },
};
</script>

