<template>
  <el-container>
    <el-aside width="240px">
      <h3 class="side_title">通知公告</h3>
      <ul class="side-list">
        <li
          :class="currentComponent === name ? 'active' : ''"
          v-for="{ isTop, time, name, label } in list"
          :key="name"
          @click="currentComponent = name"
        >
          <h4>{{ label }}</h4>
          <div>
            <span class="isTop" v-if="isTop">置顶</span>
            <span class="time">{{ time }}</span>
          </div>
        </li>
      </ul>
    </el-aside>
    <el-main>
      <component :is="currentComponent"></component>
    </el-main>
  </el-container>
</template>
<script>
import AllianceApply from "./components/AllianceApply.vue"
import HospitalsList from "./components/HospitalsList.vue"
export default {
  name: "Notice",
  props: {
    noticeName: {
      type: String,
      default: "AllianceApply",
    },
  },
  components: {
    AllianceApply,
    HospitalsList,
  },
  data() {
    return {
      list: [
        {
          name: "AllianceApply",
          label: "申请加入国家消化道早癌防治中心联盟",
          time: "2022-09-20",
          isTop: true,
        },
        {
          name: "HospitalsList",
          label: "GECA联盟理事及医院名单",
          time: "2022-11-20",
          isTop: true,
        },
      ],
      currentComponent: this.$props.noticeName,
    }
  },
  methods: {},
  mounted() {},
  watch: {
    noticeName(val) {
      this.currentComponent = val
    },
  },
}
</script>
<style lang="scss" scoped>
.el-aside {
  background-color: #fff;
  border-radius: 4px;
  .side_title {
    font-size: 18px;
    font-weight: bold;
    color: #333333;
    margin: 20px;
    padding-left: 15px;
    letter-spacing: 2px;
    border-radius: 4px;
    position: relative;
    &::before {
      content: " ";
      border-left: 4px solid #4e68ff;
      position: absolute;
      height: 18px;
      top: 4px;
      left: 0;
    }
  }
  .side-list {
    li {
      padding: 20px 15px;
      cursor: pointer;
      font-size: 12px;
      &.active {
        background: rgba(78, 104, 255, 0.06);
        h4 {
          color: #4e68ff;
        }
      }
      h4 {
        font-size: 16px;
        letter-spacing: 1px;
        font-weight: bold;
        line-height: 26px;
      }
      .isTop {
        width: 32px;
        height: 20px;
        padding: 2px 5px;
        color: #7085fe;
        background: rgba(112, 133, 254, 0.1);
        border-radius: 1px;
      }
      .time {
        color: #999999;
      }
    }
  }
}
.el-main {
  background-color: #fff;
  border-radius: 4px;
  margin-left: 20px;
}
</style>