<template>

    <el-drawer title="安全生产任务上报内容查看" :visible.sync="dialogFormVisible" direction="rtl">
    <div class="dialogConcent" :style="{height:clientHeight+'px'}" style="padding: 20px;" >
      <el-scrollbar style="flex: 1">
        <el-form :model="form" ref="form" label-position="right" label-width="120">
          <el-form-item label="内容">
            <div style="width: 99.9%;" v-html="form.content">
            </div>
          </el-form-item>

          <el-form-item label="附件" prop="file_list">
            <div style="display: flex;flex-direction: column;">

              <div v-for="item in form.files" style="display: flex;justify-content: space-between;">
                <el-link target="_blank" :href="item.url" type="primary">
                  {{item.original_name}}
                </el-link>
                <div style="display: flex;">
                  <el-link target="_blank" style="margin-right: 10px;" @click="toshowFile(item.url)"
                    type="primary">
                    预览
                  </el-link>
                  <el-link target="_blank" @click="base.downLoadFileUrl(item.id)" type="primary">
                    下载
                  </el-link>
                </div>
              </div>

            </div>

          </el-form-item>
        </el-form>
      </el-scrollbar>
    </div>
    <viewFile :is-show.sync="isShowViewFile" :url="fileUrl"></viewFile>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogFormVisible=false">关 闭</el-button>
    </div> </el-drawer>
</template>

<script>
  import {
    get
  } from "../../../api/daily/deptindex.js";

  import viewFile from '@/components/viewFile/viewFile.vue'

  export default {
    components: {
      viewFile
    },
    data() {
      return {
        dialogFormVisible: false,
        form: {},
        fileList: [],
        clientHeight: 0
        ,isShowViewFile: false,
        fileUrl: ""
      }
    },
    created() {
      this.clientHeight = document.documentElement.clientHeight * .6;
    },
    methods: {
      toshowFile(url) {
        this.fileUrl = url;
        this.isShowViewFile = true;
      },
      async getinfo(id) {
        var that = this;
        await get(id).then(res => {
          // this.$set(that.form,res);
          that.form = res;
          let _files = [];
          for (var mod of result.files) {
            let m = Object.assign({}, mod);
            m.name = mod.original_name;
            _files.push(m);
          }
          that.fileList = _files;
        }).catch(error => {
          //reject(error)
        })
      }
    }
  }
</script>

<style>
</style>
