<template>
  <div class="family">
    <user-family-form type="update" title="修改信息" :information="information"></user-family-form>
  </div>
</template>
<script>
import { mapState, mapActions } from "vuex";
import form from "../modules/FamilyForm";

export default {
  name: "FamilyDetail",
  components: {
    userFamilyForm: form
  },
  data() {
    return {
      information: {
        userInfoSecId: "",
        nameMask: "",
        idNoMask: "",
        socialSecurity: "",
        relation: ""
      }
    };
  },
  async created() {
    await this.setFamilyList();
    const information = this.familyList.find(
      family => +family.userInfoSecId === +this.$route.params.id
    );
    this.information = {
      ...information,
      relation: information.appellation,
      socialSecurity: information.socialSecurity ? "true" : "false"
    };
  },
  computed: {
    ...mapState("user", ["familyList"])
  },
  methods: {
    ...mapActions("user", ["setFamilyList"])
  }
};
</script>
<style lang="less" src="../index.less" scoped></style>
