<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: @m-black26;
            margin-bottom: 0;
        }
        .ant-tabs-tab {
            width: 140px;
            text-align: center;
            margin-right: 0;
        }
        .ant-tabs-nav {
            height: 50px;
            font-size: 16px;
            color: @m-grey2;
            font-family: Adobe Heiti Std;
            font-weight: normal;
            .ant-tabs-tab-active {
                color: @m-white0;
                background: linear-gradient(0deg, @m-blue8 0%, @m-blue9 100%);
            }
        }
        .ant-tabs-ink-bar {
            display: none !important;
        }
    }
    .ant-modal-close-x {
        height: 50px;
        line-height: 50px;
        svg {
            color: @m-grey1;
        }
    }
    .ant-modal-body {
        padding: 0;
        background: @m-grey9;
    }
}
</style
>;
