<template>
  <div class="app-container">
    <el-card style="width: 70%; margin: auto" shadow="always">
      <el-descriptions title="公文信息" :column="2" border>
        <template slot="extra">
          <el-button type="primary" size="small" @click="close">关闭</el-button>
        </template>
        <el-descriptions-item content-style="height: 80px;">
          <template slot="label"> 发文字号</template>
          {{ offical.issuedNum }}
        </el-descriptions-item>
        <el-descriptions-item :span="2" content-style="height: 80px;">
          <template slot="label"> 发文标题</template>
          {{ offical.issuedName }}
        </el-descriptions-item>
        <el-descriptions-item content-style="height: 80px;">
          <template slot="label"> 收文时间</template>
          {{ offical.receiveDate }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label"> 办理期限</template>
          {{ offical.deadline }}
        </el-descriptions-item>
        <el-descriptions-item :span="2" content-style="height: 80px;">
          <template slot="label"> 紧急程度</template>
          <dict-tag :options="dict.type.urgency" :value="offical.urgency"/>
        </el-descriptions-item>
        <el-descriptions-item :span="2" content-style="height: 150px;">
          <template slot="label"> 简介</template>
          {{ offical.remarks }}
        </el-descriptions-item>
        <el-descriptions-item :span="2" content-style="height: 100px;">
          <template slot="label"> 文件</template>
          <div v-for="item in offical.fileList">
            {{ item.fjmc }}
            <el-button
              style="margin-left: 20px"
              plain type="primary"
              size="mini"
              @click="handleExport(item)">下载
            </el-button>
          </div>

        </el-descriptions-item>
      </el-descriptions>
      <br/>
      <b>流转信息</b>
      <br/>
      <br/>
      <el-table :data="review" border style="width: 100%">
        <el-table-column prop="userName" label="接收人" min-width="100"/>
        <el-table-column prop="receiveTime" label="接收时间" min-width="100"/>
        <el-table-column prop="finishTime" label="办理时间" min-width="100"/>
        <el-table-column prop="opinion" label="意见" min-width="250"/>
      </el-table>
    </el-card>
  </div>
</template>

<script>
import {getOfficialView, downloadFile} from '@/api/smartSchool/schoolManage/documentFlow/view'

export default {
  name: 'DocumentFlowView',
  dicts: ['secret_level', 'urgency'],
  data() {
    return {
      id: '',
      back: "",
      offical: {},
      review: []
    }
  },
  created() {
    this.id = this.$route.query && this.$route.query.id
    this.back = this.$route.query && this.$route.query.back
    this.getData()
  },
  methods: {
    //导出文件
    handleExport(file) {
      this.download('schoolOffical/downloadFile', {
        id: file.id
      }, file.fjmc)
    },
    getData() {
      getOfficialView(this.id).then(res => {
        this.offical = res.offical
        this.review = res.review
      })
    },
    close() {
      if (this.back == 'schoolManage') {
        this.$tab.closeOpenPage({
          path: '/schoolManage/documentFlow'
        })
      } else if (this.back == 'indexMould') {
        this.$tab.closeOpenPage({
          path: '/indexMould/myTask/documentFlow'
        })
      }


    }
  }
}
</script>

<style scoped>
.body {
  height: 50px;
}
</style>
