<template>
  <div v-loading="loading">
    <div class="white-box">
      <div class="white-box-title">
        <h1>{{title}}</h1>
        <span>{{tool.formatDate(createdAt)}}</span>
      </div>
      <div v-html="content" class="white-box-content">
      </div>
      <el-divider content-position="left" v-if="attachment">附件</el-divider>
      <ul v-if="attachment">
        <li v-for="(item,key) in attachment" :key="key">
          <a :href="item" target="_blank">附件{{key+1}}</a>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import Vue from 'vue'
import network from '@/utils/network'
import tool from '@/utils/tool'
import store from '@/utils/vuexStore'

export default {
  name: 'message_detail',
  mounted () {
    this.getData()
  },
  data () {
    return {
      title: null,
      content: null,
      createdAt: '',
      loading: true,
      tool: tool,
      attachment:'',
    }
  },
  methods: {
    getData () {
      network.getData(`message/detail/${this.$route.params.id}`).then(response => {
        this.title = response.TITLE
        this.content = response.CONTENT_DATA
        this.createdAt = response.CREATED_AT
        this.attachment = response.ATTACHMENT;
        this.loading = false
        return network.getUnreadMessage()
      }).catch(response => {
      })
    },
  }
}

</script>

<style scoped>
.white-box-title span{color: #999}
.white-box-content{font-size: 16px;padding: 15px 0;line-height: 2;}
</style>