<template>
  <div class="app-container">
    <el-card style="width: 70%; margin: auto" shadow="always">
      <el-button type="primary" style="float: right" size="small" @click="submit">确定</el-button>
      <el-form ref="form" inline :model="queryForm">
        <el-form-item label="批阅意见">
          <el-input
            v-model="queryForm.opinion"
            type="textarea"
            :rows="2"
            style="width: 600px"
            placeholder="请输入内容"
          >
          </el-input>
        </el-form-item>
      </el-form>
      <el-descriptions class="margin-top" title="公文信息" :column="2" border>
        <el-descriptions-item :span="2">
          <template slot="label">
            发文字号
          </template>
          {{ offical.issuedNum }}
        </el-descriptions-item>
        <!--        <el-descriptions-item>-->
        <!--          <template slot="label">-->
        <!--            密级-->
        <!--          </template>-->
        <!--          <dict-tag :options="dict.type.secret_level" :value="offical.issuedLevel"/>-->
        <!--        </el-descriptions-item>-->
        <el-descriptions-item :span="2">
          <template slot="label">
            发文标题
          </template>
          {{ offical.issuedName }}
        </el-descriptions-item>
        <el-descriptions-item>
          <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">
          <template slot="label">
            紧急程度
          </template>
          <dict-tag :options="dict.type.urgency" :value="offical.urgency"/>
        </el-descriptions-item>
        <el-descriptions-item :span="2" content-style="height: 100px;">
          <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="tableData"
        border
        style="width: 100%">
        <el-table-column
          prop="userName"
          label="接收人"
          width="180">
        </el-table-column>
        <el-table-column
          prop="receiveTime"
          label="接收时间"
          width="180">
        </el-table-column>
        <el-table-column
          prop="finishTime"
          label="办理时间">
        </el-table-column>
        <el-table-column
          prop="opinion"
          label="意见">
        </el-table-column>
      </el-table>
      <br/>


    </el-card>
  </div>
</template>

<script>
import {getInitiator, approverSubmit} from "@/api/smartSchool/indexMould/myTask/documentFlow";

export default {
  name: "view",
  dicts: ['secret_level', 'urgency'],
  created() {
    this.id = this.$route.query && this.$route.query.id
    this.getData()
    // this.getLeader()
  },
  data() {
    return {
      id: "",
      queryForm: {
        opinion: "",
      },
      tableData: [],
      offical: {},

    }
  },
  methods: {

    getData() {
      getInitiator(this.id).then((res) => {
        if (res.code == 200) {
          this.offical = res.offical
          this.tableData = res.review
        }
      })
    },

    submit() {
      approverSubmit(this.id, this.queryForm).then((res) => {
        if (res.code == 200) {
          const obj = {path: '/indexMould/myTask/documentFlow'};
          this.$tab.closeOpenPage(obj);
          // this.$router.push({
          //   // path: '/schoolManage/documentFlow',
          //   path: '/indexMould/myTask/documentFlow',
          // })
        }
      })
    },

    formatArray(array) {
      let newArray = array.map(item => {
        return {label: item.teacherName, value: item.id};
      });
      console.log(newArray, 99999)
      return newArray;

    },

    close() {
      this.$router.push({
        path: '/schoolManage/documentFlow',
        // query: {
        //   title: row.title,
        //   type: type ? type.label : '',
        //   role: row.receivePacket
        // }
      })
    },
    //导出文件
    handleExport(file) {
      this.download('schoolOffical/downloadFile', {
        id: file.id
      }, file.fjmc)
    },


  }
}
</script>

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