<template>
  <div class="bg-white p-2">
    <el-tabs v-model="activeName" type="card" class="demo-tabs" @tab-click="handleClick">
      <el-tab-pane label="系统消息" name="SYSTEM">
        <ul>
          <li v-for="(item, index) in notifyList.records" :key="index" @click="selectMessage(item)" class="mt-1 mb-1" style="font-size: 16px">
            {{ item.content }}
          </li>
        </ul>
      </el-tab-pane>
      <el-tab-pane label="短息消息" name="SMS">
        <ul>
          <li v-for="(item, index) in notifyList.records" :key="index" @click="selectMessage(item)" class="mt-1 mb-1" style="font-size: 16px">
            {{ item.content }}
          </li>
        </ul>
      </el-tab-pane>
      <el-tab-pane label="邮件消息" name="MAIL">
        <ul>
          <li v-for="(item, index) in notifyList.records" :key="index" @click="selectMessage(item)" class="mt-1 mb-1" style="font-size: 16px">
            {{ item.content }}
          </li>
        </ul>
      </el-tab-pane>
      <el-tab-pane label="公众号消息" name="OFFICIAL">
        <ul>
          <li v-for="(item, index) in notifyList.records" :key="index" @click="selectMessage(item)" class="mt-1 mb-1" style="font-size: 16px">
            {{ item.content }}
          </li>
        </ul>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
  
  <script lang="ts" setup>
import { ref, onMounted } from 'vue';
import * as API_Company from '@/api/company';
import type { TabsPaneContext } from 'element-plus';

let activeName = ref<any>('SYSTEM');
const notifyList = ref<any>({});

const selectMessage = (message) => {
  //selectedMessage.value = message;
};
const handleClick = (tab: TabsPaneContext, event: Event) => {
  activeName.value = tab.props.name;
  GET_Notify();
};
const GET_Notify = () => {
  API_Company.getSysMsgByOwn(activeName.value).then((res) => {
    notifyList.value = res;
  });
};
onMounted(() => {
  GET_Notify();
});
</script>
  
  <style>
.demo-tabs > .el-tabs__content {
  padding: 32px;
  color: #6b778c;
  font-size: 32px;
  font-weight: 600;
}
</style>
  