<!--
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2020-03-16 09:59:39
 * @LastEditors: 无尘
 * @LastEditTime: 2020-12-14 17:11:36
 -->
<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"
              >1.超级管理员不可新增，默认为企业微信所添加的好办应用管理员，拥有好办所有管理权限；
              <br />
              2.企业微信后台新增管理员后，请在工作台-<el-button type="text" @click="changeRoute">通讯录</el-button>中刷新企业成员，否则不会同步到好办管理员列表
            </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 style="font-size:14px;" :class="['iconfont cursor-pointer font-14 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 border-set" v-for="(child, ind) in item.roleUser" :key="ind">
                    <el-col class="line-one" :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: []
    };
  },
  methods: {
    /**
     * 跳转
     */
    changeRoute() {
      this.$router.push('/contactsList');
    },
    /**
     * 展开/折叠
     */
    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) {
            if (!!resData.result && resData.result.length) {
              resData.result.forEach(ele => {
                ele.expand = false;
              });
            }
            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/scss" lang="scss" 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: 700px;
  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;
  margin-top: -17px;
}
.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;
    overflow: hidden;
    &.border-set {
      border-bottom: 0px solid #dcdfe6;
      .el-col {
        position: relative;
        border-bottom: 1px solid #dcdfe6;
        &::after {
          content: ' ';
          position: absolute;
          left: 0px;
          bottom: 0;
          width: 100%;
          height: 50px;
          border-bottom: 1px solid #dcdfe6;
          z-index: 1;
        }
        &.line-one {
          &::after {
            content: ' ';
            position: absolute;
            left: 55px;
            bottom: 0;
            width: calc(100% - 55px);
            height: 50px;
            border-bottom: 1px solid #dcdfe6;
            z-index: 1;
          }
        }
      }
    }
    .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;
    }
    >>> .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 {
    >>> .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>
