<!--
  @description: 建设项目审核-详情
  @author: 肖文龙
  @routerPath:/buildingProjectAudit/buildingProjectAuditDetail
  @date： 2019-12-4 18:37:32
-->
<template>
  <div class="main">
    <buildingProjectDetail />
    <div class="p0-16">
      <el-form ref="form" :model="formData" :rules="rules">
        <el-form-item ref="tradeMeans" label="审批意见" prop="tradeMeans">
          <el-input
            v-model="formData.receiveOpion"
            :autosize="{ minRows: 4, maxRows: 4 }"
            type="textarea"
            style="width: 100%"
          />
        </el-form-item>
      </el-form>
    </div>
    <!--操作按钮-->
    <div class="but_footer">
      <div class="but_footer-h">
        <div class="but_footer-but">
          <el-button type="primary" @click="submitForm('form','01')">
            审核通过
          </el-button>
          <el-button @click="submitForm('form','02')">
            审核不通过
          </el-button>
          <el-button @click="back">
            返 回
          </el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
/* 公共方法*/
import { characters1_50 } from '@/assets/js/validate'
/* 建设项目详情组件*/
import buildingProjectDetail from '@/views/purchasePlan/buildingProject/buildingProjectManage/buildingProject/buildingProject-detail'
/* api接口*/
import { getConstructionProjectById, checkBuildingProject } from '@/api/purchasePlan/taskplan'

export default {
  name: 'BuildingProjectAuditDetail',
  components: {
    buildingProjectDetail
  },
  data() {
    return {
      activeName: 'first',
      formData: {},
      fileListOne: [],
      //  校验
      rules: {
        receiveOpion: [{ required: false, validator: characters1_50, trigger: 'blur' }] // 委托合同类型
      }
    }
  },
  mounted() {
    const id = this.$route.params.id ? this.$route.params.id : ''
    if (id) {
      getConstructionProjectById(id).then(res => {
        this.formData = res.data
      }).catch()
    }
  },
  methods: {
    // 审核
    submitForm(formName, status) {
      this.formData.auditStatus = status
      let text = ''
      if (status === '01') {
        text = '确认审批通过？'
      } else {
        text = '确认审批不通过？'
      }
      this.$confirm(text, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        checkBuildingProject(this.formData).then(response => {
          this.$message({
            message: '提交成功',
            type: 'success'
          })
          this.$router.push({ path: '/buildingProject/buildingProjectAuditList' })
        }).catch(() => {

        })
      }).catch(() => {

      })
    },
    // 返回
    back() {
      this.$router.history.go(-1)
    }
  }
}
</script>

<style lang="less" scoped>
</style>
