|
|
@@ -7,61 +7,46 @@
|
|
|
<el-radio-button label="message">消息</el-radio-button>
|
|
|
</el-radio-group>
|
|
|
</template>
|
|
|
- <!-- <el-timeline>
|
|
|
- <template v-for="(item,index) in tableList" :key="index">
|
|
|
- <el-timeline-item :timestamp="moment(item.createtime).format('YYYY-MM-DD HH:mm:ss')" placement="top">
|
|
|
- <el-card shadow="never">
|
|
|
- <h4 style="margin-bottom: 10px;font-weight: bold;">{{ item.title }}</h4>
|
|
|
- <p>{{ item.content }}</p>
|
|
|
- </el-card>
|
|
|
- </el-timeline-item>
|
|
|
- </template>
|
|
|
- </el-timeline> -->
|
|
|
- <el-collapse v-model="selectedItem" accordion v-if="tableList.length" @change="collapseChange">
|
|
|
- <template v-for="(item,index) in tableList" :key="index">
|
|
|
- <el-collapse-item :name="index">
|
|
|
- <template #title>
|
|
|
- <h4 :style="selectedItem === index ? 'font-weight: bold;' : 'color: #666;'">
|
|
|
- <el-badge :is-dot="!item.readed" style="margin-right: 8px;" />
|
|
|
- <span>{{ item.title }}</span>
|
|
|
- </h4>
|
|
|
+ <el-tabs tab-position="left" v-model="activeId" @tab-change="collapseChange" v-if="dataList.length">
|
|
|
+ <template v-for="(item, index) in dataList" :key="index">
|
|
|
+ <el-tab-pane :name="item.autoid">
|
|
|
+ <template #label>
|
|
|
+ <el-badge :is-dot="!item.readed" style="margin-right: 8px;" />
|
|
|
+ <span>{{ formatDate(item.createtime, 'MM/DD HH:mm') }}</span>
|
|
|
</template>
|
|
|
- <p style="padding-left: 28px;color: #999;">{{
|
|
|
- moment(item.createtime).format('YYYY-MM-DD HH:mm:ss')
|
|
|
- }}</p>
|
|
|
- <p style="padding-left: 28px;">{{ item.content }}</p>
|
|
|
- </el-collapse-item>
|
|
|
+ <div style="padding:0 28px;">
|
|
|
+ <h4 style="display: flex; flex-direction: column;">
|
|
|
+ <span style="font-weight: bold;">{{ item.title }}</span>
|
|
|
+ <span style="font-size: 12px; color: #999;margin: 8px 0;">{{ formatDate(item.createtime)
|
|
|
+ }}</span>
|
|
|
+ </h4>
|
|
|
+ <p style="line-height: 26px;color: #555;">{{ item.content }}</p>
|
|
|
+ </div>
|
|
|
+ </el-tab-pane>
|
|
|
</template>
|
|
|
- </el-collapse>
|
|
|
+ </el-tabs>
|
|
|
<el-empty v-else />
|
|
|
</app-drawer>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { shallowRef, PropType, computed } from 'vue'
|
|
|
-import { useNotice } from '@/business/notice'
|
|
|
-import moment from 'moment'
|
|
|
+import { shallowRef, computed, onMounted } from 'vue'
|
|
|
+import { formatDate } from '@/filters'
|
|
|
+import { useNotice } from '@/stores'
|
|
|
import AppDrawer from '@pc/components/base/drawer/index.vue'
|
|
|
|
|
|
-const props = defineProps({
|
|
|
- dataList: {
|
|
|
- type: Array as PropType<Ermcp.NoticeRsp[]>,
|
|
|
- default: () => ([])
|
|
|
- }
|
|
|
-})
|
|
|
-
|
|
|
-const { updateNoticeReaded } = useNotice()
|
|
|
+const noticeStore = useNotice()
|
|
|
const show = shallowRef(true)
|
|
|
const selectedTab = shallowRef('notice')
|
|
|
-const selectedItem = shallowRef(0)
|
|
|
+const activeId = shallowRef(0)
|
|
|
|
|
|
-const tableList = computed(() => {
|
|
|
+const dataList = computed(() => {
|
|
|
switch (selectedTab.value) {
|
|
|
case 'notice': {
|
|
|
- return props.dataList.filter((e) => e.msgtype === 1)
|
|
|
+ return noticeStore.noticeList.filter((e) => e.msgtype === 1)
|
|
|
}
|
|
|
case 'message': {
|
|
|
- return props.dataList.filter((e) => e.msgtype === 2)
|
|
|
+ return noticeStore.noticeList.filter((e) => e.msgtype === 2)
|
|
|
}
|
|
|
default: {
|
|
|
return []
|
|
|
@@ -69,16 +54,15 @@ const tableList = computed(() => {
|
|
|
}
|
|
|
})
|
|
|
|
|
|
-const collapseChange = (index: number) => {
|
|
|
- if (tableList.value.length && index.toString()) {
|
|
|
- const item = tableList.value[index]
|
|
|
- if (!item.readed) {
|
|
|
- updateNoticeReaded(item.autoid).then(() => {
|
|
|
- //item.readed = true
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
+const collapseChange = (id: number) => {
|
|
|
+ noticeStore.updateNoticeReaded(id)
|
|
|
}
|
|
|
|
|
|
-collapseChange(selectedItem.value)
|
|
|
+onMounted(() => {
|
|
|
+ const [firstItem] = dataList.value
|
|
|
+ if (firstItem) {
|
|
|
+ activeId.value = firstItem.autoid
|
|
|
+ collapseChange(activeId.value)
|
|
|
+ }
|
|
|
+})
|
|
|
</script>
|