<template>
  <div class="app-content" style="height:100%;overflow:auto;">
    <div style="height: calc(100% - 32px);overflow:auto;margin-top: 16px;">
      <a-spin :spinning="loading" style="width: 100%;height: 100%;">
        <info-edit :formData.sync="formData" @load="onLoad" ref="infoEdit" />
        <a-row>
          <a-col style="text-align: center;width:100%;">
            <a-button type="primary" style="width:80px;" @click="submit">保存</a-button>
          </a-col>
        </a-row>
      </a-spin>
    </div>
  </div>
</template>

<script>

import infoEdit from '@/views/basicSetting/person/components/infoEdit'

export default {
  name: "personInfoEdit",
  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.getCurrentUnitInfo()
  },
  methods: {
    getCurrentUnitInfo () {
      this.loading = true
      this.$api.unit.getCurrentUnitInfo().then(({ data = {} }) => {
        if (data) {
          this.formData = data
        }
        this.loading = false
      }).catch(() => {
        this.loading = false
      })
    },
    submit () {
      this.$refs.infoEdit.submit()
    },
    onLoad (value) {
      this.loading = value
    },
  }
}
</script>