<template>
  <div class="sign-confirmation">
    <sign-confirmation-content ref="signConfirmationContent" />
    <div class="submit-btn">
      <el-button @click="() => { $router.push({ name: 'MyTrade', query: {type: 'SalesContractManagement'} })}">关闭</el-button>
      <el-button type="primary" @click="onSubmit">提交</el-button>
    </div>
  </div>
</template>

<script>
import { salesContractManagementDoSign, salesContractChangeDoSign } from '@/api/myTrade/salesContractManagement/salesContractManagement'
export default {
  name: 'SalesContractManagementSignConfirmation',
  components: {
    SignConfirmationContent: () => import('./components/SignConfirmationContent.vue')
  },
  methods: {
    onSubmit() {
      this.$refs.signConfirmationContent.getParams().then((data) => {
        const params = {
          Loading: true,
          ...data
        }
        const { taskName } = this.$route.query
        if (taskName === '签署确认') {
          salesContractManagementDoSign(params).then(() => {
            this.$message.success('提交成功')
            this.$router.push({
              name: 'MyTrade',
              query: {
                type: 'SalesContractManagement'
              }
            })
          })
        }
        if (taskName === '变更签署确认') {
          salesContractChangeDoSign(params).then(() => {
            this.$message.success('提交成功')
            this.$router.push({
              name: 'MyTrade',
              query: {
                type: 'SalesContractManagement'
              }
            })
          })
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.sign-confirmation {

}
</style>
