<template>
  <div class="box">
    <!-- 查询 -->
    <div class="inquire">
      <span>平台ID</span>
      <el-input v-model="inquire.id" placeholder="" class="input"></el-input>
    </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="backgroundId" align="center" label="个人主页id" />
      <el-table-column
        prop="backgroundName"
        align="center"
        label="个人主页名称"
      />
      <el-table-column prop="uid" align="center" label="用户uID" />
      <el-table-column prop="nick" align="center" label="用户昵称" />
      <el-table-column prop="days" align="center" label="赠送天数" />
      <el-table-column prop="remake" align="center" label="备注" />
      <el-table-column prop="createTime" align="center" label="操作时间" />
      <el-table-column prop="optUser" align="center" label="操作人" />
      <el-table-column align="center" label="操作" width="300">
        <template v-slot="scope">
          <el-button
            v-if="scope.row.status=1"
            @click="personalBackground(scope.row)"
            class="primary"
            type="primary"
            size="default"
            >撤回</el-button
          >
          <div v-else>已撤回</div>
        </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 {
  pesonalBackgroundListRecordByPage,
  pesonalBackgroundListRecordRecoveryPersonalBackground,
} from "@/api/personalHomepageResourceManagement/personalHomepageResourceManagement";
// @ts-ignore
import { dateFormat } from "@/utils/system-helper";
// @ts-ignore
import { ElMessage } from "element-plus";
export default {
  name: "personalHomepageRecordManagementSend",
  data() {
    return {
      loading: false,
      //查询所需条件对象
      inquire: {
        id: "",
      },
      // 表格
      tableData: [],
      // 分页
      total: 10, //总页数
      currentPage: 1, //页码
      pageSize: 10, //条数
    };
  },
  created() {
    this.getData();
  },
  methods: {
    // 查询接口
    getData() {
      this.loading = true;
      pesonalBackgroundListRecordByPage({
        erbanNo: this.inquire.id,
        page: this.currentPage,
        comeFrom: 2,
        pageSize: this.pageSize,
      }).then((res) => {
        if (res.code == 200) {
          this.loading = false;
          this.total = res.data.total;
          this.tableData = res.data.rows;
        } else {
          ElMessage({
            showClose: true,
            message: res.message,
            type: "error",
          });
        }
      });
    },
    personalBackground(val) {
      pesonalBackgroundListRecordRecoveryPersonalBackground({
        recordId: val.recordId,
      }).then((res) => {
        if (res.code == 200) {
          this.getData();
        } else {
          ElMessage({
            showClose: true,
            message: res.message,
            type: "error",
          });
        }
      });
    },
    // 分页导航
    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;
  }
}
.operation {
  margin-bottom: 20px;
  width: 55%;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
</style>
