<template>
  <div class="app-container">
    <!--搜索区-->
    <div class="float">
      <el-input
        v-model="page.data.newUsername"
        placeholder="请输入现单位"
        clearable
        class="margin-left input"
      ></el-input>
      <el-input
        v-model="page.data.oldUsername"
        placeholder="请输入原单位"
        clearable
        class="margin-left input"
      ></el-input>
      <el-button
        type="primary"
        icon="el-icon-search"
        @click="fetchData"
        class="margin-left"
        >搜索</el-button
      >
    </div>
    <!--主表格-->
    <el-table
      class="table"
      ref="table_form"
      v-loading="listLoading"
      :data="list"
      element-loading-text="Loading"
      border
      fit
      highlight-current-row
    >
      <el-table-column label="序号" align="center" width="80px">
        <template slot-scope="scope">
          {{ indexMethod(scope.$index) }}
        </template>
      </el-table-column>
      <el-table-column label="头像（证件照）" align="center">
        <template slot-scope="scope">
          <el-image
            v-if="scope.row.avatar"
            class="table-img"
            :src="scope.row.avatar"
            :preview-src-list="[scope.row.avatar]"
          >
          </el-image>
          <span v-else>暂无</span>
        </template>
      </el-table-column>
      <el-table-column label="姓名" align="center">
        <template slot-scope="scope">
          {{ scope.row.name }}
        </template>
      </el-table-column>
      <!-- <el-table-column label="身份证号" align="center">
        <template slot-scope="scope">
          {{ scope.row.content }}
        </template>
      </el-table-column> -->
      <el-table-column label="手机号 " align="center">
        <template slot-scope="scope">
          {{ scope.row.phone }}
        </template>
      </el-table-column>

      <el-table-column label="现单位" align="center">
        <template slot-scope="scope">
          {{ scope.row.newUsername }}
        </template>
      </el-table-column>
      <el-table-column label="现部门" align="center">
        <template slot-scope="scope">
          {{ scope.row.newDeptName }}
        </template>
      </el-table-column>
      <el-table-column label="现岗位" align="center">
        <template slot-scope="scope">
          {{ scope.row.newDeptPostName }}
        </template>
      </el-table-column>
      <el-table-column label="原单位" align="center">
        <template slot-scope="scope">
          {{ scope.row.oldUsername }}
        </template>
      </el-table-column>
      <el-table-column label="原部门" align="center">
        <template slot-scope="scope">
          {{ scope.row.oldDeptName }}
        </template>
      </el-table-column>
      <el-table-column label="原岗位" align="center">
        <template slot-scope="scope">
          {{ scope.row.oldDeptPostName }}
        </template>
      </el-table-column>
      <el-table-column label="变更时间" align="center">
        <template slot-scope="scope">
          {{ scope.row.createTime }}
        </template>
      </el-table-column>
      <!-- <el-table-column label="审核状态 " align="center">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.status === 1" type="info">审核中</el-tag>
          <el-tag v-if="scope.row.status === 2" type="warning">整改中</el-tag>
          <el-tag v-if="scope.row.status === 3" type="success">已通过</el-tag>
          <el-tag v-if="scope.row.status === 4" type="danger">已驳回</el-tag>
        </template>
      </el-table-column> -->
    </el-table>

    <!--分页栏-->
    <pagination
      :total="total"
      :page.sync="page.pageNum"
      :limit.sync="page.pageSize"
      @pagination="fetchData"
    />
  </div>
</template>

<script>
import Pagination from "@/components/Pagination";
import { getChangePageList } from "@/api/user";
export default {
  components: { Pagination },
  filters: {},
  computed: {},
  data() {
    return {
      role: this.$store.getters.role,
      // 主表格&主表格加载状态
      list: [],
      listLoading: true,
      // 分页参数
      page: {
        data: {
          newUsername: null,
          oldUsername: null,
        },
        pageNum: 1,
        pageSize: 10,
      },
      total: 0,
    };
  },
  created() {
    this.fetchData();
  },
  watch: {},
  methods: {
    // 获取列表数据
    fetchData() {
      this.listLoading = true;
      getChangePageList(this.page).then((res) => {
        this.list = res.data.records;
        this.total = res.data.total;
        this.listLoading = false;
      });
    },
    // 返回列表序号
    indexMethod(index) {
      return (this.page.pageNum - 1) * this.page.pageSize + index + 1;
    },
  },
};
</script>
<style scoped lang="scss">
</style>
