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

<script>
const _ = require('lodash');
import viewForm from './util/view-form.vue';
import mUpload from './util/m-upload.vue';
const { nation, politics, exam_grade, gender } = require('@common/src/layout/deploy/dict');
import { mapState, createNamespacedHelpers } from 'vuex';
const { mapActions } = createNamespacedHelpers('company_legal_person');
export default {
  name: 'unit_legal_person',
  props: {},
  components: { mUpload, viewForm },
  data: function () {
    return {
      form: {},
      fields: [
        { label: '姓名', model: 'name' },
        { label: '性别', model: 'gender', type: 'select', list: 'genderList' },
        { label: '公民身份号码', model: 'card', options: { maxLength: 18 } },
        { label: '民族', model: 'nation', type: 'select', list: 'nationList' },
        { label: '出生日期', model: 'birth', type: 'date' },
        { label: '学历', model: 'education' },
        { label: '政治面貌', model: 'politics', type: 'select', list: 'politicList' },
        { label: '法人联系电话', model: 'legal_phone' },
        { label: '职务', model: 'zw' },
        { label: '户籍地省市县', model: 'household' },
        { label: '户籍地详址', model: 'household_detailed', span: 12 },
        { label: '现住址省市县', model: 'onhouse_city' },
        { label: '现住址详址', model: 'onaddress_detailed', span: 12 },
        { label: '保安职业等级代码', model: 'exam_grade', type: 'select', list: 'examGradeList' },
        { label: '保安员证编号', model: 'baoan_num' },
        { label: '保安员发证日期', model: 'baoan_cert_date', type: 'date' },
        {
          label: '简历',
          model: 'resume',
          type: 'textarea',
          span: 24,
          options: { autosize: { minRows: 4, maxRows: 4 }, maxlength: '500', showWordLimit: true },
        },
      ],
      genderList: gender,
      nationList: nation,
      politicList: politics,
      examGradeList: exam_grade,
    };
  },
  mounted() {
    this.init();
  },
  methods: {
    ...mapActions(['fetch', 'update', 'create']),
    async init() {
      const res = await this.fetch({ company_id: this.id });
      if (this.$checkRes(res)) {
        if (res.data) this.$set(this, 'form', res.data);
      }
    },
    getList(listName) {
      return _.get(this, listName, []);
    },
  },
  computed: {
    id() {
      return this.$route.query.id;
    },
  },
};
</script>

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