<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="单位名称" prop="Dept">
        <el-input
          v-model="queryParams.Dept"
          placeholder="请输入单位名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="姓名" prop="Name">
        <el-input
          v-model="queryParams.Name"
          placeholder="请输入姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="身份证" prop="ShenFenZheng">
        <el-input
          v-model="queryParams.ShenFenZheng"
          placeholder="请输入身份证"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="handleQuery">查询</el-button>
        <el-button @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table
      v-loading="loading"
      :data="RenCaiList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column label="序号" align="center" type="index">
        <template slot-scope="scope">
          <span>{{ handleTableIndex(scope.$index, queryParams) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="姓名" align="center" prop="Name" />
      <el-table-column label="性别" align="center" prop="Sex" />
      <el-table-column
        label="身份证号"
        align="center"
        width="200"
        prop="ShenFenZheng"
      />
      <el-table-column
        label="单位名称"
        align="center"
        prop="Dept"
        width="300"
      />
      <el-table-column
        label="监理员证书号"
        align="center"
        width="300"
        prop="JLYZhengHao"
      />
      <!-- <el-table-column
        label="监理员证号"
        align="center"
        prop="JLYZhengHaoNum"
      /> -->
      <el-table-column
        label="监理员发证日期"
        align="center"
        prop="JLYfzrq"
        width="200"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.JLYfzrq, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="监理工程师证书号"
        align="center"
        width="200"
        prop="JLZhengHao"
      />
      <el-table-column
        label="监理工程师证书号(纯数字)"
        align="center"
        prop="JLZhengHaoNum"
        width="200"
      />
      <el-table-column
        label="监理工程师证书发证日期"
        align="center"
        prop="JLfzrq"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.JLfzrq, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="监理工程师证书有效期至"
        align="center"
        prop="JLYxqz"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.JLYxqz, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="总监证书号"
        align="center"
        width="200"
        prop="ZJZhengHao"
      />
      <el-table-column
        label="总监发证日期"
        align="center"
        prop="ZJfzrq"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.ZJfzrq, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column label="不良记录"></el-table-column>
      <el-table-column label="处罚"></el-table-column>

      <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-edit"
            @click="handleView(scope.row)"
            v-hasPermi="['jlry:RenCai:edit']"
            >查看</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="业绩/简历"
      :visible.sync="viewDia"
      width="600px"
      :before-close="
        () => {
          viewDia = false;
        }
      "
    >
      <span slot="footer" class="dialog-footer">
        <el-button @click="viewDia = false">关 闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { listRenCai, getRenCai } from "@/api/xiehui/tjgl/supervisor";
import { handleTableIndex } from "@/utils/index";

export default {
  name: "RenCai",
  dicts: ["jxjy_sfkyjxjy", "jxjy_jlgcszfbz", "jxjy_bljl", "jxjy_jlyzfbz"],
  data() {
    return {
      viewDia: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      activeView: {},
      // 监理人才管理表格数据
      RenCaiList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
    };
  },
  created() {
    this.getList();
  },
  methods: {
    handleTableIndex,
    handleView(row) {
      this.activeView = row;
      console.log(this.activeView);
      this.viewDia = true;
    },
    /** 查询监理人才管理列表 */
    getList() {
      this.loading = true;
      listRenCai(this.queryParams).then((response) => {
        this.RenCaiList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const ID = row.ID || this.ids;
      getRenCai(ID).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改监理人才管理";
      });
    },
  },
};
</script>
