<template>
  <div class="app-container">

    <div class="btn-group">
      <div class="pull-right">
        <!-- <el-button type="success" @click="sent">发送</el-button> -->
        <el-button type="default" @click="returnBack">{{ $t('ec.dialog.close') }}</el-button>
      </div>
    </div>
    <el-form ref="form" :model="formItem" :rules="rules" :label-width="'100px'">
      <el-form-item
        :label="$t('ec.notice.sender')"
        prop="title"
      >
        <el-input v-model="formItem.userName" :readonly="true" type="text" :placeholder="$t('ec.notice.sender')" />
      </el-form-item>
      <el-form-item
        :label="$t('ec.notice.title')"
        prop="title"
      >
        <el-input v-model="formItem.title" :readonly="true" type="text" :placeholder="$t('ec.notice.title')" />
      </el-form-item>
      <el-form-item
        v-if="parseInt(this.formItem.sendWay) === 1"
        :label="$t('ec.notice.type')"
        prop="type"
      >
        <ec-select v-model="formItem.type" readonly :placeholder="$t('ec.notice.type')" dict-type="noticeType" />
      </el-form-item>
      <el-form-item
        :label="$t('ec.notice.sendWay')"
        prop="sendWayText"
      >
        <el-input v-model="formItem.sendWayText" readonly type="text" :placeholder="$t('ec.notice.sendWay')" />
      </el-form-item>
      <el-form-item
        :label="$t('ec.notice.sendTime')"
        prop="sendTime"
      >
        <el-input v-model="formItem.sendTime" readonly type="text" :placeholder="$t('ec.notice.sendTime')" />
      </el-form-item>
      <el-form-item
        :label="$t('ec.notice.content')"
        prop="content"
      >
        <el-input
          v-model="formItem.content"
          :readonly="true"
          type="textarea"
          :rows="10"
          :placeholder="$t('ec.notice.content')"
        />
      </el-form-item>
    </el-form>
  </div>
</template>

<script>

import mixin from 'ecip-web/utils/common-mixin'
import { getReceivedDetail } from 'ecip-web/api/vue/notice/noticeApi'

export default {
  name: 'modules.system.sysrNoticeReceivedForm.detail',
  components: {},
  mixins: [...mixin],
  props: {
    isEdit: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      id: this.$route.params.id,
      sendWay: this.$route.params.sendWay,
      formItem: {
      },
      rules: {}
    }
  },
  created() {
    this.getData()
  },
  methods: {
    getData() {
      getReceivedDetail(this.id).then(res => {
        this.formItem = res.data
      })
    },
    /* sent() {
      let validFlag
      this.$refs.form.validate(valid => { validFlag = valid })
      if (!validFlag) {
        return
      }
      this.formItem.userId = this.formItem.user.id
      this.formItem.userName = this.formItem.user.realName
      sentNotice(this.formItem).then(res => {
        this.returnBack()
        this.$layer.alert('发送成功')
      })
    }, */
    returnBack() {
      this.$store.dispatch('tagsView/delView', this.$route).then(({ visitedViews }) => {
        if (this.formItem.sendWay.indexOf('5') > -1) {
          this.$router.push(`/sysrNoticeMyInboxView`)
        } else {
          this.$router.push(`/sysrNoticeReceivedView`)
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
