<template>
|
<div class="app-container">
|
<el-row :gutter="10" class="mb8">
|
<el-col :span="1.5">
|
<el-button
|
type="primary"
|
plain
|
icon="el-icon-plus"
|
size="mini"
|
@click="handleAdd"
|
v-hasPermi="['ycl:threshold:add']"
|
>新增
|
</el-button>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button
|
type="success"
|
plain
|
icon="el-icon-edit"
|
size="mini"
|
:disabled="single"
|
@click="handleUpdate"
|
v-hasPermi="['ycl:threshold:edit']"
|
>修改
|
</el-button>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button
|
type="danger"
|
plain
|
icon="el-icon-delete"
|
size="mini"
|
:disabled="multiple"
|
@click="handleDelete"
|
v-hasPermi="['ycl:threshold:remove']"
|
>删除
|
</el-button>
|
</el-col>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
</el-row>
|
|
<el-table v-loading="loading" :data="thresholdList" @selection-change="handleSelectionChange">
|
<el-table-column type="selection" width="55" align="center"/>
|
<el-table-column label="设备类型" align="center" prop="monitorType">
|
<template slot-scope="scope">
|
<span v-show="scope.row['monitorType'] === '1'">人脸</span>
|
<span v-show="scope.row['monitorType'] === '2'">车辆</span>
|
<span v-show="scope.row['monitorType'] === '3'">视频</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="超时天数" align="center" prop="timeout"/>
|
<el-table-column label="指标" align="center" prop="indicator">
|
<template slot-scope="scope">
|
<div v-for="item in JSON.parse(scope.row.indicator)" :key="item">
|
{{ item.label }}:{{ item.value }}
|
</div>
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<template slot-scope="scope">
|
<el-button
|
size="mini"
|
type="text"
|
icon="el-icon-edit"
|
@click="handleUpdate(scope.row)"
|
v-hasPermi="['ycl:threshold:edit']"
|
>修改
|
</el-button>
|
<el-button
|
size="mini"
|
type="text"
|
icon="el-icon-delete"
|
@click="handleDelete(scope.row)"
|
v-hasPermi="['ycl:threshold:remove']"
|
>删除
|
</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<pagination
|
v-show="total>0"
|
:total="total"
|
:page.sync="queryParams.pageNum"
|
:limit.sync="queryParams.pageSize"
|
@pagination="getList"
|
/>
|
|
<!-- 添加或修改运维阈值对话框 -->
|
<el-dialog :title="title" :visible.sync="open" width="400px" append-to-body>
|
<el-form ref="form" :model="form" :rules="rules" label-width="150px">
|
<el-form-item label="设备类型" prop="monitorType">
|
<el-select v-model="form.monitorType" placeholder="请选择设备类型" @change="handleModeNameChange">
|
<el-option label="人脸" value="1"/>
|
<el-option label="车辆" value="2"/>
|
<el-option label="视频" value="3"/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="超时天数" prop="timeout" label-width="150px">
|
<el-input type="number" min="0" max="1000" v-model="form.timeout" placeholder="请输入超时天数"/>
|
</el-form-item>
|
<el-form-item :label="indicator.label" prop="indexOneValue" v-for="indicator in indicators" label-width="150px">
|
<el-input class="el-input-width" v-model="indicator.value" :placeholder="'请输入' + indicator.label"/>
|
</el-form-item>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
<el-button @click="cancel">取 消</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import { listThreshold, getThreshold, delThreshold, addThreshold, updateThreshold } from '@/api/platform/threshold'
|
|
export default {
|
name: 'Threshold',
|
data() {
|
return {
|
indicators: [],
|
// 遮罩层
|
loading: true,
|
// 选中数组
|
ids: [],
|
// 非单个禁用
|
single: true,
|
// 非多个禁用
|
multiple: true,
|
// 显示搜索条件
|
showSearch: true,
|
// 总条数
|
total: 0,
|
// 运维阈值表格数据
|
thresholdList: [],
|
// 弹出层标题
|
title: '',
|
// 是否显示弹出层
|
open: false,
|
// 查询参数
|
queryParams: {
|
pageNum: 1,
|
pageSize: 10,
|
monitorType: null
|
},
|
// 表单参数
|
form: {},
|
// 表单校验
|
rules: {
|
monitorType: [
|
{ required: true, message: '设备类型:1人脸 2车辆 3视频不能为空', trigger: 'change' }
|
],
|
timeout: [
|
{ required: true, message: '超时天数不能为空', trigger: 'blur' }
|
]
|
}
|
}
|
},
|
created() {
|
this.getList()
|
},
|
methods: {
|
/** 查询运维阈值列表 */
|
getList() {
|
this.loading = true
|
listThreshold(this.queryParams).then(response => {
|
this.thresholdList = response.rows
|
this.total = response.total
|
this.loading = false
|
})
|
},
|
// 取消按钮
|
cancel() {
|
this.open = false
|
this.reset()
|
},
|
// 表单重置
|
reset() {
|
this.form = {
|
id: null,
|
monitorType: null,
|
timeout: null,
|
indicator: null,
|
createTime: null,
|
updateTime: null,
|
deleted: null
|
}
|
this.resetForm('form')
|
},
|
/** 搜索按钮操作 */
|
handleQuery() {
|
this.queryParams.pageNum = 1
|
this.getList()
|
},
|
/** 重置按钮操作 */
|
resetQuery() {
|
this.resetForm('queryForm')
|
this.handleQuery()
|
},
|
// 多选框选中数据
|
handleSelectionChange(selection) {
|
this.ids = selection.map(item => item.id)
|
this.single = selection.length !== 1
|
this.multiple = !selection.length
|
},
|
/** 新增按钮操作 */
|
handleAdd() {
|
this.reset()
|
this.open = true
|
this.title = '添加运维阈值'
|
this.handleModeNameChange()
|
},
|
/** 修改按钮操作 */
|
handleUpdate(row) {
|
this.reset()
|
const id = row.id || this.ids
|
getThreshold(id).then(response => {
|
this.form = response.data
|
this.indicators = JSON.parse(this.form.indicator)
|
this.open = true
|
this.title = '修改运维阈值'
|
})
|
},
|
/** 提交按钮 */
|
submitForm() {
|
this.$refs['form'].validate(valid => {
|
if (valid) {
|
// 将indicators转为json赋值到form
|
this.form.indicator = JSON.stringify(this.indicators)
|
if (this.form.id != null) {
|
updateThreshold(this.form).then(response => {
|
this.$modal.msgSuccess('修改成功')
|
this.open = false
|
this.getList()
|
})
|
} else {
|
addThreshold(this.form).then(response => {
|
this.$modal.msgSuccess('新增成功')
|
this.open = false
|
this.getList()
|
})
|
}
|
}
|
})
|
},
|
/** 删除按钮操作 */
|
handleDelete(row) {
|
const ids = row.id || this.ids
|
this.$modal.confirm('是否确认删除运维阈值编号为"' + ids + '"的数据项?').then(function() {
|
return delThreshold(ids)
|
}).then(() => {
|
this.getList()
|
this.$modal.msgSuccess('删除成功')
|
}).catch(() => {
|
})
|
},
|
/** 切换不同指标 */
|
handleModeNameChange() {
|
if (this.form.monitorType === '1' || this.form.monitorType === null) {
|
this.indicators = [
|
{
|
label: '抓拍量',
|
value: null
|
},
|
{
|
label: '及时率',
|
value: null
|
},
|
{
|
label: '延迟量',
|
value: null
|
},
|
{
|
label: '抽检量',
|
value: null
|
},
|
{
|
label: '设备活跃率',
|
value: null
|
},
|
{
|
label: '抓拍及时率',
|
value: null
|
},
|
{
|
label: '时钟准确率',
|
value: null
|
},
|
{
|
label: '时钟不准确率',
|
value: null
|
}
|
]
|
} else if (this.form.monitorType === '2') {
|
this.indicators = [
|
{
|
label: '过车数据量',
|
value: null
|
},
|
{
|
label: '过车缺失率',
|
value: null
|
},
|
{
|
label: '有效过车数据量',
|
value: null
|
},
|
{
|
label: '抽检量',
|
value: null
|
},
|
{
|
label: '设备活跃率',
|
value: null
|
},
|
{
|
label: '抓拍及时率',
|
value: null
|
},
|
{
|
label: '时钟准确率',
|
value: null
|
},
|
{
|
label: '时钟不准确率',
|
value: null
|
}
|
]
|
} else if (this.form.monitorType === '3') {
|
this.indicators = [
|
{
|
label: '采集设备总数',
|
value: null
|
},
|
{
|
label: '监测正常设备数',
|
value: null
|
},
|
{
|
label: '编码异常设备数',
|
value: null
|
},
|
{
|
label: '经纬度异常设备数',
|
value: null
|
}
|
]
|
}
|
}
|
}
|
}
|
</script>
|