index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <div class="app-container position-r">
  3. <div class="dark-el-input dark-el-button">
  4. <el-form ref="queryForm" size="small" :inline="true" popper-class="cpp-popper">
  5. <el-form-item label="时间">
  6. <el-date-picker
  7. :clearable="false"
  8. v-model="dateTime"
  9. type="datetimerange"
  10. range-separator="至"
  11. start-placeholder="开始日期"
  12. end-placeholder="结束日期"
  13. :default-time="['00:00:00', '23:45:00']" popper-class="cpp-popper"
  14. :picker-options="pickerOptions"
  15. />
  16. </el-form-item>
  17. <el-form-item label="场站名称">
  18. <el-select v-model="stationCode" placeholder="请选择" popper-class="cpp-popper">
  19. <el-option
  20. v-for="item in stationList"
  21. :key="item.value"
  22. :label="item.label"
  23. :value="item.value">
  24. </el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="告警类型">
  28. <el-select v-model="alarmType" clearable popper-class="cpp-popper">
  29. <el-option
  30. v-for="item in alarmTypes"
  31. :key="item.value"
  32. :label="item.label"
  33. :value="item.value">
  34. </el-option>
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item>
  38. <el-button type="primary" style="margin-left: 5px" icon="el-icon-search" @click="beforeQuery">查询
  39. </el-button>
  40. </el-form-item>
  41. <el-form-item>
  42. <el-button type="primary" style="margin-left: 5px" icon="el-icon-download" @click="exportFile">导出
  43. </el-button>
  44. </el-form-item>
  45. </el-form>
  46. </div>
  47. <div class="top-badge position-a" style="top: 20px;right: 2vw;">
  48. <el-badge v-loading="loading" :value="this.alarmNum">
  49. <img src="../../assets/images/svg/remind.svg" width="30px"/>
  50. </el-badge>
  51. </div>
  52. <div class="dark-el-button">
  53. <el-button type="primary" @click="acknowledgeByStationCode">全部确认
  54. </el-button>
  55. </div>
  56. <div style="padding-top: 10px">
  57. <vxe-table
  58. ref="xTable"
  59. align="center"
  60. class="mytable-style"
  61. auto-resize
  62. border
  63. height="calc(60vh)"
  64. resizable
  65. export-config
  66. highlight-current-row
  67. show-overflow
  68. :data="tableData"
  69. :loading="loading"
  70. :radio-config="{trigger: 'row'}">
  71. <vxe-table-column field="stationCode" title="所属场站" :formatter="stationCodeFormat"></vxe-table-column>
  72. <vxe-table-column field="startTime" title="开始时间"></vxe-table-column>
  73. <vxe-table-column field="endTime" title="结束时间"></vxe-table-column>
  74. <vxe-table-column field="alarmType" title="告警类型" :formatter="alarmTypeFormat"></vxe-table-column>
  75. <vxe-table-column field="msg" title="告警描述"></vxe-table-column>
  76. <vxe-table-column field="voltage" title="操作人"></vxe-table-column>
  77. <vxe-table-column field="" title="操作">
  78. <template v-slot="{ row }">
  79. <svg-icon v-if="row.status !== 0" slot="prefix" h icon-class="alarm1" class="el-input__icon input-icon"/>
  80. <svg-icon v-if="row.status === 0" slot="prefix" viewBox="0 0 5 5" icon-class="alarm2"
  81. class="el-input__icon input-icon"
  82. @click="acknowledge(row)"/>
  83. </template>
  84. </vxe-table-column>
  85. </vxe-table>
  86. <vxe-pager
  87. background
  88. :loading="loading"
  89. :current-page.sync="currentPage"
  90. :page-size.sync="pageSize"
  91. :total="total"
  92. @page-change="handlePageChange"
  93. :layouts="['PrevJump', 'PrevPage', 'JumpNumber', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total']">
  94. </vxe-pager>
  95. </div>
  96. </div>
  97. </template>
  98. <script>
  99. export default {
  100. name: 'inverterinfo',
  101. data() {
  102. return {
  103. alarmType: '',
  104. alarmTypes: [
  105. {
  106. label: "站端通道告警",
  107. value: "E1"
  108. },
  109. {
  110. label: "站端上报告警",
  111. value: "E2"
  112. },
  113. {
  114. label: "站端硬件报警",
  115. value: "E3"
  116. },
  117. {
  118. label: "中心解析告警",
  119. value: "E4"
  120. },
  121. {
  122. label: "通用告警",
  123. value: "E5"
  124. }
  125. ],
  126. dateTime: [new Date(new Date().toLocaleDateString()).getTime(), new Date(new Date().toLocaleDateString()).getTime() + 60 * 60 * 24 * 1000 - 5 * 1000 * 60],
  127. total: 0,
  128. sortOrder: 'asc',
  129. pageSize: 15,
  130. currentPage: 1,
  131. stationList: [],
  132. stationCode: [],
  133. searchForm: {},
  134. tableData: [],
  135. loading: false,
  136. alarmNum: 0,
  137. // 日期使用
  138. pickerOptions: {
  139. disabledDate: (time) => {
  140. return time.getTime() >= new Date(new Date().toLocaleDateString()).getTime() + 60 * 60 * 24 * 1000 - 1
  141. }
  142. },
  143. }
  144. },
  145. created() {
  146. // 获取场站下拉列表
  147. this.getStationCode()
  148. },
  149. mounted() {
  150. },
  151. computed: {},
  152. methods: {
  153. exportFile(){
  154. this.$refs.xTable.exportData({
  155. filename: '告警管理' + new Date().getTime(),
  156. type: 'csv',
  157. isHeader: true,
  158. isFooter: true,
  159. data: this.tableData
  160. })
  161. },
  162. beforeQuery() {
  163. this.currentPage = 1
  164. this.pageSize = 10
  165. this.dataQuery()
  166. },
  167. stationCodeFormat({cellValue, row, column}) {
  168. const item = this.stationList.find(item => item.value === cellValue)
  169. return item ? item.label : ''
  170. },
  171. alarmTypeFormat({cellValue, row, column}) {
  172. const item = this.alarmTypes.find(item => item.value === cellValue)
  173. return item ? item.label : ''
  174. },
  175. handlePageChange({currentPage, pageSize}) {
  176. this.currentPage = currentPage
  177. this.pageSize = pageSize
  178. this.dataQuery();
  179. },
  180. dataQuery() {
  181. let startTime = Math.round(this.dateTime[0])
  182. let endTime = Math.round(this.dateTime[1])
  183. if (endTime <= startTime) {
  184. this.$message.error("开始时间不能大于结束时间")
  185. return
  186. }
  187. this.loading = true
  188. let queryParams = {
  189. "currentPage": this.currentPage,
  190. "pageSize": this.pageSize,
  191. "stationCode": this.stationCode,
  192. "alarmType": this.alarmType,
  193. "startTime": startTime,
  194. "endTime": endTime
  195. }
  196. this.$axios.get('/abnormalAlarm/getByTimeBetweenAndAlarmTypeAndStationCode', {params: queryParams}).then(response => {
  197. this.tableData = response.data.records
  198. this.total = response.data.total
  199. this.$axios.get('/abnormalAlarm/getCountByStatusAndStationCode', {
  200. params: {
  201. "status": 0,
  202. "stationCode": this.stationCode,
  203. }
  204. }).then(response => {
  205. this.alarmNum = response.data
  206. this.loading = false
  207. })
  208. }).catch(() => {
  209. this.loading = false
  210. })
  211. },
  212. async getStationCode() {
  213. await this.$axios({url: '/electricfield/all', method: 'get'}).then(response => {
  214. this.stationList = response.data
  215. if (this.stationList.length > 0) {
  216. // 默认查全部
  217. this.stationList.push({value: 'all', label: '全部'})
  218. const sortItems = (arr, sortValue) => {
  219. return arr.sort((a, b) => {
  220. if (a.value === sortValue) {
  221. return -1;
  222. }
  223. if (b.value === sortValue) {
  224. return 1;
  225. }
  226. return a.value - b.value; // 示例:按id升序排序
  227. });
  228. };
  229. const sortValue = 'all';
  230. const sortedItems = sortItems(this.stationList, sortValue);
  231. this.stationList = sortedItems
  232. this.stationCode = this.stationList[0].value
  233. this.dataQuery()
  234. }
  235. })
  236. },
  237. acknowledgeByStationCode() {
  238. this.$confirm('是否确认对 【场站:' + this.formatStation(this.stationCode) + '】 进行"全部确认"操作?', '提示', {
  239. confirmButtonText: '确定',
  240. cancelButtonText: '取消',
  241. type: 'warning'
  242. }).then(() => {
  243. this.$axios.get('/abnormalAlarm/acknowledgeByStationCode', {
  244. params: {
  245. "stationCode": this.stationCode,
  246. }
  247. }).then(response => {
  248. this.beforeQuery()
  249. this.$message.info("确认成功!")
  250. }).catch(() => {
  251. this.loading = false
  252. })
  253. })
  254. },
  255. acknowledge(row) {
  256. this.$confirm('是否对【' + row.msg + '】进行确认操作?', '提示', {
  257. confirmButtonText: '确定',
  258. cancelButtonText: '取消',
  259. type: 'warning'
  260. }).then(() => {
  261. row.status = 1
  262. this.$axios.post('/abnormalAlarm/updateStatus1', row).then(response => {
  263. this.$message.info("【" + row.msg + "】 已确认!")
  264. this.beforeQuery()
  265. }).catch(() => {
  266. this.loading = false
  267. })
  268. })
  269. },
  270. formatStation(stationCode) {
  271. let name = '未知场站名称'
  272. this.stationList.forEach(s => {
  273. if (stationCode == s.value) {
  274. name = s.label
  275. return
  276. }
  277. })
  278. return name
  279. },
  280. }
  281. }
  282. </script>