|
|
@@ -3,20 +3,21 @@
|
|
|
<template #header>
|
|
|
<app-navbar :title="$t('notices.title')" />
|
|
|
</template>
|
|
|
- <Tabs v-model:active="active" @change="onTabChange">
|
|
|
+ <Tabs v-model:active="active">
|
|
|
<Tab :title="$t('notices.announcement')" :name="1" />
|
|
|
<Tab :title="$t('notices.notice')" :name="2" />
|
|
|
</Tabs>
|
|
|
- <app-pull-refresh ref="pullRefreshRef" v-model:loading="loading" v-model:error="error"
|
|
|
- v-model:pageIndex="pageIndex" :page-count="pageCount" @refresh="onRefresh">
|
|
|
+ <app-pull-refresh ref="pullRefreshRef" v-model:loading="noticeStore.loading" @refresh="onRefresh">
|
|
|
<CellGroup class="article" style="background-color: transparent;padding-top: 10px;" v-if="dataList.length">
|
|
|
<template v-for="(item, index) in dataList" :key="index">
|
|
|
<Cell :value="formatDate(item.createtime, 'YYYY/MM/DD HH:mm:ss')" @click="openDetail(item)">
|
|
|
<template #title>
|
|
|
- <TextEllipsis :content="item.title" />
|
|
|
+ <TextEllipsis :content="handleNoneValue(item.title)" />
|
|
|
</template>
|
|
|
<template #value>
|
|
|
- <span style="font-size: 13px">{{ formatDate(item.createtime, 'YYYY/MM/DD HH:mm:ss') }}</span>
|
|
|
+ <span style="font-size: 13px">
|
|
|
+ {{ formatDate(item.createtime, 'YYYY/MM/DD HH:mm:ss') }}
|
|
|
+ </span>
|
|
|
</template>
|
|
|
<template #right-icon v-if="!item.readed">
|
|
|
<Badge :offset="[0, 5]" dot />
|
|
|
@@ -31,52 +32,31 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { shallowRef, defineAsyncComponent } from 'vue'
|
|
|
+import { shallowRef, defineAsyncComponent, computed } from 'vue'
|
|
|
import { Tab, Tabs, CellGroup, Cell, TextEllipsis, Badge } from 'vant'
|
|
|
-import { formatDate } from '@/filters'
|
|
|
+import { formatDate, handleNoneValue } from '@/filters'
|
|
|
import { useComponent } from '@/hooks/component'
|
|
|
-import { useRequest } from '@/hooks/request'
|
|
|
-import { queryNotice } from '@/services/api/common'
|
|
|
+import { useNoticeStore } from '@/stores'
|
|
|
import AppPullRefresh from '@mobile/components/base/pull-refresh/index.vue'
|
|
|
|
|
|
const componentMap = new Map<string, unknown>([
|
|
|
['detail', defineAsyncComponent(() => import('./components/detail/index.vue'))],
|
|
|
])
|
|
|
|
|
|
-const { componentRef, componentId, openComponent, closeComponent } = useComponent(() => onTabChange())
|
|
|
+const noticeStore = useNoticeStore()
|
|
|
+
|
|
|
+const { componentRef, componentId, openComponent, closeComponent } = useComponent()
|
|
|
const active = shallowRef(1)
|
|
|
-const error = shallowRef(false)
|
|
|
-const dataList = shallowRef<Model.NoticeRsp[]>([])
|
|
|
const selectedRow = shallowRef<Model.NoticeRsp>()
|
|
|
|
|
|
-const { loading, pageIndex, pageCount, run } = useRequest(queryNotice, {
|
|
|
- params: {
|
|
|
- msgType: active.value,
|
|
|
- },
|
|
|
- onSuccess: (res) => {
|
|
|
- if (pageIndex.value === 1) {
|
|
|
- dataList.value = []
|
|
|
- }
|
|
|
- dataList.value.push(...res.data)
|
|
|
- },
|
|
|
- onError: () => {
|
|
|
- error.value = true
|
|
|
- }
|
|
|
-})
|
|
|
+const dataList = computed(() => noticeStore.localizedNoticeList.filter((e) => e.msgtype === active.value))
|
|
|
|
|
|
const openDetail = (item: Model.NoticeRsp) => {
|
|
|
selectedRow.value = item
|
|
|
openComponent('detail')
|
|
|
}
|
|
|
|
|
|
-const onTabChange = () => {
|
|
|
- pageIndex.value = 1
|
|
|
- onRefresh()
|
|
|
-}
|
|
|
-
|
|
|
const onRefresh = () => {
|
|
|
- run({
|
|
|
- msgType: active.value,
|
|
|
- })
|
|
|
+ noticeStore.getNoticeList()
|
|
|
}
|
|
|
</script>
|