<template>
  <a-modal class="notice"
           v-model:visible="visible"
           @cancel="cancel"
           width="890px"
           centered
           :footer="null">
    <a-tabs v-model:activeKey="activeKey">
      <a-tab-pane key="1">
        <template #tab>
          <span>
            公告
            <a-badge :count="getUnReadNoticeByType([1])"
                     :number-style="{ backgroundColor: '#FF9000' }" />
          </span>
        </template>
        <NoticeContent :noticeList="getNoticeByType([1])" />
      </a-tab-pane>
      <a-tab-pane key="2">
        <template #tab>
          <span>
            系统消息
            <a-badge :count="getUnReadNoticeByType([2])"
                     :number-style="{ backgroundColor: '#FF9000' }" />
          </span>
        </template>
        <NoticeContent :noticeList="getNoticeByType([2])" />
      </a-tab-pane>
    </a-tabs>
  </a-modal>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue';
import { closeModal } from '@/common/setup/modal/index';
import NoticeContent from './components/noticeContent.vue';
import { initData } from '@/common/methods';
import { handleNotice } from './setup';

export default defineComponent({
    name: 'notice',
    components: {
        NoticeContent,
    },
    setup() {
        const { visible, cancel } = closeModal('notice');
        // 公告消息
        const { noticeList, queryNoticeAction, getNoticeByType, updateNotice, getUnReadNoticeByType } = handleNotice();

        initData(() => {
            queryNoticeAction();
            updateNotice();
        });
        return {
            visible,
            cancel,
            noticeList,
            getNoticeByType,
            getUnReadNoticeByType,
            activeKey: ref('1'),
        };
    },
});
</script>

<style lang="less">
.notice {
    .ant-tabs {
        width: 100%;
        .ant-tabs-bar {
            border-bottom-color: #192125;
            margin-bottom: 0;
        }
        .ant-tabs-tab {
            width: 140px;
            text-align: center;
            margin-right: 0;
        }
        .ant-tabs-nav {
            height: 50px;
            font-size: 16px;
            color: #88a0ae;
            font-family: Adobe Heiti Std;
            font-weight: normal;
            .ant-tabs-tab-active {
                color: #ffffff;
                background: linear-gradient(0deg, #3163ba 0%, #4179db 100%);
            }
        }
        .ant-tabs-ink-bar {
            display: none !important;
        }
    }
    .ant-modal-close-x {
        height: 50px;
        line-height: 50px;
        svg {
            color: #7a8a94;
        }
    }
    .ant-modal-body {
        padding: 0;
        background: #252d34;
    }
}
</style
>;
