<template>
  <div class="audit-remark">
    <h5>审核批注</h5>
    <ul v-if="remarkList.length > 0">
      <li
        v-for="{ id: remarkId, content, remark_person_name, remark_time, content_select, component_id } in remarkList"
        :key="remarkId"
      >
        <template v-if="content_select">
          <span class="el-icon-notebook-2"> 原文</span>
          <span class="content-select">{{ content_select }}</span>
        </template>
        <p v-html="content"></p>
        <div v-if="isAudit" class="remark-bottom">
          <span>{{ remark_person_name + ':' + remark_time }}</span>
          <div class="btn-box">
            <el-link type="primary" class="delete-black delete-btn" @click="deleteRemarks(remarkId)"
              ><SvgIcon icon-class="delete-black" size="12"
            /></el-link>
            <el-link
              type="primary"
              class="el-icon-place linkLocation"
              v-if="component_id !== 'WHOLE'"
              @click="handleLocation(component_id)"
            />
          </div>
        </div>
      </li>
    </ul>
    <p v-else style="text-align: center">暂无批注</p>
  </div>
</template>

<script>
export default {
  name: 'AuditRemark',
  props: {
    isAudit: {
      type: Boolean,
      default: false,
    },
    remarkList: {
      type: Array,
      required: true,
    },
  },
  data() {
    return {};
  },
  methods: {
    deleteRemarks(remarkId) {
      this.$emit('deleteRemarks', remarkId);
    },
    handleLocation(componentId) {
      this.$emit('handleLocationRemarks', componentId);
    },
  },
};
</script>

<style lang="scss" scoped>
.audit-remark {
  width: 240px;
  height: 100%;
  overflow: auto;
  border: 1px solid #e5e5e5;

  h5 {
    padding: 0 5px;
    margin: 0;
    font-size: 18px;
    line-height: 40px;
    background: #f2f3f5;
  }

  .btn-box {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 55px;
    padding: 0 10px;
    border-left: 1px solid #e5e5e5;
  }

  .delete-btn {
    color: #f44444;
  }

  ul {
    height: calc(100% - 40px);
    overflow: auto;

    li {
      border-bottom: 1px solid #e5e5e5;

      .el-icon-notebook-2 {
        display: block;
        padding: 10px 10px 0;
        margin-bottom: 4px;
        font-size: 12px;
        color: grey;
      }

      .content-select {
        display: block;
        margin-left: 10px;
        border-bottom: 1px solid #eee;
      }

      > p {
        padding: 5px;
      }

      :deep p {
        margin: 0;
      }

      .remark-bottom {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 5px;
        font-size: 12px;
        color: #555;
        border-top: 1px solid #e5e5e5;
      }
    }
  }
}
</style>
