/* @description: 澄清质疑-公共方法
@Modifier: 肖文龙
@routerPath:
@date: 2020-04-05
*/

/* 公用方法*/
export const clarificationMixin = {
  data() {
    return {
      flowStatus: this.$route.query.flowStatus, // true 工作流进入驳回编辑
      /* ==============================投标人提出的问题==============================*/
      questionId: this.$route.query.questionId, // 澄清问题Id
      // 投标人提出的问题pdf
      clarificationQuestionContentData: {
        bizId: '', // 业务主键Id
        fileType: 'clarification_question_content '// 文件类型
      },
      // 投标人提出的问题附件
      clarificationQuestionAttachmentData: {
        bizId: '', // 业务主键Id
        fileType: 'clarification_question_attachment '// 文件类型
      },
      /* ==============================项目经理澄清==============================*/
      clarificationId: '', // 澄清Id
      // 回复/发布澄清pdf
      clarificationContentData: {
        bizId: '', // 业务主键Id
        fileType: 'clarification_content'// 文件类型
      },
      // 发布/回复澄清附件
      upLoadData: {
        bizId: '', // 业务主键Id
        fileType: 'clarification_attachment'// 文件类型
      },
      /* ==============================项目经理-澄清回执==============================*/
      clarificationReceiptId: this.$route.query.clarificationReceiptId, // 回执详情Id
      // 澄清回执pdf
      clarificationReceiptContent: {
        bizId: '', // 业务主键Id
        fileType: 'clarification_receipt_content'// 文件类型
      },
      // 澄清回执附件
      clarificationReceiptAttachment: {
        bizId: '', // 业务主键Id
        fileType: 'clarification_receipt_attachment'// 文件类型
      },
      /* ==============================评标澄清==============================*/
      bidClarificationId: this.$route.query.bidClarificationId, // 投标文件澄清Id
      // 投标文件澄清内容附件pdf
      bidClarificationContent: {
        bizId: '', // 业务主键Id
        fileType: 'bid_clarification_content'// 投标文件澄清内容附件
      },
      // 投标文件澄清附件
      bidClarificationAttachment: {
        bizId: '', // 业务主键Id
        fileType: 'bid_clarification_attachment'// 投标文件澄清附件
      },
      /* ==============================评标澄清回执==============================*/
      bidClarificationSupplierRecordId: this.$route.query.bidClarificationSupplierRecordId, // 回执机构Id
      // 投标文件澄清回执内容附件PDF
      bidClarificationReceiptContent: {
        bizId: '', // 业务主键Id
        fileType: 'bid_clarification_receipt_content'// 投标文件澄清附件
      },
      // 投标文件澄清回执附件
      bidClarificationReceiptAttachment: {
        bizId: '', // 业务主键Id
        fileType: 'bid_clarification_receipt_attachment'// 投标文件澄清附件
      },
      // 配置编辑路由 驱动进入和工作流待办进入路由不同（项目经理澄清）
      clarificationPath: {
        clarificationAddPath: '/bidding/projectDrive/clarification/clarificationAdd', // 新增选择标包路由
        makeClarificationLetterAddPath: '/bidding/projectDrive/clarification/makeClarificationLetterAdd', // 富文本编辑器编辑
        submitClarificationLetterPath: '/bidding/projectDrive/clarification/submitClarificationLetter', // 提交路由
        submitListPath: '/bidding/projectDrive/clarification/clarificationList', // 提交后跳转路由
        toolMakePath: '/bidding/projectDrive/clarification/toolMakeClarification', // 工具端制作url
        pdfDetailPath: '/bidding/projectDrive/clarification/clarificationLetterPdfDetail' // 预览澄清pdf
      }
    }
  },
  created() {
    // 项目经理澄清id flowStatus 为true工作流进入取bizId 否则取clarificationId
    this.clarificationId = this.flowStatus ? this.$route.query.bizId : this.$route.query.clarificationId
    this.handlePath() // 项目经理澄清路由
    this.initBizData()// pdf附件初始化业务主键Id
  },
  methods: {
    /* ==============================公用==============================*/
    // pdf+附件初始化业务主键Id
    initBizData() {
      /* 投标人提出的问题*/
      this.clarificationQuestionContentData.bizId = this.questionId// 投标人提出的问题pdf-业务主键Id
      this.clarificationQuestionAttachmentData.bizId = this.questionId// 投标人提出的问题附件-业务主键Id
      /* 项目经理澄清*/
      this.clarificationContentData.bizId = this.clarificationId// 回复/发布澄清pdf-业务主键Id
      this.upLoadData.bizId = this.clarificationId// 发布澄清附件-业务主键Id
      /* 项目经理-澄清回执*/
      this.clarificationReceiptContent.bizId = this.clarificationReceiptId// 澄清回执pdf
      this.clarificationReceiptAttachment.bizId = this.clarificationReceiptId// 澄清回执附件
      /* 评标澄清*/
      this.bidClarificationContent.bizId = this.bidClarificationId// 投标文件澄清附件
      this.bidClarificationAttachment.bizId = this.bidClarificationId// 投标文件澄清内容
      /* 投标文件澄清回执*/
      this.bidClarificationReceiptContent.bizId = this.bidClarificationSupplierRecordId// 投标文件澄清附件
      this.bidClarificationReceiptAttachment.bizId = this.bidClarificationSupplierRecordId// 投标文件澄清内容
    },
    /* ==============================项目经理澄清==============================*/
    // 配置项目经理澄清路径
    handlePath() {
      let clarificationPath = {}
      // 审批流进入
      if (this.flowStatus) {
        clarificationPath = {
          clarificationAddPath: '/work/clarification/clarificationAdd', // 新增选择标包路由
          makeClarificationLetterAddPath: '/work/clarification/makeClarificationLetterAdd', // 富文本编辑器编辑
          submitClarificationLetterPath: '/work/clarification/submitClarificationLetter', // 提交路由
          submitListPath: '/work/todo', // 提交后跳转路由
          toolMakePath: '/work/clarification/toolMakeClarification', // 工具端制作url
          pdfDetailPath: '/work/clarification/clarificationLetterPdfDetail' // 预览澄清pdf
        }
        this.clarificationPath = clarificationPath // 配置路径
      }
    }
  }
}
