<script setup lang="ts">
import type { DiscussInfo, DiscussCommentItem } from '../types'
import { ChatLineRound } from '@element-plus/icons-vue'

interface Props {
  info: DiscussInfo
  list: DiscussCommentItem[]
}
defineProps<Props>()

defineEmits<{
  (e: 'update'): void
}>()
</script>
<template>
  <div class="discuss-item">
    <div class="discuss-box">
      <div class="discuss-box-user">
        <img :src="info.created_operator_avatar" />
        <p>{{ info.student_id_name }}</p>
      </div>
      <div class="discuss-box-main">
        <div class="discuss-box-header">
          <p class="discuss-box-time">{{ info.created_time }}</p>
          <div class="tools">
            <el-icon><ChatLineRound></ChatLineRound></el-icon>{{ info.replies_num }}
          </div>
        </div>
        <h3>{{ info.title }}</h3>
        <div class="discuss-box-content" v-html="info.content"></div>
      </div>
    </div>
    <div class="discuss-box discuss-comment" v-for="item in list" :key="item.id">
      <div class="discuss-box-user">
        <img :src="item.sso_id_avatar" />
        <p>{{ item.sso_id_name }}</p>
      </div>
      <div class="discuss-box-main">
        <p class="discuss-box-time">{{ item.created_time }}</p>
        <div class="discuss-box-content" v-html="item.content"></div>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.discuss-box {
  display: flex;
  margin: 10px 0;
  padding: 10px;
  font-size: 12px;
  color: var(--main-color);
  border-radius: 10px;
  border: 1px solid var(--main-color);
  &.discuss-comment {
    margin-left: 40px;
    color: #016fa0;
    border: 1px solid #016fa0;
  }
}
.discuss-box-user {
  img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
    object-fit: cover;
  }
  p {
    text-align: center;
  }
}
.discuss-box-main {
  flex: 1;
  padding-left: 10px;
  h3 {
    font-size: 14px;
    font-weight: 500;
  }
}
.discuss-box-content {
  padding: 5px 0;
  color: #555;
}
.discuss-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  .tools {
    display: flex;
    align-items: center;
    .el-icon {
      font-size: 16px;
      margin-left: 10px;
      margin-right: 5px;
      color: #333333;
    }
  }
}
</style>
