<template>
  <div class="record-warp">
    <div class="record-main">
      <!-- <el-row>
        <el-col :span="24">
          <div class="search-head">
            <span>用户名：</span>
            <el-input v-model="name" clearable placeholder="请输入用户名"></el-input
            >&nbsp;&nbsp;&nbsp;&nbsp;
            <span>用户昵称：</span>
            <el-input v-model="userName" clearable placeholder="请输入用户昵称"></el-input
            >&nbsp;&nbsp;
            <el-button type="primary" icon="el-icon-search" @click="searchTarget"
              >搜索</el-button
            >
            <el-button type="primary" icon="el-icon-delete-solid" @click="clearSearch"
              >清空</el-button
            >
          </div>
        </el-col>
      </el-row> -->

      <div class="table-content">
        <el-table
          :data="tableData"
          :row-style="{ height: '0px' }"
          :cell-style="{ padding: '5px' }"
        >
          <!-- <el-table-column prop="name" label="姓名" align="center" width=""  show-overflow-tooltip>
            </el-table-column> -->
        
        
          <el-table-column
            prop="roleName"
            label="角色名称"
            align="center"
            width=""
          ></el-table-column>
          <el-table-column
            prop="roleId"
            label="角色编码"
            align="center"
            width=""
            :formatter="formatterRole"
            show-overflow-tooltip
          >
          </el-table-column>
        </el-table>
      </div>

      <el-pagination
        small
        background
        @current-change="handleCurrentChange"
        :current-page.sync="pageNum"
        layout="total, prev, pager, next"
        :page-size="pageSize"
        :total="total"
      >
      </el-pagination>
      <!-- <el-pagination small background layout="total prev, pager, next" :total="36">
        </el-pagination> -->
    </div>
  </div>
</template>

<script>
import { oSessionStorage } from "../../utils/utils";
export default {
  name: "userManage",
  components: {},
  data() {
    return {
      centerDialogVisible: false,
      editUserFlag: false,
      startTime: "",
      endTime: "",
      value1: null,
      total: 2,
      pageSize: 10,
      pageNum: 1,
      keyword: "",
      tableData: [],
      userInfo: {}, //用户信息
      userId: "", //用户id
      name: "", //根据名称搜索
      userName: "", //根据昵称搜索
      hospitalOrDepartment: "", //医院科室

      invitationCode: "",
      roleType: "0",
      type: 0,
      view: {
        name: "",
        userName: "",
        channelId: "",
        role: "",
      },
    };
  },
  created() {},
  mounted() {
    this.userInfo = JSON.parse(oSessionStorage.getItem("userInfo"));
    this.invitationCode = this.userInfo.invitationCode;
    //判断是超级管理员吗
    if (this.userInfo.roleType == "1") {
      this.type = 0;
    } else if (this.userInfo.roleType == "3") {
      //如果登录的是代理用户
      this.type = 4;
    } else if (this.userInfo.roleType == "2") {
      this.type = 5;
    }

    if (this.$route.query.invitationCode) {
      this.invitationCode = this.$route.query.invitationCode;
      this.type = this.$route.query.type;
    }
    if (!this.userInfo) {
      //如果用户信息不存在跳转登陆页
      this.$router.push({ path: "/" });
    }
    this.searchTarget();
  },
  methods: {
    handleCurrentChange(val) {
      this.pageNum = val;
      this.searchList();
    },
    //根据现有情况进行搜索
    searchList() {
      //  let url =``
      this.$http.get(`/role/find`, {}, (res) => {
        // console.log(res,'用户测试记录')
        if (res && res.code == 200) {
          this.tableData = res.data;
        } else {
          // this.$toast.fail(res.msg);
          this.$message.error(res.msg);
        }
      });
    },
    searchTarget() {
      this.pageNum = 1;
      this.searchList();
    },
    //跳转首页
    goHome() {
      this.$router.push({ path: "/home" });
    },
    //跳转记录页
    goRecord() {
      this.$router.push({ path: "/record" });
    },
    //退出登陆
    logout() {
      oSessionStorage.removeItem("userInfo");
      oSessionStorage.removeItem("token");
      this.$router.push({ path: "/" });
    },
    //点击日历获取日期
    getDate(param) {
      // console.log(param,"日期。。。")
      this.userRecord(param.dateStr);
    },
    //点击获取月出勤次数
    getTimes(param) {
      this.monthTimes = param;
    },
    // 用户测试记录显示
    userRecord(date) {
      this.$http.get(
        `gameRecord/findListByUserIdAndDate/${this.userId}/${date}`,
        {},
        (res) => {
          // console.log(res,'用户测试记录')
          if (res && res.code == 200) {
            this.listData = res.data;
          } else {
            this.$toast.fail(res.msg);
          }
        }
      );
    },
  },
};
</script>

<style lang="less" scoped>
@import "../../styles/theme.less";

.record-warp {
  width: 100%;
  height: 80vh;
  //background: url(../../assets/img/index/19.png) no-repeat center;
  //background-size: 100% 100%;
  position: relative;

  .record-main {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    overflow-y: auto;

    .search-head {
      width: 100%;
      display: flex;
      flex-direction: row;
      justify-content: flex-start;
      align-items: center;

      .zc-title {
        color: #606266;
        font-size: 14px;
      }
    }

    .table-content {
      margin: 10px 0;
    }
  }
}

.add_user_class {
  margin-top: 10px;
}

.user_out {
  display: flex;
  width: 100%;
  align-items: center;
  border: 1px solid #eeeeef;
  line-height: 50px;
  margin-top: 10px;
}

.user_out_sub {
  flex: 1;
  background-color: #fafafa;
  text-align: center;
  // color:#ffffff
}

.user_out_subNext {
  padding-left: 10px;
  flex: 3;
}
</style>
