<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 class="flex items-center justify-center gap-2">
      <div class="search-box">
        <div class="flex gap-2">
          <div class="item border">
            <span class="pl-[15px] text-[14px]">选择时间</span>
            <el-popover trigger="click" placement="bottom-start">
              <div>
                <div class="tab-box">
                  <div
                    :class="['tab-item', { active: active == 'year' }]"
                    @click="changeTab('year')"
                  >
                    按年
                  </div>
                  <div
                    :class="['tab-item', { active: active == 'month' }]"
                    @click="changeTab('month')"
                  >
                    按月
                  </div>
                  <div
                    :class="['tab-item', { active: active == 'date' }]"
                    @click="changeTab('date')"
                  >
                    按日
                  </div>
                </div>
                <div class="tab-content w-ull">
                  <date :type="active" @pick="handlePick"></date>
                  <!-- <y-date-picker
                    v-model="value1"
                    type="date"
                    placeholder="选择日期"
                  >
                  </y-date-picker> -->
                </div>
              </div>
              <el-input
                size="small"
                placeholder="暂未选择"
                slot="reference"
              ></el-input>
            </el-popover>
          </div>
          <div class="item border">
            <span class="pl-[15px] text-[14px]">选择业务</span>
            <el-popover trigger="click" placement="bottom-start">
              <el-input
                size="small"
                placeholder="暂未选择"
                slot="reference"
              ></el-input>
            </el-popover>
          </div>
          <div class="item border">
            <span class="pl-[15px] text-[14px]">选择部门</span>
            <el-popover trigger="click" placement="bottom-start">
              <el-input
                size="small"
                placeholder="暂未选择"
                slot="reference"
              ></el-input>
            </el-popover>
          </div>
          <div class="item">
            <span class="pl-[15px] text-[14px]">选择窗口</span>
            <el-popover trigger="click" placement="bottom-start">
              <el-input
                size="small"
                placeholder="暂未选择"
                slot="reference"
              ></el-input>
            </el-popover>
          </div>
        </div>
        <div class="btn">检索</div>
      </div>
      <div class="back-btn" @click="$router.push('/engine')">返回</div>
    </div>
  </div>
</template>

<script>
import date from "./date-picker/src/panel/date";
import { findBottomSubarrays } from "@/utils";
export default {
  components: {
    date,
  },
  data() {
    return {
      subMenus: [],
      active: "date",
    };
  },
  computed: {
    activeKey() {
      return this.$route.path;
    },
  },
  created() {
    this.getSubMenus();
  },
  mounted() {},
  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
      );
    },
    changeTab(key) {
      this.active = key;
    },
    handlePick(val) {
      console.log(val);
    },
  },
};
</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;
  }
}
.border {
  border-right: 1px solid #ccc;
}
.search-box {
  height: 68px;
  width: 60%;
  padding: 0px 15px;
  background: #fff;
  border-radius: 34px;
  display: flex;
  align-items: center;
}

.btn,
.back-btn {
  width: 96px;
  height: 60px;
  flex-shrink: 0;
  font-weight: 700;
  color: #fff;
  line-height: 60px;
  text-align: center;
  background: linear-gradient(90deg, #5ab6ff, #2e9aff);
  border-radius: 30px;
  cursor: pointer;
}
.back-btn {
  color: var(--primary);
  background: #fff;
}
:deep(.el-input) {
  .el-input__inner {
    border: none;
  }
}
.tab-box {
  width: 300px;
  height: 40px;
  background-color: #ebebeb;
  border-radius: 20px;
  display: flex;
  position: relative;
  .tab-item {
    width: 100px;
    height: 100%;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  .active {
    background-color: #fff;
    border: 2px solid var(--primary);
  }
}

:deep(.el-picker-panel) {
  border: none;
  box-shadow: none;
  border-radius: 0px;
}
</style>
