<template>
  <div class="acceptance-adjust-review">
    <cy-up-down-drag>
      <div slot="top">
        <history-view></history-view>
      </div>
      <div slot="bar">
        <div>
          单价审核
        </div>
      </div>
      <div slot="bottom">
        <div class="tempalte-content" style="min-height: auto; padding: 0px 20px ">
          <acceptance-adjust-conclusion ref="conclusion"></acceptance-adjust-conclusion>
          <div class="submit-btn">
            <el-button style="width: 150px;" @click="() => { $router.go(-1) }">取消</el-button>
            <el-button style="width: 150px;" type="primary" @click="onSubmit">提交</el-button>
          </div>
        </div>
      </div>
    </cy-up-down-drag>
  </div>
</template>

<script >
import AcceptanceAdjustConclusion from './components/AcceptanceAdjustConclusion.vue'
import { adjustReview, Loadings } from '@/api/acceptanceManagement/index'
import HistoryView from './components/HistoryView.vue'
export default {
  name: 'AcceptanceAdjustReview',
  components: {
    AcceptanceAdjustConclusion,
    HistoryView
  },
  data() {
    return {
      loadingInstance: null,
      submitDisable: false
    }
  },
  methods: {
    async onSubmit() {
      const conclusionResult = await this.$refs.conclusion.getSubmit()
      const { taskId, id } = this.$route.query
      const { approvalConclusion, approvalComment } = conclusionResult
      const postData = new FormData()
      postData.append('taskId', taskId)
      postData.append('businessKey', id)
      postData.append('approvalConclusion', approvalConclusion)
      postData.append('approvalComment', approvalComment)
      this.loadingInstance = Loadings()
      adjustReview(postData).then(res => {
        if (res.success) {
          this.loadingInstance && this.loadingInstance.close()
          this.$message.success('提交成功。')
          this.$router.push({
            name: 'AcceptanceManagement'
          })
        } else {
          this.$message.warning(res.msg)
          this.loadingInstance && this.loadingInstance.close()
        }
      }).catch(
        res => {
          this.loadingInstance && this.loadingInstance.close()
          this.$message.warning(res)
        }
      )
    }
  }
}
</script>

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

