<template>
  <div>
    <el-form disabled>
      <Base :form-data="formData" page-type="frock" :module="module" :common-data="commonData" />
      <Model :form-data="formData" page-type="frock" :module="module" :common-data="commonData" />
    </el-form>
    <Examine :form-data="formData" page-type="frock" :module="module" :common-data="commonData" />
    <div style="margin: 20px 0">
      <el-button type="primary" size="small" @click="onSbumit">提交</el-button>
      <el-button size="small" @click="handleBack">返回</el-button>
    </div>
  </div>
</template>

<script>
import Base from '../components/base.vue'
import Model from '../components/model.vue'
import Examine from '../components/examine.vue'
import Mixin from '../mixin'
import { examineLoginFrock } from '@/api/frock'
export default {
  components: {
    Base,
    Model,
    Examine
  },
  mixins: [Mixin],
  methods: {
    onSbumit() {
      const params = {
        ...this.formData

      }

      if (this.formData.files.length) {
        this.formData.files = this.formData.files.map(k => {
          return {
            ...k,
            fileName: k.name,
            fileUrl: k.url
          }
        })
      }

      if (params.loginStatus === 'FAIL' && !params.projectNo) {
        this.$errorMsg('请填写项目编号')
        return
      }

      if (params.loginStatus === 'REJECT' && !params.examineNote) {
        this.$errorMsg('请填写审核备注')
        return
      }
      examineLoginFrock(params).then(res => {
        this.commonFn('审核成功')
      })
    },
    commonFn(name) {
      this.$successMsg(name)
      this.handleBack()
    },
    handleBack() {
      this.$emit('updateList')
    }
  }
}
</script>

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