<template>
    <el-dialog v-el-drag-dialog title="人员情况" :visible.sync="dialogVisible" width="40%" :before-close="handleClose"
        @open="handleDialogOpen">
        <div class="info-personInfo">
            <div class="personInfo-content">
                <div v-for="item in personList" class="everyTeam">
                    <div class="teamInfo">
                        <span>队伍名称：<span>{{ item.teamName }}</span></span>
                        <!-- <span>角色：<span>{{ item.teamType }}</span></span> -->
                    </div>
                    <div class="peopleInfo">
                        <div v-for="item1 in item.teamMemberStateBOList" class="everyPersonList">
                            <span class="isOnline" :style="{ backgroundColor: item1.online ? 'green' : 'gray' }"></span>
                            <span class="username" :style="{ color: item1.online ? 'green' : 'white' }"
                                v-text="item1.userId"></span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </el-dialog>
</template>


<script>
import elDragDialog from "@/util/directive/el-dragDialog";
import { getChatRoomMemberInfo } from "@/api/chat/chatRoom";
export default {
    data() {
        return {
            dialogVisible: false,
            personList: [],
            teamInfo: {}
        }
    },
    directives: {
        elDragDialog
    },
    props: {
        currentTeamInfo: Object
    },
    methods: {
        handleClose() {
            this.dialogVisible = false;
        },
        showDialog() {
            this.dialogVisible = true;
        },
        handleDialogOpen() {
            this.teamInfo = this.$props.currentTeamInfo;
            this.getCurrentTeamPeople(this.teamInfo);
        },
        getCurrentTeamPeople(item) {
            //查询聊天组的人员
            getChatRoomMemberInfo(item.id, this.userInfo.account).then(res => {
                this.personList = res;
            }).catch(error => {
                this.$message.error(error);
            });
        },
    },
    computed: {
        userInfo() {
            if (this.$store.getters.userInfo) {
                return this.$store.getters.userInfo;
            } else {
                return { account: "" };
            }
        }
    }
}
</script>


<style lang="scss">
.info-personInfo {
    width: 100%;
    height: 30%;
    overflow-y: auto;

    .title {
        width: 100%;
        height: 30px;
        line-height: 30px;

        img {
            width: 20px;
            height: 20px;
        }

        span {
            font-size: 16px;
            font-weight: 500;
            color: white;
            vertical-align: text-bottom;
        }
    }

    .personInfo-content {
        width: 100%;
        height: 100%;

        .everyTeam {
            width: calc(33% - 10px);
            height: calc(100% - 30px);
            border: 1px solid #3a5f94c9;
            border-radius: 6px;
            padding: 5px;
            box-sizing: border-box;
            float: left;
            margin-top: 10px;
            margin-left: 8px;

            .teamInfo {
                width: 100%;
                height: 30px;
                text-align: center;

                &>span {
                    margin-left: 20px;
                    color: white;

                    &>span {
                        color: #2c8aeb;
                    }
                }

            }

            .peopleInfo {
                width: 100%;
                height: calc(100% - 30px);
                overflow-y: auto;

                &::-webkit-scrollbar {
                    display: none;
                }

                .everyPersonList {
                    width: 100%;
                    height: 30px;
                    line-height: 35px;
                    padding-left: 70px;
                    margin-top: 5px;

                    .isOnline {
                        width: 10px;
                        height: 10px;
                        border-radius: 50%;
                        display: inline-block;
                        margin-right: 5px;
                    }

                    .username {
                        color: white;
                    }
                }

                &>div:nth-child(3n) {
                    background-image: url(@/assets/img/ddkz/12.png);
                    background-size: 100% 100%;
                }

                &>div:nth-child(3n+1) {
                    background-image: url(@/assets/img/ddkz/13.png);
                    background-size: 100% 100%;
                }

                &>div:nth-child(3n+2) {
                    background-image: url(@/assets/img/ddkz/14.png);
                    background-size: 100% 100%;
                }
            }
        }
    }
}
</style>