
<template>
  <div class="app-content" style="height:260px;overflow: auto;">
    <a-spin :spinning="loading" style="width: 100%;height: 100%;">
      <div>
        <a-form-model ref="form" :model="auditObj" :rules="rules" class="from-table font-line-space">
          <audit-edit :auditObj.sync="auditObj" />
        </a-form-model>
      </div>
      <div style="text-align: center;margin-top: 12px;">
        <a-button type="primary" @click="submit" style="margin-left:16px;">提交</a-button>
      </div>
    </a-spin>
  </div>
</template>
<script>

import { isEmptyParams } from "@/views/utils/common";
import AuditEdit from '@/views/audit/components/auditEdit'
export default {
  name: "Audit",
  components: {
    AuditEdit
  },
  data () {
    return {
      auditObj: { id: null, auditObjectId: null, auditResult: null, auditType: 1, auditContent: '', idList: this.idList },
      rules: {
        auditContent: { required: true, message: '请填写审核意见', trigger: 'blur' },
        auditResult: { required: true, message: '请选择审核结果', trigger: 'change' },
      },
      loading: false,
    };
  },
  props: {
    idList: {
      type: Array,
      default () {
        return []
      }
    },
  },
  created () {

  },
  methods: {
    submit () {
      this.$refs.form.validate(valid => {
        if (valid) {
          this.loading = true
          let pars = isEmptyParams(this.auditObj)
          let par = { ...pars }
          this.$api.auditManager.projectBatchAudit(par).then(({ data = {} }) => {
            if (data) {
              this.$message.success('审核成功！')
              this.$emit('close', 'audit')
            }
            this.loading = false
          }).catch(() => { this.loading = false })
        } else {
          this.$message.error('请选择审核结果或填写审核意见！')
          return false
        }
      })
    },
  },
}
</script>
<style scoped lang="less">
::v-deep .ant-spin-container {
  width: 100%;
  height: 100%;
}
textarea {
  height: 115px;
}
</style>
