<template>
  <div class="menu">
    <div class="home" @click="$emit('update:modelNum', 0)"></div>
    <div>
      <div
        v-for="(item, index) in list"
        :key="index"
        :class="{ 'is-active': item.state }"
        @click="clickEventAcitve(item, index)"
      >{{ item.name }}</div>
    </div>
  </div>
</template>

<script>
export default {
  props: ["modelNum"],
  data() {
    return {
      list: [
        { name: "项目概况", state: false, route: "overview" },
        { name: "楼层功能", state: false, route: "floorFunc" }, //楼层功能
        { name: "设备设施", state: false, route: "equipment" }, //设备设施
        { name: "其他事项", state: false, route: "other" } //其他
      ]
    };
  },
  computed: {},
  created() {},
  mounted() {},
  watch: {
    modelNum(val) {
      this.list = this.list.map((item, index) => {
        if (val == index + 1) {
          item.state = true;
        } else {
          item.state = false;
        }
        return item;
      });
    }
  },
  methods: {
    clickEventAcitve(item) {
      this.list.forEach(ele => {
        ele.state = false;
      });
      item.state = true;
      this.$router.push({ path: `/home/${item.route}` });
    }
  },
  components: {}
};
</script>

<style scoped lang="less">
.menu {
  height: 42px;
  padding-top: 33px;
  padding-left: 500px;
  color: #fff;
  font-size: 16px;
  position: relative;
  .home {
    width: 430px;
    height: 75px;
    position: absolute;
    left: 0;
    top: 0;
    cursor: pointer;
  }
  & > div:nth-of-type(2) {
    & > div {
      line-height: 42px;
      text-align: center;
      background: url("../assets/images/topbar1.png") no-repeat;
      float: left;
      width: 132px;
      height: 42px;
      cursor: pointer;
      transition: all 0.2s;
    }
    .is-active {
      background: url("../assets/images/topbar2.png") no-repeat;
    }
  }
}
</style>
