<template>
  <div class="fullheight">
    <ht-sidebar-dialog
      width="50%"
      title="消息详细信息"
      class="sp-manager__dialog"
      :visible="dialogVisible"
      :before-close="beforeCloseDialog"
    >
      <el-form v-form data-vv-scope="PortalMsgSendLogForm">
        <el-form-item label="ID：" style="font-weight:900;">
        <span> {{PortalMsgSendLog.id}}</span>
        </el-form-item>
        <el-form-item label="触发用户(发送者)ID：" style="font-weight:900;">
          <span> {{PortalMsgSendLog.trigUserId}}</span>
        </el-form-item>
        <el-form-item label="流程key：" style="font-weight:900;">
          <span> {{PortalMsgSendLog.flowKey}}</span>
        </el-form-item>
        <el-form-item label="审批动作类型：" style="font-weight:900;">
          <span> {{PortalMsgSendLog.actionType}}</span>
        </el-form-item>
        <el-form-item label="任务节点Id：" style="font-weight:900;">
          <span> {{PortalMsgSendLog.trigNodeId}}</span>
        </el-form-item>
        <el-form-item label="消息标题：" style="font-weight:900;">
           <span> {{PortalMsgSendLog.title}}</span>
        </el-form-item>
        <el-form-item label="MQ文本内容：" style="font-weight:900;">
          <br/>
          <ht-input type="textarea" :value="PortalMsgSendLog.content" :autosize="{ minRows: 2 }" style="width: 70%"></ht-input>
        </el-form-item>
        <el-form-item label="发送状态" style="font-weight:900;">
           <el-button type="danger" v-if="PortalMsgSendLog.status=='0'">失败</el-button>
            <el-button type="success" v-else>成功</el-button>
        </el-form-item>
      </el-form>
      <div slot="footer" style="text-align: right">
        <el-button @click="beforeCloseDialog">{{$t("eip.common.cancel")}}</el-button>
         <el-button type="primary" v-if="PortalMsgSendLog.status=='0'" @click="retrySendMsg(PortalMsgSendLog.id)">重发消息</el-button>
      </div>
    </ht-sidebar-dialog>
  </div>
</template>
<script>
export default {
  data() {
    return {
      dialogVisible: false,
      PortalMsgSendLog: {},
      saveMethod: "POST"
    };
  },
  mounted() {
    this.$validator = this.$root.$validator;
  },
  methods: {
    showDialog(id) {
      if (id) {
        this.saveMethod = "PUT";
        this.$http.get("${portal}/portalMsgSendLog/v1/" + id).then(
          resp => {
            this.PortalMsgSendLog = resp.data;
            if(this.PortalMsgSendLog.actionType=='approve'){
              this.PortalMsgSendLog.actionType='审批'
            }else if(this.PortalMsgSendLog.actionType=='back'){
              this.PortalMsgSendLog.actionType='驳回'
            }else if(this.PortalMsgSendLog.actionType=='backToStart'){
              this.PortalMsgSendLog.actionType='驳回到发起人'
            }else if(this.PortalMsgSendLog.actionType=='commu'){
              this.PortalMsgSendLog.actionType='沟通'
            }else if(this.PortalMsgSendLog.actionType=='recover'){
              this.PortalMsgSendLog.actionType='撤销'
            }else if(this.PortalMsgSendLog.actionType='trans'){
              this.PortalMsgSendLog.actionType='流转'
            }else{
              this.PortalMsgSendLog.actionType='其他'
            }
            this.dialogVisible = true;
          }
        );
      } else {
        this.saveMethod = "POST";
        this.dialogVisible = true;
      }
    },
    beforeCloseDialog() {
      this.PortalMsgSendLog = {};
      this.dialogVisible = false;
    },
    afterSaveData() {
      setTimeout(() => {
        this.beforeCloseDialog();
      }, 500);
      
    },
    retrySendMsg(id){
      this.$http.get("${portal}/portalMsgSendLog/v1/retrySendMsg?id="+id).then(res=>{
        if(res){
           this.$message({
            message: res.data.message,
            type: 'success'
        });
          setTimeout(() => {
          location.reload()
          }, 1000);
        }

      })
    }
  }
};
</script>

<style lang="scss" scoped>
.sp-manager__dialog /deep/ > .el-dialog > .el-dialog__body {
  height: calc(100% - 170px);
}

.el-form-item__label{
  color:#409EFF;
}
</style>
