<template>
  <div class="page">
    <topBar v-if="topList.length > 0" :topList="topList" :moren="moren" />

    <!-- 搜索框 -->
    <div class="thetopbox">
      <el-form ref="queryParams" :model="queryParams" label-width="100px">
        <el-row>
          <el-col :span="4">
            <el-form-item label="会员编号" prop="memberCode">
              <el-input clearable v-model="queryParams.memberCode" />
            </el-form-item>
          </el-col>
          <el-col :span="4" style="margin-left: 20px">
            <div class="searchbox">
              <el-button class="searchbtn" @click="getSearch">搜索</el-button>
              <el-button @click="reChongzhi">重置</el-button>
            </div>
          </el-col>
        </el-row>
      </el-form>
    </div>

    <!-- 表格 -->
      <div class="maintable">
        <el-table
          :data="tableData"
          height="750px"
          v-loading="loading"
          style="width: 100%"
          :header-cell-style="{ background: '#EEEEEE' }"
        >
          <el-table-column align="center" prop="memberCode" label="会员编号" />
          <el-table-column align="center" prop="memberName" label="会员姓名" />
          <el-table-column align="center" prop="pkSettleGrade" label="结算等级" />
          <el-table-column align="center" prop="parMemberCode" label="推荐编号" />
          <el-table-column align="center" prop="placeMemberCode" label="安置编号" />
          <el-table-column align="center" prop="placeDept" label="安置位置" />
          <el-table-column align="center" prop="creationTime" label="注册时间" />

          <!-- 删除按钮列 -->
          <el-table-column label="操作" align="center" width="100">
            <template slot-scope="scope">
              <el-button
                type="text"
                size="mini"
                @click="handleDelete(scope.row.memberCode)"
              >
                删除
              </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="getSearch"
    />
  </div>
</template>

<script>
import topBar from "@/components/topBar";
import * as spe from "@/api/deletedeadlock";

export default {
  name: "DeleteDeadLock",
  components: { topBar },
  data() {
    return {
      loading: false,
      moren: "deleteDeadLock",
      topList: [
        {
          name: "删除死点",
          path: "deleteDeadLock",
        },
      ],
      queryParams: {
        pageNum: 1,
        pageSize: 50,
        memberCode: "",
      },
      total: 0,
      tableData: [],
    };
  },
  created() {
    this.getSearch();
  },
  methods: {
    // 查询
    getSearch() {
      this.loading = true;
      spe.getdeleteDeadLockList(this.queryParams).then((res) => {
        this.loading = false;
        this.tableData = res.rows;
        this.total = res.total;
      });
    },
    // 重置
    reChongzhi() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 50,
        memberCode: "",
      };
      this.getSearch();
    },
    // 删除
    handleDelete(memberCode) {
      this.$confirm(`是否删除会员编号：${memberCode} ?`, "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        spe.getdeleteDeadLockDel({memberCode:memberCode}).then((res) => {
          if(res.code == 200){
            this.$message.success("删除成功");
          }
          this.getSearch();
        });
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.page {
  padding: 10px 20px;
  background: #f9f9f9;
  font-size: 14px;
  .thetopbox {
    padding-top: 20px;
    background: #ffffff;
    border-radius: 8px;
    .searchbox {
      display: flex;
      align-items: center;
      .searchtitle {
        margin-right: 10px;
      }
      .searchbtn {
        background: #c8161d;
        color: #ffffff;
      }
    }
  }
  .main {
    // margin-top: 20px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0px 2px 20px 0px rgba(238, 238, 238, 0.5);
  }
}
</style>
  