<template>
  <div>
    <a-row>
      <!-- 角色列表 -->
      <a-col :span="5">
        <div class="cardTitle">所有角色</div>
        <a-collapse accordion>
          <a-collapse-panel v-for="item,index in roleList" :key="index" :header="item.name">
            <div v-for="rolechild,indexs in item.children" class='role-card'  :key="indexs">
              <span>{{rolechild.name}}</span>
              <a-button type="link" icon="form"></a-button>
            </div>
          </a-collapse-panel>
        </a-collapse>
      </a-col>
      <!-- 人员表格 -->
      <a-col :span="19">
        <commonTable
          :columns="columns"
          :tableData="tableData"
          :ActionsList="ActionsList"
          @handleTableChange="handleTableChange"
          @Actions="Actions"
          @selectionChoosed="selectionChoosed"
        >
          <template v-slot:actionBox="data">
            <a-space size="small">
              <a class="ant-dropdown-link" @click='detail(data)'>分配角色</a>
              <a class="ant-dropdown-link" @click='del(data)'>删除</a>
            </a-space>
          </template>
        </commonTable>
      </a-col>
    </a-row>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tableChoosed: [],
      roleList: [{ name: "管理角色",children:[{ name: "管理员"},{name:'部门经理'}] }, { name: "安保部" }],
      // 分页
      pagination: {
        current: 1,
        total: 0,
        pageSize: 10,
      },
      //   列
      columns: [
        {
          title: "真实姓名",
          dataIndex: "actualName",
          width: "20%",
        },
        {
          title: "手机号",
          dataIndex: "tel",
          width: "20%",
        },
        {
          title: "角色",
          dataIndex: "roleNameList",
          width: "20%",
          customRender:function(roleNameList){
            return roleNameList.toString();
          }
        },
        {
          title: "备注",
          dataIndex: "remake",
          width: "20%",
        },
        {
          title: "操作",
          dataIndex: "action",
          key: "action",
          width: "180",
          fixed: "right",
          scopedSlots: { customRender: "action" },
        },
      ],
      //   数据
      tableData: [
        { name: 1, roleNameList: ['点点3','212','点点'] },
      ],
      ActionsList: [
        {
          label: "批量删除",
          value: 1,
        },
        {
          label: "批量导出",
          value: 2,
        },
      ],
    };
  },
  methods: {
    handleTableChange(pagination) {
      console.log(pagination);
      const pager = { ...this.pagination };
      pager.current = pagination.current;
      pager.pageSize = pagination.pageSize;
      this.pagination = pager;
    },
    del(data) {
       this.$confirm({
        title: "是否删除",
        // okText:'删除',
        // cancelText:'取消',
        icon: "",
        onOk: function () {
          console.log(data);
        },
      });
    },
    Actions(data) {
      console.log(data);
    },
    selectionChoosed(data) {
      console.log(data);
      this.tableChoosed = data;
    },
  },
};
</script>

<style lang="less" scoped>
.role-card{
  line-height: 30px;
  font-size: 16px;
  cursor: pointer;
  border-bottom: 1px solid #d9d9d9;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
}
</style>