index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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="Data.Filter" @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="油机ID">
  11. <el-input v-model="Data.Filter.fuelld" placeholder="请输入油机ID" 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="Data.Filter.gasStation" 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-input v-model="Data.Filter.serialNumber" placeholder="请输入序列号" clearable></el-input>
  22. </el-form-item>
  23. </el-col>
  24. <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
  25. <el-form-item label="报警来源">
  26. <el-input v-model="Data.Filter.alarmSource" placeholder="请输入报警来源" clearable></el-input>
  27. </el-form-item>
  28. </el-col>
  29. <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
  30. <el-form-item label="报警类型">
  31. <el-input v-model="Data.Filter.alarmType" placeholder="请输入报警类型" clearable></el-input>
  32. </el-form-item>
  33. </el-col>
  34. <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
  35. <el-form-item label="报警设备">
  36. <el-input v-model="Data.Filter.alarmDevice" placeholder="请输入报警设备" clearable></el-input>
  37. </el-form-item>
  38. </el-col>
  39. <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
  40. <el-form-item label="报警时间">
  41. <el-date-picker v-model="Data.time" type="datetimerange" value-format="YYYY-MM-DD HH:mm:ss"
  42. range-separator="To" start-placeholder="开始日期" end-placeholder="结束日期" />
  43. </el-form-item>
  44. </el-col>
  45. <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
  46. <el-form-item>
  47. </el-form-item>
  48. </el-col>
  49. </el-form-item>
  50. </el-form>
  51. <hr>
  52. <!-- 按钮 -->
  53. <el-row justify="space-between" class="submit-button" style="margin-bottom:-6px">
  54. <el-row>
  55. <el-button type="primary" icon="ele-Search" @click="onQuery"> 查询 </el-button>
  56. <el-button type="primary" icon="ele-RefreshRight" @click="onReset"> 重置 </el-button>
  57. <!-- 在现有模板中修改按钮的点击事件 -->
  58. <el-button
  59. v-auth="'api:admin:file:upload-file'"
  60. type="primary"
  61. icon="ele-Upload"
  62. @click="handlePushRules"
  63. >
  64. 执行推送规则
  65. </el-button>
  66. </el-row>
  67. </el-row>
  68. </el-card>
  69. </el-col>
  70. <!--表格-->
  71. <el-col :xs="24">
  72. <el-card class="my-fill mt8" shadow="hover">
  73. <!-- 修改表格引用,添加ref -->
  74. <el-table ref="tableRef" v-loading="Data.loading" stripe :data="Data.tableModel"
  75. style="width: 100%;overflow: hidden;">
  76. <!-- 多选框 -->
  77. <el-table-column type="selection" width="55" fixed="left"></el-table-column>
  78. <el-table-column v-for="column in Data.dynamicColumns" :key="column.prop" :prop="column.prop"
  79. :label="column.label" />
  80. <el-table-column label="操作" fixed="right" header-align="center" align="center" class="right-operation"
  81. width="150">
  82. <template #default="{ row }">
  83. <el-link class="my-el-link mr12 ml12" :href="row.linkUrl" type="primary" icon="ele-Download" size="small"
  84. :underline="false" target="_blank" @click="toList">报警推送记录</el-link>
  85. <el-link class="my-el-link mr12 ml12" :href="row.linkUrl" type="primary" icon="ele-Edit" size="small"
  86. :underline="false" target="_blank" @click="toPage(row)">油机详情</el-link>
  87. <el-link class="my-el-link mr12 ml12" :href="row.linkUrl" type="primary" icon="ele-InfoFilled" size="small"
  88. :underline="false" target="_blank">诊断说明</el-link>
  89. </template>
  90. </el-table-column>
  91. </el-table>
  92. <div class="my-flex my-flex-end" style="margin-top: 20px">
  93. <el-pagination
  94. v-model:currentPage="pageState.pageInput.currentPage"
  95. v-model:page-size="pageState.pageInput.pageSize"
  96. :total="Data.total"
  97. :page-sizes="[5, 10, 15, 25, 50, 100]"
  98. small
  99. background
  100. @size-change="onSizeChange"
  101. @current-change="onCurrentChange"
  102. layout="total, sizes, prev, pager, next, jumper" />
  103. </div>
  104. </el-card>
  105. </el-col>
  106. </el-row>
  107. </div>
  108. </template>
  109. <script setup lang="ts" name="authorize/fuelingsdk">
  110. import { onMounted, reactive, ref, watch } from "vue";
  111. import { ElMessage, ElTable } from 'element-plus'
  112. import { alarmFilterModel_SearchFilter, alarmFilterModel, PageInputAlarmFilterModel, PushRulesQuery } from "/@/api/admin/reportManagement/alarm/alarmDto";
  113. import { AlarmApi } from "/@/api/admin/reportManagement/alarm/alarmApi";
  114. import { useDynamicPageSize } from "/@/composables/useDynamicPageSize";
  115. import router from "/@/router";
  116. import { PushRulesApi } from "/@/api/admin/reportManagement/alarm/alarmApi";
  117. import { ResultOutputBoolean } from "/@/api/admin/reportManagement/alarm/alarmDto";
  118. const pushRulesApi = new PushRulesApi();
  119. const tableRef = ref<InstanceType<typeof ElTable>>(); // 添加表格引用
  120. // 使用组合式函数获取分页状态
  121. const pageState = useDynamicPageSize(10, 15);
  122. /**页面对象 */
  123. const Data = reactive({
  124. time: '',
  125. /**加载显示 */
  126. loading: false,
  127. /**条件查询模块 */
  128. Filter: {
  129. /**油机id */
  130. fuelld: "",
  131. /**加油站 */
  132. gasStation: "",
  133. /**油机号*/
  134. name: "",
  135. /**序列号*/
  136. serialNumber: "",
  137. /**报警来源 */
  138. alarmSource: "",
  139. /**报警类型 */
  140. alarmType: "",
  141. /**报警描述 */
  142. alarmDescription: "",
  143. /**报警设备 */
  144. alarmDevice: "",
  145. /** 油枪*/
  146. nozzleControlName: "",
  147. /**创建开始的时间 */
  148. CreateBeginTime: "",
  149. /**创建结束的时间 */
  150. CreateEndTime: "",
  151. } as alarmFilterModel_SearchFilter,
  152. /**表格信息 */
  153. tableModel: [] as Array<alarmFilterModel>,
  154. /**动态表头 */
  155. dynamicColumns: [
  156. // { prop: 'fuelld', label: '油机id' },
  157. { prop: 'gasStation', label: '加油站名称' },
  158. { prop: 'name', label: '油机号' },
  159. { prop: 'serialNumber', label: '序列号' },
  160. { prop: 'alarmSource', label: '报警来源' },
  161. { prop: 'alarmType', label: '报警类型' },
  162. { prop: 'alarmDescription', label: '报警描述' },
  163. { prop: 'alarmDevice', label: '报警设备' },
  164. { prop: 'nozzleControlName', label: '油枪' },
  165. { prop: 'createdDate', label: '报警时间' },
  166. { prop: '', label: '诊断说明' },
  167. { prop: '', label: '是否推送' },
  168. // { prop: 'alarmHistoryID', label: '报警历史ID' },
  169. ],
  170. /**分页标识 */
  171. pageInput: {
  172. currentPage: 1,
  173. pageSize: 15,
  174. } as PageInputAlarmFilterModel,
  175. /**分页总数 */
  176. total: 0,
  177. })
  178. /**初始化 */
  179. const init = async () => {
  180. Data.loading = true
  181. const res: any = await new AlarmApi().getPage({ ...Data.pageInput, filter: Data.Filter })
  182. Data.tableModel = res?.data?.list ?? []
  183. Data.total = res?.data?.total ?? 0
  184. Data.loading = false
  185. }
  186. onMounted(async () => {
  187. // 初始化分页大小
  188. Data.pageInput.pageSize = pageState.pageInput.pageSize;
  189. await onQuery()
  190. init()
  191. })
  192. /**
  193. * 监听时间变换
  194. */
  195. watch(() => Data.time, (newVal) => {
  196. if (newVal.length === 0) {
  197. return
  198. }
  199. Data.Filter.CreateBeginTime = newVal?.[0].toString()
  200. Data.Filter.CreateEndTime = newVal?.[1].toString()
  201. })
  202. /**条件查询 */
  203. const onQuery = () => {
  204. init()
  205. }
  206. /**重置查询条件 */
  207. const resetQuery = () => {
  208. Data.Filter.fuelld = ''
  209. Data.Filter.gasStation = ''
  210. Data.Filter.name = ''
  211. Data.Filter.serialNumber = ''
  212. Data.Filter.alarmSource = ''
  213. Data.Filter.alarmType = ''
  214. Data.Filter.alarmDescription = ''
  215. Data.Filter.alarmDevice = ''
  216. Data.Filter.nozzleControlName = ''
  217. Data.Filter.CreateBeginTime = ''
  218. Data.Filter.CreateEndTime = ''
  219. Data.time = ''
  220. }
  221. /**重置 */
  222. const onReset = () => {
  223. resetQuery()
  224. init()
  225. }
  226. /**
  227. * 页条变化
  228. * @param val
  229. */
  230. const onSizeChange = (val: number) => {
  231. Data.pageInput.pageSize = val
  232. init()
  233. }
  234. /**
  235. * 页数 变化
  236. * @param val
  237. */
  238. const onCurrentChange = (val: number) => {
  239. Data.pageInput.currentPage = val
  240. init()
  241. }
  242. const toPage = (row: {fuelId: any;
  243. }) => {
  244. router.push({ path: `/statement/${row.fuelId}` })
  245. }
  246. const toList = () =>{
  247. router.push({ path:`/authorize/statement/alarmQuery`})
  248. }
  249. /**
  250. * 执行推送规则
  251. */
  252. const handlePushRules = async () => {
  253. const selection = tableRef.value?.getSelectionRows() || [];
  254. if (selection.length === 0) {
  255. ElMessage.warning('请至少选择一行数据');
  256. return;
  257. }
  258. const alarmHistoryIDs: string[] = selection
  259. .map(row => row.alarmHistoryID)
  260. .filter((id): id is string => !!id);
  261. if (alarmHistoryIDs.length === 0) {
  262. ElMessage.warning('所选项中没有有效的报警历史ID');
  263. return;
  264. }
  265. const idsString = alarmHistoryIDs.join(',');
  266. try {
  267. const res = await pushRulesApi.executePushRuleImmediately(undefined, {
  268. query: {
  269. alarmHistoryID: idsString,
  270. },
  271. });
  272. if (res.success && res.data) {
  273. ElMessage.success(`推送成功`);
  274. } else {
  275. ElMessage.error(`推送失败:${res.msg || '未知错误'}`);
  276. }
  277. } catch (error: any) {
  278. console.error('推送失败', error);
  279. ElMessage.error('报警推送过程中发生异常');
  280. }
  281. };
  282. </script>
  283. <style scoped lang="scss">
  284. .el-input,
  285. .el-select {
  286. width: 240px;
  287. }
  288. /* 输入框标签固定四个字符宽度 */
  289. ::v-deep .el-form-item__label {
  290. // 字体大小14,4个字符,12px右间距
  291. width: 14*4px+12px;
  292. justify-content: start;
  293. }
  294. /* 数据表头 设置灰色样式 */
  295. ::v-deep .el-table th.el-table__cell {
  296. background-color: #F6F6F6;
  297. }
  298. </style>