<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 { examineLoginHomeDecoration } from '@/api/crossDistrict'
export default {
  components: {
    Base,
    Model,
    Examine
  },
  mixins: [Mixin],
  methods: {
    onSbumit(type) {
      const params = {
        ...this.formData,
        isSpan: true

      }
      if (this.formData.files.length) {
        params.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 && !params.note) {
        this.$errorMsg('请填写审核备注')
        return
      }
      if (params.loginStatus === 'FAIL' && params.projectNo === params.successLoginProject) {
        this.$errorMsg('项目编号不能审核项目编号')
        return
      }
      if (params.orderType === 'HOME' && params.orderType === 'HOME' && params.homeProjectNameRadio) {
        params.projectName = {
          'AREA': params.homeProjectNameArea + params.homeProjectNameSeat + params.homeProjectNameNumber,
          'SELF': params.homeProjectNameArea2,
          'VILLA': params.homeProjectNameArea3 + params.homeProjectNameNumber3
        }[params.homeProjectNameRadio]
      }
      if (params.homeProjectNameRadio === 'SELF') {
        params.homeProjectNameArea = params.homeProjectNameArea2
      }
      if (params.homeProjectNameRadio === 'VILLA') {
        params.homeProjectNameNumber = params.homeProjectNameNumber3
        params.homeProjectNameArea = params.homeProjectNameArea3
      }
      if (params.fileList.length) {
        params.drawUpload = params.fileList[0].url
      }

      examineLoginHomeDecoration(params).then(res => {
        this.commonFn('审核成功')
      })
    },
    commonFn(name) {
      this.$successMsg(name)
      this.handleBack()
    },
    handleBack() {
      this.$emit('updateList')
    }
  }
}
</script>

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