index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <div class="layout-pd">
  3. <el-row>
  4. <!--操作-->
  5. <el-col :xs="24" >
  6. <el-card class="mt8" shadow="hover" >
  7. <el-form :model="state.filter" :inline="true" @submit.stop.prevent style="margin-bottom:-20px;">
  8. <el-form-item prop="name" style="width: 100%">
  9. <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
  10. <el-form-item label="推送用户">
  11. <el-input v-model="state.filter.pushUser" placeholder="单行输入" clearable></el-input>
  12. </el-form-item>
  13. </el-col>
  14. <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
  15. <el-form-item label="是否推送">
  16. <el-input v-model="state.filter.isPushed" placeholder="单行输入" clearable></el-input>
  17. </el-form-item>
  18. </el-col>
  19. <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
  20. <el-form-item label="推送时间">
  21. <el-date-picker
  22. v-model="state.filter.pushTime"
  23. type="datetimerange"
  24. value-format="YYYY-MM-DD HH:mm:ss"
  25. range-separator="To"
  26. start-placeholder="开始日期"
  27. end-placeholder="结束日期"
  28. />
  29. </el-form-item>
  30. </el-col>
  31. </el-form-item>
  32. </el-form>
  33. <hr>
  34. <el-row justify="space-between" class="submit-button" style="margin-bottom:-6px;">
  35. <el-row>
  36. <el-button type="primary" icon="ele-Search" @click="onQuery"> 查询 </el-button>
  37. <el-button type="primary" icon="ele-RefreshRight" @click="onReset"> 重置 </el-button>
  38. <el-button v-auth="'api:admin:file:upload-file'" type="primary" icon="ele-Upload"> 立即推送
  39. </el-button>
  40. </el-row>
  41. </el-row>
  42. </el-card>
  43. </el-col>
  44. <!--表格-->
  45. <el-col :xs="24" >
  46. <el-card style="height: 70vh" class="my-fill mt8" shadow="hover">
  47. <el-table v-loading="state.loading" stripe :data="state.tableModel" row-key="id" style="width: 100%">
  48. <el-table-column type="selection" width="55" fixed="left"></el-table-column>
  49. <el-table-column v-for="column in state.dynamicColumns" :key="column.prop" :prop="column.prop" :label="column.label" >
  50. </el-table-column>
  51. <el-table-column label="操作" fixed="right" header-align="center" align="center" class="right-operation" width="140">
  52. <template #default="{ row }" >
  53. <el-link v-if="row.isPushed === '未推送'"
  54. class="my-el-link mr12 ml12"
  55. type="primary"
  56. icon="ele-Upload"
  57. @click="onDateUpdate(row)"
  58. :underline="false"
  59. target="_blank"
  60. >立即推送</el-link>
  61. </template>
  62. </el-table-column>
  63. </el-table>
  64. <div class="my-flex my-flex-end" style="margin-top: 20px">
  65. <el-pagination v-model:currentPage="pageState.pageInput.currentPage"
  66. v-model:page-size="pageState.pageInput.pageSize" :total="state.total" :page-sizes="[10, 15, 20, 50, 100]"
  67. small background @size-change="onSizeChange" @current-change="onCurrentChange"
  68. layout="total, sizes, prev, pager, next, jumper" />
  69. </div>
  70. </el-card>
  71. </el-col>
  72. </el-row>
  73. </div>
  74. </template>
  75. <script setup lang="ts">
  76. import {onBeforeMount, onMounted, reactive, ref, watch} from "vue";
  77. import eventBus from "/@/utils/mitt";
  78. import {Api} from "/@/api/admin/AlarmService/alarmQueryApi";
  79. import { PushDto } from "/@/api/admin/AlarmService/alarmQueryDto";
  80. import { PageInputAlarmFilterModel } from "/@/api/admin/reportManagement/alarm/alarmDto";
  81. import { useDynamicPageSize } from "/@/composables/useDynamicPageSize";
  82. // 使用组合式函数获取分页状态
  83. const pageState = useDynamicPageSize(10, 15);
  84. /**创建假数据 */
  85. const mockData = [
  86. {
  87. id: 1,
  88. ruleId: "rule-001",
  89. pushUserid: "user-001",
  90. pushUser: "张三",
  91. content: "设备A报警:温度过高",
  92. isPushed: "已推送",
  93. pushTime: "2023-10-01 10:00:00",
  94. alarmhistoryID: "alarm-001",
  95. taskPriority: "高",
  96. },
  97. {
  98. id: 2,
  99. ruleId: "rule-002",
  100. pushUserid: "user-002",
  101. pushUser: "李四",
  102. content: "设备B报警:电压异常",
  103. isPushed: "未推送",
  104. pushTime: "2023-10-02 15:30:00",
  105. alarmhistoryID: "alarm-002",
  106. taskPriority: "中",
  107. },
  108. {
  109. id: 3,
  110. ruleId: "rule-003",
  111. pushUserid: "user-003",
  112. pushUser: "王五",
  113. content: "设备C报警:湿度超标",
  114. isPushed: "已推送",
  115. pushTime: "2023-10-03 09:45:00",
  116. alarmhistoryID: "alarm-003",
  117. taskPriority: "低",
  118. },
  119. ];
  120. /**数据对象*/
  121. const state = reactive({
  122. /**加载显示 */
  123. loading: false,
  124. /**条件查询模块 */
  125. filter: {
  126. /**推送用户 */
  127. pushUser: "",
  128. /**是否推送 */
  129. isPushed: "",
  130. /**推送时间 */
  131. pushTime: "",},
  132. /**表格信息 */
  133. tableModel: [] as PushDto,
  134. /**动态表头 */
  135. dynamicColumns: [
  136. { prop: 'ruleId', label: '规则id' },
  137. { prop: 'pushUserid', label: '推送用户id' },
  138. { prop: 'pushUser', label: '推送用户' },
  139. { prop: 'content', label: '推送内容' },
  140. { prop: 'isPushed', label: '是否推送' },
  141. { prop: 'pushTime', label: '推送时间' },
  142. { prop: 'alarmhistoryID', label: '报警ID' },
  143. { prop: 'taskPriority', label: '优先级' },],
  144. /**分页标识 */
  145. pageInput: {
  146. currentPage: 1,
  147. pageSize: 15,
  148. } as PageInputAlarmFilterModel,
  149. /**分页总数 */
  150. total: 0,
  151. })
  152. onMounted(async () => {
  153. // 初始化分页大小
  154. state.pageInput.pageSize = pageState.pageInput.pageSize;
  155. await onQuery()
  156. init()
  157. eventBus.off('refreshView')
  158. eventBus.on('refreshView', async () => {
  159. await init()
  160. })
  161. console.log()
  162. })
  163. onBeforeMount(() => {
  164. eventBus.off('refreshView')
  165. })
  166. /**
  167. * 页条变化
  168. * @param val
  169. */
  170. const onSizeChange = (val: number) => {
  171. state.pageInput.pageSize = val
  172. init()
  173. }
  174. /**
  175. * 页数 变化
  176. * @param val
  177. */
  178. const onCurrentChange = (val: number) => {
  179. state.pageInput.currentPage = val
  180. init()
  181. }
  182. /**
  183. * 监听变换
  184. */
  185. watch(() => {})
  186. /**条件查询 */
  187. const onQuery = () => {
  188. init()
  189. }
  190. /**初始化 */
  191. const init = async () => {
  192. state.loading = true;
  193. // 模拟后端返回的数据
  194. const mockResponse = {
  195. data: {
  196. list: mockData, // 使用假数据
  197. },
  198. };
  199. // 假设接口返回的数据格式为 { data: { list: [] } }
  200. state.tableModel = mockResponse.data.list ?? [];
  201. state.loading = false;
  202. };
  203. // state.loading = true
  204. // const res:any = await new Api().getList({...state.filter})
  205. // state.tableModel = res?.data?.list ?? []
  206. // state.loading = false
  207. // }
  208. /**重置 */
  209. const onReset=()=>{
  210. // 重置查询条件
  211. state.filter = {
  212. pushUser: "",
  213. isPushed: "",
  214. pushTime: "",
  215. };
  216. // 重新加载数据
  217. init();
  218. }
  219. /**编辑 */
  220. const onDateUpdate=(row)=>{
  221. console.log("编辑行数据:", row);
  222. }
  223. </script>
  224. <style scoped lang="scss">
  225. .fengexian{
  226. margin-top: -3vh;
  227. margin-bottom: 1vh;
  228. }
  229. .el-input,
  230. .el-select {
  231. width: 240px;
  232. }
  233. /* 输入框标签固定四个字符宽度 */
  234. ::v-deep .el-form-item__label {
  235. // 字体大小14,4个字符,12px右间距
  236. width: 14*4px+12px;
  237. justify-content: start;
  238. }
  239. /* 数据表头 设置灰色样式 */
  240. ::v-deep .el-table th.el-table__cell {
  241. background-color: #F6F6F6;
  242. }
  243. </style>