<template>
    <div class="">
        <div v-for="(item, index) in familyList" :key="index" class="familylist">
            <div :class="['item', {'bgf':index== 0 }] ">
                <div>
                    <img v-if="index == 0 && userInfo.gender == '1'" src="../../../../assets/images/index/nan.png" alt=""
                        width="56px">
                    <img v-if="index == 0 && userInfo.gender == '2'" src="../../../../assets/images/index/nv.png" alt=""
                        width="56px">
                    <span class="name">{{ item.name }}</span>（{{ item.houseHolderRel == "本人" ? "户主" : item.houseHolderRel ? item.houseHolderRel : '--'
                    }}）
                </div>
                <div>
                    <span>人户状况：</span>{{item.householdSituation||'--'}}
                </div>
                <div>
                    <span>居民分类：</span>{{item.resiCategory||'--'}}
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import { requestPost, requestGet } from '@/js/dai/request'
export default {
    //数据
    data() {
        return {
            familyList: []
        };
    },
    //创建前
    created() {
    },
    mounted() {
        console.log(this.userInfo);
        this.getFamilyRelationshipList()
    },
    props: {
        userInfo: {
            type: Object,
            default: () => { }
        }
    },
    //方法
    methods: {
        async getFamilyRelationshipList() {
            let url = `/actual/base/peopleRoomOverview/getFamilyRelationshipList?type=0&resid=` + this.userInfo.resiId
            let { code, data, msg } = await requestPost(url)
            if (code == 0) {
                // 找到符合条件的对象的索引
                const index = data.findIndex(item => item.name == this.userInfo.name);
                // 如果找到符合条件的对象
                if (index !== -1) {
                    // 移除这个对象并将其放到数组的第一个位置
                    const [item] = data.splice(index, 1);
                    data.unshift(item);
                }
               for(let i in data){
                if(data[i].classificationOfInhabitantsList){
                    data[i].resiCategory = data[i].classificationOfInhabitantsList.join(',')
                }
               }
                this.familyList = data
            } else {
                this.$message.error(msg)
            }
        }
    },
    //子组件注册
    components: {},
    //计算
    computed: {},
    //监听
    watch: {},
}
</script>

<style lang="scss" scoped>
@import "@/assets/scss/pages/huaxiang";
@import "@/assets/scss/modules/management/list-main.scss";
.item{
    padding: 0 15px;
    &>div{
        margin-top: 18px;
        .name{
        font-family: PingFang SC;
        font-weight: bold;
        color: #000000;
    }
    }
}
.bgf>:nth-child(1){
    margin: 0!important;
    padding-top: 16px;
    box-sizing: border-box;
}
</style>
