Merge pull request 'projects/mesxc-zjl' (#309) from projects/mesxc-zjl into projects/mesxc-test

Reviewed-on: #309
This commit is contained in:
朱菊兰 2024-04-07 12:19:50 +08:00
commit f6d866907c
18 changed files with 1978 additions and 1372 deletions

View File

@ -18,7 +18,7 @@ VUE_APP_TITLE = MES系统
# VUE_APP_BASE_API = 'http://192.168.2.173:48080' # VUE_APP_BASE_API = 'http://192.168.2.173:48080'
# VUE_APP_BASE_API = 'http://192.168.1.49:48082' # VUE_APP_BASE_API = 'http://192.168.1.49:48082'
# VUE_APP_BASE_API = 'http://192.168.1.8:48082' # VUE_APP_BASE_API = 'http://192.168.1.8:48082'
# VUE_APP_BASE_API = 'http://192.168.4.173:48082' # VUE_APP_BASE_API = 'http://192.168.4.173:9001'
# VUE_APP_BASE_API = 'http://192.168.1.104:48082' # VUE_APP_BASE_API = 'http://192.168.1.104:48082'
VUE_APP_BASE_API = 'http://192.168.0.33:48082' VUE_APP_BASE_API = 'http://192.168.0.33:48082'
# VUE_APP_BASE_API = 'http://192.168.1.62:48082' # VUE_APP_BASE_API = 'http://192.168.1.62:48082'

View File

@ -54,3 +54,27 @@ export function energyQuantityManualExport(data) {
responseType: 'blob' responseType: 'blob'
}) })
} }
// 获得能源表名配置分页
export function energyTablePage(data) {
return request({
url: '/base/energy-table/page',
method: 'post',
data: data
})
}
// 获得能源表名配置
export function energyTableGet(query) {
return request({
url: '/base/energy-table/get',
method: 'get',
params: query
})
}
// 更新能源表名配置
export function energyTableUpdate(data) {
return request({
url: '/base/energy-table/update',
method: 'put',
data: data
})
}

View File

@ -32,6 +32,7 @@ const actions = {
} }
// 处理 dictValue 层级 // 处理 dictValue 层级
dictDataMap[dictData.dictType].push({ dictDataMap[dictData.dictType].push({
id: dictData.id,
value: dictData.value, value: dictData.value,
label: dictData.label, label: dictData.label,
colorType: dictData.colorType, colorType: dictData.colorType,

View File

@ -14,7 +14,7 @@ export default {
return { return {
chartDom: '', chartDom: '',
chart: '', chart: '',
chartHeight: this.tableHeight(214) - 100, chartHeight: this.tableHeight(314),
}; };
}, },
props: { props: {
@ -37,7 +37,7 @@ export default {
}, },
mounted() { mounted() {
window.addEventListener('resize', () => { window.addEventListener('resize', () => {
this.chartHeight = this.tableHeight(214) - 70; this.chartHeight = this.tableHeight(314);
}); });
}, },
methods: { methods: {

View File

@ -1,37 +1,40 @@
<template> <template>
<div id="analysischartLine" style="width: 100%;height: 100%;"></div> <div
id="analysischartLine"
style="width: 100%"
:style="{ height: chartHeight + 'px' }"></div>
</template> </template>
<script> <script>
import * as echarts from 'echarts' import * as echarts from 'echarts';
import resize from '@/utils/chartMixins/resize' import resize from '@/utils/chartMixins/resize';
export default { export default {
name: "LineChart", name: 'LineChart',
mixins: [resize], mixins: [resize],
data() { data() {
return { return {
chartDom: '', chartDom: '',
chart: '', chart: '',
chartHeight: this.tableHeight(214) - 70 chartHeight: this.tableHeight(250) / 2,
} };
}, },
props: { props: {
chartData: { chartData: {
type: Array, type: Array,
required: true, required: true,
default: () => { default: () => {
return [] return [];
} },
} },
}, },
watch: { watch: {
chartData: function () { chartData: function () {
this.getChart() this.getChart();
} },
}, },
mounted() { mounted() {
window.addEventListener('resize', () => { window.addEventListener('resize', () => {
this.chartHeight = this.tableHeight(214) - 70 this.chartHeight = this.tableHeight(250) / 2;
}) });
}, },
methods: { methods: {
getChart() { getChart() {
@ -40,63 +43,77 @@ export default {
this.chart !== '' && this.chart !== '' &&
this.chart !== undefined this.chart !== undefined
) { ) {
this.chart.dispose() // Dom this.chart.dispose(); // Dom
} }
this.chartDom = document.getElementById('analysischartLine') this.chartDom = document.getElementById('analysischartLine');
this.chart = echarts.init(this.chartDom) this.chart = echarts.init(this.chartDom);
if (this.chartData.length === 0) { if (this.chartData.length === 0) {
return false return false;
} }
let xData = [] let xData = [];
let arr = this.chartData[0].type let arr = this.chartData[0].type;
let keys = Object.keys(this.chartData[0]) let keys = Object.keys(this.chartData[0]);
let yData = [] let yData = [];
for (let j = 0; j < arr.length; j++) { for (let j = 0; j < arr.length; j++) {
for (let k = 0; k < keys.length; k++) { for (let k = 0; k < keys.length; k++) {
if (keys[k].indexOf(arr[j] + '_上年同期') > -1 || keys[k].indexOf(arr[j] + '_能源消耗') > -1) { if (
keys[k].indexOf(arr[j] + '_上年同期') > -1 ||
keys[k].indexOf(arr[j] + '_能源消耗') > -1
) {
let obj = { let obj = {
name: '', name: '',
type: 'line', type: 'line',
data: [] data: [],
} };
obj.name = keys[k] obj.name = keys[k];
yData.push(obj) yData.push(obj);
} }
} }
} }
for (let i = 0; i < this.chartData.length; i++) { for (let i = 0; i < this.chartData.length; i++) {
xData.push(this.chartData[i].time) xData.push(this.chartData[i].time);
for (let p = 0; p < yData.length; p++) { for (let p = 0; p < yData.length; p++) {
yData[p].data.push(this.chartData[i][yData[p].name]) yData[p].data.push(this.chartData[i][yData[p].name]);
} }
} }
var option = { var option = {
color: ['#FFDC94', '#8EF0AB', '#63BDFF', '#288AFF', '#7164FF', '#FF6860', '#FF9747', '#B0EB42', '#D680FF', '#0043D2'], color: [
'#FFDC94',
'#8EF0AB',
'#63BDFF',
'#288AFF',
'#7164FF',
'#FF6860',
'#FF9747',
'#B0EB42',
'#D680FF',
'#0043D2',
],
legend: { legend: {
data: keys, data: keys,
right: '1%' right: '1%',
}, },
tooltip: { tooltip: {
trigger: 'axis' trigger: 'axis',
}, },
grid: { grid: {
left: '1%', left: '1%',
right: '1%', right: '1%',
bottom: '3%', bottom: '3%',
containLabel: true containLabel: true,
}, },
xAxis: { xAxis: {
type: 'category', type: 'category',
data: xData data: xData,
}, },
yAxis: { yAxis: {
type: 'value' type: 'value',
}, },
series: yData series: yData,
}; };
option && this.chart.setOption(option); option && this.chart.setOption(option);
} },
} },
} };
</script> </script>

View File

@ -1,31 +1,36 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<search-area @submit="getList" @exportD="exportData"/> <search-area
<div v-show='chartData.length'> @submit="getList"
@exportD="exportData" />
<div v-show="chartData.length">
<div class="chartTitle">同比分析图</div> <div class="chartTitle">同比分析图</div>
<div style='width: 100%;height: 400px;'> <div style="width: 100%">
<line-chart ref="analysisLineChart" :chartData="chartData"/> <line-chart
ref="analysisLineChart"
:chartData="chartData" />
</div> </div>
<!-- 表格 --> <!-- 表格 -->
<base-table <base-table
:table-props="tableProps" :table-props="tableProps"
:table-data="list" :table-data="list"
:max-height="tableH" :max-height="tableH"
class="yoy-out-table" class="yoy-out-table" />
/>
</div> </div>
<!-- 没有数据 --> <!-- 没有数据 -->
<div class="no-data-bg" v-show='!chartData.length'></div> <div
class="no-data-bg"
v-show="!chartData.length"></div>
</div> </div>
</template> </template>
<script> <script>
import { getYoy } from "@/api/analysis/energyAnalysis" import { getYoy } from '@/api/analysis/energyAnalysis';
import subRate from "./components/subRate.vue" import subRate from './components/subRate.vue';
import SearchArea from "./components/searchArea" import SearchArea from './components/searchArea';
import LineChart from "./components/lineChart" import LineChart from './components/lineChart';
import FileSaver from "file-saver" import FileSaver from 'file-saver';
import * as XLSX from 'xlsx/xlsx.mjs' import * as XLSX from 'xlsx/xlsx.mjs';
export default { export default {
name: 'YoyAnalysis', name: 'YoyAnalysis',
components: { SearchArea, LineChart }, components: { SearchArea, LineChart },
@ -34,98 +39,103 @@ export default {
chartData: [], chartData: [],
tableProps: [], tableProps: [],
list: [], list: [],
tableH: this.tableHeight(640) tableH: this.tableHeight(250) / 2,
} };
}, },
mounted() { mounted() {
window.addEventListener('resize', () => { window.addEventListener('resize', () => {
this.tableH = this.tableHeight(640) this.tableH = this.tableHeight(250) / 2;
}) });
}, },
methods: { methods: {
getList(params) { getList(params) {
getYoy({ ...params }).then((res) => { getYoy({ ...params }).then((res) => {
if (res.code === 0 && res.data) { if (res.code === 0 && res.data) {
this.getTableList(res.data) this.getTableList(res.data);
} else { } else {
this.chartData = [] this.chartData = [];
this.list = [] this.list = [];
} }
}) });
}, },
getTableList(arr) { getTableList(arr) {
let data = arr.data let data = arr.data;
let nameData = arr.nameData let nameData = arr.nameData;
let tempX = [] let tempX = [];
data[0].data.map((item) => { data[0].data.map((item) => {
let obj = {} let obj = {};
obj.prop = item.dynamicName obj.prop = item.dynamicName;
obj.label = item.dynamicName obj.label = item.dynamicName;
obj.id = item.id obj.id = item.id;
obj.children = [] obj.children = [];
tempX.push(obj) tempX.push(obj);
}) });
for (let i = 0; i < nameData.length; i++) { for (let i = 0; i < nameData.length; i++) {
for (let j = 0; j < tempX.length; j++) { for (let j = 0; j < tempX.length; j++) {
if (tempX[j].id === nameData[i].parentId) { if (tempX[j].id === nameData[i].parentId) {
let obj = {} let obj = {};
obj.prop = tempX[j].prop + '_' + nameData[i].name obj.prop = tempX[j].prop + '_' + nameData[i].name;
obj.label = nameData[i].name obj.label = nameData[i].name;
if (obj.label.indexOf('同比') != -1) { if (obj.label.indexOf('同比') != -1) {
obj.subcomponent = subRate obj.subcomponent = subRate;
} }
tempX[j].children.push(obj) tempX[j].children.push(obj);
} }
} }
} }
this.tableProps = [{prop: 'time',label: '时间'}].concat(tempX) this.tableProps = [{ prop: 'time', label: '时间' }].concat(tempX);
console.log(this.tableProps) console.log(this.tableProps);
// //
this.list = [] this.list = [];
for (let k = 0; k < data.length; k++) { for (let k = 0; k < data.length; k++) {
let obj = {} let obj = {};
obj.time = data[k].time obj.time = data[k].time;
let arr1 = data[k].data let arr1 = data[k].data;
obj.type = [] obj.type = [];
for (let q = 0; q < arr1.length; q++) { for (let q = 0; q < arr1.length; q++) {
let name = arr1[q].dynamicName let name = arr1[q].dynamicName;
obj.type.push(name) obj.type.push(name);
let arr2 = arr1[q].children let arr2 = arr1[q].children;
for (let p = 0; p < arr2.length; p++) { for (let p = 0; p < arr2.length; p++) {
let prop = name + '_' + arr2[p].dynamicName let prop = name + '_' + arr2[p].dynamicName;
obj[prop] = arr2[p].dynamicValue obj[prop] = arr2[p].dynamicValue;
} }
} }
this.list.push(obj) this.list.push(obj);
} }
this.chartData = this.list this.chartData = this.list;
}, },
exportData(val) { exportData(val) {
if (this.list.length > 0) { if (this.list.length > 0) {
var wb = XLSX.utils.table_to_book(document.querySelector(".yoy-out-table")) var wb = XLSX.utils.table_to_book(
let fileName = val.name + "同比分析.xlsx" document.querySelector('.yoy-out-table')
);
let fileName = val.name + '同比分析.xlsx';
var wbout = XLSX.write(wb, { var wbout = XLSX.write(wb, {
bookType: "xlsx", bookType: 'xlsx',
bookSST: true, bookSST: true,
type: "array" type: 'array',
}) });
try { try {
FileSaver.saveAs( FileSaver.saveAs(
new Blob([wbout], { type: "application/octet-stream" }), new Blob([wbout], { type: 'application/octet-stream' }),
fileName fileName
) );
} catch (e) { } catch (e) {
if (typeof console !== "undefined") console.log(e, wbout); if (typeof console !== 'undefined') console.log(e, wbout);
} }
return wbout return wbout;
} else { } else {
this.$modal.msgWarning("暂无数据导出") this.$modal.msgWarning('暂无数据导出');
}
}
}
} }
},
},
};
</script> </script>
<style lang='scss' scoped> <style lang='scss' scoped>
.yoy-out-table {
margin-top: 20px;
}
.chartTitle { .chartTitle {
font-size: 16px; font-size: 16px;
color: #000; color: #000;
@ -135,7 +145,7 @@ export default {
display: inline-block; display: inline-block;
width: 4px; width: 4px;
height: 18px; height: 18px;
background-color: #0B58FF; background-color: #0b58ff;
border-radius: 1px; border-radius: 1px;
margin-right: 8px; margin-right: 8px;
vertical-align: bottom; vertical-align: bottom;

View File

@ -1,51 +1,72 @@
<template> <template>
<el-form ref="form" :rules="rules" label-width="100px" :model="form"> <el-form
ref="form"
:rules="rules"
label-width="100px"
:model="form">
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="能源类型" prop="typeId"> <el-form-item
<el-select v-model="form.typeId" placeholder="请选择" style="width: 100%;" filterable> label="能源类型"
prop="typeId">
<el-select
v-model="form.typeId"
placeholder="请选择"
style="width: 100%"
filterable>
<el-option <el-option
v-for="item in energyListType" v-for="item in energyListType"
:key="item.id" :key="item.id"
:label="item.name" :label="item.labelName"
:value="item.id"> :value="item.id"></el-option>
</el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="参数列名" prop="plcParamName"> <el-form-item
label="参数列名"
prop="plcParamName">
<el-input v-model="form.plcParamName"></el-input> <el-input v-model="form.plcParamName"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="参数名称" prop="name"> <el-form-item
label="参数名称"
prop="name">
<el-input v-model="form.name"></el-input> <el-input v-model="form.name"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="单位" prop="unit"> <el-form-item
<el-select v-model="form.unit" placeholder="请选择" style="width: 100%;"> label="单位"
prop="unit">
<el-select
v-model="form.unit"
placeholder="请选择"
style="width: 100%">
<el-option <el-option
v-for="item in getDictDatas(DICT_TYPE.ENERGY_UNIT)" v-for="item in getDictDatas(DICT_TYPE.UNIT_DICT)"
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
:value="item.value"> :value="item.value"></el-option>
</el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="是否采集" prop="collection"> <el-form-item
label="是否采集"
prop="collection">
<el-switch v-model="form.collection"></el-switch> <el-switch v-model="form.collection"></el-switch>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="描述" prop="description"> <el-form-item
label="描述"
prop="description">
<el-input v-model="form.description"></el-input> <el-input v-model="form.description"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -53,8 +74,12 @@
</el-form> </el-form>
</template> </template>
<script> <script>
import { getEnergyPlcParam, updateEnergyPlcParam, createEnergyPlcParam } from '@/api/base/energyPlcParam' import {
import { getEnergyTypeListAll } from '@/api/base/energyType' getEnergyPlcParam,
updateEnergyPlcParam,
createEnergyPlcParam,
} from '@/api/base/energyPlcParam';
import { getEnergyTypeListAll } from '@/api/base/energyType';
export default { export default {
name: 'EnergyPlcParamAdd', name: 'EnergyPlcParamAdd',
data() { data() {
@ -67,66 +92,72 @@ export default {
unit: '', unit: '',
description: '', description: '',
collection: true, collection: true,
connectId: '' connectId: '',
}, },
energyListType: [], energyListType: [],
isEdit: false, // isEdit: false, //
rules: { rules: {
typeId: [{ required: true, message: '能源类型不能为空', trigger: 'change' }], typeId: [
plcParamName: [{ required: true, message: '参数列名不能为空', trigger: 'blur' }], { required: true, message: '能源类型不能为空', trigger: 'change' },
name: [{ required: true, message: '参数名称不能为空', trigger: 'blur' }] ],
} plcParamName: [
} { required: true, message: '参数列名不能为空', trigger: 'blur' },
],
name: [
{ required: true, message: '参数名称不能为空', trigger: 'blur' },
],
},
};
}, },
methods: { methods: {
init(param) { init(param) {
this.form.connectId = param.connectId this.form.connectId = param.connectId;
getEnergyTypeListAll().then((res) => { getEnergyTypeListAll().then((res) => {
this.energyListType = res.data || [] this.energyListType = res.data || [];
}) });
if (param.id) { if (param.id) {
this.isEdit = true this.isEdit = true;
this.form.id = param.id this.form.id = param.id;
getEnergyPlcParam(this.form.id).then((res) => { getEnergyPlcParam(this.form.id).then((res) => {
if (res.code === 0) { if (res.code === 0) {
this.form = res.data this.form = res.data;
this.form.collection = this.form.collection === 0 ? false : true this.form.collection = this.form.collection === 0 ? false : true;
} }
}) });
} else { } else {
this.isEdit = false this.isEdit = false;
this.form.id = '' this.form.id = '';
} }
}, },
submitForm() { submitForm() {
this.$refs['form'].validate((valid) => { this.$refs['form'].validate((valid) => {
if (valid) { if (valid) {
this.form.collection = this.form.collection === false ? 0 : 1 this.form.collection = this.form.collection === false ? 0 : 1;
if (this.isEdit) { if (this.isEdit) {
// //
updateEnergyPlcParam({ ...this.form }).then((res) => { updateEnergyPlcParam({ ...this.form }).then((res) => {
if (res.code === 0) { if (res.code === 0) {
this.$modal.msgSuccess("操作成功"); this.$modal.msgSuccess('操作成功');
this.$emit('successSubmit') this.$emit('successSubmit');
} }
}) });
} else { } else {
createEnergyPlcParam({ ...this.form }).then((res) => { createEnergyPlcParam({ ...this.form }).then((res) => {
if (res.code === 0) { if (res.code === 0) {
this.$modal.msgSuccess("操作成功"); this.$modal.msgSuccess('操作成功');
this.$emit('successSubmit') this.$emit('successSubmit');
} }
}) });
} }
} else { } else {
return false return false;
} }
}) });
}, },
formClear() { formClear() {
this.$refs.form.resetFields() this.$refs.form.resetFields();
this.isEdit = false this.isEdit = false;
} },
} },
} };
</script> </script>

View File

@ -0,0 +1,139 @@
<template>
<div class="energyQuantityManualAddTable">
<el-table
:data="renderData"
border
style="width: 100%"
:header-cell-style="{
background: '#F2F4F9',
color: '#606266',
}">
<el-table-column
prop="tableName"
label="表名*">
<template slot-scope="scope">
<div class="tableInner">
<el-select
v-model="scope.row.tableName"
placeholder="请选择"
style="width: 100%"
@change="changeSelect(scope.row, 'tableName')">
<el-option
v-for="item in tableNameList"
:key="item.id"
:label="item.label"
:value="item.id"></el-option>
</el-select>
</div>
</template>
</el-table-column>
<el-table-column
prop="readingQuantity"
label="抄表数*">
<template slot-scope="scope">
<div class="tableInner">
<el-input-number
v-model="scope.row.readingQuantity"
:min="0"
:max="999999999"
style="width: 100%"
:controls="false"
@change="changeInput(scope.row, 'readingQuantity')"
:precision="2"></el-input-number>
</div>
</template>
</el-table-column>
</el-table>
<el-button
class="addButton"
icon="el-icon-plus"
@click="emitButtonClick">
新增
</el-button>
</div>
</template>
<script>
export default {
name: 'AddTable',
props: {
tableData: {
type: Array,
required: true,
default: () => {
return [];
},
},
tableNameList: {
type: Array,
required: true,
default: () => {
return [];
},
},
},
data() {
return {};
},
computed: {
renderData() {
return this.tableData.map((item, index) => {
return {
...item,
_pageIndex: index + 1,
};
});
},
},
methods: {
emitButtonClick() {
this.$emit('emitButtonClick');
},
changeInput(val1, val2) {
val1.prop = val2;
this.$emit('emitFun', val1);
},
changeSelect(val1, val2) {
val1.prop = val2;
this.$emit('emitFun', val1);
},
},
};
</script>
<style lang='scss' scoped>
.energyQuantityManualAddTable {
.el-table .el-table__cell {
padding: 0;
height: 35px;
}
.addButton {
width: 100%;
height: 35px;
border-top: none;
color: #0b58ff;
border-color: #ebeef5;
border-radius: 0;
}
.addButton:hover {
color: #0b58ff;
border-color: #ebeef5;
background-color: #fff;
}
.addButton:focus {
border-color: #ebeef5;
background-color: #fff;
}
.tableInner .el-input__inner {
border: none;
padding: 0;
height: 33px;
}
}
</style>
<style lang='scss'>
.energyQuantityManualAddTable {
.el-table .el-table__cell {
padding: 0;
height: 35px;
}
}
</style>

View File

@ -1,47 +1,84 @@
<template> <template>
<el-form ref="energyQuantityManualForm" :rules="rules" label-width="90px" :model="form"> <el-form
ref="energyQuantityManualForm"
:rules="rules"
label-width="90px"
:model="form">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span='12'> <el-col :span="12">
<el-form-item label="能源类型" prop="energyTypeId"> <el-form-item
<el-select v-model="form.energyTypeId" placeholder="请选择" style="width: 100%;" filterable> label="能源类型"
<el-option v-for="item in this.energyTypeList" :key="item.id" :label="item.name" :value="item.id"> prop="energyTypeId">
</el-option> <el-select
v-model="form.energyTypeId"
placeholder="请选择"
style="width: 100%"
@change="selEnergyType"
filterable>
<el-option
v-for="item in this.energyTypeList"
:key="item.id"
:label="item.labelName"
:value="item.id"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span='12'> <el-col :span="12">
<el-form-item label="抄表日期" prop="recordTime"> <el-form-item
<el-date-picker v-model="form.recordTime" type="date" format="yyyy-MM-dd" value-format="timestamp" label="抄表日期"
placeholder="选择日期" style="width: 100%;"> prop="recordTime">
</el-date-picker> <el-date-picker
v-model="form.recordTime"
type="date"
format="yyyy-MM-dd"
value-format="timestamp"
placeholder="选择日期"
style="width: 100%"></el-date-picker>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span='24'> <el-col :span="24">
<base-table border :table-props="tableProps" :table-data="tableData" :add-button-show="addButtonShow" <add-table
@emitFun="inputChange" @emitButtonClick="emitButtonClick" /> :table-props="tableProps"
:table-data="tableData"
:table-name-list="tableNameList"
@emitFun="inputChange"
@emitButtonClick="emitButtonClick" />
<!-- <base-table
border
:table-props="tableProps"
:table-data="tableData"
:add-button-show="addButtonShow"
@emitFun="inputChange"
@emitButtonClick="emitButtonClick" /> -->
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
</template> </template>
<script> <script>
import { energyQuantityManualCreate, energyQuantityManualUpdate, energyQuantityManualGet } from '@/api/base/energyQuantityManual' import {
import moment from 'moment' energyQuantityManualCreate,
import InputArea from './InputArea' energyQuantityManualUpdate,
import SelectArea from './SelectArea' energyQuantityManualGet,
} from '@/api/base/energyQuantityManual';
import moment from 'moment';
import AddTable from './AddTable';
import InputArea from './InputArea';
import SelectArea from './SelectArea';
import { energyTableGet } from '@/api/base/energyQuantityManual';
const tableProps = [ const tableProps = [
{ {
prop: 'tableName', prop: 'tableName',
label: '表名*', label: '表名*',
subcomponent: SelectArea subcomponent: SelectArea,
}, },
{ {
prop: 'readingQuantity', prop: 'readingQuantity',
label: '抄表数*', label: '抄表数*',
subcomponent: InputArea subcomponent: InputArea,
} },
] ];
export default { export default {
name: 'EnergyQuantityManualAdd', name: 'EnergyQuantityManualAdd',
props: { props: {
@ -49,78 +86,102 @@ export default {
type: Array, type: Array,
required: true, required: true,
default: () => { default: () => {
return [] return [];
} },
} },
}, },
data() { data() {
return { return {
tableProps, tableProps,
tableData: [], tableData: [],
tableNameList: [], //list
addButtonShow: '新增', addButtonShow: '新增',
form: { form: {
id: '', id: '',
energyTypeId: '', energyTypeId: '',
unit: '', unit: '',
recordTime: '' recordTime: '',
}, },
rules: { rules: {
energyTypeId: [{ required: true, message: '能源类型不能为空', trigger: 'change' }], energyTypeId: [
recordTime: [{ required: true, message: '抄表日期不能为空', trigger: 'change' }] { required: true, message: '能源类型不能为空', trigger: 'change' },
],
recordTime: [
{ required: true, message: '抄表日期不能为空', trigger: 'change' },
],
}, },
isEdit: false isEdit: false,
} };
}, },
components: { AddTable },
methods: { methods: {
init(params) { init(params) {
this.form.recordTime = moment().valueOf() this.form.recordTime = moment().valueOf();
if (params.type === 'add') { if (params.type === 'add') {
this.isEdit = false this.isEdit = false;
} else if (params.type === 'meterReading') { } else if (params.type === 'meterReading') {
this.isEdit = false this.isEdit = false;
this.form.energyTypeId = params.energyTypeId this.form.energyTypeId = params.energyTypeId;
let obj = {} let obj = {};
obj.tableName = params.tableName + '' obj.tableName = params.tableName + '';
obj.readingQuantity = 0 obj.readingQuantity = 0;
this.tableData.push(obj) this.tableData.push(obj);
} else { } else {
this.isEdit = true this.isEdit = true;
this.form.id = params.id this.form.id = params.id;
this.addButtonShow = '' this.addButtonShow = '';
energyQuantityManualGet({ id: this.form.id }).then(res => { energyQuantityManualGet({ id: this.form.id }).then((res) => {
if (res.code === 0) { if (res.code === 0) {
this.form.energyTypeId = res.data.energyTypeId this.form.energyTypeId = res.data.energyTypeId;
this.form.recordTime = res.data.recordTime ? res.data.recordTime : null this.form.recordTime = res.data.recordTime
let obj = {} ? res.data.recordTime
obj.tableName = res.data.tableName ? res.data.tableName + '' : '' : null;
obj.readingQuantity = res.data.readingQuantity let obj = {};
this.tableData.push(obj) obj.tableName = res.data.tableName ? res.data.tableName + '' : '';
obj.readingQuantity = res.data.readingQuantity;
this.tableData.push(obj);
} }
}) });
} }
}, },
inputChange(val) { inputChange(val) {
this.tableData[val._pageIndex - 1][val.prop] = val[val.prop] this.tableData[val._pageIndex - 1][val.prop] = val[val.prop];
console.log(this.tableData);
}, },
emitButtonClick() { emitButtonClick() {
let obj = {} if (!this.form.energyTypeId) {
obj.tableName = '' this.$modal.msgWarning('请先选择能源类型');
obj.readingQuantity = 0 return false;
this.tableData.push(obj) }
let obj = {};
obj.tableName = '';
obj.readingQuantity = 0;
this.tableData.push(obj);
},
selEnergyType(id) {
//
this.tableData = [];
this.tableNameList = [];
energyTableGet({ energyTypeId: id }).then((res) => {
this.tableNameList = res.data.tableObjs || [];
});
}, },
submitForm() { submitForm() {
this.$refs['energyQuantityManualForm'].validate((valid) => { this.$refs['energyQuantityManualForm'].validate((valid) => {
if (valid) { if (valid) {
// //
if (this.tableData.length === 0) { if (this.tableData.length === 0) {
this.$modal.msgError("抄表数据不能为空"); this.$modal.msgError('抄表数据不能为空');
return false return false;
} else { } else {
for (let item of this.tableData) { for (let item of this.tableData) {
console.log(item) console.log(item);
if (!item.tableName || (!item.readingQuantity && item.readingQuantity !== 0)) { if (
this.$modal.msgError("抄表数据有空值,请检查"); !item.tableName ||
return false (!item.readingQuantity && item.readingQuantity !== 0)
) {
this.$modal.msgError('抄表数据有空值,请检查');
return false;
} }
} }
} }
@ -131,37 +192,37 @@ export default {
energyTypeId: this.form.energyTypeId, energyTypeId: this.form.energyTypeId,
recordTime: this.form.recordTime, recordTime: this.form.recordTime,
tableName: this.tableData[0].tableName, tableName: this.tableData[0].tableName,
readingQuantity: this.tableData[0].readingQuantity readingQuantity: this.tableData[0].readingQuantity,
}).then((res) => { }).then((res) => {
if (res.code === 0) { if (res.code === 0) {
this.$modal.msgSuccess("操作成功"); this.$modal.msgSuccess('操作成功');
this.$emit('successSubmit') this.$emit('successSubmit');
} }
}) });
} else { } else {
energyQuantityManualCreate({ energyQuantityManualCreate({
energyTypeId: this.form.energyTypeId, energyTypeId: this.form.energyTypeId,
recordTime: this.form.recordTime, recordTime: this.form.recordTime,
data: this.tableData data: this.tableData,
}).then((res) => { }).then((res) => {
if (res.code === 0) { if (res.code === 0) {
this.$modal.msgSuccess("操作成功"); this.$modal.msgSuccess('操作成功');
this.$emit('successSubmit') this.$emit('successSubmit');
} }
}) });
} }
} else { } else {
return false return false;
} }
}) });
}, },
formClear() { formClear() {
this.$refs.energyQuantityManualForm.resetFields() this.$refs.energyQuantityManualForm.resetFields();
this.form.unit = '' this.form.unit = '';
this.isEdit = false this.isEdit = false;
this.addButtonShow = '新增' this.addButtonShow = '新增';
this.tableData = [] this.tableData = [];
} },
} },
} };
</script> </script>

View File

@ -1,116 +1,145 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" /> <search-bar
:formConfigs="formConfig"
ref="searchBarForm"
@headBtnClick="buttonClick" />
<!-- 列表 --> <!-- 列表 -->
<base-table :page="queryParams.pageNo" :limit="queryParams.pageSize" :table-props="tableProps" :table-data="list" <base-table
:max-height="tableH" @selection-change="selectChange"> :page="queryParams.pageNo"
<method-btn v-if="tableBtn.length" slot="handleBtn" :width="120" label="操作" :method-list="tableBtn" :limit="queryParams.pageSize"
:table-props="tableProps"
:table-data="list"
:max-height="tableH"
@selection-change="selectChange">
<method-btn
v-if="tableBtn.length"
slot="handleBtn"
:width="120"
label="操作"
:method-list="tableBtn"
@clickBtn="handleClick" /> @clickBtn="handleClick" />
</base-table> </base-table>
<pagination :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" :total="total" <pagination
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
:total="total"
@pagination="getList" /> @pagination="getList" />
<!-- 新增 --> <!-- 新增 -->
<base-dialog :dialogTitle="addOrEditTitle" :dialogVisible="centervisible" @cancel="handleCancel" <base-dialog
@confirm="handleConfirm" :before-close="handleCancel"> :dialogTitle="addOrEditTitle"
<energy-quantity-manual-add ref="energyQuantityManualAdd" :energyTypeList="energyTypeList" :dialogVisible="centervisible"
@cancel="handleCancel"
@confirm="handleConfirm"
:before-close="handleCancel">
<energy-quantity-manual-add
ref="energyQuantityManualAdd"
:energyTypeList="energyTypeList"
@successSubmit="successSubmit" /> @successSubmit="successSubmit" />
</base-dialog> </base-dialog>
</div> </div>
</template> </template>
<script> <script>
import { energyQuantityManualPage, energyQuantityManualDelete, energyQuantityManualExport } from "@/api/base/energyQuantityManual" import {
import { getEnergyTypeListAll } from "@/api/base/energyType" energyQuantityManualPage,
import { publicFormatter } from '@/utils/dict' energyQuantityManualDelete,
import { parseTime, parseTimeTable } from '@/utils/ruoyi' energyQuantityManualExport,
// import FileSaver from "file-saver" } from '@/api/base/energyQuantityManual';
// import * as XLSX from 'xlsx/xlsx.mjs' import { getEnergyTypeListAll } from '@/api/base/energyType';
import EnergyQuantityManualAdd from './components/energyQuantityManualAdd' import { publicFormatter } from '@/utils/dict';
import moment from 'moment' import { parseTimeTable } from '@/utils/ruoyi';
import EnergyQuantityManualAdd from './components/energyQuantityManualAdd';
import moment from 'moment';
const tableProps = [ const tableProps = [
{ {
prop: 'energyType', prop: 'energyType',
label: '能源类型', label: '能源类型',
minWidth: 110, minWidth: 110,
showOverflowtooltip: true filter: publicFormatter('energy_type'),
showOverflowtooltip: true,
}, },
{ {
prop: 'unit', prop: 'unit',
label: '单位', label: '单位',
filter: publicFormatter('energy_unit'), filter: publicFormatter('energy_unit'),
minWidth: 110 minWidth: 110,
}, },
{ {
prop: 'tableName', prop: 'tableName',
label: '能源表名', label: '能源表名',
filter: publicFormatter('table_name'), filter: publicFormatter('table_name'),
minWidth: 110, minWidth: 110,
showOverflowtooltip: true showOverflowtooltip: true,
}, },
{ {
prop: 'recordTime', prop: 'recordTime',
label: '抄表日期', label: '抄表日期',
filter: parseTimeTable('{y}-{m}-{d}'), filter: parseTimeTable('{y}-{m}-{d}'),
minWidth: 110 minWidth: 110,
}, },
{ {
prop: 'readingQuantity', prop: 'readingQuantity',
label: '抄表值' label: '抄表值',
}, },
{ {
prop: 'useQty', prop: 'useQty',
label: '差值' label: '差值',
} },
] ];
export default { export default {
name: "EnergyQuantityManual", name: 'EnergyQuantityManual',
data() { data() {
return { return {
formConfig: [ formConfig: [
{ {
type: 'select', type: 'select',
label: '能源类型', label: '能源类型',
labelField: 'labelName',
selectOptions: [], selectOptions: [],
param: 'energyTypeId', param: 'energyTypeId',
filterable: true filterable: true,
}, },
{ {
type: 'datePicker', type: 'datePicker',
label: '抄表日期', label: '抄表日期',
dateType: 'daterange', dateType: 'daterange',
format: 'yyyy-MM-dd', format: 'yyyy-MM-dd',
valueFormat: "timestamp", valueFormat: 'timestamp',
rangeSeparator: '-', rangeSeparator: '-',
startPlaceholder: '开始时间', startPlaceholder: '开始时间',
endPlaceholder: '结束时间', endPlaceholder: '结束时间',
param: 'timeVal', param: 'timeVal',
defaultSelect: [] defaultSelect: [],
}, },
{ {
type: 'button', type: 'button',
btnName: '查询', btnName: '查询',
name: 'search', name: 'search',
color: 'primary' color: 'primary',
}, },
{ {
type: 'separate' type: 'separate',
}, },
{ {
type: this.$auth.hasPermi('base:energy-quantity-manual:export') ? 'button' : '', type: this.$auth.hasPermi('base:energy-quantity-manual:export')
? 'button'
: '',
btnName: '导出', btnName: '导出',
name: 'export', name: 'export',
color: 'primary', color: 'primary',
plain: true plain: true,
}, },
{ {
type: this.$auth.hasPermi('base:energy-quantity-manual:create') ? 'button' : '', type: this.$auth.hasPermi('base:energy-quantity-manual:create')
? 'button'
: '',
btnName: '新增', btnName: '新增',
name: 'add', name: 'add',
color: 'success', color: 'success',
plain: true plain: true,
} },
], ],
tableProps, tableProps,
tableH: this.tableHeight(260), tableH: this.tableHeight(260),
@ -122,150 +151,171 @@ export default {
this.$auth.hasPermi('base:energy-quantity-manual:create') this.$auth.hasPermi('base:energy-quantity-manual:create')
? { ? {
type: 'meterReading', type: 'meterReading',
btnName: '抄表' btnName: '抄表',
} }
: undefined, : undefined,
this.$auth.hasPermi('base:energy-quantity-manual:update') this.$auth.hasPermi('base:energy-quantity-manual:update')
? { ? {
type: 'edit', type: 'edit',
btnName: '编辑' btnName: '编辑',
} }
: undefined, : undefined,
this.$auth.hasPermi('base:energy-quantity-manual:delete') this.$auth.hasPermi('base:energy-quantity-manual:delete')
? { ? {
type: 'delete', type: 'delete',
btnName: '删除' btnName: '删除',
} }
: undefined : undefined,
].filter((v) => v), ].filter((v) => v),
// //
queryParams: { queryParams: {
pageNo: 1, pageNo: 1,
pageSize: 20, pageSize: 20,
energyTypeId: '', energyTypeId: '',
recordTime: [] recordTime: [],
}, },
energyTypeList: [], energyTypeList: [],
exportList: [], exportList: [],
addOrEditTitle: '', addOrEditTitle: '',
centervisible: false, centervisible: false,
}; };
}, },
components: { EnergyQuantityManualAdd }, components: { EnergyQuantityManualAdd },
created() { created() {
window.addEventListener('resize', () => { window.addEventListener('resize', () => {
this.tableH = this.tableHeight(260) this.tableH = this.tableHeight(260);
}) });
let end = moment(moment().format('YYYY-MM-DD 23:59:59')).valueOf() let end = moment(moment().format('YYYY-MM-DD 23:59:59')).valueOf();
let start = moment(moment().subtract(7, 'days').format('YYYY-MM-DD 00:00:00')).valueOf() let start = moment(
this.formConfig[1].defaultSelect = [start, end] moment().subtract(7, 'days').format('YYYY-MM-DD 00:00:00')
this.queryParams.recordTime[0] = start ).valueOf();
this.queryParams.recordTime[1] = end this.formConfig[1].defaultSelect = [start, end];
this.queryParams.recordTime[0] = start;
this.queryParams.recordTime[1] = end;
this.getList(); this.getList();
this.getTypeList() this.getTypeList();
}, },
methods: { methods: {
buttonClick(val) { buttonClick(val) {
this.queryParams.pageNo = 1; this.queryParams.pageNo = 1;
this.queryParams.energyTypeId = val.energyTypeId this.queryParams.energyTypeId = val.energyTypeId;
this.queryParams.recordTime[0] = val.timeVal ? moment(moment(val.timeVal[0]).format('YYYY-MM-DD 00:00:00')).valueOf() : null this.queryParams.recordTime[0] = val.timeVal
this.queryParams.recordTime[1] = val.timeVal ? moment(moment(val.timeVal[1]).format('YYYY-MM-DD 23:59:59')).valueOf() : null ? moment(moment(val.timeVal[0]).format('YYYY-MM-DD 00:00:00')).valueOf()
: null;
this.queryParams.recordTime[1] = val.timeVal
? moment(moment(val.timeVal[1]).format('YYYY-MM-DD 23:59:59')).valueOf()
: null;
switch (val.btnName) { switch (val.btnName) {
case 'search': case 'search':
this.getList() this.getList();
break break;
case 'add': case 'add':
this.addOrEditTitle = '新增' this.addOrEditTitle = '新增';
this.centervisible = true this.centervisible = true;
let params = {} let params = {};
params.type = 'add' params.type = 'add';
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.energyQuantityManualAdd.init(params) this.$refs.energyQuantityManualAdd.init(params);
}) });
break break;
default: default:
this.$modal.confirm('是否确认导出').then(() => { this.$modal
return energyQuantityManualExport({ energyTypeId: this.queryParams.energyTypeId, recordTime: this.queryParams.recordTime }); .confirm('是否确认导出')
}).then(response => { .then(() => {
return energyQuantityManualExport({
energyTypeId: this.queryParams.energyTypeId,
recordTime: this.queryParams.recordTime,
});
})
.then((response) => {
this.$download.excel(response, '能源报表.xls'); this.$download.excel(response, '能源报表.xls');
}).catch(() => { }) })
.catch(() => {});
} }
}, },
/** 查询列表 */ /** 查询列表 */
getList() { getList() {
energyQuantityManualPage(this.queryParams).then(response => { energyQuantityManualPage(this.queryParams).then((response) => {
let arr = response.data.list || [] let arr = response.data.list || [];
arr && arr.map(item => { arr &&
item.amount = item.amount ? (!isNaN(parseFloat(item.amount)) && isFinite(item.amount) ? item.amount.toFixed(2) : '') : '' arr.map((item) => {
}) item.amount = item.amount
this.list = arr ? !isNaN(parseFloat(item.amount)) && isFinite(item.amount)
? item.amount.toFixed(2)
: ''
: '';
});
this.list = arr;
this.total = response.data.total; this.total = response.data.total;
this.exportList = [] this.exportList = [];
}); });
}, },
getTypeList() { getTypeList() {
getEnergyTypeListAll().then((res) => { getEnergyTypeListAll().then((res) => {
this.formConfig[0].selectOptions = res.data || [] this.formConfig[0].selectOptions = res.data || [];
this.energyTypeList = res.data || [] this.energyTypeList = res.data || [];
}) });
}, },
selectChange(val) { selectChange(val) {
console.log(val) console.log(val);
this.exportList = val this.exportList = val;
}, },
handleClick(val) { handleClick(val) {
console.log(val) console.log(val);
switch (val.type) { switch (val.type) {
case 'edit': case 'edit':
this.addOrEditTitle = '编辑' this.addOrEditTitle = '编辑';
this.centervisible = true this.centervisible = true;
let paramA = {} let paramA = {};
paramA.type = 'edit' paramA.type = 'edit';
paramA.id = val.data.id paramA.id = val.data.id;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.energyQuantityManualAdd.init(paramA) this.$refs.energyQuantityManualAdd.init(paramA);
}) });
break break;
case 'meterReading': case 'meterReading':
this.addOrEditTitle = '新增' this.addOrEditTitle = '新增';
this.centervisible = true this.centervisible = true;
let paramB = {} let paramB = {};
paramB.type = 'meterReading' paramB.type = 'meterReading';
paramB.energyTypeId = val.data.energyTypeId paramB.energyTypeId = val.data.energyTypeId;
paramB.tableName = val.data.tableName paramB.tableName = val.data.tableName;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.energyQuantityManualAdd.init(paramB) this.$refs.energyQuantityManualAdd.init(paramB);
}) });
break break;
default: default:
this.handleDelete(val.data) this.handleDelete(val.data);
} }
}, },
// //
handleCancel() { handleCancel() {
this.$refs.energyQuantityManualAdd.formClear() this.$refs.energyQuantityManualAdd.formClear();
this.centervisible = false this.centervisible = false;
this.addOrEditTitle = '' this.addOrEditTitle = '';
}, },
handleConfirm() { handleConfirm() {
this.$refs.energyQuantityManualAdd.submitForm() this.$refs.energyQuantityManualAdd.submitForm();
}, },
successSubmit() { successSubmit() {
this.handleCancel() this.handleCancel();
this.getList() this.getList();
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
console.log(row.id) console.log(row.id);
this.$modal.confirm('是否确认删除能源类型为"' + row.energyType + '"的数据项?').then(function () { this.$modal
.confirm('是否确认删除能源类型为"' + row.energyType + '"的数据项?')
.then(function () {
return energyQuantityManualDelete({ id: row.id }); return energyQuantityManualDelete({ id: row.id });
}).then(() => { })
.then(() => {
this.queryParams.pageNo = 1; this.queryParams.pageNo = 1;
this.getList(); this.getList();
this.$modal.msgSuccess("删除成功"); this.$modal.msgSuccess('删除成功');
}).catch(() => { }); })
} .catch(() => {});
} },
},
}; };
</script> </script>

View File

@ -0,0 +1,76 @@
<template>
<el-form
ref="form"
label-width="100px"
:model="form">
<el-form-item
label="能源类型"
prop="energyType">
<el-input v-model="form.energyType"></el-input>
</el-form-item>
<el-form-item
label="能源表名"
prop="tableIds">
<el-select
v-model="form.tableIds"
placeholder="请选择"
style="width: 100%"
:multiple="true"
filterable>
<el-option
v-for="dict in getDictDatas('table_name')"
:key="dict.id"
:label="dict.label"
:value="dict.id" />
</el-select>
</el-form-item>
</el-form>
</template>
<script>
import {
energyTableGet,
energyTableUpdate,
} from '@/api/base/energyQuantityManual';
export default {
name: 'TableNameConfigUpdate',
data() {
return {
form: {
energyType: '',
energyTypeId: '',
tableIds: [],
},
};
},
methods: {
init(id) {
energyTableGet({ energyTypeId: id }).then((res) => {
this.form.energyType = res.data.energyType || '';
this.form.energyTypeId = res.data.energyTypeId || '';
this.form.tableIds =
res.data.tableObjs &&
res.data.tableObjs.map((item) => {
return item.id;
});
});
},
submitForm() {
this.$refs['form'].validate((valid) => {
//
energyTableUpdate({ ...this.form }).then((res) => {
if (res.code === 0) {
this.$modal.msgSuccess('操作成功');
this.$emit('successSubmit');
}
});
});
},
formClear() {
this.form.energyType = '';
this.form.energyTypeId = '';
this.form.tableIds = [];
this.isEdit = false;
},
},
};
</script>

View File

@ -0,0 +1,106 @@
<template>
<div class="app-container">
<!-- 列表 -->
<base-table
:page="queryParams.pageNo"
:limit="queryParams.pageSize"
:table-props="tableProps"
:table-data="list"
:max-height="tableH">
<method-btn
v-if="tableBtn.length"
slot="handleBtn"
:width="80"
label="操作"
:method-list="tableBtn"
@clickBtn="handleClick" />
</base-table>
<!-- 新增 -->
<base-dialog
dialogTitle="编辑"
:dialogVisible="centervisible"
@cancel="handleCancel"
@confirm="handleConfirm"
:before-close="handleCancel">
<table-name-config-update
ref="tableNameConfigU"
@successSubmit="successSubmit" />
</base-dialog>
</div>
</template>
<script>
import { energyTablePage } from '@/api/base/energyQuantityManual';
import { publicFormatter } from '@/utils/dict';
import tableNameConfigUpdate from './components/tableNameConfigUpdate.vue';
const tableProps = [
{
prop: 'energyType',
label: '能源类型',
width: 200,
filter: publicFormatter('energy_type'),
},
{
prop: 'tableName',
label: '能源表名',
},
];
export default {
name: 'TableNameConfig',
components: { tableNameConfigUpdate },
data() {
return {
tableProps,
tableBtn: [
this.$auth.hasPermi('base:table-name-config:edit')
? {
type: 'edit',
btnName: '编辑',
}
: undefined,
].filter((v) => v),
list: [],
queryParams: {
pageNo: 1,
pageSize: 100,
},
tableH: this.tableHeight(165),
centervisible: false,
};
},
created() {
this.getList();
},
methods: {
getList() {
energyTablePage({ ...this.queryParams }).then((res) => {
let temp = res.data.list || [];
this.list = temp.map((item) => {
return {
energyType: item.energyType,
energyTypeId: item.energyTypeId,
tableName: item.tables.join('、'),
};
});
});
},
handleClick(val) {
console.log('编辑');
this.centervisible = true;
this.$nextTick(() => {
this.$refs.tableNameConfigU.init(val.data.energyTypeId);
});
},
handleCancel() {
this.$refs.tableNameConfigU.formClear();
this.centervisible = false;
},
handleConfirm() {
this.$refs.tableNameConfigU.submitForm();
},
successSubmit() {
this.handleCancel();
this.getList();
},
},
};
</script>

View File

@ -33,11 +33,28 @@
v-model="objIds" v-model="objIds"
:options="objList" :options="objList"
:props="{ checkStrictly: true, value: 'id', label: 'name' }" :props="{ checkStrictly: true, value: 'id', label: 'name' }"
popper-class="cascaderParent"
@change="selectObj" @change="selectObj"
clearable></el-cascader> clearable></el-cascader>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12">
<el-form-item
label="监控能源类型"
prop="energyTypeId">
<el-select
v-model="form.energyTypeId"
placeholder="请选择"
style="width: 100%"
filterable
@change="toggleType">
<el-option
v-for="item in this.energyTypeList"
:key="item.id"
:label="item.labelName"
:value="item.id"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col <el-col
:span="12" :span="12"
v-if="form.method == 2"> v-if="form.method == 2">
@ -56,24 +73,6 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12">
<el-form-item
label="监控能源类型"
prop="energyTypeId">
<el-select
v-model="form.energyTypeId"
placeholder="请选择"
style="width: 100%"
filterable
@change="toggleType">
<el-option
v-for="item in this.energyTypeList"
:key="item.id"
:label="item.name"
:value="item.id"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col <el-col
:span="12" :span="12"
v-if="form.method == 1"> v-if="form.method == 1">
@ -353,8 +352,3 @@ export default {
}, },
}; };
</script> </script>
<style>
.cascaderParent .el-cascader-panel .el-scrollbar:first-child .el-radio {
display: none;
}
</style>

View File

@ -48,7 +48,7 @@ import {
deleteEnergyLimit, deleteEnergyLimit,
} from '@/api/monitoring/energyLimit'; } from '@/api/monitoring/energyLimit';
import { getEnergyTypeListAll } from '@/api/base/energyType'; import { getEnergyTypeListAll } from '@/api/base/energyType';
import { getTree } from '@/api/base/factory'; import { getTree } from '@/api/analysis/energyAnalysis';
import { publicFormatter } from '@/utils/dict'; import { publicFormatter } from '@/utils/dict';
import EnergyLimitAdd from './components/energyLimitAdd'; import EnergyLimitAdd from './components/energyLimitAdd';
const tableProps = [ const tableProps = [
@ -60,20 +60,27 @@ const tableProps = [
{ {
prop: 'objName', prop: 'objName',
label: '监控对象', label: '监控对象',
minWidth: 100,
showOverflowtooltip: true,
}, },
{ {
prop: 'objCode', prop: 'objCode',
label: '对象编码', label: '对象编码',
minWidth: 140,
showOverflowtooltip: true,
}, },
{ {
prop: 'tableName', prop: 'tableName',
label: '能源表名', label: '能源表名',
filter: publicFormatter('table_name'), filter: publicFormatter('table_name'),
minWidth: 120,
showOverflowtooltip: true,
}, },
{ {
prop: 'energyType', prop: 'energyType',
label: '能源类型', label: '能源类型',
filter: publicFormatter('energy_type'), filter: publicFormatter('energy_type'),
showOverflowtooltip: true,
}, },
{ {
prop: 'type', prop: 'type',
@ -104,6 +111,7 @@ export default {
type: 'select', type: 'select',
label: '能源类型', label: '能源类型',
selectOptions: [], selectOptions: [],
labelField: 'labelName',
param: 'energyTypeId', param: 'energyTypeId',
}, },
{ {

View File

@ -1,115 +1,137 @@
<template> <template>
<div class="app-container energyOverlimitLog"> <div class="app-container energyOverlimitLog">
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" /> <search-bar
<el-tabs v-model="activeName" @tab-click="toggleTab"> :formConfigs="formConfig"
<el-tab-pane label="自动抄表" name="auto"></el-tab-pane> ref="searchBarForm"
<el-tab-pane label="手动抄表" name="manual"></el-tab-pane> @headBtnClick="buttonClick" />
<el-tabs
v-model="activeName"
@tab-click="toggleTab">
<el-tab-pane
label="自动抄表"
name="auto"></el-tab-pane>
<el-tab-pane
label="手动抄表"
name="manual"></el-tab-pane>
</el-tabs> </el-tabs>
<!-- 列表 --> <!-- 列表 -->
<div v-if="activeName === 'auto'"> <div v-if="activeName === 'auto'">
<base-table :page="queryParams.pageNo" :limit="queryParams.pageSize" :table-props="tableProps" :table-data="list" <base-table
:page="queryParams.pageNo"
:limit="queryParams.pageSize"
:table-props="tableProps"
:table-data="list"
:max-height="tableH" /> :max-height="tableH" />
</div> </div>
<div v-if="activeName === 'manual'"> <div v-if="activeName === 'manual'">
<base-table :page="queryParams.pageNo" :limit="queryParams.pageSize" :table-props="tableProps2" <base-table
:table-data="list2" :max-height="tableH" /> :page="queryParams.pageNo"
:limit="queryParams.pageSize"
:table-props="tableProps2"
:table-data="list2"
:max-height="tableH" />
</div> </div>
<pagination :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" :total="total" <pagination
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
:total="total"
@pagination="getList" /> @pagination="getList" />
</div> </div>
</template> </template>
<script> <script>
import { getEnergyOverlimitLogPage } from "@/api/monitoring/energyOverlimitLog"; import { getEnergyOverlimitLogPage } from '@/api/monitoring/energyOverlimitLog';
import { getEnergyTypeListAll } from "@/api/base/energyType"; import { getEnergyTypeListAll } from '@/api/base/energyType';
import { publicFormatter } from '@/utils/dict' import { publicFormatter } from '@/utils/dict';
import { parseTime } from '@/utils/ruoyi' import { parseTime } from '@/utils/ruoyi';
const tableProps = [ const tableProps = [
{ {
prop: 'objName', prop: 'objName',
label: '监控对象' label: '监控对象',
}, },
{ {
prop: 'objCode', prop: 'objCode',
label: '对象编码' label: '对象编码',
}, },
{ {
prop: 'energyType', prop: 'energyType',
label: '能源类型' label: '能源类型',
filter: publicFormatter('energy_type'),
}, },
{ {
prop: 'type', prop: 'type',
label: '监控模式' label: '监控模式',
}, },
{ {
prop: 'paramName', prop: 'paramName',
label: '监控参数' label: '监控参数',
}, },
{ {
prop: 'limitType', prop: 'limitType',
label: '指标类型', label: '指标类型',
filter: publicFormatter('monitor_index_type') filter: publicFormatter('monitor_index_type'),
}, },
{ {
prop: 'realityValue', prop: 'realityValue',
label: '实际值' label: '实际值',
}, },
{ {
prop: 'limitValue', prop: 'limitValue',
label: '阈值' label: '阈值',
}, },
{ {
prop: 'overValue', prop: 'overValue',
label: '超出值' label: '超出值',
}, },
{ {
prop: 'time', prop: 'time',
label: '提醒时间', label: '提醒时间',
filter: parseTime, filter: parseTime,
minWidth: 160 minWidth: 160,
} },
] ];
const tableProps2 = [ const tableProps2 = [
{ {
prop: 'energyType', prop: 'energyType',
label: '能源类型' label: '能源类型',
filter: publicFormatter('energy_type'),
}, },
{ {
prop: 'limitType', prop: 'limitType',
label: '指标类型', label: '指标类型',
filter: publicFormatter('monitor_index_type') filter: publicFormatter('monitor_index_type'),
}, },
{ {
prop: 'realityValue', prop: 'realityValue',
label: '实际值' label: '实际值',
}, },
{ {
prop: 'limitValue', prop: 'limitValue',
label: '阈值' label: '阈值',
}, },
{ {
prop: 'overValue', prop: 'overValue',
label: '超出值' label: '超出值',
}, },
{ {
prop: 'time', prop: 'time',
label: '提醒时间', label: '提醒时间',
filter: parseTime, filter: parseTime,
minWidth: 160 minWidth: 160,
} },
] ];
export default { export default {
name: "EnergyOverlimitLog", name: 'EnergyOverlimitLog',
data() { data() {
return { return {
formConfig: [ formConfig: [
{ {
type: 'select', type: 'select',
label: '能源类型', label: '能源类型',
labelField: 'labelName',
selectOptions: [], selectOptions: [],
param: 'energyTypeId' param: 'energyTypeId',
}, },
{ {
type: 'select', type: 'select',
@ -117,14 +139,14 @@ export default {
selectOptions: this.getDictDatas(this.DICT_TYPE.MONITOR_INDEX_TYPE), selectOptions: this.getDictDatas(this.DICT_TYPE.MONITOR_INDEX_TYPE),
labelField: 'label', labelField: 'label',
valueField: 'value', valueField: 'value',
param: 'indexType' param: 'indexType',
}, },
{ {
type: 'button', type: 'button',
btnName: '查询', btnName: '查询',
name: 'search', name: 'search',
color: 'primary' color: 'primary',
} },
], ],
activeName: 'auto', activeName: 'auto',
tableProps, tableProps,
@ -139,80 +161,81 @@ export default {
pageSize: 20, pageSize: 20,
energyTypeId: '', energyTypeId: '',
indexType: '', indexType: '',
method: '1' method: '1',
}, },
typeList: [ typeList: [
{ id: 1, name: '合并' }, { id: 1, name: '合并' },
{ id: 2, name: '详细' } { id: 2, name: '详细' },
] ],
}; };
}, },
created() { created() {
window.addEventListener('resize', () => { window.addEventListener('resize', () => {
this.tableH = this.tableHeight(260) this.tableH = this.tableHeight(260);
}) });
this.getList(); this.getList();
this.getTypeList() this.getTypeList();
}, },
methods: { methods: {
buttonClick(val) { buttonClick(val) {
this.queryParams.pageNo = 1; this.queryParams.pageNo = 1;
this.queryParams.energyTypeId = val.energyTypeId this.queryParams.energyTypeId = val.energyTypeId;
this.queryParams.indexType = val.indexType this.queryParams.indexType = val.indexType;
this.getList() this.getList();
}, },
/** 查询列表 */ /** 查询列表 */
getList() { getList() {
getEnergyOverlimitLogPage(this.queryParams).then(response => { getEnergyOverlimitLogPage(this.queryParams).then((response) => {
let arr = response.data.list || []; let arr = response.data.list || [];
arr && arr.map((item) => { arr &&
arr.map((item) => {
this.typeList.map((i) => { this.typeList.map((i) => {
if (item.type === i.id) { if (item.type === i.id) {
item.type = i.name item.type = i.name;
} }
}) });
if (item.minValue && item.maxValue) { if (item.minValue && item.maxValue) {
item.limitValue = item.minValue + '-' + item.maxValue item.limitValue = item.minValue + '-' + item.maxValue;
} else if (item.minValue) { } else if (item.minValue) {
item.limitValue = '最小值' + item.minValue item.limitValue = '最小值' + item.minValue;
} else if (item.maxValue) { } else if (item.maxValue) {
item.limitValue = '最大值' + item.maxValue item.limitValue = '最大值' + item.maxValue;
} else { } else {
item.limitValue = '' item.limitValue = '';
} }
}) });
if (this.queryParams.method === '1') { if (this.queryParams.method === '1') {
this.list = arr this.list = arr;
this.list2 = [] this.list2 = [];
} else { } else {
this.list2 = arr this.list2 = arr;
this.list1 = [] this.list1 = [];
} }
this.total = response.data.total; this.total = response.data.total;
}); });
}, },
getTypeList() { getTypeList() {
getEnergyTypeListAll().then((res) => { getEnergyTypeListAll().then((res) => {
console.log(res) console.log(res);
this.formConfig[0].selectOptions = res.data || [] this.formConfig[0].selectOptions = res.data || [];
}) });
}, },
toggleTab() { toggleTab() {
if (this.activeName === 'auto') { if (this.activeName === 'auto') {
this.queryParams.method = '1' this.queryParams.method = '1';
} else { } else {
this.queryParams.method = '2' this.queryParams.method = '2';
}
this.queryParams.pageNo = 1
this.getList()
}
} }
this.queryParams.pageNo = 1;
this.getList();
},
},
}; };
</script> </script>
<style lang='scss'> <style lang='scss'>
.energyOverlimitLog { .energyOverlimitLog {
.el-tabs__nav::after { .el-tabs__nav::after {
content: ""; content: '';
position: absolute; position: absolute;
left: 0; left: 0;
bottom: 0; bottom: 0;

View File

@ -56,6 +56,7 @@ const tableProps = [
{ {
prop: 'energyType', prop: 'energyType',
label: '能源类型', label: '能源类型',
filter: publicFormatter('energy_type'),
}, },
{ {
prop: 'startNum', prop: 'startNum',
@ -79,6 +80,7 @@ export default {
{ {
type: 'select', type: 'select',
label: '能源类型', label: '能源类型',
labelField: 'labelName',
selectOptions: [], selectOptions: [],
param: 'energyTypeId', param: 'energyTypeId',
filterable: true, filterable: true,

View File

@ -1,46 +1,67 @@
<template> <template>
<el-form ref="form" :rules="rules" label-width="100px" :model="form"> <el-form
ref="form"
:rules="rules"
label-width="100px"
:model="form">
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="方案名称" prop="name"> <el-form-item
label="方案名称"
prop="name">
<el-input v-model="form.name"></el-input> <el-input v-model="form.name"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="方案编码" prop="code"> <el-form-item
<el-input v-model="form.code" disabled></el-input> label="方案编码"
prop="code">
<el-input
v-model="form.code"
disabled></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="统计类型" prop="type"> <el-form-item
<el-select v-model="form.type" placeholder="请选择" style="width: 100%;"> label="统计类型"
prop="type">
<el-select
v-model="form.type"
placeholder="请选择"
style="width: 100%">
<el-option <el-option
v-for="item in getDictDatas(DICT_TYPE.STATISTIC_TYPE)" v-for="item in getDictDatas(DICT_TYPE.STATISTIC_TYPE)"
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
:value="item.value"> :value="item.value"></el-option>
</el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="能源类型" prop="energyTypeId"> <el-form-item
<el-select v-model="form.energyTypeId" placeholder="请选择" style="width: 100%;" filterable> label="能源类型"
prop="energyTypeId">
<el-select
v-model="form.energyTypeId"
placeholder="请选择"
style="width: 100%"
filterable>
<el-option <el-option
v-for="item in energyListType" v-for="item in energyListType"
:key="item.id" :key="item.id"
:label="item.name" :label="item.labelName"
:value="item.id"> :value="item.id"></el-option>
</el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="备注" prop="remark"> <el-form-item
label="备注"
prop="remark">
<el-input v-model="form.remark"></el-input> <el-input v-model="form.remark"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -48,8 +69,13 @@
</el-form> </el-form>
</template> </template>
<script> <script>
import { getCode, createEnergyStatistics, updateEnergyStatistics, getEnergyStatistics } from "@/api/monitoring/energyStatistics"; import {
import { getEnergyTypeListAll } from '@/api/base/energyType' getCode,
createEnergyStatistics,
updateEnergyStatistics,
getEnergyStatistics,
} from '@/api/monitoring/energyStatistics';
import { getEnergyTypeListAll } from '@/api/base/energyType';
import { number } from 'echarts'; import { number } from 'echarts';
export default { export default {
name: 'EnergyStatisticsAdd', name: 'EnergyStatisticsAdd',
@ -60,39 +86,45 @@ export default {
name: '', name: '',
code: '', code: '',
type: '', type: '',
energyTypeId: '' energyTypeId: '',
}, },
plcList: [], plcList: [],
objList: [], objList: [],
isEdit: false, // isEdit: false, //
rules: { rules: {
name: [{ required: true, message: '方案名称不能为空', trigger: 'blur' }], name: [
type: [{ required: true, message: '统计类型不能为空', trigger: 'change' }], { required: true, message: '方案名称不能为空', trigger: 'blur' },
energyTypeId: [{ required: true, message: '能源类型不能为空', trigger: 'change' }] ],
type: [
{ required: true, message: '统计类型不能为空', trigger: 'change' },
],
energyTypeId: [
{ required: true, message: '能源类型不能为空', trigger: 'change' },
],
}, },
energyListType: [], energyListType: [],
} };
}, },
methods: { methods: {
init(id) { init(id) {
getEnergyTypeListAll().then((res) => { getEnergyTypeListAll().then((res) => {
this.energyListType = res.data || [] this.energyListType = res.data || [];
}) });
if (id) { if (id) {
this.isEdit = true this.isEdit = true;
this.form.id = id this.form.id = id;
getEnergyStatistics(id).then((res) => { getEnergyStatistics(id).then((res) => {
if (res.code === 0) { if (res.code === 0) {
this.form = res.data this.form = res.data;
this.form.type = this.form.type + '' this.form.type = this.form.type + '';
} }
}) });
} else { } else {
getCode().then((res) => { getCode().then((res) => {
this.form.code = res.data this.form.code = res.data;
}) });
this.isEdit = false this.isEdit = false;
this.form.id = '' this.form.id = '';
} }
}, },
submitForm() { submitForm() {
@ -102,27 +134,27 @@ export default {
// //
updateEnergyStatistics({ ...this.form }).then((res) => { updateEnergyStatistics({ ...this.form }).then((res) => {
if (res.code === 0) { if (res.code === 0) {
this.$modal.msgSuccess("操作成功"); this.$modal.msgSuccess('操作成功');
this.$emit('successSubmit') this.$emit('successSubmit');
} }
}) });
} else { } else {
createEnergyStatistics({ ...this.form }).then((res) => { createEnergyStatistics({ ...this.form }).then((res) => {
if (res.code === 0) { if (res.code === 0) {
this.$modal.msgSuccess("操作成功"); this.$modal.msgSuccess('操作成功');
this.$emit('successSubmit') this.$emit('successSubmit');
} }
}) });
} }
} else { } else {
return false return false;
} }
}) });
}, },
formClear() { formClear() {
this.$refs.form.resetFields() this.$refs.form.resetFields();
this.isEdit = false this.isEdit = false;
} },
} },
} };
</script> </script>

View File

@ -1,64 +1,90 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" /> <search-bar
:formConfigs="formConfig"
ref="searchBarForm"
@headBtnClick="buttonClick" />
<!-- 列表 --> <!-- 列表 -->
<base-table :page="queryParams.pageNo" :limit="queryParams.pageSize" :table-props="tableProps" :table-data="list" <base-table
:page="queryParams.pageNo"
:limit="queryParams.pageSize"
:table-props="tableProps"
:table-data="list"
:max-height="tableH"> :max-height="tableH">
<method-btn v-if="tableBtn.length" slot="handleBtn" :width="160" label="操作" :method-list="tableBtn" <method-btn
v-if="tableBtn.length"
slot="handleBtn"
:width="160"
label="操作"
:method-list="tableBtn"
@clickBtn="handleClick" /> @clickBtn="handleClick" />
</base-table> </base-table>
<pagination :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" :total="total" <pagination
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
:total="total"
@pagination="getList" /> @pagination="getList" />
<!-- 新增 --> <!-- 新增 -->
<base-dialog :dialogTitle="addOrEditTitle" :dialogVisible="centervisible" @cancel="handleCancel" <base-dialog
@confirm="handleConfirm" :before-close="handleCancel"> :dialogTitle="addOrEditTitle"
<energy-statistics-add ref="energyStatistics" @successSubmit="successSubmit" /> :dialogVisible="centervisible"
@cancel="handleCancel"
@confirm="handleConfirm"
:before-close="handleCancel">
<energy-statistics-add
ref="energyStatistics"
@successSubmit="successSubmit" />
</base-dialog> </base-dialog>
<!-- 参数绑定/查看 --> <!-- 参数绑定/查看 -->
<energy-statistics-det ref="plcParam" @closeDrawer="closeDrawer" <energy-statistics-det
ref="plcParam"
@closeDrawer="closeDrawer"
:energyTypeList="energyTypeList"></energy-statistics-det> :energyTypeList="energyTypeList"></energy-statistics-det>
</div> </div>
</template> </template>
<script> <script>
import { getEnergyStatisticsPage, deleteEnergyStatistics } from "@/api/monitoring/energyStatistics"; import {
import { publicFormatter } from '@/utils/dict' getEnergyStatisticsPage,
import { getEnergyTypeListAll } from '@/api/base/energyType' deleteEnergyStatistics,
import EnergyStatisticsAdd from './components/energyStatisticsAdd' } from '@/api/monitoring/energyStatistics';
import EnergyStatisticsDet from './components/energyStatisticsDet' import { publicFormatter } from '@/utils/dict';
import { getEnergyTypeListAll } from '@/api/base/energyType';
import EnergyStatisticsAdd from './components/energyStatisticsAdd';
import EnergyStatisticsDet from './components/energyStatisticsDet';
const tableProps = [ const tableProps = [
{ {
prop: 'name', prop: 'name',
label: '方案名称' label: '方案名称',
}, },
{ {
prop: 'code', prop: 'code',
label: '方案编码', label: '方案编码',
minWidth: 120, minWidth: 120,
showOverflowtooltip: true showOverflowtooltip: true,
}, },
{ {
prop: 'type', prop: 'type',
label: '统计类型', label: '统计类型',
filter: publicFormatter('statistic_type') filter: publicFormatter('statistic_type'),
}, },
{ {
prop: 'energyType', prop: 'energyType',
label: '能源类型' label: '能源类型',
filter: publicFormatter('energy_type'),
}, },
{ {
prop: 'paramNum', prop: 'paramNum',
label: '统计参数数量' label: '统计参数数量',
}, },
{ {
prop: 'remark', prop: 'remark',
label: '备注' label: '备注',
} },
] ];
export default { export default {
name: "EnergyStatistics", name: 'EnergyStatistics',
components: { EnergyStatisticsAdd, EnergyStatisticsDet }, components: { EnergyStatisticsAdd, EnergyStatisticsDet },
data() { data() {
return { return {
@ -67,49 +93,51 @@ export default {
type: 'input', type: 'input',
label: '方案名称', label: '方案名称',
placeholder: '方案名称', placeholder: '方案名称',
param: 'name' param: 'name',
}, },
{ {
type: 'button', type: 'button',
btnName: '查询', btnName: '查询',
name: 'search', name: 'search',
color: 'primary' color: 'primary',
}, },
{ {
type: 'separate' type: 'separate',
}, },
{ {
type: this.$auth.hasPermi('monitoring:energy-statistics:create') ? 'button' : '', type: this.$auth.hasPermi('monitoring:energy-statistics:create')
? 'button'
: '',
btnName: '新增', btnName: '新增',
name: 'add', name: 'add',
color: 'success', color: 'success',
plain: true plain: true,
} },
], ],
tableProps, tableProps,
tableBtn: [ tableBtn: [
this.$auth.hasPermi('monitoring:energy-statistics:bind') this.$auth.hasPermi('monitoring:energy-statistics:bind')
? { ? {
type: 'connect', type: 'connect',
btnName: '绑定' btnName: '绑定',
} }
: undefined, : undefined,
{ {
type: 'detail', type: 'detail',
btnName: '详情' btnName: '详情',
}, },
this.$auth.hasPermi('monitoring:energy-statistics:update') this.$auth.hasPermi('monitoring:energy-statistics:update')
? { ? {
type: 'edit', type: 'edit',
btnName: '编辑' btnName: '编辑',
} }
: undefined, : undefined,
this.$auth.hasPermi('monitoring:energy-statistics:delete') this.$auth.hasPermi('monitoring:energy-statistics:delete')
? { ? {
type: 'delete', type: 'delete',
btnName: '删除' btnName: '删除',
} }
: undefined : undefined,
].filter((v) => v), ].filter((v) => v),
tableH: this.tableHeight(260), tableH: this.tableHeight(260),
// //
@ -117,106 +145,110 @@ export default {
// //
list: [], list: [],
// //
addOrEditTitle: "", addOrEditTitle: '',
// //
centervisible: false, centervisible: false,
// //
queryParams: { queryParams: {
pageNo: 1, pageNo: 1,
pageSize: 20, pageSize: 20,
name: null name: null,
}, },
energyTypeList: [] energyTypeList: [],
}; };
}, },
created() { created() {
window.addEventListener('resize', () => { window.addEventListener('resize', () => {
this.tableH = this.tableHeight(260) this.tableH = this.tableHeight(260);
}) });
this.getList(); this.getList();
}, },
mounted() { mounted() {
// //
this.getEnergyTypeList() this.getEnergyTypeList();
}, },
methods: { methods: {
buttonClick(val) { buttonClick(val) {
switch (val.btnName) { switch (val.btnName) {
case 'search': case 'search':
this.queryParams.pageNo = 1; this.queryParams.pageNo = 1;
this.queryParams.name = val.name this.queryParams.name = val.name;
this.getList() this.getList();
break break;
default: default:
this.addOrEditTitle = '新增' this.addOrEditTitle = '新增';
this.centervisible = true this.centervisible = true;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.energyStatistics.init() this.$refs.energyStatistics.init();
}) });
} }
}, },
/** 查询列表 */ /** 查询列表 */
getList() { getList() {
getEnergyStatisticsPage(this.queryParams).then(response => { getEnergyStatisticsPage(this.queryParams).then((response) => {
let arr = response.data.list || []; let arr = response.data.list || [];
this.list = arr this.list = arr;
this.total = response.data.total; this.total = response.data.total;
}); });
}, },
handleClick(val) { handleClick(val) {
console.log(val) console.log(val);
switch (val.type) { switch (val.type) {
case 'edit': case 'edit':
this.addOrEditTitle = '编辑' this.addOrEditTitle = '编辑';
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.energyStatistics.init(val.data.id) this.$refs.energyStatistics.init(val.data.id);
}) });
this.centervisible = true this.centervisible = true;
break break;
case 'delete': case 'delete':
this.handleDelete(val.data) this.handleDelete(val.data);
break break;
case 'detail': case 'detail':
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.plcParam.init(val.data, 'detail') this.$refs.plcParam.init(val.data, 'detail');
}) });
break break;
default: default:
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.plcParam.init(val.data, 'connect') this.$refs.plcParam.init(val.data, 'connect');
}) });
} }
}, },
handleCancel() { handleCancel() {
this.$refs.energyStatistics.formClear() this.$refs.energyStatistics.formClear();
this.centervisible = false this.centervisible = false;
this.addOrEditTitle = '' this.addOrEditTitle = '';
}, },
handleConfirm() { handleConfirm() {
this.$refs.energyStatistics.submitForm() this.$refs.energyStatistics.submitForm();
}, },
successSubmit() { successSubmit() {
this.handleCancel() this.handleCancel();
this.getList() this.getList();
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
this.$modal.confirm('是否确认删除方案名称为"' + row.name + '"的数据项?').then(function () { this.$modal
.confirm('是否确认删除方案名称为"' + row.name + '"的数据项?')
.then(function () {
return deleteEnergyStatistics(row.id); return deleteEnergyStatistics(row.id);
}).then(() => { })
.then(() => {
this.queryParams.pageNo = 1; this.queryParams.pageNo = 1;
this.getList(); this.getList();
this.$modal.msgSuccess("删除成功"); this.$modal.msgSuccess('删除成功');
}).catch(() => { }); })
.catch(() => {});
}, },
closeDrawer() { closeDrawer() {
this.getList() this.getList();
}, },
getEnergyTypeList() { getEnergyTypeList() {
getEnergyTypeListAll().then((res) => { getEnergyTypeListAll().then((res) => {
this.energyTypeList = res.data || [] this.energyTypeList = res.data || [];
}) });
} },
} },
}; };
</script> </script>