<template>
  <div class="app-content" style="height:480px;overflow:auto;">
    <a-spin :spinning="loading" style="width: 100%;height: 100%;">
      <info-edit :formData.sync="formData" @load="onLoad" @sub="save" ref="infoEdit" />
      <a-row>
        <a-col style="text-align: center;width:100%;margin-top: 12px;">
          <a-button type="primary" style="width:80px;" @click="submit">提交</a-button>
        </a-col>
      </a-row>
    </a-spin>
  </div>
</template>

<script>

import { getType, getComplete, setComplete } from '@/views/utils/auth'
import infoEdit from '@/views/basicSetting/person/components/infoEdit'

export default {
  name: "personInfoEdit2",
  components: {
    infoEdit
  },
  data () {
    return {
      formData: {
        id: null,
        personName: null,
        nation: null,
        title: null,
        spec: null,
        degree: null,
        duty: null,
        telephone: null,
        fax: null,
        email: null,
        address: null,
      },
      loading: false
    }
  },
  created () {
    this.getAppPersonInfo()
  },
  methods: {
    getAppPersonInfo () {
      this.loading = true
      this.$api.person.getAppPersonInfo().then(({ data = {} }) => {
        if (data) {
          this.formData = data.person
          if (data.isComplete) {
            setComplete(data.isComplete)
            this.$emit('sub', data.isComplete)
          }
        }
        this.loading = false
      }).catch(() => { this.loading = false })
    },
    submit () {
      this.$refs.infoEdit.submit()
    },
    onLoad (value) {
      this.loading = value
    },
    save (value) {
      this.$emit('sub', value)
    },
  }
}
</script>