<template>
  <div
    class="search mb-[15px] flex h-[170px] w-full flex-col items-center justify-around"
  >
    <div class="flex gap-10">
      <router-link v-for="(v, i) in subMenus" :key="i" :to="v.path">
        {{ v.meta.title }}
      </router-link>
    </div>
    <div>
      <el-form :model="form" inline ref="form">
        <el-form-item>
          <el-input></el-input>
        </el-form-item>
        <el-form-item>
          <el-input></el-input>
        </el-form-item>
        <el-form-item>
          <el-input></el-input>
        </el-form-item>
        <el-form-item>
          <el-input></el-input>
        </el-form-item>
        <el-form-item>
          <el-button>检索</el-button>
        </el-form-item>
        <el-form-item>
          <el-button @click="$router.push('/engine')">返回</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import { findBottomSubarrays } from "@/utils";
export default {
  data() {
    return {
      subMenus: [],
    };
  },
  computed: {
    activeKey() {
      return this.$route.path;
    },
  },
  created() {
    this.getSubMenus();
  },
  methods: {
    changeRouter(e) {
      this.$router.push(e.name);
    },
    // 获取当前顶层路由下的所有子路由
    getSubMenus() {
      let path = this.$route?.meta.parentPath
        ? this.$route.meta.parentPath
        : this.$route.path;
      let options = this.$router.options.routes[0].children;
      let curRouters = options.filter((v) => v.path == path);
      this.subMenus = findBottomSubarrays(curRouters).filter(
        (v) => !v.meta.hidden
      );
    },
  },
};
</script>

<style lang="less" scoped>
.search {
  background: url("@/assets/img/engineSearch_bg.svg") no-repeat center / 100%
    100%;
  a {
    color: rgba(254, 254, 254, 0.65);
  }
  .router-link-active {
    color: #fff;
    font-weight: 600;
  }
}
</style>
