<template>
  <div class="box">
    <!-- 查询 -->
    <div class="inquire">
      <span>ID</span>
      <el-input
        v-model="inquire.userId"
        placeholder=""
        class="input"
      ></el-input>
    </div>
    <!-- 时间选择器 -->
    <div class="inquire">
      <div class="block">
        <span class="demonstration">移除日期</span>
        <el-date-picker
          v-model="inquire.time"
          type="datetimerange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        >
        </el-date-picker>
      </div>
    </div>
    <!-- 查询按钮 -->
    <el-button class="primary" type="primary" @click="getData()"
      >查询</el-button
    >

    <!-- 表格 -->
    <el-table
      v-loading="loading"
      :data="tableData"
      border
      style="width: 100%; margin-top: 25px"
    >
      <el-table-column prop="familyName" align="center" label="家族昵称" />
      <el-table-column prop="erbanNo" align="center" label="成员ID" />
      <el-table-column prop="nick" align="center" label="成员昵称" />
      <el-table-column prop="targetErbanNo" align="center" label="目标成员ID" />
      <el-table-column prop="targetNick" align="center" label="目标成员昵称" />
      <el-table-column prop="type" align="center" label="操作类型">
        <template v-slot="scope">
          {{
            scope.row.type == 1
              ? "申请加入"
              : scope.row.type == 2
              ? "申请退出"
              : scope.row.type == 3
              ? "邀请加入"
              : scope.row.type == 4
              ? "设置管理员"
              : scope.row.type == 5
              ? "移除管理员"
              : "移除成员"
          }}
        </template>
      </el-table-column>
      <el-table-column prop="createTime" align="center" label="操作时间" />
      <el-table-column prop="updateTime" align="center" label="最后更新时间" />
      <el-table-column prop="status" align="center" label="状态">
        <template v-slot="scope">
          {{
            scope.row.status == 1
              ? "未处理"
              : scope.row.status == 2
              ? "同意"
              : scope.row.status == 2
              ? "拒绝"
              : "过期"
          }}
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <el-pagination
      style="margin-top: 10px"
      class="paginationClass"
      v-model:current-page="currentPage"
      v-model:page-size="pageSize"
      :page-sizes="[10, 20, 30, 40, 50, 100, 200, 300, 400, 500, 999999999]"
      layout="sizes, prev, pager, next"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>
<script>
import { pageOperateRecord } from "@/api/noblemanNew/noblemanNew";
// @ts-ignore
import { dateFormat } from "@/utils/system-helper";
// @ts-ignore
import { ElMessage } from "element-plus";
export default {
  name: "GuildMoveNew",
  data() {
    return {
      loading: false,
      //查询所需条件对象
      inquire: {
        userId: "",
        nick: "",
        time: "",
      },
      //新增所需对象
      resource: {
        id: "",
        nick: "",
      },
      // 表格
      tableData: [],
      //   新增弹窗
      addDialog: false,
      // 分页
      total: 10, //总页数
      currentPage: 1, //页码
      pageSize: 10, //条数
    };
  },
  created() {
    this.getData();
  },
  methods: {
    // 查询接口
    getData() {
      this.loading = true;
      let time = this.inquire.time;
      let startTime = "";
      let endTime = "";
      if (time && time.length > 0) {
        startTime = dateFormat(this.inquire.time[0], "yyyy-MM-dd hh:mm:ss");
        endTime = dateFormat(this.inquire.time[1], "yyyy-MM-dd hh:mm:ss");
      }
      pageOperateRecord({
        erbanNo: this.inquire.userId,
        startDate: startTime,
        endDate: endTime,
        pageNum: this.currentPage,
        pageSize: this.pageSize,
      }).then((res) => {
        this.total = res.data.total;
        this.tableData = res.data.rows;
        this.loading = false;
      });
    },
    // 分页导航
    handleSizeChange() {
      this.getData();
    },
    handleCurrentChange() {
      this.getData();
    },
  },
};
</script>
<style lang="less" scoped>
.box {
  padding-top: 20px;
  background: #ecf0f5;
  .inquire {
    display: inline-block;
    margin-right: 20px;
    span {
      margin-right: 10px;
    }
    .input {
      width: 180px;
      margin-right: 10px;
    }
  }
  .dialogTableVisibleBut {
    display: block;
    margin: 30px 0 0 830px;
  }
  .paginationClass {
    margin: 15px 0 5px 0px;
  }
}
</style>
