<template>
    <div class="per-set-div">
        <el-form
            label-width="120px">
            <el-form-item label="当前范围:">
                <span>{{groupInfo.label}}</span>
            </el-form-item>
            <el-form-item label="设置可见范围:">
                <ul class="particular-list">
                    <template v-for="(li, index) in visibleList">
                        <li class="item person-item" v-if="li.type == 1" :key="index+'_'+li.id">
                            <img :src="li.iconUrl">
                            <p class="name">{{li.name}}</p>
                            <i class="el-icon-circle-close" @click="delCurrent(li)"></i>
                        </li>
                        <li class="item group-item" v-else :key="index+'_'+li.id">
                            {{li.name}}
                            <i class="el-icon-circle-close" @click="delCurrent(li)"></i>
                        </li>
                    </template>
                    <li class="item J_add-btn" @click="callSelector"><i class="el-icon-plus"></i></li>
                </ul>
            </el-form-item>
        </el-form>
    </div>
</template>
<script>
import { getRequest, postRequest, postJsonRequest, postJson } from '@/api/api';
export default {
    name: "permission-set",
    props: {
        groupInfo: {
            type: Object,
            required: true
        }
    },
    data() {
        return {
            visibleList: []
        };
    },
    methods: {
        getVisibleRange() {
            let ths = this;
            let group = ths.groupInfo;
            let paramas = {
                sharedContactGroupId: group.sharedContactGroupId
            };
            getRequest("/haoban-manage-web/shared-contact/get-shared-group-visible-range", paramas)
            .then(res => {
                console.log(res, "range");
                if (res.data.errorCode == 1) {
                    ths.visibleList = res.data.result || [];
                } else {
                    ths.$message.error({
                        message: res.data.message
                    });
                }
            })
            .catch(e => {
                ths.$message.error({
                    message: e.message
                });
            });
        },
        delCurrent() {},
        callSelector() {},
    },
    beforeMount() {
        this.getVisibleRange();
    }
}
</script>
<style lang="scss">
.per-set-div {
    width: 100%;
    height: 690px;
    background: #fff;
    padding: 30px;
    box-sizing: border-box;
.particular-list {
        display: flex;
        flex-wrap: wrap;
        margin-bottom: 30px;
        .item {
            position: relative;
            margin-right: 24px;
            margin-bottom: 30px;
            width:40px;
            .el-icon-circle-close {
                position: absolute;
                font-size: 16px;
                color: #808995;
                right: -8px;
                top: -8px;
                cursor: pointer;
            }
            img {
                width: 100%;
                border-radius:4px;
            }
            .name {
                font-size: 12px;
                text-align: center;
                margin-top: 20px;
            }
            &.group-item {
                padding: 0 10px;
                width: auto;
                height:30px;
                line-height: 32px;
                background:rgba(236,245,255,1);
                border:1px solid rgba(217,236,255,1);
                border-radius:4px;
                font-size:12px;
                color:rgba(64,158,255,1);
                margin-top: 34px;
            }
            &.J_add-btn {
                height:40px;
                background:rgba(251,253,255,1);
                border:1px dashed rgba(192,204,218,1);
                border-radius:50%;
                text-align: center;
                line-height: 40px;
                font-size: 16px;
                box-sizing: border-box;
                cursor: pointer;
            }
        }
    }
    }
</style>


