index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  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"
  18. />
  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. <content-wrap>
  78. <el-table ref="tableRef" v-loading="loading" :data="list" :height="tableHeight">
  79. <el-table-column label="编号" align="center" prop="id" />
  80. <el-table-column label="用户类型" align="center" prop="userType">
  81. <template #default="scope">
  82. <dict-tag :type="DICT_TYPE.USER_TYPE" :value="scope.row.userType" />
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="用户编号" align="center" prop="userId" width="80" />
  86. <el-table-column label="模版编号" align="center" prop="templateId" width="80" />
  87. <el-table-column label="模板编码" align="center" prop="templateCode" width="80" />
  88. <el-table-column label="发送人名称" align="center" prop="templateNickname" width="180" />
  89. <el-table-column
  90. label="模版内容"
  91. align="center"
  92. prop="templateContent"
  93. width="200"
  94. show-overflow-tooltip
  95. />
  96. <el-table-column
  97. label="模版参数"
  98. align="center"
  99. prop="templateParams"
  100. width="180"
  101. show-overflow-tooltip
  102. >
  103. <template #default="scope"> {{ scope.row.templateParams }}</template>
  104. </el-table-column>
  105. <el-table-column label="模版类型" align="center" prop="templateType" width="120">
  106. <template #default="scope">
  107. <dict-tag :type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE" :value="scope.row.templateType" />
  108. </template>
  109. </el-table-column>
  110. <el-table-column label="是否已读" align="center" prop="readStatus" width="100">
  111. <template #default="scope">
  112. <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.readStatus" />
  113. </template>
  114. </el-table-column>
  115. <el-table-column
  116. label="阅读时间"
  117. align="center"
  118. prop="readTime"
  119. width="180"
  120. :formatter="dateFormatter"
  121. />
  122. <el-table-column
  123. label="创建时间"
  124. align="center"
  125. prop="createTime"
  126. width="180"
  127. :formatter="dateFormatter"
  128. />
  129. <el-table-column label="操作" align="center">
  130. <template #default="scope">
  131. <el-button
  132. link
  133. type="primary"
  134. @click="openModal(scope.row)"
  135. v-hasPermi="['system:notify-message:query']"
  136. >
  137. 详情
  138. </el-button>
  139. </template>
  140. </el-table-column>
  141. </el-table>
  142. <!-- 分页 -->
  143. <Pagination
  144. :total="total"
  145. v-model:page="queryParams.pageNo"
  146. v-model:limit="queryParams.pageSize"
  147. @pagination="getList"
  148. />
  149. </content-wrap>
  150. <!-- 表单弹窗:详情 -->
  151. <notify-message-detail ref="modalRef" />
  152. </template>
  153. <script setup lang="ts" name="NotifyMessage">
  154. import { DICT_TYPE, getDictOptions } from '@/utils/dict'
  155. import { dateFormatter } from '@/utils/formatTime'
  156. import * as NotifyMessageApi from '@/api/system/notify/message'
  157. import NotifyMessageDetail from './detail.vue'
  158. const loading = ref(true) // 列表的加载中
  159. const total = ref(0) // 列表的总页数
  160. const list = ref([]) // 列表的数据
  161. const queryParams = reactive({
  162. pageNo: 1,
  163. pageSize: 10,
  164. userType: undefined,
  165. userId: undefined,
  166. templateCode: undefined,
  167. templateType: undefined,
  168. createTime: []
  169. })
  170. const queryFormRef = ref() // 搜索的表单
  171. const tableRef = ref()
  172. const tableHeight = ref() // table高度
  173. /** 查询参数列表 */
  174. const getList = async () => {
  175. loading.value = true
  176. try {
  177. const data = await NotifyMessageApi.getNotifyMessagePageApi(queryParams)
  178. list.value = data.list
  179. total.value = data.total
  180. } finally {
  181. loading.value = false
  182. }
  183. }
  184. /** 搜索按钮操作 */
  185. const handleQuery = () => {
  186. queryParams.pageNo = 1
  187. getList()
  188. }
  189. /** 重置按钮操作 */
  190. const resetQuery = () => {
  191. queryFormRef.value.resetFields()
  192. handleQuery()
  193. }
  194. /** 详情操作 */
  195. const modalRef = ref()
  196. const openModal = (data: NotifyMessageApi.NotifyMessageVO) => {
  197. modalRef.value.openModal(data)
  198. }
  199. /** 初始化 **/
  200. onMounted(() => {
  201. getList()
  202. // TODO 感觉表格自适应高度体验很好的,目前简单实现 需要进一步优化,如根据筛选条件展开或收缩改变盒子高度时
  203. tableHeight.value = window.innerHeight - tableRef.value.$el.offsetTop - 85 - 155
  204. // 监听浏览器高度变化
  205. window.onresize = () => {
  206. tableHeight.value = window.innerHeight - tableRef.value.$el.offsetTop - 85 - 155
  207. }
  208. })
  209. </script>