add: 历史模块添加设备报警记录
This commit is contained in:
249
acs/nladmin-ui/src/views/acs/history/deviceErrorInfo/index.vue
Normal file
249
acs/nladmin-ui/src/views/acs/history/deviceErrorInfo/index.vue
Normal file
@@ -0,0 +1,249 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!--工具栏-->
|
||||
<div class="head-container">
|
||||
<div v-if="crud.props.searchToggle">
|
||||
<!-- 搜索 -->
|
||||
<label class="el-form-item-label">设备编码</label>
|
||||
<el-input
|
||||
v-model="query.device_code"
|
||||
clearable
|
||||
placeholder="设备编码"
|
||||
style="width: 185px;"
|
||||
class="filter-item"
|
||||
@keyup.enter.native="crud.toQuery"
|
||||
/>
|
||||
<el-input
|
||||
v-model="query.error_code"
|
||||
clearable
|
||||
placeholder="报警编码"
|
||||
style="width: 185px;"
|
||||
class="filter-item"
|
||||
@keyup.enter.native="crud.toQuery"
|
||||
/>
|
||||
<el-input
|
||||
v-model="query.error_info"
|
||||
clearable
|
||||
placeholder="报警信息"
|
||||
style="width: 185px;"
|
||||
class="filter-item"
|
||||
@keyup.enter.native="crud.toQuery"
|
||||
/>
|
||||
<!-- <el-date-picker
|
||||
v-model="query.error_time"
|
||||
clearable
|
||||
placeholder="错误时间"
|
||||
format="yyyy-MM-dd HH:mm:ss"
|
||||
:range-separator="'至'"
|
||||
:start-placeholder="'开始时间'"
|
||||
:end-placeholder="'结束时间'"
|
||||
class="date-item"
|
||||
@change="handleDateChange"
|
||||
@keyup.enter.native="crud.toQuery"
|
||||
/> -->
|
||||
<!-- <el-date-picker
|
||||
v-model="query.start_time"
|
||||
clearable
|
||||
placeholder="错误时间"
|
||||
format="yyyy-MM-dd HH:mm:ss"
|
||||
class="date-item"
|
||||
@keyup.enter.native="crud.toQuery"
|
||||
/> -->
|
||||
<el-date-picker
|
||||
v-model="query.timeRange"
|
||||
type="daterange"
|
||||
clearable
|
||||
range-separator="至"
|
||||
start-placeholder="开始时间"
|
||||
end-placeholder="结束时间"
|
||||
format="yyyy-MM-dd HH:mm:ss"
|
||||
class="date-item"
|
||||
@keyup.enter.native="crud.toQuery"
|
||||
/>
|
||||
<!-- <el-date-picker
|
||||
v-model="timeRange"
|
||||
type="datetimerange"
|
||||
clearable
|
||||
picker-options="{
|
||||
format: 'yyyy-MM-dd HH:mm:ss',
|
||||
shortcuts: [{
|
||||
text: '最近一小时',
|
||||
onClick(picker) {
|
||||
const end = new Date();
|
||||
const start = new Date(end.getTime() - 3600000);
|
||||
picker.$emit('pick', [start, end]);
|
||||
// 将时间范围值赋值给start_time和end_time
|
||||
this.start_time = start;
|
||||
this.end_time = end;
|
||||
}
|
||||
}, {
|
||||
text: '最近一天',
|
||||
onClick(picker) {
|
||||
const end = new Date();
|
||||
const start = new Date(end.getTime() - 24 * 3600000);
|
||||
picker.$emit('pick', [start, end]);
|
||||
// 将时间范围值赋值给start_time和end_time
|
||||
this.start_time = start;
|
||||
this.end_time = end;
|
||||
}
|
||||
}, {
|
||||
text: '最近一周',
|
||||
onClick(picker) {
|
||||
const end = new Date();
|
||||
const start = new Date(end.getTime() - 7 * 24 * 3600000);
|
||||
picker.$emit('pick', [start, end]);
|
||||
// 将时间范围值赋值给start_time和end_time
|
||||
this.start_time = start;
|
||||
this.end_time = end;
|
||||
}
|
||||
}]
|
||||
}"
|
||||
/> -->
|
||||
<rrOperation :crud="crud" />
|
||||
</div>
|
||||
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
||||
<crudOperation :permission="permission">
|
||||
<el-button
|
||||
slot="left"
|
||||
class="filter-item"
|
||||
type="warning"
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
:loading="downLoadDeviceErrorLogging"
|
||||
@click="doExportDeviceErrorLogging()"
|
||||
>
|
||||
{{ $t('common.Export') }}
|
||||
</el-button>
|
||||
</crudOperation>
|
||||
<!--表单组件-->
|
||||
<el-dialog
|
||||
:close-on-click-modal="false"
|
||||
:before-close="crud.cancelCU"
|
||||
:visible.sync="crud.status.cu"
|
||||
:title="crud.status.title"
|
||||
width="500px"
|
||||
>
|
||||
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px" />
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="text" @click="crud.cancelCU">取消</el-button>
|
||||
<el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!--表格渲染-->
|
||||
<el-table
|
||||
ref="table"
|
||||
v-loading="crud.loading"
|
||||
:data="crud.data"
|
||||
size="small"
|
||||
style="width: 100%;"
|
||||
@selection-change="crud.selectionChangeHandler"
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column prop="device_code" label="设备编码" />
|
||||
<el-table-column prop="error_code" label="报警编码" />
|
||||
<el-table-column prop="error_info" label="报警信息" />
|
||||
<el-table-column prop="error_time" label="报警时间" />
|
||||
<el-table-column
|
||||
v-permission="['admin','acsDeviceErrorLog:edit','acsDeviceErrorLog:del']"
|
||||
label="操作"
|
||||
width="150px"
|
||||
align="center"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<udOperation
|
||||
:data="scope.row"
|
||||
:permission="permission"
|
||||
:disabled-edit="true"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!--分页组件-->
|
||||
<pagination />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CRUD, { crud, form, header, presenter } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
import crudAcsDeviceErrorLog from '@/api/acs/history/acsDeviceErrorLog'
|
||||
import { download } from '@/api/data'
|
||||
import { downloadFile } from '@/utils'
|
||||
|
||||
const defaultForm = { error_log_uuid: null, device_code: null, error_code: null, error_info: null, error_time: null }
|
||||
export default {
|
||||
name: 'DeviceErrorLog',
|
||||
components: { pagination, crudOperation, rrOperation, udOperation },
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
cruds() {
|
||||
return CRUD({
|
||||
title: '设备报警记录',
|
||||
url: 'api/deviceErrorLog',
|
||||
idField: 'error_log_uuid',
|
||||
sort: 'error_log_uuid,desc',
|
||||
crudMethod: {
|
||||
...crudAcsDeviceErrorLog },
|
||||
optShow: {
|
||||
add: false,
|
||||
edit: false,
|
||||
del: false,
|
||||
download: false
|
||||
}
|
||||
})
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
permission: {
|
||||
add: ['admin', 'deviceErrorLog:add'],
|
||||
edit: ['admin', 'deviceErrorLog:edit'],
|
||||
del: ['admin', 'adeviceErrorLog:del']
|
||||
},
|
||||
rules: {},
|
||||
queryTypeOptions: [
|
||||
{ key: 'device_code', display_name: '设备编码' },
|
||||
{ key: 'error_code', display_name: '报警编码' },
|
||||
{ key: 'error_info', display_name: '报警信息' }
|
||||
]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 钩子:在获取表格数据之前执行,false 则代表不获取数据
|
||||
[CRUD.HOOK.beforeRefresh]() {
|
||||
return true
|
||||
},
|
||||
handleDateChange() {
|
||||
/* if (this.timeRange && this.timeRange.length === 2) {
|
||||
this.crud.url = 'api/deviceErrorLog?page=0&size=10&sort=error_log_uuid,desc' +
|
||||
'&start_time=' + this.timeRange[0] + '&end_time=' + this.timeRange[1]
|
||||
} else {
|
||||
this.crud.url = 'api/deviceErrorLog?page=0&size=10&sort=error_log_uuid,desc'
|
||||
} */
|
||||
},
|
||||
doExportDeviceErrorLogging() {
|
||||
this.downLoadTaskLogging = true
|
||||
const params = {
|
||||
device_code: this.query.device_code,
|
||||
error_code: this.query.error_code,
|
||||
error_info: this.query.error_info,
|
||||
start_time: this.crud.createTime,
|
||||
end_time: this.crud.endTime
|
||||
}
|
||||
const url = '/api/deviceErrorLog/download'
|
||||
download(url, params).then(result => {
|
||||
downloadFile(result, this.crud.title + '数据', 'csv')
|
||||
this.downLoadTaskTreeLogging = false
|
||||
}).catch(() => {
|
||||
this.downLoadTaskTreeLogging = false
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user