|
1 | 1 | <template>
|
2 |
| - <ContentWrap> |
3 |
| - <!-- 列表 --> |
4 |
| - <XTable @register="registerTable"> |
5 |
| - <template #actionbtns_default="{ row }"> |
6 |
| - <!-- 操作:详情 --> |
7 |
| - <XTextButton |
8 |
| - preIcon="ep:view" |
9 |
| - :title="t('action.detail')" |
10 |
| - v-hasPermi="['system:notify-message:query']" |
11 |
| - @click="handleDetail(row.id)" |
| 2 | + <content-wrap> |
| 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="userId"> |
| 12 | + <el-input |
| 13 | + v-model="queryParams.userId" |
| 14 | + placeholder="请输入用户编号" |
| 15 | + clearable |
| 16 | + @keyup.enter="handleQuery" |
| 17 | + class="!w-240px" |
12 | 18 | />
|
13 |
| - </template> |
14 |
| - </XTable> |
15 |
| - </ContentWrap> |
16 |
| - <!-- 弹窗 --> |
17 |
| - <XModal id="messageModel" :loading="modelLoading" v-model="modelVisible" :title="modelTitle"> |
18 |
| - <!-- 表单:详情 --> |
19 |
| - <Descriptions |
20 |
| - v-if="actionType === 'detail'" |
21 |
| - :schema="allSchemas.detailSchema" |
22 |
| - :data="detailData" |
| 19 | + </el-form-item> |
| 20 | + <el-form-item label="用户类型" prop="userType"> |
| 21 | + <el-select |
| 22 | + v-model="queryParams.userType" |
| 23 | + placeholder="请选择用户类型" |
| 24 | + clearable |
| 25 | + class="!w-240px" |
| 26 | + > |
| 27 | + <el-option |
| 28 | + v-for="dict in getDictOptions(DICT_TYPE.USER_TYPE)" |
| 29 | + :key="parseInt(dict.value)" |
| 30 | + :label="dict.label" |
| 31 | + :value="parseInt(dict.value)" |
| 32 | + /> |
| 33 | + </el-select> |
| 34 | + </el-form-item> |
| 35 | + <el-form-item label="模板编码" prop="templateCode"> |
| 36 | + <el-input |
| 37 | + v-model="queryParams.templateCode" |
| 38 | + placeholder="请输入模板编码" |
| 39 | + clearable |
| 40 | + @keyup.enter="handleQuery" |
| 41 | + class="!w-240px" |
| 42 | + /> |
| 43 | + </el-form-item> |
| 44 | + <el-form-item label="模版类型" prop="templateType"> |
| 45 | + <el-select |
| 46 | + v-model="queryParams.templateType" |
| 47 | + placeholder="请选择模版类型" |
| 48 | + clearable |
| 49 | + class="!w-240px" |
| 50 | + > |
| 51 | + <el-option |
| 52 | + v-for="dict in getDictOptions(DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE)" |
| 53 | + :key="parseInt(dict.value)" |
| 54 | + :label="dict.label" |
| 55 | + :value="parseInt(dict.value)" |
| 56 | + /> |
| 57 | + </el-select> |
| 58 | + </el-form-item> |
| 59 | + <el-form-item label="创建时间" prop="createTime"> |
| 60 | + <el-date-picker |
| 61 | + v-model="queryParams.createTime" |
| 62 | + value-format="YYYY-MM-DD HH:mm:ss" |
| 63 | + type="daterange" |
| 64 | + start-placeholder="开始日期" |
| 65 | + end-placeholder="结束日期" |
| 66 | + :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" |
| 67 | + class="!w-240px" |
| 68 | + /> |
| 69 | + </el-form-item> |
| 70 | + <el-form-item> |
| 71 | + <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> |
| 72 | + <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button> |
| 73 | + </el-form-item> |
| 74 | + </el-form> |
| 75 | + </content-wrap> |
| 76 | + |
| 77 | + <!-- 列表 --> |
| 78 | + <content-wrap> |
| 79 | + <el-table ref="tableRef" v-loading="loading" :data="list" :height="tableHeight"> |
| 80 | + <el-table-column label="编号" align="center" prop="id" /> |
| 81 | + <el-table-column label="用户类型" align="center" prop="userType"> |
| 82 | + <template #default="scope"> |
| 83 | + <dict-tag :type="DICT_TYPE.USER_TYPE" :value="scope.row.userType" /> |
| 84 | + </template> |
| 85 | + </el-table-column> |
| 86 | + <el-table-column label="用户编号" align="center" prop="userId" width="80" /> |
| 87 | + <el-table-column label="模版编号" align="center" prop="templateId" width="80" /> |
| 88 | + <el-table-column label="模板编码" align="center" prop="templateCode" width="80" /> |
| 89 | + <el-table-column label="发送人名称" align="center" prop="templateNickname" width="180" /> |
| 90 | + <el-table-column |
| 91 | + label="模版内容" |
| 92 | + align="center" |
| 93 | + prop="templateContent" |
| 94 | + width="200" |
| 95 | + show-overflow-tooltip |
| 96 | + /> |
| 97 | + <el-table-column |
| 98 | + label="模版参数" |
| 99 | + align="center" |
| 100 | + prop="templateParams" |
| 101 | + width="180" |
| 102 | + show-overflow-tooltip |
| 103 | + > |
| 104 | + <template #default="scope"> {{ scope.row.templateParams }}</template> |
| 105 | + </el-table-column> |
| 106 | + <el-table-column label="模版类型" align="center" prop="templateType" width="120"> |
| 107 | + <template #default="scope"> |
| 108 | + <dict-tag :type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE" :value="scope.row.templateType" /> |
| 109 | + </template> |
| 110 | + </el-table-column> |
| 111 | + <el-table-column label="是否已读" align="center" prop="readStatus" width="100"> |
| 112 | + <template #default="scope"> |
| 113 | + <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.readStatus" /> |
| 114 | + </template> |
| 115 | + </el-table-column> |
| 116 | + <el-table-column |
| 117 | + label="阅读时间" |
| 118 | + align="center" |
| 119 | + prop="readTime" |
| 120 | + width="180" |
| 121 | + :formatter="dateFormatter" |
| 122 | + /> |
| 123 | + <el-table-column |
| 124 | + label="创建时间" |
| 125 | + align="center" |
| 126 | + prop="createTime" |
| 127 | + width="180" |
| 128 | + :formatter="dateFormatter" |
| 129 | + /> |
| 130 | + <el-table-column label="操作" align="center"> |
| 131 | + <template #default="scope"> |
| 132 | + <el-button |
| 133 | + link |
| 134 | + type="primary" |
| 135 | + @click="openModal(scope.row)" |
| 136 | + v-hasPermi="['system:notify-message:query']" |
| 137 | + > |
| 138 | + 详情 |
| 139 | + </el-button> |
| 140 | + </template> |
| 141 | + </el-table-column> |
| 142 | + </el-table> |
| 143 | + <!-- 分页 --> |
| 144 | + <Pagination |
| 145 | + :total="total" |
| 146 | + v-model:page="queryParams.pageNo" |
| 147 | + v-model:limit="queryParams.pageSize" |
| 148 | + @pagination="getList" |
23 | 149 | />
|
24 |
| - <template #footer> |
25 |
| - <!-- 按钮:关闭 --> |
26 |
| - <XButton :loading="actionLoading" :title="t('dialog.close')" @click="modelVisible = false" /> |
27 |
| - </template> |
28 |
| - </XModal> |
| 150 | + </content-wrap> |
| 151 | + |
| 152 | + <!-- 表单弹窗:详情 --> |
| 153 | + <notify-message-detail ref="modalRef" /> |
29 | 154 | </template>
|
30 | 155 | <script setup lang="ts" name="NotifyMessage">
|
31 |
| -// 业务相关的 import |
32 |
| -import { allSchemas } from './message.data' |
| 156 | +import { DICT_TYPE, getDictOptions } from '@/utils/dict' |
| 157 | +import { dateFormatter } from '@/utils/formatTime' |
33 | 158 | import * as NotifyMessageApi from '@/api/system/notify/message'
|
| 159 | +import NotifyMessageDetail from './detail.vue' |
34 | 160 |
|
35 |
| -const { t } = useI18n() // 国际化 |
36 |
| -
|
37 |
| -// 列表相关的变量 |
38 |
| -const [registerTable] = useXTable({ |
39 |
| - allSchemas: allSchemas, |
40 |
| - topActionSlots: false, |
41 |
| - getListApi: NotifyMessageApi.getNotifyMessagePageApi |
| 161 | +const loading = ref(true) // 列表的加载中 |
| 162 | +const total = ref(0) // 列表的总页数 |
| 163 | +const list = ref([]) // 列表的数据 |
| 164 | +const queryParams = reactive({ |
| 165 | + pageNo: 1, |
| 166 | + pageSize: 10, |
| 167 | + userType: undefined, |
| 168 | + userId: undefined, |
| 169 | + templateCode: undefined, |
| 170 | + templateType: undefined, |
| 171 | + createTime: [] |
42 | 172 | })
|
| 173 | +const queryFormRef = ref() // 搜索的表单 |
| 174 | +const tableRef = ref() |
| 175 | +const tableHeight = ref() // table高度 |
43 | 176 |
|
44 |
| -// 弹窗相关的变量 |
45 |
| -const modelVisible = ref(false) // 是否显示弹出层 |
46 |
| -const modelTitle = ref('edit') // 弹出层标题 |
47 |
| -const modelLoading = ref(false) // 弹出层loading |
48 |
| -const actionType = ref('') // 操作按钮的类型 |
49 |
| -const actionLoading = ref(false) // 按钮 Loading |
50 |
| -const detailData = ref() // 详情 Ref |
| 177 | +/** 查询参数列表 */ |
| 178 | +const getList = async () => { |
| 179 | + loading.value = true |
| 180 | + try { |
| 181 | + const data = await NotifyMessageApi.getNotifyMessagePageApi(queryParams) |
| 182 | + list.value = data.list |
| 183 | + total.value = data.total |
| 184 | + } finally { |
| 185 | + loading.value = false |
| 186 | + } |
| 187 | +} |
| 188 | +
|
| 189 | +/** 搜索按钮操作 */ |
| 190 | +const handleQuery = () => { |
| 191 | + queryParams.pageNo = 1 |
| 192 | + getList() |
| 193 | +} |
51 | 194 |
|
52 |
| -// 设置标题 |
53 |
| -const setDialogTile = (type: string) => { |
54 |
| - modelLoading.value = true |
55 |
| - modelTitle.value = t('action.' + type) |
56 |
| - actionType.value = type |
57 |
| - modelVisible.value = true |
| 195 | +/** 重置按钮操作 */ |
| 196 | +const resetQuery = () => { |
| 197 | + queryFormRef.value.resetFields() |
| 198 | + handleQuery() |
58 | 199 | }
|
59 | 200 |
|
60 |
| -// 详情操作 |
61 |
| -const handleDetail = async (rowId: number) => { |
62 |
| - setDialogTile('detail') |
63 |
| - const res = await NotifyMessageApi.getNotifyMessageApi(rowId) |
64 |
| - detailData.value = res |
65 |
| - modelLoading.value = false |
| 201 | +/** 详情操作 */ |
| 202 | +const modalRef = ref() |
| 203 | +const openModal = (data: NotifyMessageApi.NotifyMessageVO) => { |
| 204 | + modalRef.value.openModal(data) |
66 | 205 | }
|
| 206 | +
|
| 207 | +/** 初始化 **/ |
| 208 | +onMounted(() => { |
| 209 | + getList() |
| 210 | + // TODO 感觉表格自适应高度体验很好的,目前简单实现 需要进一步优化,如根据筛选条件展开或收缩改变盒子高度时 |
| 211 | + tableHeight.value = window.innerHeight - tableRef.value.$el.offsetTop - 85 - 155 |
| 212 | + // 监听浏览器高度变化 |
| 213 | + window.onresize = () => { |
| 214 | + tableHeight.value = window.innerHeight - tableRef.value.$el.offsetTop - 85 - 155 |
| 215 | + } |
| 216 | +}) |
67 | 217 | </script>
|
0 commit comments