<template>
  <el-dialog
    title="查看"
    width="60%"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <div style="margin-left: 20px;margin-right: 20px">
      <e-desc title="基本信息" column="2">
        <e-desc-item label="公告主题名称">{{dataForm.title}}</e-desc-item>
        <e-desc-item label="级别">{{dataForm.levelName}}</e-desc-item>
        <e-desc-item span="2" style="min-height: 80px" label="公告内容">{{dataForm.content}}</e-desc-item>
      </e-desc>
      <e-desc title="详细信息" column="2">
        <e-desc-item span="2" label="附件">
          <a v-for="(item, index) in dataForm.attachList" :key="item.fileName + index" type="primary" :href="downloadUrl + item.url">{{ item.fileName }}</a>
        </e-desc-item>
        <e-desc-item span="2" style="min-height: 80px" label="备注说明">{{dataForm.notes}}</e-desc-item>
      </e-desc>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">返回</el-button>
    </span>
  </el-dialog>
</template>

<script>
  import EDesc from '../common/e-desc'
  import EDescItem from '../common/e-desc-item'
  import { getAnnouncementInfo } from '@/api/msg'
  import { downloadUrl } from '@/api/file'
  export default {
    name: 'notice-add-or-update',
    components: {
      EDesc, EDescItem
    },
    data () {
      return {
        visible: false,
        fileList: [],
        downloadUrl: downloadUrl,
        id: 0,
        dataForm: {
          attachList: []
        }
      }
    },
    methods: {
      async init (id) {
        this.visible = true
        this.id = id || 0
        this.getAnnouncementInfo()
      },
      getAnnouncementInfo () {
        getAnnouncementInfo(this.id).then(({data}) => {
          if (data && data.code === '200') {
            this.dataForm = data.data
          }
        })
      }
    }
  }
</script>

<style scoped>
.my-line{
  border-bottom: 1px solid #c0c4cc;
  margin-bottom: 10px;
}
.title{
  padding: 10px 0 ;
}
</style>
