
<!--
  @description: 供应商-桌面-消息通知弹框
  @Modifier：wxy
  @routerPath:/procurement/procurementDesktopSupplier
  @date：  2020-09-02 13:09:18
-->

<template>
  <div>
    <el-dialog
      v-dialogDrag
      :visible.sync="dialogData.dialog"
      :before-close="handleClose"
      title="查看消息记录"
      width="896px"
      custom-class="el-dialog__body-p0"
    >
      <div class="p8">
        <table class="tableData">
          <tr>
            <td>
              标题
            </td>
            <td colspan="3">
              {{ messageContent.title }}
            </td>
          </tr>
          <tr>
            <td>
              发送人
            </td>
            <td>
              {{ filterDictText(mailSourceTypeList, messageContent.mailSourceType) }}
            </td>
            <td>
              发送时间
            </td>
            <td>
              {{ messageContent.createTime }}
            </td>
          </tr>
          <tr>
            <td>
              内容
            </td>
            <td colspan="3">
              {{ messageContent.mailContent }}
            </td>
          </tr>
        </table>
      </div>
    </el-dialog>
  </div>
</template>

<script>
/* api接口*/
import { getMailToastInfoById } from '@/api/procurement/commonDesk'
/* 混合开发方法-参数字段*/
import { procurementDesktopGroupMixin } from './mixins/procurementDesktopGroupMixin' // 公共方法

import { filterDictText } from '@assets/js/utils'// 常用方法
export default {
  name: 'ConsignContractSelectDialog',
  mixins: [procurementDesktopGroupMixin],
  props: {
    // 弹框展示状态
    dialogData: {
      type: Object,
      default: () => {}
    },
    currentId: {
      type: String,
      default: () => {}
    }
  },
  data() {
    return {
      // 消息内容数据
      messageContent: {}
    }
  },
  watch: {
    // 监听-弹框展示状态
    'dialogData.dialog'(val) {
      if (val) {
        // 弹框已打开
        // 加载数据
      }
    }
  },
  created() {
    this.getMailToastInfoById(this.currentId)
  },
  methods: {
    filterDictText, // 字典值替换文本通用方法
    getMailToastInfoById(currentId) {
      getMailToastInfoById(currentId).then(res => {
        if (res.header.ret === '0') {
          this.messageContent = res.data.mailToastInfo
          this.messageContent.createTime = this.$Moment(this.messageContent.createTime).format(this.momentSaveFormat)
        }
      })
    },
    handleClose(done) {
      done()
      // 关闭之后传给父组件，刷新一次消息
      this.$emit('cloneDialog', false)
    }
  }
}
</script>

<style scoped lang="less">
</style>

