
<template>
  <div class="report-detail">
    <div style="margin-top: 16px;">
      <test-info v-model="testInfo" />
      <a-form-model ref="form" :model="auditObj" :rules="rules">
        <audit-edit :auditObj.sync="auditObj" />
        <a-row>
          <a-col :span="24" class="bg-gray">
            <a-button @click="cancel">取消</a-button>
            <a-button type="primary" @click="submit">提交</a-button>
          </a-col>
        </a-row>
      </a-form-model>
    </div>
  </div>
</template>
<script>
import { isEmptyParams } from "@/views/utils/common";
import TestInfo from '@/views/report/task/components/taskInfo'
import AuditList from '@/views/audit/components/auditInfo'
import AuditEdit from '@/views/audit/components/auditEdit'

const cont1 = () => { return { id: null, testId: null, contentInfo: '', startTime: null, endTime: null, contentType: 'd37abeb6-14e0-4486-924d-e1e4baf67098', showIndex: 1 } }
const cont2 = () => { return { id: null, testId: null, contentInfo: '', startTime: null, endTime: null, contentType: 'b1fe4003-16ed-482f-8fd5-e34b1482c3d4', showIndex: 1 } }
const cont3 = () => { return { id: null, testId: null, contentInfo: '', startTime: null, endTime: null, contentType: 'b19cf66b-c1bb-4974-a524-114c1895dbd8', showIndex: 1 } }
const cont4 = () => { return { id: null, testId: null, contentInfo: '', startTime: null, endTime: null, contentType: 'cf3abeff-9f1a-420e-b375-6aad33f12080', showIndex: 1 } }
const cont5 = () => { return { id: null, testId: null, contentInfo: '', startTime: null, endTime: null, contentType: 'f1cea24c-d13d-48af-8abb-58eed9367c27', showIndex: 1 } }
const cont6 = () => { return { id: null, testId: null, contentInfo: '', startTime: null, endTime: null, contentType: 'ebcdf2b0-011c-4d40-a064-f22d6f7ec646', showIndex: 1 } }
export default {
  name: "Audit",
  components: {
    TestInfo, AuditList, AuditEdit
  },
  data () {
    return {
      testInfo: {
        id: '',
        projId: '',
        projName: '',
        startDate: null,
        endDate: null,
        appUnitName: '',
        linkTel: '',
        linkAddress: '',
        linkEmail: '',
        // 实施目标和主要内容
        testContent: '',
        // 总经费
        budgetCount: 0,
        // 市卫计委资助
        budgetGovCount: 0,
        // 起止日期
        startDate: null,
        endDate: null,
        // 申报人
        appPersonName: null,
        sex: null,
        birthYear: null,
        mobile: null,
        degreeName: null,
        titleName: null,
        // 依托单位
        appUnitName: null,
        linkEmail: null,
        linkTel: null,
        linkAddress: null,
        postcode: null,
        authority: null,
        // 项目内容
        cont1: [cont1()],
        cont2: [cont2()],
        cont3: [cont3()],
        cont4: [cont4()],
        cont5: [cont5()],
        cont6: [cont6()],
        // 成员
        members: [],
        // 预期成果形式
        target: [],
        // 经费
        budget: [],
        //审核记录
        auditList: [{ result: '', unit: '', time: '' }],
      },
      auditObj: { id: this.value, auditObjectId: this.objId, auditResult: null, auditType: 2, auditContent: '' },
      rules: {
        auditContent: { required: true, message: '请填写审核意见', trigger: 'blur' },
        auditResult: { required: true, message: '请选择审核结果', trigger: 'change' },
      },
    };
  },
  props: {
    value: {
      type: String,
      default: () => {
        return null
      }
    },
    objId: {
      type: String,
      default () {
        return null
      }
    },
    projId: {
      type: String,
      default () {
        return null
      }
    }
  },
  created () {
    this.getTestInfoByProjId();
  },
  methods: {
    getTestInfoByProjId () {
      let pars = { projId: this.projId }
      this.$api.task.getTestInfoByProjId(pars).then(({ data = {} }) => {
        if (data) {
          this.testInfo = data
        }
      }).catch(() => {
      })
    },
    cancel () {
      this.$emit('closeWindow', 'auditcel')
    },
    submit () {
      this.$refs.form.validate(valid => {
        if (valid) {
          let pars = isEmptyParams(this.auditObj)
          let par = { ...pars }
          this.$api.audit.testAudit(par).then(({ data = {} }) => {
            if (data) {
              this.$message.success('审核成功！')
              this.$emit('closeWindow', 'audit')
            }
          }).catch(() => {
            f
            this.loading = false
          })
        } else {
          return false
        }
      })
    },
  },
}
</script>
<style lang="less" scoped>
.report-detail {
  height: 70vh;
  overflow: auto;
  border-left: 1px solid #f0f0f0;
  border-top: 1px solid #f0f0f0;
}
</style>

