<template>
  <div>

    <div class="dialog-h-content scroll-h div_form">

      <div class="form_item">
        <div class="item_title">关怀类型</div>
        <div class="item_content"> {{formData.concernType}}</div>
      </div>
      <div class="form_item">
        <div class="item_title">关怀人员</div>
        <div class="item_content"> {{formData.resiName}}</div>
      </div>
      <div v-if="formData.phone"
           class="form_item">
        <div class="item_title">电话</div>
        <div class="item_content"> {{formData.phone}}</div>
      </div>
      <div v-if="formData.address"
           class="form_item">
        <div class="item_title">地址</div>
        <div class="item_content"> {{formData.address}}</div>
      </div>

      <div class="form_item">
        <div class="item_title">关怀事项</div>
        <div class="item_content"> {{formData.content}}</div>
      </div>

      <div v-if="formData.scheduledTime"
           class="form_item">
        <div class="item_title">预计关怀时间</div>
        <div class="item_content"> {{formData.scheduledTime}}</div>
      </div>

      <div v-if="formData.remindTime"
           class="form_item">
        <div class="item_title">提醒时间</div>
        <div class="item_content"> {{formData.remindTime}}</div>
      </div>
      <div v-if="formData.status"
           class="form_item">
        <div class="item_title">状态</div>
        <div class="item_content"> {{formData.status==='0'?'未完成':'已完成'}}</div>
      </div>
      <div v-if="formData.attachmentList.length>0"
           class="form_item">
        <div class="item_title">附件</div>
        <div>
          <div class="attach_item"
               v-for="(item, index) in formData.attachmentList"
               :key="index">
            <i class="el-icon-tickets"></i>
            <div class="attach_item_name"
                 @click="handleFileDownload(item)">{{item.fileName}}</div>
          </div>
        </div>

      </div>

    </div>

    <div class="div_btn">
      <el-button size="small"
                 @click="handleCancle">取 消</el-button>

    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { Loading } from 'element-ui' // 引入Loading服务
import { requestPost } from '@/js/dai/request'


let loading // 加载动画
export default {
  data () {
    return {

      difficultyId: '',
      formData: {
        content: '',//内容	
        resolveWay: '',//解决方式		
        remark: '',//备注	
        scheduledTime: '',//预计处理时间yyyy-mm-dd hh:mm	
        remindTime: '',//提醒时间yyyy-mm-dd hh:mm	
        attachmentList: []
      },

    }
  },
  components: {},
  mounted () {

  },

  methods: {

    async initForm (row) {
      this.startLoading()

      this.difficultyId = row.id
      await this.loadFormData()

      this.endLoading()

    },

    async loadFormData () {

      // const url = 'http://yapi.elinkservice.cn/mock/245/gov/project/memoDifficulty/detail'
      const url = '/gov/project/memoDifficulty/detail'
      let params = {
        id: this.difficultyId,
        readFlag: '0',
      }
      const { data, code, msg } = await requestPost(url, params)
      if (code === 0) {
        this.formData = data

      } else {
        this.$message.error(msg)
      }
    },

    handleCancle () {


      this.$emit('diaClose')

    },



    //下载
    handleFileDownload (file) {
      var a = document.createElement('a');
      var event = new MouseEvent('click');
      a.download = file.fileName;
      console.log(a)
      a.href = file.attachmentUrl;
      a.dispatchEvent(event);


    },


    // 开启加载动画
    startLoading () {
      loading = Loading.service({
        lock: true, // 是否锁定
        text: '正在加载……', // 加载中需要显示的文字
        background: 'rgba(0,0,0,.7)' // 背景颜色
      })
    },
    // 结束加载动画
    endLoading () {
      // clearTimeout(timer);
      if (loading) {
        loading.close()
      }
    }
  },
  computed: {},
  props: {}
}
</script>


<style lang="scss" scoped >
@import "@/assets/scss/modules/management/secretaryLog.scss";
</style>
<style  lang="scss" scoped>
</style>

