<template>
  <div id="index">
    <el-row>
      <el-col :span="24" class="top">
        <topInfo :topTitle="topTitle" :display="display" @add="add"></topInfo>
      </el-col>
      <el-col :span="24" class="main">
        <el-col :span="24" class="search">
          <searchInfo></searchInfo>
        </el-col>
        <el-col :span="24" class="list">
          <otheruserList :debtTable="debtTable" :total="total" @deleteRow="deleteRow" @clickRest="clickRest"></otheruserList>
        </el-col>
      </el-col>
    </el-row>

    <!-- <el-col :span="24" class="debt">
      <el-col :span="24" class="top">
        <topInfo :topTitle="topTitle" :display="display" @clickBtn="clickBtn"></otheruserList>
      </el-col>
      <el-col :span="24" class="search">
        <searchInfo></searchInfo>
      </el-col>
      <el-col :span="24" class="main">
        <otheruserList :debtTable="debtTable" :total="total" @deleteRow="deleteRow" @clickRest="clickRest"></otheruserList>
      </el-col>
    </el-col> -->
  </div>
</template>

<script>
import topInfo from '@/layout/common/topInfo.vue';
import searchInfo from '@/layout/common/searchInfo.vue';
import otheruserList from '@/layout/otheruser/otheruserList.vue';
import { createNamespacedHelpers, mapGetters } from 'vuex';
const { mapActions: otheruser } = createNamespacedHelpers('otheruser');
const { mapActions: character } = createNamespacedHelpers('character');
export default {
  name: 'index',
  props: {},
  components: {
    topInfo, //头部导航
    searchInfo, //搜素
    otheruserList, //其他用户列表
  },
  data: () => ({
    topTitle: '其他用户',
    display: 'block',
    debtTable: [],
    total: '',
  }),
  created() {
    this.searchInfo();
  },
  computed: {},
  methods: {
    ...otheruser(['query', 'delete']),
    ...character({ userquery: 'query' }),

    ...otheruser(['query', 'delete', 'update']),
    async searchInfo({ skip = 0, limit = 10, ...info } = {}) {
      const res = await this.query({ skip, limit, ...info });
      this.$set(this, `debtTable`, res.data);
      this.$set(this, `total`, res.total);
    },
    // 添加
    add() {
      this.$router.push({ path: '/otheruser/detail' });
    },
    // 删除
    async deleteRow(id) {
      const res = await this.delete(id);
      this.$checkRes(res, '删除成功', '删除失败');
      this.searchInfo();
    },
    async clickRest(id) {
      let data = {};
      data.id = id;
      data.passwd = '123456';
      const res = await this.update(data);
      if (res.errcode === 0) {
        this.$message({
          message: '密码重置成功',
          type: 'success',
        });
      }
    },
  },
};
</script>

<style lang="less" scoped>
.debt {
  padding: 20px;
}
.top {
  border-bottom: 1px solid #ccc;
}
</style>
