feat: 添加计算中心及相应的js
This commit is contained in:
parent
b6857c3ab8
commit
bb1a63437a
|
@ -3,6 +3,64 @@ import http from "@/utils/request"
|
|||
/*EM接口*/
|
||||
export default {
|
||||
// 测点
|
||||
xscript: {
|
||||
list: {
|
||||
name: "脚本",
|
||||
req: async function(data){
|
||||
return await http.get(
|
||||
`${config.API_URL}/enm/xscript/`,
|
||||
data
|
||||
);
|
||||
}
|
||||
},
|
||||
item: {
|
||||
name: "获取详情",
|
||||
req: async function(id){
|
||||
return await http.get(
|
||||
`${config.API_URL}/enm/xscript/${id}/`
|
||||
);
|
||||
}
|
||||
},
|
||||
update: {
|
||||
name: "更新",
|
||||
req: async function(id, data){
|
||||
return await http.put(
|
||||
`${config.API_URL}/enm/xscript/${id}/`,
|
||||
data);
|
||||
}
|
||||
},
|
||||
create: {
|
||||
name: "创建",
|
||||
req: async function(data){
|
||||
return await http.post(
|
||||
`${config.API_URL}/enm/xscript/`,
|
||||
data);
|
||||
}
|
||||
},
|
||||
delete: {
|
||||
name: "删除",
|
||||
req: async function(id){
|
||||
return await http.delete(
|
||||
`${config.API_URL}/enm/xscript/${id}/`);
|
||||
}
|
||||
},
|
||||
toggle: {
|
||||
name: "启用/禁用",
|
||||
req: async function(id, data){
|
||||
return await http.put(
|
||||
`${config.API_URL}/enm/xscript/${id}/toggle/`,
|
||||
data);
|
||||
}
|
||||
},
|
||||
change_data: {
|
||||
name: "变更数据",
|
||||
req: async function(id, data){
|
||||
return await http.put(
|
||||
`${config.API_URL}/enm/xscript/${id}/change_data/`,
|
||||
data);
|
||||
}
|
||||
}
|
||||
},
|
||||
mpoint: {
|
||||
mplog: {
|
||||
name: "测点原始记录",
|
||||
|
|
|
@ -2721,7 +2721,7 @@ const routes = [
|
|||
{
|
||||
path: "/fac_cal/mpointstat",
|
||||
meta: {
|
||||
title: "计算数据",
|
||||
title: "计算结果",
|
||||
// icon: "el-icon-postcard",
|
||||
type: "menu",
|
||||
perms: ["mpointstat"],
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<template>
|
||||
<el-container>
|
||||
<el-header>
|
||||
<div class="left-panel">
|
||||
<el-segmented v-model="value" :options="options" size="large" />
|
||||
</div>
|
||||
|
||||
</el-header>
|
||||
<el-main class="nopadding">
|
||||
<TaskResult v-if="value == 0" />
|
||||
<Xscript v-if="value == 1" />
|
||||
</el-main>
|
||||
</el-container>
|
||||
</template>
|
||||
<script>
|
||||
import Xscript from './xscript.vue'
|
||||
import TaskResult from './taskresult.vue'
|
||||
export default {
|
||||
components: {
|
||||
Xscript, TaskResult
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
value: 0,
|
||||
options: [{
|
||||
label: '任务执行',
|
||||
value: 0
|
||||
},
|
||||
{
|
||||
label: '数据转储',
|
||||
value: 1
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,221 @@
|
|||
<template>
|
||||
<el-container>
|
||||
<el-header>
|
||||
<div class="left-panel">
|
||||
<el-select
|
||||
v-model="query.mpoint"
|
||||
placeholder="测点"
|
||||
clearable
|
||||
style="margin: 0 6px; width: 300px"
|
||||
@change="handleQuery"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in mpoints"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
></el-option>
|
||||
</el-select>
|
||||
<el-select
|
||||
v-model="query.type"
|
||||
placeholder="类型"
|
||||
style="margin: 0 6px; width: 120px"
|
||||
@change="handleQuery"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
<el-date-picker v-model="timeRange" type="datetimerange" range-separator="至"
|
||||
start-placeholder="开始时间" end-placeholder="结束时间" @change="handleQuery"
|
||||
style="width: 100%" />
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="el-icon-search"
|
||||
style="margin-left: 6px"
|
||||
@click="handleQuery"
|
||||
></el-button>
|
||||
</div>
|
||||
</el-header>
|
||||
<el-main class="nopadding">
|
||||
<scTable
|
||||
ref="table"
|
||||
:apiObj="apiObj"
|
||||
row-key="id"
|
||||
stripe
|
||||
:params="params"
|
||||
:query="query"
|
||||
highlightCurrentRow
|
||||
@row-click="rowClick"
|
||||
>
|
||||
<el-table-column type="index" width="50" />
|
||||
<el-table-column label="测点" prop="mpoint_name">
|
||||
</el-table-column>
|
||||
<el-table-column label="所属集合" prop="mgroup_name">
|
||||
</el-table-column>
|
||||
<el-table-column label="年" prop="year_s" width="80"> </el-table-column>
|
||||
<el-table-column label="班年" prop="year_s" width="80"> </el-table-column>
|
||||
<el-table-column label="月" prop="month_s" width="50"> </el-table-column>
|
||||
<el-table-column label="班月" prop="month_s" width="50"> </el-table-column>
|
||||
<el-table-column label="日" prop="day_s" width="50"> </el-table-column>
|
||||
<el-table-column label="班日" prop="day_s" width="50"> </el-table-column>
|
||||
<el-table-column label="时" prop="hour" width="50"> </el-table-column>
|
||||
<el-table-column label="当前值" prop="val"></el-table-column>
|
||||
<el-table-column
|
||||
label="校正值"
|
||||
prop="val_correct"
|
||||
></el-table-column>
|
||||
<el-table-column
|
||||
label="原始计算值"
|
||||
prop="val_origin"
|
||||
></el-table-column>
|
||||
<!-- <el-table-column
|
||||
label="操作"
|
||||
fixed="right"
|
||||
align="center"
|
||||
width="140"
|
||||
>
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
link
|
||||
size="small"
|
||||
@click="handle_edit(scope.row)"
|
||||
type="primary"
|
||||
>校正</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column> -->
|
||||
</scTable>
|
||||
</el-main>
|
||||
<el-dialog title="校正" v-model="visible">
|
||||
<el-main style="padding: 0 20px 20px 20px">
|
||||
<el-form
|
||||
ref="dialogForm"
|
||||
:model="form"
|
||||
label-position="right"
|
||||
label-width="80px"
|
||||
style="padding: 0 10px"
|
||||
>
|
||||
<el-row>
|
||||
<el-col :md="12" :sm="24">
|
||||
<el-form-item label="所属部门">
|
||||
<span>{{ form.belong_dept_name }}</span>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :md="12" :sm="24">
|
||||
<el-form-item label="工段名称">
|
||||
<span>{{ form.mgroup_name }}</span>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :md="12" :sm="24">
|
||||
<el-form-item label="校正值">
|
||||
<el-input-number
|
||||
v-model="form.val_correct"
|
||||
:min="0"
|
||||
controls-position="right"
|
||||
></el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</el-main>
|
||||
<el-footer>
|
||||
<el-button type="primary" :loading="isSaveing" @click="submit"
|
||||
>保存</el-button
|
||||
>
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
</el-footer>
|
||||
</el-dialog>
|
||||
</el-container>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: "sflog",
|
||||
data() {
|
||||
return {
|
||||
apiObj: this.$API.enm.mpoint.stat,
|
||||
params: {},
|
||||
query: {
|
||||
mpoint: null,
|
||||
type: "hour",
|
||||
start_time: null,
|
||||
end_time: null
|
||||
},
|
||||
options: [
|
||||
{ label: "小时", value: "hour"},
|
||||
{ label: "天", value: "day" },
|
||||
{ label: "月", value: "month"},
|
||||
{ label: "班天", value: "day_s" },
|
||||
{ label: "班月", value: "month_s" },
|
||||
],
|
||||
form: {
|
||||
id: "",
|
||||
val_correct: "",
|
||||
},
|
||||
visible: false,
|
||||
mpoints: [],
|
||||
timeRange: []
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.getMpoints();
|
||||
},
|
||||
methods: {
|
||||
getMpoints() {
|
||||
let that = this;
|
||||
this.$API.enm.mpoint.list
|
||||
.req({ page: 0})
|
||||
.then((res) => {
|
||||
that.mpoints = res;
|
||||
});
|
||||
},
|
||||
handle_add() {},
|
||||
handleQuery() {
|
||||
console.log(this.query)
|
||||
if (this.timeRange) {
|
||||
this.query.start_time = this.timeRange[0]
|
||||
this.query.end_time = this.timeRange[1]
|
||||
} else {
|
||||
this.query.start_time = null
|
||||
this.query.end_time = null
|
||||
}
|
||||
this.$refs.table.queryData(this.query);
|
||||
},
|
||||
//编辑
|
||||
handle_edit(row) {
|
||||
this.form = { ...row };
|
||||
this.form.val_correct = row.val;
|
||||
this.visible = true;
|
||||
},
|
||||
//提交
|
||||
submit() {
|
||||
this.$refs.dialogForm.validate((valid) => {
|
||||
if (valid) {
|
||||
this.isSaveing = true;
|
||||
let obj = {};
|
||||
obj.val_correct = this.form.val_correct;
|
||||
this.$API.enm.mpointstat.correct
|
||||
.req(this.form.id, obj)
|
||||
.then((res) => {
|
||||
this.isSaveing = false;
|
||||
this.visible = false;
|
||||
this.$refs.table.queryData(this.query);
|
||||
})
|
||||
.catch((e) => {
|
||||
this.isSaveing = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.searchBtn {
|
||||
margin-left: 5px;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,60 @@
|
|||
<template>
|
||||
<el-container>
|
||||
<el-header>
|
||||
<div class="right-panel">
|
||||
<el-select v-model="query.status" placeholder="执行状态" clearable @change="handleQuery">
|
||||
<el-option v-for="item in statusOptions" :key="item.value" :label="item.label" :value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
<el-date-picker v-model="timeRange" type="datetimerange" range-separator="至"
|
||||
start-placeholder="开始时间" end-placeholder="结束时间" clearable @change="handleQuery"/>
|
||||
</div>
|
||||
</el-header>
|
||||
<el-main>
|
||||
<scTable ref="table" :apiObj="apiObj" :params="params">
|
||||
<el-table-column label="执行ID" prop="task_id" width="280" :show-overflow-tooltip="true"></el-table-column>
|
||||
<el-table-column label="名称" prop="periodic_task_name" width="240" :show-overflow-tooltip="true"></el-table-column>
|
||||
<el-table-column label="执行方法" prop="task_name" width="260" :show-overflow-tooltip="true"></el-table-column>
|
||||
<el-table-column label="状态" prop="status" width="80" :show-overflow-tooltip="true"></el-table-column>
|
||||
<el-table-column label="执行返回" prop="result" width="180" :show-overflow-tooltip="true"></el-table-column>
|
||||
<el-table-column label="开始时间" prop="date_created" width="160" :show-overflow-tooltip="true"></el-table-column>
|
||||
<el-table-column label="结束时间" prop="date_done" width="160" :show-overflow-tooltip="true"></el-table-column>
|
||||
<el-table-column label="错误信息" prop="traceback" min-width="80" :show-overflow-tooltip="true"></el-table-column>
|
||||
</scTable>
|
||||
</el-main>
|
||||
</el-container>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
apiObj: this.$API.system.task.result,
|
||||
params: {
|
||||
task_name__in: "apps.enm.tasks.cal_mpointstats"
|
||||
},
|
||||
timeRange:[],
|
||||
query: {},
|
||||
statusOptions: [
|
||||
{label: 'SUCCESS', value: 'SUCCESS'},
|
||||
{label: 'FAILURE', value: 'FAILURE'},
|
||||
{label: 'REVOKED', value: 'REVOKED'},
|
||||
{label: 'PENDING', value: 'PENDING'},
|
||||
{label: 'RETRY', value: 'RETRY'},
|
||||
]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleQuery(){
|
||||
if(this.timeRange){
|
||||
this.query.date_created__gte = this.timeRange[0]
|
||||
this.query.date_created__lte = this.timeRange[1]
|
||||
}
|
||||
else{
|
||||
this.query.date_created__gte = null
|
||||
this.query.date_created__lte = null
|
||||
}
|
||||
this.$refs.table.queryData(this.query)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,224 @@
|
|||
<template>
|
||||
<el-container>
|
||||
<el-header>
|
||||
<div class="left-panel">
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="el-icon-plus"
|
||||
@click="add"
|
||||
v-auth="'xscript.create'"
|
||||
></el-button>
|
||||
</div>
|
||||
</el-header>
|
||||
<el-main class="nopadding">
|
||||
<scTable ref="table" :apiObj="apiObj" hidePagination>
|
||||
<el-table-column label="#" type="index" width="50">
|
||||
<template #default="scope">
|
||||
<el-link type="primary" @click="lastDetail(scope.row)">{{ scope.$index + 1 }}</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="名称" prop="name" min-width="240" :show-overflow-tooltip="true"></el-table-column>
|
||||
<el-table-column label="时间策略" prop="myschedule_name" min-width="300" :show-overflow-tooltip="true"></el-table-column>
|
||||
<el-table-column label="是否启用" width="80" :show-overflow-tooltip="true">
|
||||
<template #default="scope">
|
||||
<el-icon v-if="scope.row.enabled" color="green"
|
||||
><CircleCheckFilled
|
||||
/></el-icon>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="运行次数" prop="total_run_count" width="80" :show-overflow-tooltip="true"></el-table-column>
|
||||
<el-table-column label="最后运行时间" prop="last_run_at" width="160" :show-overflow-tooltip="true"></el-table-column>
|
||||
<el-table-column label="操作" fixed="right" align="left" width="200">
|
||||
<template #default="scope">
|
||||
<el-button plain type="warning" size="small" @click="table_toggle(scope.row, scope.$index)"
|
||||
v-auth="'xscript.update'">开/停</el-button>
|
||||
<el-button plain type="warning" size="small" @click="table_edit(scope.row, scope.$index)"
|
||||
v-auth="'xscript.update'">编辑</el-button>
|
||||
<el-popconfirm title="确定删除吗?" @confirm="table_del(scope.row, scope.$index)">
|
||||
<template #reference>
|
||||
<el-button plain type="danger" size="small" v-auth="'xscript.delete'">删除</el-button>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</scTable>
|
||||
</el-main>
|
||||
<el-drawer
|
||||
title="新增/编辑"
|
||||
v-model="visible"
|
||||
:size="1000"
|
||||
destroy-on-close
|
||||
>
|
||||
<el-container>
|
||||
<el-main style="padding: 0 20px 20px 20px">
|
||||
<el-form ref="rForm" :model="form">
|
||||
<el-form-item label="脚本名称" required>
|
||||
<el-input v-model="form.name"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="脚本内容" required>
|
||||
<Codemirror
|
||||
v-model:value="form.code"
|
||||
:options="cmOptions"
|
||||
border
|
||||
ref="cmRef"
|
||||
height="300"
|
||||
width="100%"
|
||||
style="line-height: 180%"
|
||||
>
|
||||
</Codemirror>
|
||||
</el-form-item>
|
||||
<el-form-item label="基础数据">
|
||||
<JsonEditorVue
|
||||
style="width: 100%"
|
||||
v-model="form.base_data"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="变动数据">
|
||||
<el-button type="warning" @click="openCdg" size="small">变更</el-button><span> ------ {{ form.change_data }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="时间策略" required>
|
||||
<el-select
|
||||
v-model="form.myschedule"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in schOptions"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-main>
|
||||
<el-footer>
|
||||
<el-button type="primary" @click="submit">提交</el-button>
|
||||
</el-footer>
|
||||
</el-container>
|
||||
</el-drawer>
|
||||
<el-dialog title="最后执行" v-model="detailVisible">
|
||||
<el-descriptions :column="1" border v-if="detailForm.last_run_data != null">
|
||||
<el-descriptions-item label="开始执行">{{ detailForm.last_run_data.date_created }}</el-descriptions-item>
|
||||
<el-descriptions-item label="结束执行">{{ detailForm.last_run_data.date_created }}</el-descriptions-item>
|
||||
<el-descriptions-item label="执行状态">{{ detailForm.last_run_data.status }}</el-descriptions-item>
|
||||
<el-descriptions-item label="返回结果">{{ detailForm.last_run_data.result }}</el-descriptions-item>
|
||||
<el-descriptions-item label="错误信息">{{ detailForm.last_run_data.traceback }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-dialog>
|
||||
<el-dialog title="变更数据" v-model="cDgVisible">
|
||||
<JsonEditorVue
|
||||
style="width: 100%"
|
||||
v-model="xdata"
|
||||
/>
|
||||
<el-footer>
|
||||
<el-button type="primary" @click="submit2">提交</el-button>
|
||||
</el-footer>
|
||||
</el-dialog>
|
||||
</el-container>
|
||||
</template>
|
||||
<script>
|
||||
import JsonEditorVue from "json-editor-vue3";
|
||||
import "codemirror/mode/python/python.js";
|
||||
import 'codemirror/lib/codemirror.css'
|
||||
import Codemirror from "codemirror-editor-vue3";
|
||||
const dForm = {
|
||||
base_data: {},
|
||||
};
|
||||
export default {
|
||||
components: { JsonEditorVue, Codemirror },
|
||||
data() {
|
||||
return {
|
||||
apiObj: this.$API.enm.xscript.list,
|
||||
visible: false,
|
||||
form: {},
|
||||
detailForm: {},
|
||||
detailVisible: false,
|
||||
schOptions: [],
|
||||
cmOptions: {
|
||||
mode: "text/x-python",
|
||||
theme: "default",
|
||||
readOnly: false,
|
||||
lineNumbers: true,
|
||||
lineWiseCopyCut: true,
|
||||
// gutters: ["CodeMirror-lint-markers"],
|
||||
lint: true,
|
||||
autoRefresh: true
|
||||
},
|
||||
cDgVisible: false,
|
||||
xdata: {}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.getSchOptions();
|
||||
},
|
||||
methods: {
|
||||
openCdg(){
|
||||
this.xdata = Object.assign({}, this.form.change_data)
|
||||
this.cDgVisible = true;
|
||||
},
|
||||
lastDetail(row) {
|
||||
this.$API.enm.xscript.item.req(row.id).then(res=>{
|
||||
this.detailForm = res
|
||||
this.detailVisible = true
|
||||
})
|
||||
},
|
||||
getSchOptions() {
|
||||
this.$API.system.myschedule.list.req({ page: 0 }).then((res) => {
|
||||
this.schOptions = res;
|
||||
});
|
||||
},
|
||||
add() {
|
||||
this.form = Object.assign({}, dForm);
|
||||
this.visible = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.cmRef.refresh()
|
||||
})
|
||||
},
|
||||
table_edit(row) {
|
||||
this.$API.enm.xscript.item.req(row.id).then(res=>{
|
||||
this.form = res
|
||||
this.visible = true
|
||||
})
|
||||
},
|
||||
table_del(row) {
|
||||
this.$API.enm.xscript.delete.req(row.id).then(()=>{
|
||||
this.$message.success('删除成功')
|
||||
this.$refs.table.refresh()
|
||||
})
|
||||
},
|
||||
table_toggle(row) {
|
||||
this.$API.enm.xscript.toggle.req(row.id).then(() => {
|
||||
this.$message.success("操作成功");
|
||||
this.$refs.table.refresh();
|
||||
})
|
||||
},
|
||||
submit2() {
|
||||
this.$API.enm.xscript.change_data.req(this.form.id, {change_data: this.xdata}).then(() => {
|
||||
this.$message.success("操作成功");
|
||||
this.form.change_data = this.xdata;
|
||||
this.cDgVisible = false;
|
||||
})
|
||||
},
|
||||
submit() {
|
||||
this.$refs.rForm.validate(async (valid)=>{
|
||||
if(valid){
|
||||
if(this.form.id){
|
||||
this.$API.enm.xscript.update.req(this.form.id, this.form).then(()=>{
|
||||
this.$message.success('更新成功')
|
||||
this.visible = false
|
||||
this.$refs.table.refresh()
|
||||
})
|
||||
}else{
|
||||
this.$API.enm.xscript.create.req(this.form).then(()=>{
|
||||
this.$message.success('添加成功')
|
||||
this.visible = false
|
||||
this.$refs.table.refresh()
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
Loading…
Reference in New Issue