<template>
   
    <div class="cellbox" v-for="(item, index) in childList" :key="item.comment_id">
        <commentunit :item="item"  :parentIndex="parentIndex" :index="index" :childList="childList"  :parent_id="item.comment_id" :root_id="root_id" :case_id="case_id" :project_id="project_id" @freshLike="freshLike"  @freshList="freshList" :replyName="replyName"></commentunit>
        <expandunit v-if="parentIndex<0 && item.case_comment && item.case_comment.length>0" :parent_id="item.comment_id" :case_id="case_id" :project_id="project_id" :total_amount="item.total_amount" @freshSecComment="freshSecComment" :index="index" :listLength="item.case_comment.length"></expandunit>
    </div>
</template>

<script setup>
import { ref } from "vue";
const expand = ref(true);
const props = defineProps({
   item:{
     type:Object,
     default:()=>{}
   },
   parentIndex:{
     type:Number,
     default:-1
   },
   index:{
     type:Number,
     default:0
   },
   root_id:{
     type:String,
     default:''
   },
   childList:{
     type:Array,
     default:()=>[]
   },
   parent_id:{
     type:String,
     default:''
   },
   root_id:{
     type:String,
     default:''
   },
   replyName:{
     type:String,
     default:''
   },
   case_id:{
     type:String,
     default:''
   },
   project_id:{
     type:String,
     default:''
   }
})
const  emit = defineEmits(['freshLike','handleFreshList','freshSecComment']);
const freshLike = (data) => {
    emit('freshLike',data);
};
const freshList = () => {
    
    emit('handleFreshList',true);
   
};
const freshSecComment = (data) => {
    emit('freshSecComment',data);
}
// const list=ref(props.childList);
// const handleShowMore = () => {
//     list.value=expand.value?props.childList:props.childList.slice(0,3);
// }

// watch(() =>props.childList, () => {
//    if(props.childList.length>=1 && props.parentIndex<0 ) {
//         expand.value=false;
//         handleShowMore()
//    }
  
// },{
//     immediate:true
// });

</script>

<style lang='scss' scoped>
.cellbox {
    padding-top: 15px;
}





.active {
    border-bottom: 1px solid #E5E5E5;
}


.comemntcell {
    display: flex;

    .descbox {
        margin-left: 12px;
        flex: 1;
        // border-bottom: 1px solid #E5E5E5;


        .depart {
            margin-top: 10px;
            font-weight: 400;
            font-size: 12px;
            color: #333333;
        }

        .hospital {
            margin-top: 4px;
            font-weight: 400;
            font-size: 12px;
            color: #333333;
        }

        .date {
            margin-top: 4px;
            font-weight: 400;
            font-size: 12px;
            color: #333333;
        }

        .comemntcell {
            border-bottom: 1px solid #E5E5E5;

            .descbox {
                border: none;
                padding-bottom: 15px;
            }
        }

        .comment {
            margin-top: 4px;
            display: flex;

            .text {
                font-size: 12px;
                color: #333333;
                line-height: 17px;
                flex: 1;
            }

            .reply {
                margin-left: 30px;
                width: 40px;
                height: 20px;
                background: #43C9C3;
                border-radius: 4px;
                display: flex;
                justify-content: center;
                align-items: center;
                font-size: 12px;
                color: #FFFFFF;
            }

        }

        .tag {
            margin-top: 2px;
            font-size: 12px;
            color: #FFFFFF;
            height: 15px;
            background: #43C9C3;
            border-radius: 10px;
            display: flex;
            padding: 0 4px;
            width: 52px;

            justify-content: center;
            align-items: center;

            span {
                transform: scale(0.9);
            }
        }

        .namebox {
            display: flex;
            align-items: center;
            justify-content: space-between;

            .name {
                font-size: 17px;
                color: #333333;
            }

            .zanbox {
                display: flex;
                font-size: 15px;
                color: #333333;
                align-items: center;
                margin-right: 40px;

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

                }
            }

        }
    }
}
    .talkbox {
    margin: 12px 30px 0px 0;
}
.textbox {
    border-radius: 5px;
    border: .5px solid #43C9C3;

    :deep() .van-cell {
        background: none;
    }

    :deep() .van-field__word-limit {
        color: #999999;
    }
}
.toolbox {
    margin-top: 12px;
    display: flex;
    justify-content: space-between;

    .cancel {

        height: 38px;
        background: #FFFFFF;
        border: 1px solid #EBEBEB;
        border-radius: 4px;
        font-size: 14px;
        display: flex;
        justify-content: center;
        align-items: center;
        color: #737478;
        flex: 1;
    }

    .ok {
        margin-left: 12px;
        flex: 1;
        border-radius: 4px;
        height: 38px;
        display: flex;
        justify-content: center;
        align-items: center;
        background: #43C9C3;
        border: 1px solid #43C9C3;
        font-size: 14px;
        color: #fff;
    }
}
</style>
