|
@@ -7,9 +7,18 @@
|
|
|
<template #empty>
|
|
|
<el-empty description="暂无数据" />
|
|
|
</template>
|
|
|
- <el-table-column prop="type" align="center" label="通知种类" width="180" />
|
|
|
- <el-table-column prop="title" align="center" label="标题" />
|
|
|
- <el-table-column prop="time" align="center" label="时间" width="180" />
|
|
|
+ <el-table-column prop="type" align="center" label="通知类型" width="100">
|
|
|
+ <template #="{ row }">
|
|
|
+ {{ getDict(row, 'type') }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="content" align="center" label="内容" />
|
|
|
+ <el-table-column prop="is_read" align="center" label="是否已读" width="100">
|
|
|
+ <template #="{ row }">
|
|
|
+ {{ getDict(row, 'is_read') }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="created_time" align="center" label="时间" width="200" />
|
|
|
</el-table>
|
|
|
</el-col>
|
|
|
<el-col :span="24" class="two">
|
|
@@ -21,8 +30,14 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
+import { MessageStore } from '@/store/api/system/message'
|
|
|
+import { DictDataStore } from '@/store/api/system/dictData'
|
|
|
+import { get } from 'lodash-es'
|
|
|
import { UserStore } from '@/store/user'
|
|
|
+const $checkRes = inject('$checkRes')
|
|
|
const userStore = UserStore()
|
|
|
+const store = MessageStore()
|
|
|
+const dictDataStore = DictDataStore()
|
|
|
const user = computed(() => userStore.user)
|
|
|
// 加载中
|
|
|
const loading = ref(false)
|
|
@@ -42,20 +57,43 @@ onMounted(async () => {
|
|
|
loading.value = false
|
|
|
})
|
|
|
const search = async (query = { skip, limit }) => {
|
|
|
- // skip = query.skip
|
|
|
- // limit = query.limit
|
|
|
- // const info = {
|
|
|
- // skip: query.skip,
|
|
|
- // limit: query.limit,
|
|
|
- // user: user.value.id
|
|
|
- // }
|
|
|
- // const res = await store.query(info)
|
|
|
- // if (res.errcode == '0') {
|
|
|
- // list.value = res.data
|
|
|
- // total.value = res.total
|
|
|
- // }
|
|
|
+ skip = query.skip
|
|
|
+ limit = query.limit
|
|
|
+ const info = {
|
|
|
+ skip: query.skip,
|
|
|
+ limit: query.limit,
|
|
|
+ 'to.user': get(user, 'value.id')
|
|
|
+ }
|
|
|
+ const res = await store.query(info)
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ list.value = res.data
|
|
|
+ total.value = res.total
|
|
|
+ }
|
|
|
+}
|
|
|
+const isReadList = ref([])
|
|
|
+const msgTypeList = ref([])
|
|
|
+const searchOther = async () => {
|
|
|
+ let result = await dictDataStore.query({ code: 'messageIsRead', is_use: '0' })
|
|
|
+ if ($checkRes(result)) isReadList.value = result.data
|
|
|
+ result = await dictDataStore.query({ code: 'messageType', is_use: '0' })
|
|
|
+ if ($checkRes(result)) msgTypeList.value = result.data
|
|
|
+}
|
|
|
+const getDict = (data, type) => {
|
|
|
+ if (type === 'type') {
|
|
|
+ const i = msgTypeList.value.find((f) => f.value === get(data, 'type'))
|
|
|
+ if (i) return get(i, 'label')
|
|
|
+ } else if (type === 'is_read') {
|
|
|
+ //理论上,to中应该只有这个数据,但是还要处理
|
|
|
+ const userid = get(user, 'value.id')
|
|
|
+ if (!userid) return
|
|
|
+ const to = get(data, 'to', [])
|
|
|
+ const is_readData = to.find((f) => f.user === userid)
|
|
|
+ if (!is_readData) return
|
|
|
+ const is_read = get(is_readData, 'is_read', '0')
|
|
|
+ const d = isReadList.value.find((f) => f.value === is_read)
|
|
|
+ if (d) return get(d, 'label')
|
|
|
+ }
|
|
|
}
|
|
|
-const searchOther = async () => {}
|
|
|
// 分页
|
|
|
const changePage = (page = currentPage.value) => {
|
|
|
search({ skip: (page - 1) * limit, limit: limit })
|