<template>
  <div id="company_person_charge">
    <el-row>
      <view-form :fields="fields" :data="form" labelWidth="140px">
        <m-upload :basic_id="form.id" :uri="`/files/baoan/company_${id}_legal_${form.id}_material/upload`" :noUpload="true"></m-upload>
      </view-form>
    </el-row>
  </div>
</template>

<script>
import viewForm from './util/view-form.vue';
import mUpload from './util/m-upload.vue';
import { mapState, createNamespacedHelpers } from 'vuex';
const { mapActions } = createNamespacedHelpers('company_person_charge');
export default {
  name: 'company_person_charge',
  props: {},
  components: { mUpload, viewForm },
  data: function () {
    return {
      form: {},
      fields: [
        { label: '姓名', model: 'name' },
        { label: '性别', model: 'gender' },
        { label: '公民身份号码', model: 'card' },
        { label: '民族', model: 'nation' },
        { label: '出生日期', model: 'birth' },
        { label: '学历', model: 'education' },
        { label: '政治面貌', model: 'politics' },
        { label: '法人联系电话', model: 'legal_phone' },
        { label: '职务', model: 'zw' },
        { label: '户籍地省市县', model: 'household' },
        { label: '户籍地详址', model: 'household_detailed' },
        { label: '现住址省市县', model: 'onhouse_city' },
        { label: '现住址详址', model: 'onaddress_detailed' },
        { label: '保安员职业等级代码', model: 'exam_grade' },
        { label: '保安员证编号', model: 'baoan_num' },
        { label: '保安员发证日期', model: 'baoan_cert_date' },
        { label: '简历', model: 'resume', span: 24 },
      ],
    };
  },
  created() {},
  mounted() {
    this.init();
  },
  methods: {
    ...mapActions(['fetch']),
    async init() {
      const res = await this.fetch({ company_id: this.id });
      if (this.$checkRes(res)) {
        console.log(res);
        if (res.data) this.$set(this, 'form', 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: {
    ...mapState(['user']),
    id() {
      return this.$route.query.id;
    },
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
  watch: {
    test: {
      deep: true,
      immediate: true,
      handler(val) {},
    },
  },
};
</script>

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