能源监控

This commit is contained in:
2023-08-25 16:27:46 +08:00
parent 6e39dd48ff
commit 01fe2da523
22 changed files with 1767 additions and 576 deletions

View File

@@ -1,7 +1,14 @@
<template>
<el-form ref="form" :rules="rules" label-width="100px" :model="form">
<el-form-item label="监控对象" prop="objectId">
<el-input v-model="form.objectId"></el-input>
<el-cascader
style='width: 100%;'
v-model="objIds"
:options="objList"
:props="{ checkStrictly: true, value: 'id', label: 'name' }"
popper-class="cascaderParent"
@change="selectObj"
clearable></el-cascader>
</el-form-item>
<el-form-item label="能源类型" prop="energyTypeId">
<el-select v-model="form.energyTypeId" placeholder="请选择" style="width: 100%;">
@@ -15,11 +22,11 @@
</el-form-item>
<el-form-item label="监控模式" prop="type">
<el-select v-model="form.type" placeholder="请选择" style="width: 100%;" @change="typeChange">
<el-option label="合并" value= "1" ></el-option>
<el-option label="详细" value= "2" ></el-option>
<el-option label="合并" :value= "1" ></el-option>
<el-option label="详细" :value= "2" ></el-option>
</el-select>
</el-form-item>
<el-form-item label="监控详细参数" prop="plcParamId" v-if="form.type === '2'">
<el-form-item label="监控详细参数" prop="plcParamId" v-if="form.type === 2">
<el-select v-model="form.plcParamId" placeholder="请选择" style="width: 100%;">
<el-option
v-for="item in getDictDatas(DICT_TYPE.ENERGY_UNIT)"
@@ -29,13 +36,23 @@
</el-option>
</el-select>
</el-form-item>
<el-form-item label="消耗量阈值" prop="code">
<el-input v-model="form.code"></el-input>
<el-form-item label="指标类型" prop="limitType">
<el-select v-model="form.limitType" placeholder="请选择" style="width: 100%;">
<el-option
v-for="item in getDictDatas(DICT_TYPE.MONITOR_INDEX_TYPE)"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="消耗量阈值" prop="limitValue">
<el-input v-model="form.limitValue"></el-input>
</el-form-item>
</el-form>
</template>
<script>
import { getEnergyParamList, getEnergyType, updateEnergyType, createEnergyType } from '@/api/monitoring/energyLimit'
import { getEnergyLimit, updateEnergyLimit, createEnergyLimit } from '@/api/monitoring/energyLimit'
export default {
name: 'energyLimitAdd',
props: {
@@ -45,35 +62,43 @@ export default {
default: () => {
return []
}
},
objList: {
type: Array,
default: () => []
}
},
data() {
return {
form: {
id: '',
name: '',
code: '',
nuit: '',
pricingMethod: 1,
leaderName: ''
objectId: '',
type: '',
plcParamId: '',
limitType: '',
limitValue: ''
},
objIds: [],// 回显数组
isEdit: false, //是否是编辑
rules: {
name: [{ required: true, message: '能源类型不能为空', trigger: 'blur' }]
objectId: [{ required: true, message: '对象不能为空', trigger: 'change' }],
energyTypeId: [{ required: true, message: '能源类型不能为空', trigger: 'change' }],
type: [{ required: true, message: '监控模式不能为空', trigger: 'change' }]
}
}
},
methods: {
init(id) {
// getEnergyParamList().then((res) => {
// console.log(res)
// })
if (id) {
this.isEdit = true
this.form.id = id
getEnergyType( id ).then((res) => {
getEnergyLimit( id ).then((res) => {
if (res.code === 0) {
this.form = res.data
this.form.limitType = this.form.limitType + ''
console.log(this.objList)
this.objIds = this.changeDetSelect(this.form.objectId, this.objList)
console.log(this.objIds)
}
})
} else {
@@ -82,77 +107,50 @@ export default {
}
},
typeChange() {
// if (this.form.type === '2') {
// } else {
// }
this.form.plcParamId = ''
},
// 递归处理分类回显问题
changeDetSelect(key, treeData) {
let arr = [] // 递归时操作的数组
let returnArr = [] // 存放结果的数组
let depth = 0 // 定义全局层级
// 定义递归函数
function childrenEach(childrendData, depthN) {
for (var j = 0; j < childrendData.length; j++) {
depth = depthN
arr[depthN] = childrendData[j].id
if (childrendData[j].id == key) {
returnArr = arr.slice(0, depthN + 1)
break
} else {
if (childrendData[j].children) {
depth++
childrenEach(childrendData[j].children, depth)
}
}
}
return returnArr
}
return childrenEach(treeData, depth)
},
selectObj(val) {
this.form.objectId = val[val.length-1]
this.form.objectType = val.length-1
},
submitForm() {
this.$refs['form'].validate((valid) => {
if (valid) {
switch(this.form.pricingMethod) {
case 0:// 时间段
if (this.tableData1.length === 0) {
this.$modal.msgError('时间段表格数据不能为空')
return false
} else {
this.tableData1.map(item => {
if (item.price <= 0) {
this.$modal.msgError('单价有误请检查,请检查')
return false
}
})
}
break;
case 1:// 使用量
if (this.tableData2.length === 0) {
this.$modal.msgError('使用量表格数据不能为空')
return false
} else {
this.tableData1.map(item => {
if (item.price <= 0) {
this.$modal.msgError('单价有误请检查,请检查')
return false
}
})
}
break;
default:// 固定单价
if (!this.form.singlePrice) {
this.$modal.msgError('单价有误请检查1请检查')
return false
}
}
// this.form.limitType = Number(this.form.limitType)
if (this.isEdit) {
// 编辑
updateEnergyType({
id: this.form.id,
code: this.form.code,
name: this.form.name,
unit: this.form.unit,
pricingMethod: this.form.pricingMethod,
description: this.form.description,
singlePrice: this.form.pricingMethod === 2 ? this.form.singlePrice : '',
segPriceList: this.form.pricingMethod === 0 ? this.tableData1: [],
usedPriceList: this.form.pricingMethod === 1 ? this.tableData2: []
}).then((res) => {
updateEnergyLimit({...this.form}).then((res) => {
if (res.code === 0) {
this.$modal.msgSuccess("操作成功");
this.$emit('successSubmit')
}
})
} else {
createEnergyType({
code: this.form.code,
name: this.form.name,
unit: this.form.unit,
pricingMethod: this.form.pricingMethod,
description: this.form.description,
singlePrice: this.form.pricingMethod === 2 ? this.form.singlePrice : '',
segPriceList: this.form.pricingMethod === 0 ? this.tableData1: [],
usedPriceList: this.form.pricingMethod === 1 ? this.tableData2: []
}).then((res) => {
createEnergyLimit({...this.form}).then((res) => {
if (res.code === 0) {
this.$modal.msgSuccess("操作成功");
this.$emit('successSubmit')
@@ -171,3 +169,8 @@ export default {
}
}
</script>
<style>
.cascaderParent .el-cascader-panel .el-scrollbar:first-child .el-radio {
display: none;
}
</style>

View File

@@ -38,7 +38,7 @@
@confirm="handleConfirm"
:before-close="handleCancel"
>
<energy-limit-add ref="energyLimit" @successSubmit="successSubmit" :energyTypeList="energyTypeList"/>
<energy-limit-add ref="energyLimit" @successSubmit="successSubmit" :energyTypeList="energyTypeList" :objList="objList"/>
</base-dialog>
</div>
</template>
@@ -46,13 +46,19 @@
<script>
import { getEnergyLimitPage, deleteEnergyLimit } from "@/api/monitoring/energyLimit";
import { getEnergyTypeListAll } from "@/api/base/energyType";
// import { publicFormatter } from '@/utils/dict'
import { getTree } from '@/api/base/factory'
import { publicFormatter } from '@/utils/dict'
import EnergyLimitAdd from './components/energyLimitAdd'
const tableProps = [
{
prop: 'objectId',
prop: 'objName',
label: '监控对象'
},
{
prop: 'objectType',
label: '对象备注',
filter: publicFormatter('object_type')
},
{
prop: 'energyType',
label: '能源类型'
@@ -60,7 +66,6 @@ const tableProps = [
{
prop: 'type',
label: '监控模式'
// filter: publicFormatter('energy_unit')
},
{
prop: 'plcParamName',
@@ -68,7 +73,8 @@ const tableProps = [
},
{
prop: 'limitType',
label: '指标类型'
label: '指标类型',
filter: publicFormatter('monitor_index_type')
},
{
prop: 'limitValue',
@@ -88,9 +94,11 @@ export default {
param: 'energyTypeId'
},
{
type: 'input',
type: 'select',
label: '指标类型',
placeholder: '指标类型',
selectOptions: this.getDictDatas(this.DICT_TYPE.MONITOR_INDEX_TYPE),
labelField: 'label',
valueField: 'value',
param: 'limitType'
},
{
@@ -103,7 +111,7 @@ export default {
type: 'separate'
},
{
type: this.$auth.hasPermi('base:energy-type:create') ? 'button' : '',
type: this.$auth.hasPermi('monitoring:energy-limit:create') ? 'button' : '',
btnName: '新增',
name: 'add',
color: 'success',
@@ -112,13 +120,13 @@ export default {
],
tableProps,
tableBtn: [
this.$auth.hasPermi('base:energy-type:update')
this.$auth.hasPermi('monitoring:energy-limit:update')
? {
type: 'edit',
btnName: '编辑'
}
: undefined,
this.$auth.hasPermi('base:energy-type:delete')
this.$auth.hasPermi('monitoring:energy-limit:delete')
? {
type: 'delete',
btnName: '删除'
@@ -141,7 +149,12 @@ export default {
energyTypeId: null,
limitType: null
},
energyTypeList: []
energyTypeList: [],
typeList: [
{label: '合并', value: '1'},
{label: '详细', value: '2'}
],
objList: []
};
},
created() {
@@ -150,6 +163,8 @@ export default {
})
this.getList();
this.getTypeList()
// 获取对象树形结构
this.getObjTree()
},
methods: {
getTypeList() {
@@ -178,6 +193,13 @@ export default {
getList() {
getEnergyLimitPage(this.queryParams).then(response => {
let arr = response.data.list || [];
arr&&arr.map(item => {
this.typeList.map(i => {
if (item.type === i.value) {
item.type = i.label
}
})
})
this.list = arr
this.total = response.data.total;
});
@@ -209,13 +231,18 @@ export default {
},
/** 删除按钮操作 */
handleDelete(row) {
this.$modal.confirm('是否确认删除能源类型为"' + row.name + '"的数据项?').then(function() {
this.$modal.confirm('是否确认删除监控参数为"' + row.plcParamName + '"的数据项?').then(function() {
return deleteEnergyLimit(row.id);
}).then(() => {
this.queryParams.pageNo = 1;
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
getObjTree() {
getTree().then(res => {
this.objList = res.data || []
})
}
}
};

View File

@@ -1,296 +0,0 @@
<template>
<div class="app-container">
<!-- 搜索工作栏 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="需要监控对象的id " prop="objectId">
<el-input v-model="queryParams.objectId" placeholder="请输入需要监控对象的id " clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="需要监控的对象类型 1.产线 2.工段 3.设备" prop="objectType">
<el-select v-model="queryParams.objectType" placeholder="请选择需要监控的对象类型 1.产线 2.工段 3.设备" clearable size="small">
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
<el-form-item label="需要监控的能源类型id" prop="energyTypeId">
<el-input v-model="queryParams.energyTypeId" placeholder="请输入需要监控的能源类型id" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="监控模式 1.合并 2.详细" prop="type">
<el-select v-model="queryParams.type" placeholder="请选择监控模式 1.合并 2.详细" clearable size="small">
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
<el-form-item label="需要监控的详细参数id 可以为空" prop="plcParamId">
<el-input v-model="queryParams.plcParamId" placeholder="请输入需要监控的详细参数id 可以为空" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="限制类型 1.日 2.月" prop="limitType">
<el-select v-model="queryParams.limitType" placeholder="请选择限制类型 1.日 2.月" clearable size="small">
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
<el-form-item label="限制量 阈值" prop="limitValue">
<el-input v-model="queryParams.limitValue" placeholder="请输入限制量 阈值" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="queryParams.remark" placeholder="请输入备注" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="版本号" prop="version">
<el-input v-model="queryParams.version" placeholder="请输入版本号" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="创建时间" prop="createTime">
<el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange"
range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<!-- 操作工具栏 -->
<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="['monitoring:energy-limit:create']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
v-hasPermi="['monitoring:energy-limit:export']">导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<!-- 列表 -->
<el-table v-loading="loading" :data="list">
<el-table-column label="id" align="center" prop="id" />
<el-table-column label="需要监控对象的id " align="center" prop="objectId" />
<el-table-column label="需要监控的对象类型 1.产线 2.工段 3.设备" align="center" prop="objectType" />
<el-table-column label="需要监控的能源类型id" align="center" prop="energyTypeId" />
<el-table-column label="监控模式 1.合并 2.详细" align="center" prop="type" />
<el-table-column label="需要监控的详细参数id 可以为空" align="center" prop="plcParamId" />
<el-table-column label="限制类型 1.日 2.月" align="center" prop="limitType" />
<el-table-column label="限制量 阈值" align="center" prop="limitValue" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="版本号" align="center" prop="version" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template v-slot="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template v-slot="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
v-hasPermi="['monitoring:energy-limit:update']">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
v-hasPermi="['monitoring:energy-limit:delete']">删除</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页组件 -->
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
@pagination="getList"/>
<!-- 对话框(添加 / 修改) -->
<el-dialog :title="title" :visible.sync="open" width="500px" v-dialogDrag append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="需要监控对象的id " prop="objectId">
<el-input v-model="form.objectId" placeholder="请输入需要监控对象的id " />
</el-form-item>
<el-form-item label="需要监控的对象类型 1.产线 2.工段 3.设备" prop="objectType">
<el-select v-model="form.objectType" placeholder="请选择需要监控的对象类型 1.产线 2.工段 3.设备">
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
<el-form-item label="需要监控的能源类型id" prop="energyTypeId">
<el-input v-model="form.energyTypeId" placeholder="请输入需要监控的能源类型id" />
</el-form-item>
<el-form-item label="监控模式 1.合并 2.详细" prop="type">
<el-select v-model="form.type" placeholder="请选择监控模式 1.合并 2.详细">
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
<el-form-item label="需要监控的详细参数id 可以为空" prop="plcParamId">
<el-input v-model="form.plcParamId" placeholder="请输入需要监控的详细参数id 可以为空" />
</el-form-item>
<el-form-item label="限制类型 1.日 2.月" prop="limitType">
<el-select v-model="form.limitType" placeholder="请选择限制类型 1.日 2.月">
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
<el-form-item label="限制量 阈值" prop="limitValue">
<el-input v-model="form.limitValue" placeholder="请输入限制量 阈值" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
<el-form-item label="版本号" prop="version">
<el-input v-model="form.version" placeholder="请输入版本号" />
</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 { createEnergyLimit, updateEnergyLimit, deleteEnergyLimit, getEnergyLimit, getEnergyLimitPage, exportEnergyLimitExcel } from "@/api/monitoring/energyLimit";
export default {
name: "EnergyLimit",
components: {
},
data() {
return {
// 遮罩层
loading: true,
// 导出遮罩层
exportLoading: false,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 能源监控配置列表
list: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNo: 1,
pageSize: 10,
objectId: null,
objectType: null,
energyTypeId: null,
type: null,
plcParamId: null,
limitType: null,
limitValue: null,
remark: null,
version: null,
createTime: [],
},
// 表单参数
form: {},
// 表单校验
rules: {
objectId: [{ required: true, message: "需要监控对象的id 不能为空", trigger: "blur" }],
objectType: [{ required: true, message: "需要监控的对象类型 1.产线 2.工段 3.设备不能为空", trigger: "change" }],
energyTypeId: [{ required: true, message: "需要监控的能源类型id不能为空", trigger: "blur" }],
type: [{ required: true, message: "监控模式 1.合并 2.详细不能为空", trigger: "change" }],
}
};
},
created() {
this.getList();
},
methods: {
/** 查询列表 */
getList() {
this.loading = true;
// 执行查询
getEnergyLimitPage(this.queryParams).then(response => {
this.list = response.data.list;
this.total = response.data.total;
this.loading = false;
});
},
/** 取消按钮 */
cancel() {
this.open = false;
this.reset();
},
/** 表单重置 */
reset() {
this.form = {
id: undefined,
objectId: undefined,
objectType: undefined,
energyTypeId: undefined,
type: undefined,
plcParamId: undefined,
limitType: undefined,
limitValue: undefined,
remark: undefined,
version: undefined,
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNo = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加能源监控配置";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id;
getEnergyLimit(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改能源监控配置";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (!valid) {
return;
}
// 修改的提交
if (this.form.id != null) {
updateEnergyLimit(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
return;
}
// 添加的提交
createEnergyLimit(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
});
},
/** 删除按钮操作 */
handleDelete(row) {
const id = row.id;
this.$modal.confirm('是否确认删除能源监控配置编号为"' + id + '"的数据项?').then(function() {
return deleteEnergyLimit(id);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
// 处理查询参数
let params = {...this.queryParams};
params.pageNo = undefined;
params.pageSize = undefined;
this.$modal.confirm('是否确认导出所有能源监控配置数据项?').then(() => {
this.exportLoading = true;
return exportEnergyLimitExcel(params);
}).then(response => {
this.$download.excel(response, '能源监控配置.xls');
this.exportLoading = false;
}).catch(() => {});
}
}
};
</script>