<!--
  @description:招标项目/采购项目-合同文件列表
  @Modifier:郝定康
  @routerPath:
  @date:2021-10-18 11:01:47
-->
<template>
  <div>
    <!-- :rules="rules" -->
    <el-form
      ref="form"
      :model="formData"
      :inline-message="true"
    >
      <table class="from_table">
        <tr>
          <td>
            <el-form-item
              ref="purchaseProjectName"
              show-word-limit
              label="主合同文件"
              prop="purchaseProjectName"
            />
          </td>
          <td>
            <upload
              ref="upload"
              :title="''"
              :data="contractMainFile"
              :auto-delete="true"
              :auto-upload="true"
              :limit="1"
              :file-size="200"
              tip-text="上传附件格式.rar，.zip，.doc，.docx，.pdf，.jpg"
              accept=".rar,.zip,.doc,.docx,.pdf,.jpg"
              file-ref="fileRef"
              but-text="上传文件"
            />
          </td>
        </tr>
        <tr>
          <td>
            <el-form-item
              ref="purchaseProjectName"
              show-word-limit
              label="附件"
              prop="purchaseProjectName"
            />
          </td>
          <td>
            <upload
              ref="upload"
              :title="''"
              :data="contractAttachedFile"
              :auto-delete="true"
              :auto-upload="true"
              :limit="1"
              :file-size="200"
              tip-text="上传附件格式.rar，.zip，.doc，.docx，.pdf，.jpg"
              accept=".rar,.zip,.doc,.docx,.pdf,.jpg"
              file-ref="fileRef"
              but-text="上传文件"
            />
          </td>
        </tr>
      </table>
    </el-form>
    <!--保存按钮-->
    <div class="but_footer">
      <div class="but_footer-h" />
      <div class="but_footer-but">
        <el-button @click="prevStep">
          上一步
        </el-button>
        <el-button type="primary" :loading="confirmLoading" @click="submit('save')">
          提交
        </el-button>
      </div>
    </div>
    <!--工作流选择节点组件-->
    <processNode-com
      ref="processNode"
      :process-definition-key="processDefinitionKey"
      @processNodeData="processNodeData"
    />
    <!--工作流流程节点/获取审核用户-->
    <depart-dialog
      ref="departDialog"
      :process-node="processNode"
      @isSingleUser="isSingleUser"
      @processInitData="processInitData"
      @submit="callback"
    />
  </div>
</template>

<script>
/* api */
import { submitContractInfo } from '@/api/contractManagement'
/* 公共组件*/
import upload from '@comp/common/updownload/upload' // 文件上传组件
/* 公共混入*/
import { contractSigningMixins } from '../mixins/contractSigningMixins'
/* ==========工作流===========*/
import { workCommonMixins } from '@views/work/mixins/workCommonMixins' // 工作流公共配置
import workconstant from '@/assets/js/workutils/workconstant' // 配置流程key
import processNodeCom from '@views/work/processNodeCom' // 工作流选择节点组件
import departDialog from '@views/work/depart-dialog'
export default {
  name: 'ContractDocuments',
  components: {
    upload,
    processNodeCom,
    departDialog
  },
  mixins: [contractSigningMixins, workCommonMixins],
  data() {
    return {
      formData: {},
      rules: [],
      processDefinitionKey: '',
      confirmLoading: false
    }
  },
  created() {
    this.contractMainFile.bizId = this.$route.query.id
    this.contractAttachedFile.bizId = this.$route.query.id
    this.processDefinitionKey = workconstant.contractAudit // 工作流流程key
  },
  methods: {
    // 上一步
    prevStep() {
      const pathData = {
        ...this.$route.query
      }
      this.$emit('stepPage', 'prev', pathData)// 步骤条切换方法 prev 上一步
    },
    submit() {
      this.$confirm('确认提交吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        // 调用保存数据方法
        /*        if (JSON.stringify(this.processNode) !== '{}' && this.processNode.nodeId) {
          this.$refs.departDialog.getUserDepart(this.processNode)
        }*/
        this.callback()
      })
    },
    callback() {
      const data = {
        contractId: this.$route.query.id
      }
      // this.processInitDto.type = '01' // 01：初次提交 02：审核驳回再次提交
      // data.processInitDto = this.processInitDto // 审核人信息传回得信息
      this.confirmLoading = true
      submitContractInfo(data).then(res => {
        this.confirmLoading = false
        this.$router.push({ path: '/contractManagement/contractSigning-list' })
      }).catch(() => {
        this.confirmLoading = false
      })
    }
  }
}
</script>

<style>
</style>
