<!--
  @description:异议回复函编辑
  @Modifier: haofengxian
  @routerPath: /objection/riskDepartObjectionAdd
  @date: 2020-5-11-10:26
-->
<template>
  <div class="p0-16">
    <editor v-model="replyLetterParam.content" style="margin: 12px 0" />
    <!--保存按钮-->
    <div class="but_footer">
      <div class="but_footer-h" />
      <div class="but_footer-but">
        <el-button @click="prevStep">
          上一步
        </el-button>
        <el-button type="primary" @click="previewBulletin">
          预览
        </el-button>
      </div>
    </div>
  </div>
</template>

<script>
/* api*/
import { saveObjectionReceiptContent } from '@api/bidding/tenderObjection'
/* 组件*/
import editor from '@comp/common/editor/editor' // 富文本编辑器组件
/* 混入公共方法*/
import { objectionAcceptanceMixin } from '../mixins/objectionAcceptanceMixin'
export default {
  name: 'MakeReplyLetterAdd',
  components: {
    editor
  },
  mixins: [objectionAcceptanceMixin],
  data() {
    return {
      // 保存参数
      replyLetterParam: {
        objectionId: '', // 异议id
        content: '' // 公告内容
      }
    }
  },
  mounted() {
    this.getReplyLetterContent() // 获取异议投诉内容
  },
  methods: {
    // 获取异议投诉内容
    getReplyLetterContent() {
      this.replyLetterParam.content = sessionStorage.getItem('content')
    },
    // 上一步
    prevStep() {
      if (this.flowStatus) {
        this.$router.push({
          path: this.objectionPath.objectionAddPath, // 受理/不受理编辑页面路由
          query: {
            ...this.$route.query
          }
        })
      } else {
        this.$router.push({
          name: this.objectionPath.objectionAddPath, // 受理/不受理编辑页面路由
          params: {
            ...this.$route.params
          }
        })
      }
    },
    // 预览(保存异议投诉内容并生成pdf盖章)
    previewBulletin() {
      this.replyLetterParam.objectionId = this.form.objectionId
      saveObjectionReceiptContent(this.replyLetterParam).then(() => {
        // 工作流进入
        if (this.flowStatus) {
          this.$router.push({
            path: this.objectionPath.submitObjectionPath,
            query: {
              ...this.$route.query
            }
          })
        } else {
          this.$router.push({
            name: this.objectionPath.submitObjectionPath,
            params: {
              ...this.$route.params
            }
          })
        }
      }).catch(() => {
      })
    }
  }
}
</script>

<style scoped>
</style>
