zxl
2026-03-20 d5f3ca51818d635d3c5be7f73984b0e592a23ed4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="7" :sm="8">
            <a-form-item label="告警时间">
              <a-range-picker
                style="width: 100%"
                :value="defaultTime"
                :show-time="{
                  hideDisabledOptions: true,
                  defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('11:59:59', 'HH:mm:ss')],
                }"
                format="YYYY-MM-DD HH:mm:ss"
                @change="onChange"
              />
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="终端名称">
              <j-dict-select-tag
                v-model="queryParam.cameraCode"
                placeholder="请选择设备"
                dictCode="t_camera,name,code"
              />
            </a-form-item>
          </a-col>
 
          <template v-if="toggleSearchStatus">
            <a-col :md="6" :sm="8">
              <a-form-item label="告警类型">
                <j-dict-select-tag
                  v-model="queryParam.algorithmCode"
                  placeholder="请选择告警类型"
                  dictCode="t_sys_algorithm_item,algorithm_name,algorithm_code,algorithm_type='2'"
                />
              </a-form-item>
            </a-col>
            <a-col :md="5" :sm="8">
              <a-form-item label="状态">
                <a-select allowClear v-model="queryParam.audited" placeholder="请选择状态">
                  <a-select-option :value="0"> 未处理 </a-select-option>
                  <a-select-option :value="1"> 已处理 </a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <a-form-item label="所属机构">
                <a-tree-select
                  allow-clear
                  show-search
                  treeNodeFilterProp="title"
                  style="width: 100%"
                  v-model="queryParam.orgCode"
                  :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
                  :treeData="departTree"
                  treeDefaultExpandAll
                  placeholder="请选择机构"
                >
                </a-tree-select>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <a-form-item label="处理结果">
                <a-select allowClear v-model="queryParam.auditResult" placeholder="请选择处理结果">
                  <a-select-option :value="1"> 属实 </a-select-option>
                  <a-select-option :value="2"> 误报 </a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
          </template>
          <a-col :md="6" :sm="8">
            <span style="float: left; overflow: hidden" class="table-page-search-submit-buttons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="resetForm" icon="reload" style="margin-left: 8px">重置</a-button>
              <a-button type="primary" icon="download" style="margin-left: 8px" @click="oilExportXls()">导出</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        class="infoTable"
        rowKey="id"
        :columns="defaultColumns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange"
      >
        <span slot="status" slot-scope="text, record">
          {{ record.auditResult === 0 ? '未处理' : '已处理' }}
        </span>
        <span slot="auditResult" :style="{'color': record.auditResult==1?'red':''}" slot-scope="text, record">
          {{ record.auditResult | filterAudit }}
        </span>
        <span slot="action" slot-scope="text, record">
          <a @click="handleOk(record)">详情</a>
        </span>
      </a-table>
    </div>
 
    <!-- table区域-end -->
 
    <!-- 告警详情 -->
    <AnalysisDetailModal :visible="show" @modalClose="modalClose" :infoObj="infoObj" />
  </a-card>
</template>
 
<script>
import { JeecgListMixin } from '@tievd/cube-block/lib/mixins/JeecgListMixin'
import OiloutEventInfo from './components/OiloutEventInfo.vue'
import moment from 'moment'
import { getAction, downFile } from '@tievd/cube-block/lib/api/manage'
import { queryDepartTreeList } from '@tievd/cube-block/lib/api/api'
import AnalysisDetailModal from './components/AnalysisDetailModal.vue'
var time
export default {
  name: 'OiloutEventList',
  mixins: [JeecgListMixin],
  components: {
    OiloutEventInfo,
    AnalysisDetailModal,
  },
 
  data() {
    return {
      description: '告警查询',
      // 表头
      columns: [],
      defaultTime: [],
      show: false,
      infoObj: {},
      // 列定义
      defaultColumns: [
        // {
        //   title: '序号',
        //   dataIndex: '',
        //   key: 'rowIndex',
        //   width: 60,
        //   align: 'center',
        //   customRender: function (t, r, index) {
        //     return parseInt(index) + 1
        //   },
        // },
        {
          title: '时间',
          align: 'center',
          dataIndex: 'eventTime',
        },
        {
          title: '告警类型',
          align: 'center',
          dataIndex: 'algorithmName',
        },
        {
          title: '所属阶段',
          align: 'center',
          dataIndex: 'eventPhrase_dictText',
        },
        {
          title: '终端名称',
          align: 'center',
          dataIndex: 'cameraName',
        },
        {
          title: '所属网关',
          align: 'center',
          dataIndex: 'deviceName',
        },
        {
          title: '所属机构',
          align: 'center',
          dataIndex: 'orgName',
        },
        {
          title: '状态',
          align: 'center',
          scopedSlots: { customRender: 'status' },
        },
        {
          title: '处理结果',
          align: 'center',
          dataIndex: 'auditResult',
          scopedSlots: { customRender: 'auditResult' },
        },
        {
          title: '处理人',
          align: 'center',
          dataIndex: 'auditUser',
        },
        {
          title: '处理时间',
          align: 'center',
          dataIndex: 'auditTime',
        },
        {
          title: '操作',
          dataIndex: 'action',
          width: 150,
          align: 'center',
          scopedSlots: { customRender: 'action' },
        },
      ],
      queryParam: {},
      dataSource1: [
        {
          id: 1,
        },
      ],
      url: {
        list: '/jyz/oiloutEvent/list',
        // delete: '/jyz/oiloutEvent/delete',
        // deleteBatch: '/jyz/oiloutEvent/deleteBatch',
        exportXlsUrl: '/jyz/oiloutEvent/exportXls',
      },
      selectOrg: '',
      departTree: [],
    }
  },
  filters: {
    filterAudit(val) {
      let text = ''
      switch (val) {
        case 1:
          text = '属实'
          break
        case 2:
          text = '误报'
          break
        default:
          break
      }
      return text
    },
  },
  methods: {
    loadTreeData() {
      queryDepartTreeList({myself: true}).then((res) => {
        if (res.success) {
          this.departTree = []
          for (let i = 0; i < res.result.length; i++) {
            let temp = res.result[i]
            this.cleanData(temp)
            this.departTree.push(temp)
          }
        }
      })
    },
 
    cleanData(e) {
      e.key = e.orgCode
      e.value = e.orgCode
      e.disabled = e.orgCategory === '3' ? false : true
      if (e.children != null) {
        for (let i = 0; i < e.children.length; i++) {
          this.cleanData(e.children[i])
        }
      }
    },
 
    moment,
    // 重置表单
    resetForm() {
      this.defaultTime = []
      this.queryParam = {}
      this.loadTreeData()
      this.loadData()
    },
    // 监听时间
    onChange(date, dateString) {
      console.log(dateString)
      this.defaultTime = dateString
      this.queryParam.startTime = dateString[0]
      this.queryParam.endTime = dateString[1]
    },
    onTreeNodeSelect(id, node) {
      this.selectOrg = this.queryParam.orgCode = node.selectedNodes[0].data.props.orgCode
      console.log(id, this.selectOrg)
      this.loadData()
    },
    getImportXlsUrl() {
      return window._CONFIG['domianURL'] + this.url.importXlsUrl
    },
    // 打开弹窗
    handleOk(data) {
      console.log(data)
      this.infoObj = JSON.parse(JSON.stringify(data))
      this.show = true
    },
    // 关闭弹窗
    modalClose(data) {
      this.show = false
      if (data) this.loadData() //有返回值代表请求成功
    },
    // 下载导出
    oilExportXls() {
      if (typeof time == 'undefined') {
        this.$notification.open({
          message: '告警查询导出中...',
          description: '请耐心等待...',
          style: {
            width: '250px',
            marginLeft: '134px',
            marginTop: '28px',
            marginRight: '10px',
            backgroundColor: '#fff',
            boxShadow: ' 0 4px 12px rgba(0,0,0,.15)',
          },
          duration: null,
          icon: <a-icon type="smile" style="color: #108ee9" />,
        })
        this.getZip()
        time = setInterval(() => {
          this.getZip()
        }, 5000)
      } else {
        this.$message.warning('导出任务进行中,请稍后再试...')
        // clearInterval(time)
        // this.getZip()
        // time = setInterval(() => {
        //   this.getZip()
        // }, 5000)
      }
    },
    // 轮询网络请求
    getZip() {
      getAction('/jyz/oiloutEvent/exportZip', this.queryParam).then((res) => {
        console.log(res)
        if (res.code === 200) {
          if (res.result === 0) {
          } else {
            clearInterval(time) //关闭定时器
            time = undefined
            this.$notification.destroy()
            console.log("已获得导出成功结果");
            downFile('/jyz/oilEvent/getExportFile', { fileName: '告警查询', type: 2 }).then((res) => {
              if (!res) {
                this.$message.error('文件下载失败')
                return
              }
              this.$message.success('告警查询文件下载成功!')
              let blob = new Blob([res], { type: 'application/zip;charset=UTF-8' }) //
              let downloadElement = document.createElement('a')
              let href = window.URL.createObjectURL(blob) //创建下载的链接
              downloadElement.href = href
              downloadElement.download = '告警查询' //下载后文件名
              document.body.appendChild(downloadElement)
              downloadElement.click() //点击下载
              document.body.removeChild(downloadElement) //下载完成移除元素
              window.URL.revokeObjectURL(href) //释放掉blob对象
            })
          }
        } else {
          this.$message.error(res.message)
        }
      })
    },
  },
 
  created() {
    this.loadTreeData()
  },
}
</script>
<style scoped lang="less">
.table-top {
  margin-bottom: 16px;
  height: 32.5px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}
.query-form {
  display: flex;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}
@import '~@assets/less/common.less';
</style>