<template>
  <el-dialog
    title="查看"
    width="70%"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" ref="dataForm" label-width="auto">
      <el-row class="my-row">
        <el-col :span="12">
          <el-form-item label="公告主题名称">
            <el-input v-model="dataForm.title" :disabled="display" placeholder="请输入公告主题名称"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12" style="padding-left: 20px">
          <el-form-item label="级别" prop="level">
             <el-input v-model="dataForm.levelName" :disabled="display" placeholder="请输入公告主题名称"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row class="my-row">
        <el-form-item label="公告内容">
            <el-input v-model="dataForm.content" :disabled="display" placeholder="备注说明"></el-input>
        </el-form-item>
      </el-row>
      <el-row class="my-row">
        <div class="title">公告附件</div>
      </el-row>
      <el-row class="my-row">
        <a v-for="(item, index) in dataForm.attachList" :key="item.fileName + index" type="primary" :href="item.url">{{ item.fileName }}</a>
      </el-row>
      <el-row class="my-row">
        <el-form-item label="备注说明">
            <el-input v-model="dataForm.notes" :disabled="display" placeholder="备注说明"></el-input>
        </el-form-item>
      </el-row>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">返回</el-button>
    </span>
  </el-dialog>
</template>

<script>
  import { getAnnouncementInfo } from '@/api/msg'
  export default {
    name: 'notice-add-or-update',
    data () {
      return {
        visible: false,
        dictType: 'material_type',
        options: [],
        optionLevel: [],
        dataList: [],
        fileList: [],
        id: 0,
        dataForm: {
          attachList: []
        },
        display: true
      }
    },
    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
          }
        })
      },
      submitUpload () {
        this.$refs.upload.submit()
      },
      handleRemove (file, fileList) {
        console.log(file, fileList)
      },
      handlePreview (file) {
        console.log(file)
      },
      // 表单提交
      dataFormSubmit () {
      },
      validateField (type) {
        this.$refs.dataForm.validateField(type)
      }
    }
  }
</script>

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