提交 | 用户 | 时间
|
820397
|
1 |
<template> |
H |
2 |
<ContentWrap> |
|
3 |
<!-- 搜索工作栏 --> |
|
4 |
<el-form |
|
5 |
class="-mb-15px" |
|
6 |
:model="queryParams" |
|
7 |
ref="queryFormRef" |
|
8 |
:inline="true" |
|
9 |
label-width="68px" |
|
10 |
> |
|
11 |
<el-form-item label="是否已读" prop="readStatus"> |
|
12 |
<el-select |
|
13 |
v-model="queryParams.readStatus" |
|
14 |
placeholder="请选择状态" |
|
15 |
clearable |
|
16 |
class="!w-240px" |
|
17 |
> |
|
18 |
<el-option |
|
19 |
v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)" |
|
20 |
:key="dict.value" |
|
21 |
:label="dict.label" |
|
22 |
:value="dict.value" |
|
23 |
/> |
|
24 |
</el-select> |
|
25 |
</el-form-item> |
|
26 |
<el-form-item label="发送时间" prop="createTime"> |
|
27 |
<el-date-picker |
|
28 |
v-model="queryParams.createTime" |
|
29 |
value-format="YYYY-MM-DD HH:mm:ss" |
|
30 |
type="daterange" |
|
31 |
start-placeholder="开始日期" |
|
32 |
end-placeholder="结束日期" |
|
33 |
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" |
|
34 |
class="!w-240px" |
|
35 |
/> |
|
36 |
</el-form-item> |
|
37 |
<el-form-item> |
|
38 |
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> |
|
39 |
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button> |
|
40 |
<el-button @click="handleUpdateList"> |
|
41 |
<Icon icon="ep:reading" class="mr-5px" /> 标记已读 |
|
42 |
</el-button> |
|
43 |
<el-button @click="handleUpdateAll"> |
|
44 |
<Icon icon="ep:reading" class="mr-5px" /> 全部已读 |
|
45 |
</el-button> |
|
46 |
</el-form-item> |
|
47 |
</el-form> |
|
48 |
</ContentWrap> |
|
49 |
|
|
50 |
<!-- 列表 --> |
|
51 |
<ContentWrap> |
|
52 |
<el-table |
|
53 |
v-loading="loading" |
|
54 |
:data="list" |
|
55 |
ref="tableRef" |
|
56 |
row-key="id" |
|
57 |
@selection-change="handleSelectionChange" |
|
58 |
> |
|
59 |
<el-table-column type="selection" :selectable="selectable" :reserve-selection="true" /> |
|
60 |
<el-table-column label="发送人" align="center" prop="templateNickname" width="180" /> |
|
61 |
<el-table-column |
|
62 |
label="发送时间" |
|
63 |
align="center" |
|
64 |
prop="createTime" |
|
65 |
width="200" |
|
66 |
:formatter="dateFormatter" |
|
67 |
/> |
|
68 |
<el-table-column label="类型" align="center" prop="templateType" width="180"> |
|
69 |
<template #default="scope"> |
|
70 |
<dict-tag :type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE" :value="scope.row.templateType" /> |
|
71 |
</template> |
|
72 |
</el-table-column> |
|
73 |
<el-table-column |
|
74 |
label="消息内容" |
|
75 |
align="center" |
|
76 |
prop="templateContent" |
|
77 |
show-overflow-tooltip |
|
78 |
/> |
|
79 |
<el-table-column label="是否已读" align="center" prop="readStatus" width="160"> |
|
80 |
<template #default="scope"> |
|
81 |
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.readStatus" /> |
|
82 |
</template> |
|
83 |
</el-table-column> |
|
84 |
<el-table-column |
|
85 |
label="阅读时间" |
|
86 |
align="center" |
|
87 |
prop="readTime" |
|
88 |
width="200" |
|
89 |
:formatter="dateFormatter" |
|
90 |
/> |
|
91 |
<el-table-column label="操作" align="center" width="160"> |
|
92 |
<template #default="scope"> |
|
93 |
<el-button |
|
94 |
link |
|
95 |
:type="scope.row.readStatus ? 'primary' : 'warning'" |
|
96 |
@click="openDetail(scope.row)" |
|
97 |
> |
|
98 |
{{ scope.row.readStatus ? '详情' : '已读' }} |
|
99 |
</el-button> |
|
100 |
</template> |
|
101 |
</el-table-column> |
|
102 |
</el-table> |
|
103 |
<!-- 分页 --> |
|
104 |
<Pagination |
|
105 |
:total="total" |
|
106 |
v-model:page="queryParams.pageNo" |
|
107 |
v-model:limit="queryParams.pageSize" |
|
108 |
@pagination="getList" |
|
109 |
/> |
|
110 |
</ContentWrap> |
|
111 |
|
|
112 |
<!-- 表单弹窗:详情 --> |
|
113 |
<MyNotifyMessageDetail ref="detailRef" /> |
|
114 |
</template> |
|
115 |
|
|
116 |
<script lang="ts" setup> |
|
117 |
import { DICT_TYPE, getBoolDictOptions } from '@/utils/dict' |
|
118 |
import { dateFormatter } from '@/utils/formatTime' |
|
119 |
import * as NotifyMessageApi from '@/api/system/notify/message' |
|
120 |
import MyNotifyMessageDetail from './MyNotifyMessageDetail.vue' |
|
121 |
|
|
122 |
defineOptions({ name: 'SystemMyNotify' }) |
|
123 |
|
|
124 |
const message = useMessage() // 消息 |
|
125 |
|
|
126 |
const loading = ref(true) // 列表的加载中 |
|
127 |
const total = ref(0) // 列表的总页数 |
|
128 |
const list = ref([]) // 列表的数据 |
|
129 |
const queryParams = reactive({ |
|
130 |
pageNo: 1, |
|
131 |
pageSize: 10, |
|
132 |
readStatus: undefined, |
|
133 |
createTime: [] |
|
134 |
}) |
|
135 |
const queryFormRef = ref() // 搜索的表单 |
|
136 |
const tableRef = ref() // 表格的 Ref |
|
137 |
const selectedIds = ref<number[]>([]) // 表格的选中 ID 数组 |
|
138 |
|
|
139 |
/** 查询列表 */ |
|
140 |
const getList = async () => { |
|
141 |
loading.value = true |
|
142 |
try { |
|
143 |
const data = await NotifyMessageApi.getMyNotifyMessagePage(queryParams) |
|
144 |
list.value = data.list |
|
145 |
total.value = data.total |
|
146 |
} finally { |
|
147 |
loading.value = false |
|
148 |
} |
|
149 |
} |
|
150 |
|
|
151 |
/** 搜索按钮操作 */ |
|
152 |
const handleQuery = () => { |
|
153 |
queryParams.pageNo = 1 |
|
154 |
getList() |
|
155 |
} |
|
156 |
|
|
157 |
/** 重置按钮操作 */ |
|
158 |
const resetQuery = () => { |
|
159 |
queryFormRef.value.resetFields() |
|
160 |
tableRef.value.clearSelection() |
|
161 |
handleQuery() |
|
162 |
} |
|
163 |
|
|
164 |
/** 详情操作 */ |
|
165 |
const detailRef = ref() |
|
166 |
const openDetail = (data: NotifyMessageApi.NotifyMessageVO) => { |
|
167 |
if (!data.readStatus) { |
|
168 |
handleReadOne(data.id) |
|
169 |
} |
|
170 |
detailRef.value.open(data) |
|
171 |
} |
|
172 |
|
|
173 |
/** 标记一条站内信已读 */ |
|
174 |
const handleReadOne = async (id) => { |
|
175 |
await NotifyMessageApi.updateNotifyMessageRead(id) |
|
176 |
await getList() |
|
177 |
} |
|
178 |
|
|
179 |
/** 标记全部站内信已读 **/ |
|
180 |
const handleUpdateAll = async () => { |
|
181 |
await NotifyMessageApi.updateAllNotifyMessageRead() |
|
182 |
message.success('全部已读成功!') |
|
183 |
tableRef.value.clearSelection() |
|
184 |
await getList() |
|
185 |
} |
|
186 |
|
|
187 |
/** 标记一些站内信已读 **/ |
|
188 |
const handleUpdateList = async () => { |
|
189 |
if (selectedIds.value.length === 0) { |
|
190 |
return |
|
191 |
} |
|
192 |
await NotifyMessageApi.updateNotifyMessageRead(selectedIds.value) |
|
193 |
message.success('批量已读成功!') |
|
194 |
tableRef.value.clearSelection() |
|
195 |
await getList() |
|
196 |
} |
|
197 |
|
|
198 |
/** 某一行,是否允许选中 */ |
|
199 |
const selectable = (row) => { |
|
200 |
return !row.readStatus |
|
201 |
} |
|
202 |
|
|
203 |
/** 当表格选择项发生变化时会触发该事件 */ |
|
204 |
const handleSelectionChange = (array: NotifyMessageApi.NotifyMessageVO[]) => { |
|
205 |
selectedIds.value = [] |
|
206 |
if (!array) { |
|
207 |
return |
|
208 |
} |
|
209 |
array.forEach((row) => selectedIds.value.push(row.id)) |
|
210 |
} |
|
211 |
|
|
212 |
/** 初始化 **/ |
|
213 |
onMounted(() => { |
|
214 |
getList() |
|
215 |
}) |
|
216 |
</script> |