<template>
  <div>
    <cpt-bread
      @tap="clickBreadItem"
      v-if="breadList.length > 1"
      :bread-list="breadList"
    />
    <laonianren v-if="pageName == '老年人'" />
    <dibaorenyuan v-if="pageName == '低保人员'" />
    <zhiyuanzhe v-if="pageName == '志愿者'" />
    <dangyuan v-if="pageName == '党员'" />
    <shiyerenyuan v-if="pageName == '失业人员'" />
  </div>
</template>

<script>
import cptBread from "@/views/dataBoard/renfang/cpts/bread";
import laonianren from "./components/laonianren.vue";
import dibaorenyuan from "./components/dibaorenyuan.vue";
import zhiyuanzhe from "./components/zhiyuanzhe.vue";
import dangyuan from "./components/dangyuan.vue";
import shiyerenyuan from "./components/shiyerenyuan.vue";
export default {
  name: "visualizing",
  props: {
    title: {
      type: String,
      default: "详情",
    },
  },
  components: {
    cptBread,
    laonianren,
    dibaorenyuan,
    zhiyuanzhe,
    dangyuan,
    shiyerenyuan,
  },
  data() {
    return {
      pageName: "老年人",
      breadList: [
        {
          type: "back",
          meta: { title: "人房总览" },
        },
      ],
    };
  },
  created() {},
  activated() {
    const query = this.$route.query;
    this.breadList = [
      {
        type: "back",
        meta: { title: "人房总览" },
      },
    ];
    this.pageName = query.type_name;
    this.toBread({
      orgId: query.org_id,
      orgLevel: query.type_id,
      meta: { title: query.type_name },
    });
  },
  mounted() {},
  methods: {
    clickBreadItem({ item }) {
      if (item.type == "back") {
        this.$router.back();
      }
    },

    toBread(item) {
      const { orgId } = item;
      const { breadList } = this;
      let index = breadList.findIndex((val) => val.orgId === orgId);
      if (index >= 0) {
        this.breadList = breadList.slice(0, index + 1);
      } else {
        breadList.push(item);
        this.breadList = breadList;
      }
      console.log("breadList::", breadList);
    },
  },
};
</script>

<style
  lang="scss"
  src="@/assets/scss/dataBoard/renfang/index.scss"
  scoped
></style>
