<template>
  <div class="home-container">
    <div class="home-center">
      <div class="home-sider">
        <SiderTabs :siderList="siderTabs" @clickSiderItem="handleClickLeftSiderBtn" />
      </div>
      <div class="home-main">
        <router-view />
      </div>
    </div>
  </div>
</template>

<script setup>
import { onMounted, ref, computed, watch } from "vue";
import { useRoute } from "vue-router";
import router from '@/router'
import SiderTabs from "@/components/base/SiderTabs/index.vue";

const route = useRoute();

const siderBtnList = ref([
  {
    name: '法案简介',
    path: '/billLayout/bill/introduction'
  },
   {
    name: '法案背景',
    path: '/billLayout/bill/background'
  },
   {
    name: '法案原文',
    path: '/billLayout/bill/template'
  },
])

const siderBtnActive = ref("法案简介");

const getSiderActiveByRoutePath = path => {
	if (path.includes("/billLayout/bill/background")) return "法案背景";
	if (path.includes("/billLayout/bill/template")) return "法案原文";
	return "法案简介";
};

const siderTabs = computed(() =>
	siderBtnList.value.map(item => ({
		...item,
		active: siderBtnActive.value === item.name
	}))
);

const handleClickLeftSiderBtn = (item) => {
  siderBtnActive.value = item.name
  router.push({
    path: item.path,
    query: {
      billId: route.query.billId
    }
  })
}

onMounted(() => {});

watch(
	() => route.path,
	(newPath) => {
		siderBtnActive.value = getSiderActiveByRoutePath(newPath);
	},
	{ immediate: true }
);
</script>

<style lang="scss" scoped>
.home-container {
  width: 100%;
  height: 100%;
  // background: rgba(243, 243, 244, 1);
  .home-top {
    height: 137px;
    background: rgba(255, 255, 255, 1);
    display: flex;
    justify-content: space-between;
    .home-top-left-box {
      width: 500px;
      margin-left: 160px;
      margin-top: 13px;
      .left-box-top {
        height: 64px;
        display: flex;
        .icon {
          width: 64px;
          height: 64px;
        }
        .info {
          margin-left: 9px;
          .info-box1 {
            color: rgba(59, 65, 75, 1);
            font-family: Microsoft YaHei;
            font-size: 20px;
            font-weight: 600;
            line-height: 22px;
            letter-spacing: 0px;
            text-align: left;
            margin-top: 5px;
          }
          .info-box2 {
            margin-top: 5px;
            height: 22px;
            line-height: 22px;
            color: rgba(132, 136, 142, 1);

            font-family: Microsoft YaHei;
            font-size: 14px;
            font-weight: 400;
            line-height: 22px;
            letter-spacing: 0px;
            text-align: left;
          }
        }
      }
      .left-box-bottom {
        display: flex;
        height: 40px;
        margin-top: 21px;
        .left-box-bottom-item {
          display: flex;
          margin-right: 32px;
          height: 38px;
          .name {
            color: rgba(95, 101, 108, 1);
            font-family: Microsoft YaHei;
            font-size: 14px;
            font-weight: 400;
            line-height: 22px;
            letter-spacing: 0px;
            text-align: left;
            margin-left: 3px;
          }
        }
      }
    }
    .home-top-right-box {
      width: 300px;
      margin-right: 150px;
      margin-top: 13px;
      .right-box-top {
        .time {
          height: 24px;
          line-height: 24px;
          color: rgba(95, 101, 108, 1);
          font-family: Microsoft YaHei;
          font-size: 16px;
          font-weight: 400;
          line-height: 22px;
          letter-spacing: 0px;
          text-align: right;
        }
        .name {
          height: 24px;
          line-height: 24px;
          color: rgba(95, 101, 108, 1);
          font-family: Microsoft YaHei;
          font-size: 16px;
          font-weight: 400;
          line-height: 22px;
          letter-spacing: 0px;
          text-align: right;
        }
      }
      .right-box-bottom {
        margin-top: 24px;
        text-align: right;
      }
    }
  }
  .home-center {
    display: flex;
    height: 879px;
    position: relative;
    .home-sider {
      width: 120px;
      position: absolute;
      top: 16px;
      left: -140px;
      .sider-btn {
        margin-top: 20px;
        margin-left: 20px;
        width: 120px;
        height: 32px;
        display: flex;
        border-radius: 16px;
        cursor: pointer;
        .btn-text {
          width: 68px;
          height: 32px;
          margin-left: 28px;
          line-height: 32px;
          text-align: left;
          box-sizing: border-box;
          font-size: 16px;
          font-weight: 400;
          font-family: Microsoft YaHei;
          color: rgba(95, 101, 108, 1);
        }
        .btn-icon {
          width: 22px;
          padding-top: 9px;
        }
      }
      .siderBtnActive {
        background: var(--color-main-active);
        .btn-text {
          color: #fff !important;
        }
      }
    }
    .home-main {
      flex: 1;
      display: flex;
    }
  }
}

:deep(.el-steps--simple) {
  padding: 6px 10px;
}
:deep(.el-timeline-item) {
  padding-bottom: 5px !important;
}
:deep(.el-timeline-item__timestamp) {
  color: rgba(95, 101, 108, 1) !important;
  font-family: Microsoft YaHei !important;
  font-size: 14px !important;
  font-weight: 600 !important;
}
.timeline-content {
  color: rgba(132, 136, 142, 1);
  font-family: Microsoft YaHei;
  font-size: 14px;
  font-weight: 400;
  line-height: 22px;
}
</style>