<template>
  <div class="sales-contract-review">
    <cy-up-down-drag>
      <div slot="top">
        <sales-contract-management-view></sales-contract-management-view>
      </div>
      <div slot="bar">
        <div>
          签署审核
        </div>
      </div>
      <div slot="bottom">
        <div class="tempalte-content" style="min-height: auto; padding: 0px 20px ">
          <sign-review-content ref="signReviewContent" :deatails-info="deatailsInfo" />
          <div class="submit-btn">
            <el-button type="primary" style="width: 150px;" @click="onSubmit">确定</el-button>
            <el-button style="width: 150px;" @click="() => { $router.go(-1) }">取消</el-button>
          </div>
        </div>
      </div>
    </cy-up-down-drag>
  </div>
</template>

<script setup>
import { salesContractDoApproval, salesContractChangeSignDoApproval, salesContractChangeSignApproval, salesContractSignApproval } from '@/api/salesContractManagement/salesContractManagement'
import SignReviewContent from './components/SignReviewContent.vue'
import salesContractManagementView from './components/salesContractManagementView.vue'
export default {
  name: 'BiddingManagementTemplateReview',
  components: {
    SignReviewContent,
    salesContractManagementView
  },
  data() {
    return {
      Loading: false,
      deatailsInfo: {}
    }
  },
  created() {
    this.getDetails()
  },
  methods: {
    getDetails() {
      const { id, taskName, type } = this.$route.query
      if (type !== 'see') {
        if (taskName === '变更签署审核') {
          salesContractChangeSignApproval({ id }).then((data) => {
            this.deatailsInfo = data.data
          })
        }
        if (taskName === '签署审核') {
          salesContractSignApproval({ id }).then((data) => {
            this.deatailsInfo = data.data
          })
        }
      }
    },
    onSubmit() {
      this.$refs.signReviewContent.getParams().then(data => {
        const params = {
          Loading: true,
          ...data
        }
        const { taskName } = this.$route.query
        if (taskName === '签署审核') {
          salesContractDoApproval(params).then(() => {
            this.$message.success('签署审核成功')
            this.$router.push({ name: 'SalesContractManagement' })
          })
        }
        if (taskName === '变更签署审核') {
          salesContractChangeSignDoApproval(params).then(() => {
            this.$message.success('变更签署审核成功')
            this.$router.push({ name: 'SalesContractManagement' })
          })
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
  /* .template-examine .submit-btn {
    position: absolute;
    bottom: 40px;
    right: 40px;
  } */
</style>
