|
|
@ -1,6 +1,10 @@ |
|
|
|
<script setup> |
|
|
|
<script setup> |
|
|
|
import {reactive, ref} from "vue"; |
|
|
|
import {reactive, ref} from "vue"; |
|
|
|
import {api} from "boot/axios"; |
|
|
|
import {api} from "boot/axios"; |
|
|
|
|
|
|
|
import moment from "moment/moment"; |
|
|
|
|
|
|
|
import {useQuasar} from "quasar"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const quasar = useQuasar() |
|
|
|
|
|
|
|
|
|
|
|
const addDialogPanelOpen = ref(false) |
|
|
|
const addDialogPanelOpen = ref(false) |
|
|
|
|
|
|
|
|
|
|
@ -24,12 +28,33 @@ function getRules() { |
|
|
|
const response = r.data |
|
|
|
const response = r.data |
|
|
|
rules.value = response.data |
|
|
|
rules.value = response.data |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
.catch(msg => { |
|
|
|
|
|
|
|
quasar.dialog({ |
|
|
|
|
|
|
|
title: '啊哈', |
|
|
|
|
|
|
|
message: `请求时出现问题:${msg}` |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.finally(() => quasar.loading.hide()) |
|
|
|
|
|
|
|
quasar.loading.show({ |
|
|
|
|
|
|
|
message: '与服务器通信中...' |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getRules() |
|
|
|
getRules() |
|
|
|
|
|
|
|
|
|
|
|
function addRule() { |
|
|
|
function addRule() { |
|
|
|
api.post('/panel/rules/add', ruleForm) |
|
|
|
api.post('/panel/rules/add', ruleForm) |
|
|
|
.then(() => getRules()) |
|
|
|
.then(() => getRules()) |
|
|
|
|
|
|
|
.catch(msg => { |
|
|
|
|
|
|
|
quasar.dialog({ |
|
|
|
|
|
|
|
title: '啊哈', |
|
|
|
|
|
|
|
message: `请求时出现问题:${msg}` |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.finally(() => quasar.loading.hide()) |
|
|
|
|
|
|
|
quasar.loading.show({ |
|
|
|
|
|
|
|
message: '与服务器通信中...' |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function deleteRule(id) { |
|
|
|
function deleteRule(id) { |
|
|
@ -39,6 +64,32 @@ function deleteRule(id) { |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
.then(() => getRules()) |
|
|
|
.then(() => getRules()) |
|
|
|
|
|
|
|
.catch(msg => { |
|
|
|
|
|
|
|
quasar.dialog({ |
|
|
|
|
|
|
|
title: '啊哈', |
|
|
|
|
|
|
|
message: `请求时出现问题:${msg}` |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.finally(() => quasar.loading.hide()) |
|
|
|
|
|
|
|
quasar.loading.show({ |
|
|
|
|
|
|
|
message: '与服务器通信中...' |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const deleteDialogOpen = ref(false) |
|
|
|
|
|
|
|
const deleteId = ref() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const triggerTypeNames = { |
|
|
|
|
|
|
|
"0": "立即计算", |
|
|
|
|
|
|
|
"1": "定时计算", |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const conditionNames = { |
|
|
|
|
|
|
|
"0": "小于\t<", |
|
|
|
|
|
|
|
"1": "小于等于\t<=", |
|
|
|
|
|
|
|
"2": "等于\t==", |
|
|
|
|
|
|
|
"3": "大于等于\t>=", |
|
|
|
|
|
|
|
"4": "大于\t>", |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
@ -50,42 +101,49 @@ function deleteRule(id) { |
|
|
|
|
|
|
|
|
|
|
|
<el-table class="h-full" :data="rules" border style="width: 100%;height: 100%"> |
|
|
|
<el-table class="h-full" :data="rules" border style="width: 100%;height: 100%"> |
|
|
|
<el-table-column fixed prop="id" label="ID"/> |
|
|
|
<el-table-column fixed prop="id" label="ID"/> |
|
|
|
<el-table-column prop="expression" label="计算值"/> |
|
|
|
<el-table-column prop="expression" label="计算指标或表达式"/> |
|
|
|
<el-table-column prop="condition" label="条件"/> |
|
|
|
<el-table-column label="判断条件"> |
|
|
|
|
|
|
|
<template #default="scope"> |
|
|
|
|
|
|
|
<span>{{ conditionNames[scope.row.condition] }}</span> |
|
|
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
</el-table-column> |
|
|
|
<el-table-column prop="threshold" label="阈值"/> |
|
|
|
<el-table-column prop="threshold" label="阈值"/> |
|
|
|
<el-table-column prop="trigger" label="触发类型"/> |
|
|
|
<el-table-column label="触发类型"> |
|
|
|
|
|
|
|
<template #default="scope"> |
|
|
|
|
|
|
|
<span>{{ triggerTypeNames[scope.row.trigger] }}</span> |
|
|
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
</el-table-column> |
|
|
|
<el-table-column prop="description" label="备注"/> |
|
|
|
<el-table-column prop="description" label="备注"/> |
|
|
|
<el-table-column prop="createTime" label="添加时间"/> |
|
|
|
<el-table-column label="时间"> |
|
|
|
|
|
|
|
<template #default="scope"> |
|
|
|
|
|
|
|
<span>{{ moment(scope.row.createTime).format("YYYY-MM-DD HH:mm:ss") }}</span> |
|
|
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="操作"> |
|
|
|
<el-table-column label="操作"> |
|
|
|
<template #default="scope"> |
|
|
|
<template #default="scope"> |
|
|
|
<el-button size="small" type="danger" @click="deleteRule(scope.row.id)">删除</el-button> |
|
|
|
<q-btn unelevated color="red" @click="deleteDialogOpen = true;deleteId = scope.row.id">删除</q-btn> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
</el-table-column> |
|
|
|
</el-table> |
|
|
|
</el-table> |
|
|
|
|
|
|
|
|
|
|
|
<el-dialog v-model="addDialogPanelOpen" title="添加联系信息" width="500"> |
|
|
|
<el-dialog v-model="addDialogPanelOpen" title="添加联系信息" width="500"> |
|
|
|
<el-form :model="ruleForm"> |
|
|
|
<el-form :model="ruleForm"> |
|
|
|
<el-form-item label="值" > |
|
|
|
<el-form-item label="值"> |
|
|
|
<el-input v-model="ruleForm.expression" autocomplete="off" /> |
|
|
|
<el-input v-model="ruleForm.expression" autocomplete="off"/> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="条件"> |
|
|
|
<el-form-item label="条件"> |
|
|
|
<el-select v-model="ruleForm.condition" placeholder="选择判断条件"> |
|
|
|
<el-select v-model="ruleForm.condition" placeholder="选择判断条件"> |
|
|
|
<el-option label="<" value="0" /> |
|
|
|
<el-option v-for="(name, val) in conditionNames" :key="val" :label="name" :value="val"/> |
|
|
|
<el-option label="<=" value="1" /> |
|
|
|
</el-select> |
|
|
|
<el-option label="=" value="2" /> |
|
|
|
</el-form-item> |
|
|
|
<el-option label=">=" value="3" /> |
|
|
|
<el-form-item label="阈值"> |
|
|
|
<el-option label=">" value="4" /> |
|
|
|
<el-input v-model="ruleForm.threshold" autocomplete="off"/> |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="触发类型"> |
|
|
|
<el-form-item label="阈值" > |
|
|
|
<el-select v-model="ruleForm.trigger" placeholder="选择触发类型"> |
|
|
|
<el-input v-model="ruleForm.threshold" autocomplete="off" /> |
|
|
|
<el-option v-for="(name, val) in triggerTypeNames" :key="val" :label="name" :value="val"/> |
|
|
|
</el-form-item> |
|
|
|
</el-select> |
|
|
|
<el-form-item label="触发类型"> |
|
|
|
</el-form-item> |
|
|
|
<el-select v-model="ruleForm.trigger" placeholder="选择触发类型"> |
|
|
|
|
|
|
|
<el-option label="立即计算" value="0" /> |
|
|
|
|
|
|
|
<el-option label="定时计算" value="1" /> |
|
|
|
|
|
|
|
</el-select> |
|
|
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
<el-form-item label="备注"> |
|
|
|
<el-form-item label="备注"> |
|
|
|
<el-input v-model="ruleForm.description" type="textarea"></el-input> |
|
|
|
<el-input v-model="ruleForm.description" type="textarea"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
@ -98,6 +156,18 @@ function deleteRule(id) { |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
</el-dialog> |
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-dialog v-model="deleteDialogOpen" title="确认" width="500"> |
|
|
|
|
|
|
|
<span>确认删除?</span> |
|
|
|
|
|
|
|
<template #footer> |
|
|
|
|
|
|
|
<div class="dialog-footer flex flex-row gap-2 justify-end"> |
|
|
|
|
|
|
|
<q-btn unelevated @click="deleteDialogOpen = false">取消</q-btn> |
|
|
|
|
|
|
|
<q-btn unelevated color="red" @click="deleteDialogOpen = false;deleteRule(deleteId)"> |
|
|
|
|
|
|
|
确认 |
|
|
|
|
|
|
|
</q-btn> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
</el-dialog> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|