<template>
    <div class="work-item" v-if="commentData?.expertServiceRating">
        <div class="work-line">
            <div class="line-box">
                <div class="line-dotted">
                    <div class="dotted-inset"></div>
                </div>
            </div>
        </div>
        <div class="work-info">
            <img v-if="progress === 5" class="done-img" src="@/assets/img/gallery/done.png" />
            <div class="card-item-title"><span class="dotted"></span>用户评价</div>
            <div class="evaluate" v-if="commentData?.expertServiceRating">
                <div class="comment">
                    <div class="user-info">
                        <el-avatar
                            class="avatar"
                            :size="40"
                            :src="commentData.icon"
                        />
                        <div class="user-name">
                            <div>{{ commentData.commentUserName }}</div>
                            <span>{{ commentData.commentDate }}</span>
                        </div>
                    </div>
                    <div class="rate">
                        <div class="rate-item">
                            <span class="name">专家</span>
                            <el-rate disabled v-model="rateValue" size="small" />
                        </div>
                        <div class="line"></div>
                        <div class="rate-item">
                            <span class="name">农资</span>
                            <el-rate disabled v-model="rateValue2" size="small" />
                        </div>
                        <div class="line"></div>
                        <div class="rate-item">
                            <span class="name">农服</span>
                            <el-rate disabled v-model="rateValue3" size="small" />
                        </div>
                    </div>
                    <div class="text van-multi-ellipsis--l2">
                        {{ commentData.detailedComment }}
                    </div>
                </div>
            </div>
            <div class="comment-btn">
                <el-button class="outline-btn btn">查看更多</el-button>
                <el-button class="btn" type="primary" @click="toComment">去评价</el-button>
            </div>
        </div>
    </div>
</template>

<script setup>
import { onMounted, ref } from 'vue';
import { useRouter } from "vue-router";
const props = defineProps({
    progress: {
        type: Number,
        required: false,
    },
    orderId: {
        required: true
    },
    commentData: {},
    farmWorkName: {}
})

const rateValue = ref(5)
const rateValue2 = ref(5)
const rateValue3 = ref(5)

onMounted(() => {
    rateValue.value = props.commentData?.expertServiceRating
    rateValue2.value = props.commentData?.agricultureServiceRating
    rateValue3.value = props.commentData?.farmServiceRating
})

const router = useRouter();
const toComment = () => {
    router.push({ path: "/work_comment", query: {orderId: props.orderId, farmName: props.farmWorkName} });
}
</script>

<style lang="scss" scoped>
@import "./boxClass.scss";
.evaluate {
    // padding-top: 16px;
    background: #fff;
    border-radius: 5px;
    padding: 4px 8px 10px 8px;
    margin-right: 8px;
    .evaluate-title {
        font-size: 16px;
        font-weight: 500;
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 8px;
        .more {
            font-size: 14px;
            color: #999999;
            font-weight: 400;
            display: flex;
            align-items: center;
        }
    }
    .rate {
        display: flex;
        justify-content: space-between;
        ::v-deep {
            .el-rate {
                --el-rate-icon-margin: 0;
            }
            .el-rate--small .el-rate__icon {
                font-size: 12px;
            }
        }
        .rate-item {
            display: flex;
            align-items: center;
            // background: #f5f5f5;
            border-radius: 4px;
            padding: 4px 0px;
            font-size: 11px;
            .name {
                margin-right: 2px;
                color: #666666;
                position: relative;
                top: 2px;
            }
            .num {
                color: #f3c11d;
                margin-left: 2px;
            }
        }
        .line {
            width: 1px;
            height: 12px;
            background: #CDD7E1;
            position: relative;
            top: 10px;
        }
    }
    .comment {
        margin-top: 12px;
        .user-info {
            display: flex;
            align-items: center;
            margin-bottom: 2px;
            .user-name {
                font-weight: 500;
                margin-left: 8px;
                span {
                    font-weight: 400;
                    font-size: 12px;
                    color: #999999;
                }
            }
        }
    }
}

.comment-btn {
    display: flex;
    padding-top: 12px;
    margin-right: 10px;
    .btn {
        flex: 1;
    }
}
</style>
