<template>
  <div id="person">
    <view-form :data="info" :fields="fields"></view-form>
  </div>
</template>

<script>
import viewForm from './util/view-form.vue';
import { mapState, createNamespacedHelpers } from 'vuex';
const { mapActions } = createNamespacedHelpers('company_applicant');
export default {
  name: 'person',
  props: {},
  components: { viewForm },
  data: function () {
    return {
      info: {},
      fields: [
        {
          label: '国籍',
          model: 'nationality',
        },
        {
          label: '姓名',
          model: 'name',
        },
        {
          label: '公民身份号码',
          model: 'card',
        },
        {
          label: '现住地省市县',
          model: 'onhouse_city',
        },
        {
          label: '现住址详址',
          model: 'onaddress_detailed',
        },
        {
          label: '联系电话',
          model: 'phone',
        },
        {
          label: '单位名称',
          model: 'company',
        },
      ],
    };
  },
  created() {},
  mounted() {
    this.init();
  },
  methods: {
    ...mapActions(['fetch']),
    async init() {
      const res = await this.fetch({ company_id: this.id });
      if (this.$checkRes(res)) {
        if (res.data) this.$set(this, 'info', res.data);
      }
    },
    getData(model) {
      let data = _.get(this.info, model);
      if (!data) return;
      try {
        data = JSON.parse(data);
        data = data.join(',');
      } finally {
        return data;
      }
    },
  },
  computed: {
    id() {
      return this.$route.query.id;
    },
  },
};
</script>

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