<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 style="text-align: center;margin-top: 6px;">
          <a-col :span="24">
            <a-button type="primary" @click="submit">保存</a-button>
          </a-col>
        </a-row>
      </a-spin>
    </div>
  </div>
</template>

<script>

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

export default {
  name: "unitInfoEdit",
  components: {
    infoEdit
  },
  data () {
    return {
      formData: {
        id: null,
        unitName: null,
        unitType: null,
        unitAddress: null,
        linkName: null,
        telephone: null,
        email: null,
        fax: null,
        organizationCode: null,
        registeredAddress: null,
        postCode: null,
        legalPerson: null,
        workforce: null,
        specializedPersonnel: null,
        researchPersonnel: null,
        depositBank: null,
        bankAccount: null,
        depositBankAddress: null,
        interbankNumber: 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>