<!--
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2020-03-16 09:59:39
 * @LastEditors  : 无尘
 * @LastEditTime : 2020-03-30 16:44:13
 -->
<template>
  <div class="daily-set-wrap ">
    <div class="daily-set-content border-box">
      <div class="admin-tip-body">
        <div role="alert" class="el-alert el-alert--info">
          <i class="el-alert__icon el-icon-info"></i>
          <div class="el-alert__content">
            <span class="el-alert__title">超级管理员不可新增，默认为企业微信所添加的好办应用管理员，拥有好办所有管理权限。</span>
          </div>
        </div>
      </div>
      <div class="admin-table-body m-t-20">
        <div class="admin-thead bg-ebecf0">
          <div class="admin-th p-l-85 font-14 color-303133">角色</div>
        </div>
        <div class="admin-role-body">
          <template v-for="(item, index) in roleList">
            <div :key="index + 'role'">
              <div class="admin-role-name line-50">
                <el-row>
                  <el-col :span="24"
                    ><div class="grid-content cursor-pointer" @click="changeToggle(item)">
                      <span :class="['iconfont cursor-pointer color-606266 p-l-30', item.expand ? 'iconjian' : 'iconjia']"> </span><span class="font-14 color-606266 p-l-40">{{ item.roleName }}</span>
                    </div></el-col
                  >
                </el-row>
              </div>
              <div v-if="item.expand">
                <el-row class="bg-ebecf0">
                  <el-col :span="6"><div class="grid-content font-14 color-303133 row-th p-l-85">姓名</div></el-col>
                  <el-col :span="6"><div class="grid-content font-14 color-303133 row-th">手机号</div></el-col>
                  <el-col :span="6"><div class="grid-content font-14 color-303133 row-th">部门</div></el-col>
                  <el-col :span="6"><div class="grid-content font-14 color-303133 row-th">操作</div></el-col>
                </el-row>
                <div class="admin-role-user">
                  <el-row class="line-50" v-for="(child, ind) in item.roleUsers" :key="ind">
                    <el-col :span="6"
                      ><div class="grid-content p-l-85 hide-border">{{ child.userName }}</div></el-col
                    >
                    <el-col :span="6"
                      ><div class="grid-content">{{ child.userPhone }}</div></el-col
                    >
                    <el-col :span="6"
                      ><div class="grid-content">{{ child.departmentName }}</div></el-col
                    >
                    <el-col :span="6"
                      ><div class="grid-content">{{ '--' }}</div></el-col
                    >
                  </el-row>
                </div>
              </div>
            </div>
          </template>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { getRequest } from '@/api/api';
// import { _debounce } from '@/common/js/public';
// import showMsg from '@/common/js/showmsg';
import errMsg from '@/common/js/error';
export default {
  props: {},
  data() {
    return {
      wxEnterpriseId: localStorage.getItem('userInfos') ? JSON.parse(localStorage.getItem('userInfos')).wxEnterpriseId : '',

      roleList: [
        {
          roleId: '1',
          roleName: '管理员',
          expand: false,
          roleUsers: [
            {
              userName: '测试',
              userPhone: '13735457631',
              departmentName: '测试部'
            }
          ]
        },
        {
          roleId: '2',
          roleName: '管理员',
          expand: false,
          roleUsers: [
            {
              userName: '测试',
              userPhone: '13735457631',
              departmentName: '测试部'
            }
          ]
        }
      ]
    };
  },
  methods: {
    changeToggle(item) {
      item.expand = item.expand ? false : true;
    },
    /**
     * 获取数据
     */
    getData(val) {
      const that = this;
      let para = {
        wxEnterpriseId: that.wxEnterpriseId
      };
      getRequest('/haoban-manage3-web/admin-list', para)
        .then(res => {
          let resData = res.data;
          if (resData.errorCode == 1) {
            that.roleList = resData.result || [];
            return;
          }
          errMsg.errorMsg(resData);
        })
        .catch(function(error) {
          that.$message.error({
            duration: 1000,
            message: error.message
          });
        });
    }
  },
  watch: {},
  mounted() {
    const that = this;
    that.$emit('showTab', 2);
    document.documentElement.style.backgroundColor = '#f0f2f5';
    that.getData();
  },
  destroyed() {
    document.documentElement.style.backgroundColor = '#fff';
  },
  components: {}
};
</script>
<style type="text/less" lang="less" scoped>
.bg-ebecf0 {
  background: #ebecf0;
}
.color-c0c4cc {
  display: inline-block;
  line-height: 34px;
  padding-left: 10px;
  color: #c0c4cc;
}
.condition-tips {
  display: inline-block;
  vertical-align: middle;
  line-height: 32px;
}
.p-l-30 {
  padding-left: 30px;
}
.p-l-40 {
  padding-left: 40px;
}
.p-l-55 {
  padding-left: 55px;
}
.p-l-85 {
  padding-left: 85px;
}
.m-l-20 {
  margin-left: 20px;
}
.line-50 {
  height: 50px;
  line-height: 50px;
}
.el-alert--info {
  width: 608px;
  font-size: 14px;
  color: #606266;
  background: rgba(240, 245, 255, 1);
  border-radius: 2px;
  border: 1px solid rgba(133, 165, 255, 1);
}
.el-icon-info {
  width: 12px;
  font-size: 12px;
  color: #2f54eb;
}
.table-condition {
  /* min-width: 1200px; */
}
.admin-table-body {
  .admin-thead {
    width: 100%;
    height: 48px;
    line-height: 48px;
  }
  .row-th {
    height: 48px;
    line-height: 48px;
  }
  .el-row {
    font-size: 14px;
    border-bottom: 1px solid #dcdfe6;
    .hide-border {
      position: relative;
      &::after {
        content: ' ';
        position: absolute;
        left: 0;
        bottom: 0;
        width: 55px;
        height: 1px;
        background: #fff;
        z-index: 1;
      }
    }
  }
}
.daily-set-wrap {
  height: 100%;
  .daily-set-content {
    padding: 20px;
    .table-condition-left {
      font-size: 0;
    }
  }
  .el-form {
    .el-form-item {
      margin-bottom: 4px;
    }
    /deep/ .el-form-item__label {
      color: #606266;
    }
  }
  .depart-item-content {
    width: 213px;
    height: 32px;
    overflow: hidden;
    white-space: nowrap;
    border-radius: 4px;
    border: 1px solid #dcdfe6;
    cursor: pointer;
  }
  .item-cell-select {
    /deep/ .el-select__tags {
      white-space: nowrap;
      overflow: hidden;
    }
  }
  .depart-cell {
    position: relative;
    margin: 0 24px 24px 0;
    .el-icon-circle-close {
      position: absolute;
      top: -10px;
      right: -10px;
      font-size: 16px;
      color: #808995;
      cursor: pointer;
    }
  }
}
</style>
