projects/mesxc-zjl #301
4
.env.dev
4
.env.dev
@ -18,9 +18,9 @@ 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.159:48080'
|
VUE_APP_BASE_API = 'http://192.168.4.173:48082'
|
||||||
# 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'
|
||||||
# VUE_APP_BASE_API = 'http://192.168.1.78:48082'
|
# VUE_APP_BASE_API = 'http://192.168.1.78:48082'
|
||||||
# VUE_APP_BASE_API = 'http://192.168.1.47:48082'
|
# VUE_APP_BASE_API = 'http://192.168.1.47:48082'
|
||||||
|
@ -35,3 +35,21 @@ export function getQoq(data) {
|
|||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取能源设备树
|
||||||
|
export function getTree() {
|
||||||
|
return request({
|
||||||
|
url: '/analysis/energy-analysis/getTree',
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出(走势分析)
|
||||||
|
export function exportTrend(data) {
|
||||||
|
return request({
|
||||||
|
url: '/analysis/energy-analysis/exportTrend',
|
||||||
|
method: 'post',
|
||||||
|
responseType: 'blob',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
@ -68,3 +68,4 @@ export function exportEnergyTypeExcel(query) {
|
|||||||
responseType: 'blob'
|
responseType: 'blob'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,6 +97,8 @@ export const DICT_TYPE = {
|
|||||||
TABLE_NAME: 'table_name',
|
TABLE_NAME: 'table_name',
|
||||||
METHOD: 'method',
|
METHOD: 'method',
|
||||||
PUSH: 'push',
|
PUSH: 'push',
|
||||||
|
ENERGY_TYPE: 'energy_type',
|
||||||
|
|
||||||
|
|
||||||
// ============== ORDER - 订单模块 =============
|
// ============== ORDER - 订单模块 =============
|
||||||
ORDER_STATUS: 'order_status',
|
ORDER_STATUS: 'order_status',
|
||||||
@ -117,7 +119,7 @@ export const DICT_TYPE = {
|
|||||||
|
|
||||||
// ============== GROUP - 班组模块 =============
|
// ============== GROUP - 班组模块 =============
|
||||||
WORK_SHOP: 'workshop',
|
WORK_SHOP: 'workshop',
|
||||||
// ============== GROUP - 质量模块 =============
|
// ============== GROUP - 质量模块 =============
|
||||||
MATERIAL_GRADE: 'material_grade'
|
MATERIAL_GRADE: 'material_grade'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,148 +1,149 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
id="analysischartBar"
|
id="analysischartBar"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
:style="{ height: chartHeight + 'px' }"
|
:style="{ height: chartHeight + 'px' }"></div>
|
||||||
></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: "BarChart",
|
name: 'BarChart',
|
||||||
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 [];
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
timeDim: {
|
timeDim: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: '',
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
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() {
|
||||||
if (
|
if (
|
||||||
this.chart !== null &&
|
this.chart !== null &&
|
||||||
this.chart !== '' &&
|
this.chart !== '' &&
|
||||||
this.chart !== undefined
|
this.chart !== undefined
|
||||||
) {
|
) {
|
||||||
this.chart.dispose() // 页面多次刷新会出现警告,Dom已经初始化了一个实例,这是销毁实例
|
this.chart.dispose(); // 页面多次刷新会出现警告,Dom已经初始化了一个实例,这是销毁实例
|
||||||
}
|
}
|
||||||
this.chartDom = document.getElementById('analysischartBar')
|
this.chartDom = document.getElementById('analysischartBar');
|
||||||
this.chart = echarts.init(this.chartDom)
|
this.chart = echarts.init(this.chartDom);
|
||||||
let tempArr = []
|
let tempArr = [];
|
||||||
let xData = []
|
let xData = [];
|
||||||
let yData = []
|
let yData = [];
|
||||||
let legendData = []
|
let legendData = [];
|
||||||
if (this.chartData.length === 0) {
|
if (this.chartData.length === 0) {
|
||||||
return false
|
return false;
|
||||||
} else {
|
} else {
|
||||||
tempArr = this.chartData[0].trendRespVOList
|
tempArr = this.chartData[0].trendRespVOList;
|
||||||
}
|
}
|
||||||
for (let k = 0; k < tempArr.length; k++) {
|
for (let k = 0; k < tempArr.length; k++) {
|
||||||
let time = ''
|
let time = '';
|
||||||
if (this.timeDim === '3') {
|
if (this.timeDim === '3') {
|
||||||
let year = tempArr[k].time.slice(0,4)
|
let year = tempArr[k].time.slice(0, 4);
|
||||||
let weak = tempArr[k].time.slice(4,6)
|
let weak = tempArr[k].time.slice(4, 6);
|
||||||
time = year+' 第 '+weak+' 周'
|
time = year + ' 第 ' + weak + ' 周';
|
||||||
} else {
|
} else {
|
||||||
time = tempArr[k].time
|
time = tempArr[k].time;
|
||||||
}
|
}
|
||||||
xData.push(time)
|
xData.push(time);
|
||||||
}
|
}
|
||||||
for (let i = 0; i < this.chartData.length; i++) {
|
for (let i = 0; i < this.chartData.length; i++) {
|
||||||
let obj = {
|
let obj = {
|
||||||
name: this.chartData[i].objName + this.chartData[i].objCode,
|
name: this.chartData[i].objName + this.chartData[i].objCode,
|
||||||
type: 'bar',
|
type: 'bar',
|
||||||
barMaxWidth: 20,
|
barMaxWidth: 20,
|
||||||
label: {
|
label: {
|
||||||
show: true,
|
show: true,
|
||||||
position: 'top'
|
position: 'top',
|
||||||
},
|
},
|
||||||
data: []
|
data: [],
|
||||||
}
|
};
|
||||||
legendData.push(this.chartData[i].objName + this.chartData[i].objCode)
|
legendData.push(this.chartData[i].objName + this.chartData[i].objCode);
|
||||||
let temp = this.chartData[i].trendRespVOList
|
let temp = this.chartData[i].trendRespVOList;
|
||||||
for (let j = 0; j < temp.length; j++) {
|
for (let j = 0; j < temp.length; j++) {
|
||||||
let num = temp[j].useNum ? temp[j].useNum : ''
|
let num = temp[j].useNum ? temp[j].useNum.toFixed(2) : '';
|
||||||
obj.data.push(num)
|
obj.data.push(num);
|
||||||
}
|
}
|
||||||
yData.push(obj)
|
yData.push(obj);
|
||||||
}
|
}
|
||||||
var option = {
|
var option = {
|
||||||
color:['#FFDC94','#8EF0AB','#63BDFF','#288AFF','#7164FF'],
|
color: ['#FFDC94', '#8EF0AB', '#63BDFF', '#288AFF', '#7164FF'],
|
||||||
tooltip: {
|
tooltip: {
|
||||||
trigger: 'axis',
|
trigger: 'axis',
|
||||||
axisPointer: {
|
axisPointer: {
|
||||||
type: 'shadow'
|
type: 'shadow',
|
||||||
},
|
},
|
||||||
formatter: function(params) {
|
formatter: function (params) {
|
||||||
return (
|
return (
|
||||||
params[0].axisValue +
|
params[0].axisValue +
|
||||||
`<br>` +
|
`<br>` +
|
||||||
params.map((item) => {
|
params
|
||||||
let str = `<span style="display:inline-block;width:8px;height:8px;margin: 0 8px 0 -3px;border-radius:2px;background-color:${item.color};"></span>`
|
.map((item) => {
|
||||||
let seriesNameStr = `<span style="display:inline-block;">${item.seriesName}</span>`
|
let str = `<span style="display:inline-block;width:8px;height:8px;margin: 0 8px 0 -3px;border-radius:2px;background-color:${item.color};"></span>`;
|
||||||
let value = item.value ? item.value : '-'
|
let seriesNameStr = `<span style="display:inline-block;">${item.seriesName}</span>`;
|
||||||
let valueStr = `<span style="display:inline-block;margin-left:10px;color:rgba(0,0,0,0.45);">${value}</span>`
|
let value = item.value ? item.value : '-';
|
||||||
return `<span style="display:flex; justify-content:space-between; margin-bottom: 2px">
|
let valueStr = `<span style="display:inline-block;margin-left:10px;color:rgba(0,0,0,0.45);">${value}</span>`;
|
||||||
|
return `<span style="display:flex; justify-content:space-between; margin-bottom: 2px">
|
||||||
<span>${str}${seriesNameStr}</span>
|
<span>${str}${seriesNameStr}</span>
|
||||||
<span>${valueStr}</span>
|
<span>${valueStr}</span>
|
||||||
</span>`
|
</span>`;
|
||||||
}).join(``)
|
})
|
||||||
)
|
.join(``)
|
||||||
}
|
);
|
||||||
},
|
},
|
||||||
grid: {
|
},
|
||||||
left: '4%',
|
grid: {
|
||||||
right: '1%',
|
left: '4%',
|
||||||
bottom: '1%',
|
right: '1%',
|
||||||
containLabel: true
|
bottom: '1%',
|
||||||
},
|
containLabel: true,
|
||||||
legend: {
|
},
|
||||||
data: legendData,
|
legend: {
|
||||||
right: '1%',
|
data: legendData,
|
||||||
icon: 'rect',
|
right: '1%',
|
||||||
itemHeight: 8,
|
icon: 'rect',
|
||||||
itemWidth: 8
|
itemHeight: 8,
|
||||||
},
|
itemWidth: 8,
|
||||||
xAxis: {
|
},
|
||||||
type: 'category',
|
xAxis: {
|
||||||
data: xData,
|
type: 'category',
|
||||||
axisLabel: {
|
data: xData,
|
||||||
rotate: "45"
|
axisLabel: {
|
||||||
}
|
rotate: '45',
|
||||||
},
|
},
|
||||||
yAxis: {
|
},
|
||||||
type: 'value'
|
yAxis: {
|
||||||
},
|
type: 'value',
|
||||||
series: yData
|
},
|
||||||
};
|
series: yData,
|
||||||
|
};
|
||||||
|
|
||||||
option && this.chart.setOption(option);
|
option && this.chart.setOption(option);
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
@ -1,126 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div
|
|
||||||
id="analysischartLine"
|
|
||||||
style="width: 100%"
|
|
||||||
:style="{ height: chartHeight + 'px' }"
|
|
||||||
></div>
|
|
||||||
</template>
|
|
||||||
<script>
|
|
||||||
import * as echarts from 'echarts'
|
|
||||||
import resize from '@/utils/chartMixins/resize'
|
|
||||||
export default {
|
|
||||||
name: "LineChart",
|
|
||||||
mixins: [resize],
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
chartDom: '',
|
|
||||||
chart: '',
|
|
||||||
chartHeight: this.tableHeight(214) - 70
|
|
||||||
}
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
chartData: {
|
|
||||||
type: Array,
|
|
||||||
required: true,
|
|
||||||
default: () => {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
timeDim: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
chartData: function () {
|
|
||||||
this.getChart()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
window.addEventListener('resize', () => {
|
|
||||||
this.chartHeight = this.tableHeight(214) - 70
|
|
||||||
})
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
getChart() {
|
|
||||||
if (
|
|
||||||
this.chart !== null &&
|
|
||||||
this.chart !== '' &&
|
|
||||||
this.chart !== undefined
|
|
||||||
) {
|
|
||||||
this.chart.dispose() // 页面多次刷新会出现警告,Dom已经初始化了一个实例,这是销毁实例
|
|
||||||
}
|
|
||||||
this.chartDom = document.getElementById('analysischartLine')
|
|
||||||
this.chart = echarts.init(this.chartDom)
|
|
||||||
let tempArr = []
|
|
||||||
let xData = []
|
|
||||||
let yData = []
|
|
||||||
let legendData = []
|
|
||||||
if (this.chartData.length === 0) {
|
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
tempArr = this.chartData[0].trendRespVOList
|
|
||||||
}
|
|
||||||
for (let k = 0; k < tempArr.length; k++) {
|
|
||||||
let time = ''
|
|
||||||
if (this.timeDim === '3') {
|
|
||||||
let year = tempArr[k].time.slice(0,4)
|
|
||||||
let weak = tempArr[k].time.slice(4,6)
|
|
||||||
time = year+' 第 '+weak+' 周'
|
|
||||||
} else {
|
|
||||||
time = tempArr[k].time
|
|
||||||
}
|
|
||||||
xData.push(time)
|
|
||||||
}
|
|
||||||
for (let i = 0; i < this.chartData.length; i++) {
|
|
||||||
let obj = {
|
|
||||||
name: this.chartData[i].objName + this.chartData[i].objCode,
|
|
||||||
type: 'line',
|
|
||||||
stack: 'Total',
|
|
||||||
data: []
|
|
||||||
}
|
|
||||||
legendData.push(this.chartData[i].objName + this.chartData[i].objCode)
|
|
||||||
let temp = this.chartData[i].trendRespVOList
|
|
||||||
for (let j = 0; j < temp.length; j++) {
|
|
||||||
let num = temp[j].useNum ? temp[j].useNum : ''
|
|
||||||
obj.data.push(num)
|
|
||||||
}
|
|
||||||
yData.push(obj)
|
|
||||||
}
|
|
||||||
|
|
||||||
var option = {
|
|
||||||
color:['#FFDC94','#8EF0AB','#63BDFF','#288AFF','#7164FF'],
|
|
||||||
tooltip: {
|
|
||||||
trigger: 'axis',
|
|
||||||
axisPointer: {
|
|
||||||
type: 'cross'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
grid: {
|
|
||||||
left: '4%',
|
|
||||||
right: '1%',
|
|
||||||
bottom: '1%',
|
|
||||||
containLabel: true
|
|
||||||
},
|
|
||||||
legend: {
|
|
||||||
data: legendData,
|
|
||||||
right: '1%'
|
|
||||||
},
|
|
||||||
xAxis: {
|
|
||||||
type: 'category',
|
|
||||||
data: xData,
|
|
||||||
axisLabel: {
|
|
||||||
rotate: "45"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
yAxis: {
|
|
||||||
type: 'value'
|
|
||||||
},
|
|
||||||
series: yData
|
|
||||||
};
|
|
||||||
|
|
||||||
option && this.chart.setOption(option);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
File diff suppressed because it is too large
Load Diff
@ -1,96 +1,129 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container contrastAnalysisBox" id="contrastAnalysisBox">
|
<div
|
||||||
<!-- 搜索工作栏 -->
|
class="app-container contrastAnalysisBox"
|
||||||
<search-area :isFold="isFold" @submit="getList"/>
|
id="contrastAnalysisBox">
|
||||||
<el-tabs v-model="activeName" @tab-click="switchChart" v-show='chartData.length'>
|
<!-- 搜索工作栏 -->
|
||||||
<el-tab-pane label="柱状图" name="bar">
|
<search-area
|
||||||
<bar-chart ref="analysisBarChart" :chartData="chartData" :timeDim="timeDim" />
|
:isFold="isFold"
|
||||||
</el-tab-pane>
|
@submit="getList"
|
||||||
<el-tab-pane label="折线图" name="line">
|
@export="exportExl" />
|
||||||
<line-chart ref="analysisLineChart" :chartData="chartData" :timeDim="timeDim"/>
|
<div v-show="chartData.length">
|
||||||
</el-tab-pane>
|
<bar-chart
|
||||||
</el-tabs>
|
ref="analysisBarChart"
|
||||||
<!-- 没有数据 -->
|
:chartData="chartData"
|
||||||
<div class="no-data-bg" v-show='!chartData.length'></div>
|
:timeDim="timeDim" />
|
||||||
</div>
|
<base-table
|
||||||
|
:table-props="tableProps"
|
||||||
|
:table-data="list"
|
||||||
|
:max-height="tableH"
|
||||||
|
class="contrast-out-table" />
|
||||||
|
</div>
|
||||||
|
<!-- 没有数据 -->
|
||||||
|
<div
|
||||||
|
class="no-data-bg"
|
||||||
|
v-show="!chartData.length"></div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { getCompare } from "@/api/analysis/energyAnalysis"
|
import { getCompare } from '@/api/analysis/energyAnalysis';
|
||||||
import SearchArea from "./components/searchArea"
|
import SearchArea from './components/searchArea';
|
||||||
import BarChart from "./components/barChart"
|
import BarChart from './components/barChart';
|
||||||
import LineChart from "./components/lineChart"
|
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
|
||||||
|
import FileSaver from 'file-saver';
|
||||||
|
import * as XLSX from 'xlsx/xlsx.mjs';
|
||||||
// import moment from 'moment'
|
// import moment from 'moment'
|
||||||
export default {
|
export default {
|
||||||
name: 'ContrastAnalysis',
|
name: 'ContrastAnalysis',
|
||||||
components: { SearchArea, BarChart, LineChart },
|
components: { SearchArea, BarChart },
|
||||||
data() {
|
mixins: [tableHeightMixin],
|
||||||
return {
|
data() {
|
||||||
isFold: false,
|
return {
|
||||||
activeName: 'bar',
|
isFold: false,
|
||||||
chartData: [],
|
chartData: [],
|
||||||
timeDim: ''
|
timeDim: '',
|
||||||
}
|
tableProps: [],
|
||||||
},
|
list: [],
|
||||||
mounted() {
|
tableH: this.tableHeight(250) / 2,
|
||||||
window.addEventListener('resize', () => {
|
};
|
||||||
this.tableH = this.tableHeight(260)
|
},
|
||||||
this.isFold = this.searchBarWidth('contrastAnalysisBox', 1437)
|
mounted() {
|
||||||
// console.log(document.getElementById("contrastAnalysisBox").offsetWidth)
|
window.addEventListener('resize', () => {
|
||||||
})
|
this.isFold = this.searchBarWidth('contrastAnalysisBox', 1437);
|
||||||
this.isFold = this.searchBarWidth('contrastAnalysisBox', 1437)
|
// console.log(document.getElementById("contrastAnalysisBox").offsetWidth)
|
||||||
},
|
});
|
||||||
methods: {
|
this.isFold = this.searchBarWidth('contrastAnalysisBox', 1437);
|
||||||
getList(params) {
|
},
|
||||||
this.timeDim = params.timeDim
|
methods: {
|
||||||
getCompare({ ...params }).then((res) => {
|
_setTableHeight() {
|
||||||
console.log(res)
|
this.tableH = this.tableHeight(250) / 2;
|
||||||
if (res.code === 0) {
|
},
|
||||||
this.chartData = res.data || []
|
getList(params) {
|
||||||
} else {
|
this.timeDim = params.timeDim;
|
||||||
this.chartData = []
|
getCompare({ ...params }).then((res) => {
|
||||||
}
|
if (res.code === 0) {
|
||||||
})
|
this.getTableList(res.data || []);
|
||||||
},
|
this.chartData = res.data || [];
|
||||||
switchChart() {
|
} else {
|
||||||
if (this.activeName === 'bar') {
|
this.chartData = [];
|
||||||
this.$nextTick((res) => {
|
}
|
||||||
this.$refs.analysisBarChart.getChart()
|
});
|
||||||
})
|
},
|
||||||
} else {
|
getTableList(arr) {
|
||||||
this.$nextTick((res) => {
|
this.tableProps = [];
|
||||||
this.$refs.analysisLineChart.getChart()
|
this.list = [];
|
||||||
})
|
let tempX = [];
|
||||||
}
|
let timeArr = arr[0].trendRespVOList || [];
|
||||||
}
|
this.list = timeArr.map((item) => {
|
||||||
}
|
return { time: item.time };
|
||||||
}
|
});
|
||||||
|
for (let i = 0; i < arr.length; i++) {
|
||||||
|
let obj = {};
|
||||||
|
obj.prop = arr[i].objId;
|
||||||
|
obj.label = arr[i].objName;
|
||||||
|
obj.minWidth = 100;
|
||||||
|
tempX.push(obj);
|
||||||
|
let tiemList = arr[i].trendRespVOList;
|
||||||
|
for (let j = 0; j < tiemList.length; j++) {
|
||||||
|
this.list[j][arr[i].objId] = tiemList[j].useNum
|
||||||
|
? tiemList[j].useNum.toFixed(2)
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.tableProps = [{ prop: 'time', label: '时间' }].concat(tempX);
|
||||||
|
},
|
||||||
|
// 导出
|
||||||
|
exportExl() {
|
||||||
|
if (this.list.length > 0) {
|
||||||
|
var wb = XLSX.utils.table_to_book(
|
||||||
|
document.querySelector('.contrast-out-table')
|
||||||
|
);
|
||||||
|
let fileName = '对比分析.xlsx';
|
||||||
|
var wbout = XLSX.write(wb, {
|
||||||
|
bookType: 'xlsx',
|
||||||
|
bookSST: true,
|
||||||
|
type: 'array',
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
FileSaver.saveAs(
|
||||||
|
new Blob([wbout], { type: 'application/octet-stream' }),
|
||||||
|
fileName
|
||||||
|
);
|
||||||
|
this.$message.success('导出成功');
|
||||||
|
} catch (e) {
|
||||||
|
if (typeof console !== 'undefined') console.log(e, wbout);
|
||||||
|
}
|
||||||
|
return wbout;
|
||||||
|
} else {
|
||||||
|
this.$modal.msgWarning('暂无数据导出');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
<style lang='scss'>
|
<style lang='scss'>
|
||||||
.contrastAnalysisBox {
|
.contrastAnalysisBox {
|
||||||
.el-tabs__nav::after {
|
.contrast-out-table {
|
||||||
content: "";
|
margin-top: 20px;
|
||||||
position: absolute;
|
}
|
||||||
left: 0;
|
|
||||||
bottom: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 2px;
|
|
||||||
background-color: #e4e7ed;
|
|
||||||
/* z-index: 1; */
|
|
||||||
}
|
|
||||||
.el-tabs__nav-wrap::after {
|
|
||||||
width: 0;
|
|
||||||
}
|
|
||||||
.el-tabs__item {
|
|
||||||
padding: 0 10px;
|
|
||||||
}
|
|
||||||
.el-tabs__item:hover {
|
|
||||||
color: rgba(0, 0, 0, 0.85);
|
|
||||||
}
|
|
||||||
.el-tabs__item.is-active {
|
|
||||||
color: rgba(0, 0, 0, 0.85);
|
|
||||||
}
|
|
||||||
.el-tabs__item {
|
|
||||||
color: rgba(0, 0, 0, 0.45);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
@ -1,232 +1,253 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-form :inline="true" class="demo-form-inline">
|
<el-form
|
||||||
<span class="blue-block"></span>
|
:inline="true"
|
||||||
<el-form-item label="对象选择" required>
|
class="demo-form-inline">
|
||||||
<el-cascader
|
<span class="blue-block"></span>
|
||||||
v-model="objArr"
|
<el-form-item
|
||||||
:options="objList"
|
label="对象选择"
|
||||||
:props="{ checkStrictly: true, value: 'id', label: 'name' }"
|
required>
|
||||||
popper-class="cascaderParent"
|
<el-select
|
||||||
size="small"
|
v-model="queryParams.objId"
|
||||||
style="width: 250px;"
|
placeholder="请选择"
|
||||||
clearable></el-cascader>
|
style="width: 250px"
|
||||||
</el-form-item>
|
filterable
|
||||||
<el-form-item label="时间维度" required>
|
size="small">
|
||||||
<el-select v-model="queryParams.type" placeholder="请选择" style="width: 80px;" size="small">
|
<el-option
|
||||||
<el-option
|
v-for="item in objList"
|
||||||
v-for="item in timeType"
|
:key="item.id"
|
||||||
:key="item.id"
|
:label="item.name"
|
||||||
:label="item.name"
|
:value="item.id"
|
||||||
:value="item.id"
|
:clearable="false"></el-option>
|
||||||
:clearable="false">
|
</el-select>
|
||||||
</el-option>
|
</el-form-item>
|
||||||
</el-select>
|
<el-form-item
|
||||||
</el-form-item>
|
label="时间维度"
|
||||||
<el-form-item label="时间" required>
|
required>
|
||||||
<div v-show="queryParams.type === 1">
|
<el-select
|
||||||
<el-date-picker
|
v-model="queryParams.type"
|
||||||
v-model="monthValue"
|
placeholder="请选择"
|
||||||
type="month"
|
style="width: 80px"
|
||||||
:picker-options="pickerOptions"
|
size="small">
|
||||||
@change="selectTime"
|
<el-option
|
||||||
:clearable="false"
|
v-for="item in timeType"
|
||||||
size="small"
|
:key="item.id"
|
||||||
placeholder="选择月">
|
:label="item.name"
|
||||||
</el-date-picker>
|
:value="item.id"
|
||||||
</div>
|
:clearable="false"></el-option>
|
||||||
<div v-show="queryParams.type === 2">
|
</el-select>
|
||||||
<el-date-picker
|
</el-form-item>
|
||||||
v-model="weekValue"
|
<el-form-item
|
||||||
type="week"
|
label="时间"
|
||||||
format="yyyy 第 WW 周"
|
required>
|
||||||
:picker-options="pickerOptionsWeek"
|
<div v-show="queryParams.type === 1">
|
||||||
@change="selectTime"
|
<el-date-picker
|
||||||
:clearable="false"
|
v-model="monthValue"
|
||||||
size="small"
|
type="month"
|
||||||
placeholder="选择周">
|
:picker-options="pickerOptions"
|
||||||
</el-date-picker>
|
@change="selectTime"
|
||||||
</div>
|
:clearable="false"
|
||||||
<div v-show="queryParams.type === 3">
|
size="small"
|
||||||
<el-date-picker
|
placeholder="选择月"></el-date-picker>
|
||||||
v-model="dateValue"
|
</div>
|
||||||
type="date"
|
<div v-show="queryParams.type === 2">
|
||||||
:picker-options="pickerOptions"
|
<el-date-picker
|
||||||
@change="selectTime"
|
v-model="weekValue"
|
||||||
:clearable="false"
|
type="week"
|
||||||
size="small"
|
format="yyyy 第 WW 周"
|
||||||
placeholder="选择日">
|
:picker-options="pickerOptionsWeek"
|
||||||
</el-date-picker>
|
@change="selectTime"
|
||||||
</div>
|
:clearable="false"
|
||||||
</el-form-item>
|
size="small"
|
||||||
<el-form-item>
|
placeholder="选择周"></el-date-picker>
|
||||||
<el-button type="primary" size="small" @click="search">查询</el-button>
|
</div>
|
||||||
</el-form-item>
|
<div v-show="queryParams.type === 3">
|
||||||
<el-form-item>
|
<el-date-picker
|
||||||
<span class="separateStyle"></span>
|
v-model="dateValue"
|
||||||
</el-form-item>
|
type="date"
|
||||||
<el-form-item>
|
:picker-options="pickerOptions"
|
||||||
<el-button type="primary" size="small" @click="exportData" plain>导出</el-button>
|
@change="selectTime"
|
||||||
</el-form-item>
|
:clearable="false"
|
||||||
</el-form>
|
size="small"
|
||||||
|
placeholder="选择日"></el-date-picker>
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
size="small"
|
||||||
|
@click="search">
|
||||||
|
查询
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<span class="separateStyle"></span>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
size="small"
|
||||||
|
@click="exportData"
|
||||||
|
plain>
|
||||||
|
导出
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { getTree } from '@/api/base/factory'
|
import { getTree } from '@/api/analysis/energyAnalysis';
|
||||||
import moment from 'moment'
|
import moment from 'moment';
|
||||||
export default {
|
export default {
|
||||||
name: 'searchArea',
|
name: 'searchArea',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
type: 1,
|
type: 1,
|
||||||
searchTime: null,
|
searchTime: null,
|
||||||
objId: null
|
objId: null,
|
||||||
},
|
objType: 1,
|
||||||
timeType: [
|
},
|
||||||
{id: 1, name: '月'},
|
timeType: [
|
||||||
{id: 2, name: '周'},
|
{ id: 1, name: '月' },
|
||||||
{id: 3, name: '日'}
|
{ id: 2, name: '周' },
|
||||||
],
|
{ id: 3, name: '日' },
|
||||||
monthValue: '',
|
],
|
||||||
weekValue: '',
|
monthValue: '',
|
||||||
dateValue: '',
|
weekValue: '',
|
||||||
objArr: [],
|
dateValue: '',
|
||||||
objList: [],
|
objList: [],
|
||||||
pickerOptions: {
|
pickerOptions: {
|
||||||
disabledDate(date) {
|
disabledDate(date) {
|
||||||
return date.getTime() > Date.now()
|
return date.getTime() > Date.now();
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
pickerOptionsWeek: {
|
pickerOptionsWeek: {
|
||||||
disabledDate(time) {
|
disabledDate(time) {
|
||||||
let day = Date.now()
|
let day = Date.now();
|
||||||
let limitTime = moment(day).day(-1)
|
let limitTime = moment(day).day(-1);
|
||||||
return time.getTime() > new Date(limitTime).getTime()
|
return time.getTime() > new Date(limitTime).getTime();
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.getObjTree()
|
this.getObjTree();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getObjTree() {
|
getObjTree() {
|
||||||
getTree().then(res => {
|
getTree().then((res) => {
|
||||||
this.objList = res.data || []
|
this.objList = res.data || [];
|
||||||
})
|
if (this.objList.length > 0) {
|
||||||
},
|
this.queryParams.objId = this.objList[0].id;
|
||||||
selectTime() {
|
}
|
||||||
switch (this.queryParams.type) {
|
});
|
||||||
case 1:
|
},
|
||||||
this.queryParams.searchTime = this.monthValue
|
selectTime() {
|
||||||
break;
|
switch (this.queryParams.type) {
|
||||||
case 2:
|
case 1:
|
||||||
this.queryParams.searchTime = this.weekValue
|
this.queryParams.searchTime = this.monthValue;
|
||||||
break;
|
break;
|
||||||
default:
|
case 2:
|
||||||
this.queryParams.searchTime = this.dateValue
|
this.queryParams.searchTime = this.weekValue;
|
||||||
}
|
break;
|
||||||
},
|
default:
|
||||||
// 查询
|
this.queryParams.searchTime = this.dateValue;
|
||||||
search() {
|
}
|
||||||
if (this.objArr.length === 0) {
|
},
|
||||||
this.$modal.msgError('请选择对象')
|
// 查询
|
||||||
return false
|
search() {
|
||||||
} else {
|
if (!this.queryParams.objId) {
|
||||||
this.queryParams.objId = this.objArr[this.objArr.length-1]
|
this.$modal.msgError('请选择对象');
|
||||||
}
|
return false;
|
||||||
if (!this.queryParams.type) {
|
}
|
||||||
this.$modal.msgError('请选择时间维度')
|
if (!this.queryParams.type) {
|
||||||
return false
|
this.$modal.msgError('请选择时间维度');
|
||||||
}
|
return false;
|
||||||
if (!this.queryParams.searchTime) {
|
}
|
||||||
this.$modal.msgError('请选择时间')
|
if (!this.queryParams.searchTime) {
|
||||||
return false
|
this.$modal.msgError('请选择时间');
|
||||||
}
|
return false;
|
||||||
switch (this.queryParams.type) {
|
}
|
||||||
case 1:
|
switch (this.queryParams.type) {
|
||||||
this.queryParams.searchTime = this.transformTime(this.monthValue)
|
case 1:
|
||||||
break;
|
this.queryParams.searchTime = this.transformTime(this.monthValue);
|
||||||
case 2:
|
break;
|
||||||
let value = moment(this.weekValue).day(6).format('YYYY-MM-DD') + ' 23:59:59'
|
case 2:
|
||||||
this.queryParams.searchTime = new Date(value).getTime()
|
let value =
|
||||||
break;
|
moment(this.weekValue).day(6).format('YYYY-MM-DD') + ' 23:59:59';
|
||||||
default:
|
this.queryParams.searchTime = new Date(value).getTime();
|
||||||
let value2 = moment(this.dateValue).format('YYYY-MM-DD') + ' 23:59:59'
|
break;
|
||||||
this.queryParams.searchTime = new Date(value2).getTime()
|
default:
|
||||||
}
|
let value2 =
|
||||||
this.$emit('submit', this.queryParams)
|
moment(this.dateValue).format('YYYY-MM-DD') + ' 23:59:59';
|
||||||
},
|
this.queryParams.searchTime = new Date(value2).getTime();
|
||||||
exportData() {
|
}
|
||||||
let name
|
this.$emit('submit', this.queryParams);
|
||||||
if (this.queryParams.objId) {
|
},
|
||||||
name = this.getObjName(this.objList, this.queryParams.objId)
|
exportData() {
|
||||||
} else {
|
let name;
|
||||||
this.$modal.msgWarning("对象不能为空")
|
if (this.queryParams.objId) {
|
||||||
return false
|
name = this.getObjName(this.objList, this.queryParams.objId);
|
||||||
}
|
} else {
|
||||||
this.$emit('exportD', {name: name})
|
this.$modal.msgWarning('对象不能为空');
|
||||||
},
|
return false;
|
||||||
// 递归取对象name
|
}
|
||||||
getObjName(list, id) {
|
this.$emit('exportD', { name: name });
|
||||||
let _this = this
|
},
|
||||||
for (let i = 0; i < list.length; i++) {
|
// 递归取对象name
|
||||||
let a = list[i]
|
getObjName(list, id) {
|
||||||
if (a.id === id) {
|
for (let i = 0; i < list.length; i++) {
|
||||||
return a.name
|
let a = list[i];
|
||||||
} else {
|
if (a.id === id) {
|
||||||
if (a.children && a.children.length > 0) {
|
return a.name;
|
||||||
let res = _this.getObjName(a.children, id)
|
}
|
||||||
if (res) {
|
}
|
||||||
return res
|
},
|
||||||
}
|
transformTime(timeStamp) {
|
||||||
}
|
// 本月最后一天
|
||||||
}
|
let year = moment(timeStamp).format('YYYY');
|
||||||
}
|
let month = moment(timeStamp).format('MM');
|
||||||
},
|
let newData =
|
||||||
transformTime(timeStamp) {// 本月最后一天
|
moment(new Date(year, month, 0)).format('YYYY-MM-DD') + ' 23:59:59';
|
||||||
let year = moment(timeStamp).format('YYYY')
|
let value = new Date(newData).getTime();
|
||||||
let month = moment(timeStamp).format('MM')
|
return value;
|
||||||
let newData = moment(new Date(year,month,0)).format('YYYY-MM-DD') + ' 23:59:59'
|
},
|
||||||
let value = new Date(newData).getTime()
|
},
|
||||||
return value
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<style lang='scss'>
|
<style lang='scss'>
|
||||||
/* 级联选择器 */
|
|
||||||
.cascaderParent .el-cascader-panel .el-scrollbar:first-child .el-radio {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
.demo-form-inline {
|
.demo-form-inline {
|
||||||
.el-date-editor .el-range__icon {
|
.el-date-editor .el-range__icon {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
color: #0B58FF;
|
color: #0b58ff;
|
||||||
}
|
}
|
||||||
.el-input__prefix .el-icon-date {
|
.el-input__prefix .el-icon-date {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
color: #0B58FF;
|
color: #0b58ff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.separateStyle {
|
.separateStyle {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 1px;
|
width: 1px;
|
||||||
height: 24px;
|
height: 24px;
|
||||||
background: #E8E8E8;
|
background: #e8e8e8;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
.demo-form-inline {
|
.demo-form-inline {
|
||||||
.blue-block {
|
.blue-block {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 4px;
|
width: 4px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
background-color: #0B58FF;
|
background-color: #0b58ff;
|
||||||
border-radius: 1px;
|
border-radius: 1px;
|
||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
.el-form-item {
|
||||||
|
margin-right: 10px;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
@ -1,132 +1,140 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<!-- 搜索工作栏 -->
|
<!-- 搜索工作栏 -->
|
||||||
<search-area @submit="getList" @exportD="exportData"/>
|
<search-area
|
||||||
<!-- 表格 -->
|
@submit="getList"
|
||||||
<div v-show="chartData.length">
|
@exportD="exportData" />
|
||||||
<base-table
|
<!-- 表格 -->
|
||||||
:table-props="tableProps"
|
<div v-show="chartData.length">
|
||||||
:table-data="list"
|
<base-table
|
||||||
class="qoq-out-table"
|
:table-props="tableProps"
|
||||||
/>
|
:table-data="list"
|
||||||
<div class="chartTitle">环比分析图</div>
|
class="qoq-out-table" />
|
||||||
<div style='width: 100%'>
|
<div class="chartTitle">环比分析图</div>
|
||||||
<line-chart ref="analysisLineChart" :chartData="chartData"/>
|
<div style="width: 100%">
|
||||||
</div>
|
<line-chart
|
||||||
</div>
|
ref="analysisLineChart"
|
||||||
<!-- 没有数据 -->
|
:chartData="chartData" />
|
||||||
<div class="no-data-bg" v-show='!chartData.length'></div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- 没有数据 -->
|
||||||
|
<div
|
||||||
|
class="no-data-bg"
|
||||||
|
v-show="!chartData.length"></div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { getQoq } from "@/api/analysis/energyAnalysis"
|
import { getQoq } from '@/api/analysis/energyAnalysis';
|
||||||
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: 'QoqAnalysis',
|
name: 'QoqAnalysis',
|
||||||
components: { SearchArea, LineChart },
|
components: { SearchArea, LineChart },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
chartData: [],
|
chartData: [],
|
||||||
tableProps: [],
|
tableProps: [],
|
||||||
list: []
|
list: [],
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getList(params) {
|
getList(params) {
|
||||||
getQoq({ ...params }).then((res) => {
|
getQoq({ ...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;
|
||||||
tempX[j].children.push(obj)
|
tempX[j].children.push(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.tableProps = [{prop: 'time',label: '时间'}].concat(tempX)
|
this.tableProps = [{ prop: 'time', label: '时间' }].concat(tempX);
|
||||||
// 数据
|
// 数据
|
||||||
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(".qoq-out-table"))
|
var wb = XLSX.utils.table_to_book(
|
||||||
let fileName = val.name + "环比分析.xlsx"
|
document.querySelector('.qoq-out-table')
|
||||||
var wbout = XLSX.write(wb, {
|
);
|
||||||
bookType: "xlsx",
|
let fileName = val.name + '环比分析.xlsx';
|
||||||
bookSST: true,
|
var wbout = XLSX.write(wb, {
|
||||||
type: "array"
|
bookType: 'xlsx',
|
||||||
})
|
bookSST: true,
|
||||||
try {
|
type: 'array',
|
||||||
FileSaver.saveAs(
|
});
|
||||||
new Blob([wbout], { type: "application/octet-stream" }),
|
try {
|
||||||
fileName
|
FileSaver.saveAs(
|
||||||
)
|
new Blob([wbout], { type: 'application/octet-stream' }),
|
||||||
} catch (e) {
|
fileName
|
||||||
if (typeof console !== "undefined") console.log(e, wbout);
|
);
|
||||||
}
|
this.$message.success('导出成功');
|
||||||
return wbout
|
} catch (e) {
|
||||||
} else {
|
if (typeof console !== 'undefined') console.log(e, wbout);
|
||||||
this.$modal.msgWarning("暂无数据导出")
|
}
|
||||||
}
|
return wbout;
|
||||||
}
|
} else {
|
||||||
}
|
this.$modal.msgWarning('暂无数据导出');
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
<style lang='scss' scoped>
|
<style lang='scss' scoped>
|
||||||
.chartTitle {
|
.chartTitle {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
color: #000;
|
color: #000;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
.chartTitle::before {
|
.chartTitle::before {
|
||||||
content: '';
|
content: '';
|
||||||
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;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
@ -1,103 +1,102 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
id="analysischartLine"
|
id="analysischartLine"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
:style="{ height: chartHeight + 'px' }"
|
:style="{ height: chartHeight + 'px' }"></div>
|
||||||
></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(214) - 100,
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
chartData: {
|
chartData: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
default: () => {
|
default: () => {
|
||||||
return []
|
return [];
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
timeDim: {
|
timeDim: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: '',
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
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(214) - 70;
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getChart() {
|
getChart() {
|
||||||
if (
|
if (
|
||||||
this.chart !== null &&
|
this.chart !== null &&
|
||||||
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);
|
||||||
let xData = []
|
let xData = [];
|
||||||
let yData = []
|
let yData = [];
|
||||||
for (let i = 0; i < this.chartData.length; i++) {
|
for (let i = 0; i < this.chartData.length; i++) {
|
||||||
let time = ""
|
let time = '';
|
||||||
if (this.timeDim === '3') {
|
if (this.timeDim === '3') {
|
||||||
let year = this.chartData[i].time.slice(0,4)
|
let year = this.chartData[i].time.slice(0, 4);
|
||||||
let weak = this.chartData[i].time.slice(4,6)
|
let weak = this.chartData[i].time.slice(4, 6);
|
||||||
time = year+' 第 '+weak+' 周'
|
time = year + ' 第 ' + weak + ' 周';
|
||||||
} else {
|
} else {
|
||||||
time = this.chartData[i].time
|
time = this.chartData[i].time;
|
||||||
}
|
}
|
||||||
xData.push(time)
|
xData.push(time);
|
||||||
yData.push(this.chartData[i].useNum)
|
yData.push(this.chartData[i].useNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
var option = {
|
var option = {
|
||||||
color:['#288AFF'],
|
color: ['#288AFF'],
|
||||||
// tooltip: {
|
// tooltip: {
|
||||||
// trigger: 'axis'
|
// trigger: 'axis'
|
||||||
// },
|
// },
|
||||||
grid: {
|
grid: {
|
||||||
left: '4%',
|
left: '4%',
|
||||||
right: '1%',
|
right: '1%',
|
||||||
bottom: '1%',
|
bottom: '1%',
|
||||||
containLabel: true
|
containLabel: true,
|
||||||
},
|
},
|
||||||
xAxis: {
|
xAxis: {
|
||||||
type: 'category',
|
type: 'category',
|
||||||
data: xData,
|
data: xData,
|
||||||
axisLabel: {
|
axisLabel: {
|
||||||
rotate: "45"
|
rotate: '45',
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
yAxis: {
|
yAxis: {
|
||||||
type: 'value'
|
type: 'value',
|
||||||
},
|
},
|
||||||
series: [
|
series: [
|
||||||
{
|
{
|
||||||
data: yData,
|
data: yData,
|
||||||
type: 'line'
|
type: 'line',
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
option && this.chart.setOption(option);
|
option && this.chart.setOption(option);
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
File diff suppressed because it is too large
Load Diff
@ -1,94 +1,113 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container trendAnalysisBox" id="trendAnalysisBox">
|
<div
|
||||||
<!-- 搜索工作栏 -->
|
class="app-container trendAnalysisBox"
|
||||||
<search-area :isFold="isFold" @submit="getList"/>
|
id="trendAnalysisBox">
|
||||||
<el-tabs v-model="activeName" @tab-click="switchChart" v-show='chartData.length'>
|
<!-- 搜索工作栏 -->
|
||||||
<el-tab-pane label="柱状图" name="bar">
|
<search-area
|
||||||
<bar-chart ref="analysisBarChart" :chartData="chartData" :timeDim="timeDim"/>
|
:isFold="isFold"
|
||||||
</el-tab-pane>
|
@submit="getList"
|
||||||
<el-tab-pane label="折线图" name="line">
|
@export="exportExl" />
|
||||||
<line-chart ref="analysisLineChart" :chartData="chartData" :timeDim="timeDim"/>
|
<div v-show="chartData.length">
|
||||||
</el-tab-pane>
|
<base-table
|
||||||
</el-tabs>
|
:table-props="tableProps"
|
||||||
<!-- 没有数据 -->
|
:table-data="list"
|
||||||
<div class="no-data-bg" v-show='!chartData.length'></div>
|
class="trend-out-table" />
|
||||||
</div>
|
<line-chart
|
||||||
|
ref="analysisLineChart"
|
||||||
|
:chartData="chartData"
|
||||||
|
:timeDim="timeDim" />
|
||||||
|
</div>
|
||||||
|
<!-- 没有数据 -->
|
||||||
|
<div
|
||||||
|
class="no-data-bg"
|
||||||
|
v-show="!chartData.length"></div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { getEnergyTrend } from "@/api/analysis/energyAnalysis"
|
import { getEnergyTrend, exportTrend } from '@/api/analysis/energyAnalysis';
|
||||||
import SearchArea from "./components/searchArea"
|
import SearchArea from './components/searchArea';
|
||||||
import BarChart from "./components/barChart"
|
import LineChart from './components/lineChart';
|
||||||
import LineChart from "./components/lineChart"
|
|
||||||
// import moment from 'moment'
|
// import moment from 'moment'
|
||||||
export default {
|
export default {
|
||||||
name: 'TrendAnalysis',
|
name: 'TrendAnalysis',
|
||||||
components: { SearchArea, BarChart, LineChart },
|
components: { SearchArea, LineChart },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
isFold: false,
|
isFold: false,
|
||||||
activeName: 'bar',
|
chartData: [],
|
||||||
chartData: [],
|
timeDim: '',
|
||||||
timeDim: ''
|
tableProps: [],
|
||||||
}
|
list: [],
|
||||||
},
|
};
|
||||||
mounted() {
|
},
|
||||||
window.addEventListener('resize', () => {
|
mounted() {
|
||||||
this.tableH = this.tableHeight(260)
|
window.addEventListener('resize', () => {
|
||||||
this.isFold = this.searchBarWidth('trendAnalysisBox', 1263)
|
this.tableH = this.tableHeight(260);
|
||||||
})
|
this.isFold = this.searchBarWidth('trendAnalysisBox', 1480);
|
||||||
this.isFold = this.searchBarWidth('trendAnalysisBox', 1263)
|
});
|
||||||
},
|
this.isFold = this.searchBarWidth('trendAnalysisBox', 1480);
|
||||||
methods: {
|
},
|
||||||
getList(params) {
|
methods: {
|
||||||
this.timeDim = params.timeDim
|
getList(params) {
|
||||||
getEnergyTrend({ ...params }).then((res) => {
|
this.timeDim = params.timeDim;
|
||||||
if (res.code === 0) {
|
getEnergyTrend({ ...params }).then((res) => {
|
||||||
this.chartData = res.data
|
if (res.code === 0) {
|
||||||
} else {
|
this.getTableList(res.data || []);
|
||||||
this.chartData = []
|
this.chartData = res.data || [];
|
||||||
}
|
} else {
|
||||||
})
|
this.chartData = [];
|
||||||
},
|
}
|
||||||
switchChart() {
|
});
|
||||||
if (this.activeName === 'bar') {
|
},
|
||||||
this.$nextTick((res) => {
|
getTableList(arr) {
|
||||||
this.$refs.analysisBarChart.getChart()
|
this.tableProps = [];
|
||||||
})
|
this.list = [];
|
||||||
} else {
|
let tempX = [];
|
||||||
this.$nextTick((res) => {
|
let listObj = { useNum: '消耗量' }; // 数据
|
||||||
this.$refs.analysisLineChart.getChart()
|
for (let i = 0; i < arr.length; i++) {
|
||||||
})
|
let obj = {};
|
||||||
}
|
obj.prop = arr[i].time;
|
||||||
}
|
obj.label = arr[i].time;
|
||||||
}
|
obj.minWidth = 100;
|
||||||
}
|
tempX.push(obj);
|
||||||
|
listObj[arr[i].time] = arr[i].useNum || null;
|
||||||
|
}
|
||||||
|
this.tableProps = [{ prop: 'useNum', label: '时间' }].concat(tempX);
|
||||||
|
this.list.push(listObj);
|
||||||
|
},
|
||||||
|
// 导出excel
|
||||||
|
exportExl(params) {
|
||||||
|
exportTrend({ ...params }).then((res) => {
|
||||||
|
// let fileName = '';
|
||||||
|
// const contentDisposition = res.headers['content-disposition'];
|
||||||
|
// if (contentDisposition) {
|
||||||
|
// fileName = decodeURIComponent(
|
||||||
|
// contentDisposition.slice(
|
||||||
|
// contentDisposition.indexOf('filename=') + 9
|
||||||
|
// )
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
const blob = new Blob([res.data]);
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.readAsDataURL(blob);
|
||||||
|
reader.onload = (e) => {
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.download = '走势分析';
|
||||||
|
a.href = e.target.result;
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
document.body.removeChild(a);
|
||||||
|
this.$message.success('导出成功');
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
<style lang='scss'>
|
<style lang='scss'>
|
||||||
.trendAnalysisBox {
|
.trendAnalysisBox {
|
||||||
.el-tabs__nav::after {
|
.trend-out-table {
|
||||||
content: "";
|
margin-bottom: 15px;
|
||||||
position: absolute;
|
}
|
||||||
left: 0;
|
|
||||||
bottom: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 2px;
|
|
||||||
background-color: #e4e7ed;
|
|
||||||
/* z-index: 1; */
|
|
||||||
}
|
|
||||||
.el-tabs__nav-wrap::after {
|
|
||||||
width: 0;
|
|
||||||
}
|
|
||||||
.el-tabs__item {
|
|
||||||
padding: 0 10px;
|
|
||||||
}
|
|
||||||
.el-tabs__item:hover {
|
|
||||||
color: rgba(0, 0, 0, 0.85);
|
|
||||||
}
|
|
||||||
.el-tabs__item.is-active {
|
|
||||||
color: rgba(0, 0, 0, 0.85);
|
|
||||||
}
|
|
||||||
.el-tabs__item {
|
|
||||||
color: rgba(0, 0, 0, 0.45);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
@ -1,205 +1,227 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-form :inline="true" class="demo-form-inline">
|
<el-form
|
||||||
<span class="blue-block"></span>
|
:inline="true"
|
||||||
<el-form-item label="对象选择" required>
|
class="demo-form-inline">
|
||||||
<el-cascader
|
<span class="blue-block"></span>
|
||||||
v-model="objArr"
|
<el-form-item
|
||||||
:options="objList"
|
label="对象选择"
|
||||||
:props="{ checkStrictly: true, value: 'id', label: 'name' }"
|
required>
|
||||||
popper-class="cascaderParent"
|
<el-select
|
||||||
size="small"
|
v-model="queryParams.objId"
|
||||||
clearable></el-cascader>
|
placeholder="请选择"
|
||||||
</el-form-item>
|
style="width: 250px"
|
||||||
<el-form-item label="时间维度" required>
|
filterable
|
||||||
<el-select v-model="queryParams.type" placeholder="请选择" style="width: 80px;" size="small">
|
size="small">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in timeType"
|
v-for="item in objList"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:label="item.name"
|
:label="item.name"
|
||||||
:value="item.id"
|
:value="item.id"
|
||||||
:clearable="false">
|
:clearable="false"></el-option>
|
||||||
</el-option>
|
</el-select>
|
||||||
</el-select>
|
</el-form-item>
|
||||||
</el-form-item>
|
<el-form-item
|
||||||
<el-form-item label="时间" required>
|
label="时间维度"
|
||||||
<div v-show="queryParams.type === 1 || queryParams.type === 2">
|
required>
|
||||||
<el-date-picker
|
<el-select
|
||||||
v-model="yearValue"
|
v-model="queryParams.type"
|
||||||
type="year"
|
placeholder="请选择"
|
||||||
:picker-options="pickerOptions"
|
style="width: 80px"
|
||||||
@change="selectTime"
|
size="small">
|
||||||
:clearable="false"
|
<el-option
|
||||||
size="small"
|
v-for="item in timeType"
|
||||||
placeholder="选择年">
|
:key="item.id"
|
||||||
</el-date-picker>
|
:label="item.name"
|
||||||
</div>
|
:value="item.id"
|
||||||
<div v-show="queryParams.type === 3">
|
:clearable="false"></el-option>
|
||||||
<el-date-picker
|
</el-select>
|
||||||
v-model="yearMonth"
|
</el-form-item>
|
||||||
type="month"
|
<el-form-item
|
||||||
:picker-options="pickerOptions"
|
label="时间"
|
||||||
@change="selectTime"
|
required>
|
||||||
:clearable="false"
|
<div v-show="queryParams.type === 1 || queryParams.type === 2">
|
||||||
size="small"
|
<el-date-picker
|
||||||
placeholder="选择月">
|
v-model="yearValue"
|
||||||
</el-date-picker>
|
type="year"
|
||||||
</div>
|
:picker-options="pickerOptions"
|
||||||
</el-form-item>
|
@change="selectTime"
|
||||||
<el-form-item>
|
:clearable="false"
|
||||||
<el-button type="primary" size="small" @click="search">查询</el-button>
|
size="small"
|
||||||
</el-form-item>
|
placeholder="选择年"></el-date-picker>
|
||||||
<el-form-item>
|
</div>
|
||||||
<span class="separateStyle"></span>
|
<div v-show="queryParams.type === 3">
|
||||||
</el-form-item>
|
<el-date-picker
|
||||||
<el-form-item>
|
v-model="yearMonth"
|
||||||
<el-button type="primary" size="small" @click="exportData" plain>导出</el-button>
|
type="month"
|
||||||
</el-form-item>
|
:picker-options="pickerOptions"
|
||||||
</el-form>
|
@change="selectTime"
|
||||||
|
:clearable="false"
|
||||||
|
size="small"
|
||||||
|
placeholder="选择月"></el-date-picker>
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
size="small"
|
||||||
|
@click="search">
|
||||||
|
查询
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<span class="separateStyle"></span>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
size="small"
|
||||||
|
@click="exportData"
|
||||||
|
plain>
|
||||||
|
导出
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { getTree } from '@/api/base/factory'
|
import { getTree } from '@/api/analysis/energyAnalysis';
|
||||||
import moment from 'moment'
|
import moment from 'moment';
|
||||||
export default {
|
export default {
|
||||||
name: 'searchArea',
|
name: 'searchArea',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
type: 1, // 1季度2月3日
|
type: 1, // 1季度2月3日
|
||||||
searchTime: null,
|
searchTime: null,
|
||||||
objId: null
|
objId: null,
|
||||||
},
|
objType: 1,
|
||||||
timeType: [
|
},
|
||||||
{id: 1, name: '季度'},
|
timeType: [
|
||||||
{id: 2, name: '月'},
|
{ id: 1, name: '季度' },
|
||||||
{id: 3, name: '日'}
|
{ id: 2, name: '月' },
|
||||||
],
|
{ id: 3, name: '日' },
|
||||||
yearValue: '',
|
],
|
||||||
yearMonth: '',
|
yearValue: '',
|
||||||
objArr: [],
|
yearMonth: '',
|
||||||
objList: [],
|
objList: [],
|
||||||
pickerOptions: {
|
pickerOptions: {
|
||||||
disabledDate(date) {
|
disabledDate(date) {
|
||||||
return date.getTime() > Date.now()
|
return date.getTime() > Date.now();
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.getObjTree()
|
this.getObjTree();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getObjTree() {
|
getObjTree() {
|
||||||
getTree().then(res => {
|
getTree().then((res) => {
|
||||||
this.objList = res.data || []
|
this.objList = res.data || [];
|
||||||
})
|
if (this.objList.length > 0) {
|
||||||
},
|
this.queryParams.objId = this.objList[0].id;
|
||||||
selectTime() {
|
}
|
||||||
if (this.queryParams.type === 3) {
|
});
|
||||||
this.queryParams.searchTime = this.yearMonth
|
},
|
||||||
} else {
|
selectTime() {
|
||||||
this.queryParams.searchTime = this.yearValue
|
if (this.queryParams.type === 3) {
|
||||||
}
|
this.queryParams.searchTime = this.yearMonth;
|
||||||
},
|
} else {
|
||||||
// 查询
|
this.queryParams.searchTime = this.yearValue;
|
||||||
search() {
|
}
|
||||||
if (this.objArr.length === 0) {
|
},
|
||||||
this.$modal.msgError('请选择对象')
|
// 查询
|
||||||
return false
|
search() {
|
||||||
} else {
|
if (!this.queryParams.objId) {
|
||||||
this.queryParams.objId = this.objArr[this.objArr.length-1]
|
this.$modal.msgError('请选择对象');
|
||||||
}
|
return false;
|
||||||
if (!this.queryParams.type) {
|
}
|
||||||
this.$modal.msgError('请选择时间维度')
|
if (!this.queryParams.type) {
|
||||||
return false
|
this.$modal.msgError('请选择时间维度');
|
||||||
}
|
return false;
|
||||||
if (!this.queryParams.searchTime) {
|
}
|
||||||
this.$modal.msgError('请选择时间')
|
if (!this.queryParams.searchTime) {
|
||||||
return false
|
this.$modal.msgError('请选择时间');
|
||||||
}
|
return false;
|
||||||
if (this.queryParams.type === 3) {
|
}
|
||||||
this.queryParams.searchTime = this.transformTime(this.yearMonth) + ''
|
if (this.queryParams.type === 3) {
|
||||||
} else {
|
this.queryParams.searchTime = this.transformTime(this.yearMonth) + '';
|
||||||
this.queryParams.searchTime = this.transformYear(this.yearValue) + ''
|
} else {
|
||||||
}
|
this.queryParams.searchTime = this.transformYear(this.yearValue) + '';
|
||||||
this.$emit('submit', this.queryParams)
|
}
|
||||||
},
|
this.$emit('submit', this.queryParams);
|
||||||
exportData() {
|
},
|
||||||
let name
|
exportData() {
|
||||||
if (this.queryParams.objId) {
|
let name;
|
||||||
name = this.getObjName(this.objList, this.queryParams.objId)
|
if (this.queryParams.objId) {
|
||||||
} else {
|
name = this.getObjName(this.objList, this.queryParams.objId);
|
||||||
this.$modal.msgWarning("对象不能为空")
|
} else {
|
||||||
return false
|
this.$modal.msgWarning('对象不能为空');
|
||||||
}
|
return false;
|
||||||
this.$emit('exportD', {name: name})
|
}
|
||||||
},
|
this.$emit('exportD', { name: name });
|
||||||
// 递归取对象name
|
},
|
||||||
getObjName(list, id) {
|
// 递归取对象name
|
||||||
let _this = this
|
getObjName(list, id) {
|
||||||
for (let i = 0; i < list.length; i++) {
|
for (let i = 0; i < list.length; i++) {
|
||||||
let a = list[i]
|
let a = list[i];
|
||||||
if (a.id === id) {
|
if (a.id === id) {
|
||||||
return a.name
|
return a.name;
|
||||||
} else {
|
}
|
||||||
if (a.children && a.children.length > 0) {
|
}
|
||||||
let res = _this.getObjName(a.children, id)
|
},
|
||||||
if (res) {
|
transformTime(timeStamp) {
|
||||||
return res
|
// 本月最后一天
|
||||||
}
|
let year = moment(timeStamp).format('YYYY');
|
||||||
}
|
let month = moment(timeStamp).format('MM');
|
||||||
}
|
let newData =
|
||||||
}
|
moment(new Date(year, month, 0)).format('YYYY-MM-DD') + ' 23:59:59';
|
||||||
},
|
let value = new Date(newData).getTime();
|
||||||
transformTime(timeStamp) {// 本月最后一天
|
return value;
|
||||||
let year = moment(timeStamp).format('YYYY')
|
},
|
||||||
let month = moment(timeStamp).format('MM')
|
transformYear(timeStamp) {
|
||||||
let newData = moment(new Date(year,month,0)).format('YYYY-MM-DD') + ' 23:59:59'
|
// 本年最后一天
|
||||||
let value = new Date(newData).getTime()
|
let year = moment(timeStamp).format('YYYY');
|
||||||
return value
|
let newData = year + '-12-31 23:59:59';
|
||||||
},
|
let value = new Date(newData).getTime();
|
||||||
transformYear(timeStamp) {// 本年最后一天
|
return value;
|
||||||
let year = moment(timeStamp).format('YYYY')
|
},
|
||||||
let newData = year+'-12-31 23:59:59'
|
},
|
||||||
let value = new Date(newData).getTime()
|
};
|
||||||
return value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<style lang='scss'>
|
<style lang='scss'>
|
||||||
/* 级联选择器 */
|
|
||||||
.cascaderParent .el-cascader-panel .el-scrollbar:first-child .el-radio {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
.demo-form-inline {
|
.demo-form-inline {
|
||||||
.el-date-editor .el-range__icon {
|
.el-date-editor .el-range__icon {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
color: #0B58FF;
|
color: #0b58ff;
|
||||||
}
|
}
|
||||||
.el-input__prefix .el-icon-date {
|
.el-input__prefix .el-icon-date {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
color: #0B58FF;
|
color: #0b58ff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.demo-form-inline {
|
.demo-form-inline {
|
||||||
.blue-block {
|
.blue-block {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 4px;
|
width: 4px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
background-color: #0B58FF;
|
background-color: #0b58ff;
|
||||||
border-radius: 1px;
|
border-radius: 1px;
|
||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
.el-form-item {
|
||||||
|
margin-right: 10px;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.separateStyle {
|
.separateStyle {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 1px;
|
width: 1px;
|
||||||
height: 24px;
|
height: 24px;
|
||||||
background: #E8E8E8;
|
background: #e8e8e8;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
@ -1,139 +1,155 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-form ref="form" :rules="rules" label-width="100px" :model="form">
|
<el-form
|
||||||
<el-form-item label="关联表名" prop="plcId">
|
ref="form"
|
||||||
<el-select v-model="form.plcId" placeholder="请选择" style="width: 100%;" filterable>
|
:rules="rules"
|
||||||
<el-option
|
label-width="100px"
|
||||||
v-for="item in plcList"
|
:model="form">
|
||||||
:key="item.id"
|
<el-form-item
|
||||||
:label="item.plcTableName"
|
label="关联表名"
|
||||||
:value="item.id">
|
prop="plcId">
|
||||||
</el-option>
|
<el-select
|
||||||
</el-select>
|
v-model="form.plcId"
|
||||||
</el-form-item>
|
placeholder="请选择"
|
||||||
<el-form-item label="对象" prop="bindObjectId">
|
style="width: 100%"
|
||||||
<el-cascader
|
filterable>
|
||||||
style='width: 100%;'
|
<el-option
|
||||||
v-model="objIds"
|
v-for="item in plcList"
|
||||||
:options="objList"
|
:key="item.id"
|
||||||
:props="{ checkStrictly: true, value: 'id', label: 'name' }"
|
:label="item.plcTableName"
|
||||||
popper-class="cascaderParent"
|
:value="item.id"></el-option>
|
||||||
@change="selectObj"
|
</el-select>
|
||||||
clearable></el-cascader>
|
</el-form-item>
|
||||||
</el-form-item>
|
<el-form-item
|
||||||
</el-form>
|
label="对象"
|
||||||
|
prop="bindObjectId">
|
||||||
|
<el-cascader
|
||||||
|
style="width: 100%"
|
||||||
|
v-model="objIds"
|
||||||
|
:options="objList"
|
||||||
|
:props="{ checkStrictly: true, value: 'id', label: 'name' }"
|
||||||
|
@change="selectObj"
|
||||||
|
clearable></el-cascader>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { getEnergyPlcConnect, updateEnergyPlcConnect, createEnergyPlcConnect } from '@/api/base/energyPlcConnect'
|
import {
|
||||||
import { getEnergyPlcAll } from '@/api/base/energyPlc'
|
getEnergyPlcConnect,
|
||||||
|
updateEnergyPlcConnect,
|
||||||
|
createEnergyPlcConnect,
|
||||||
|
} from '@/api/base/energyPlcConnect';
|
||||||
|
import { getEnergyPlcAll } from '@/api/base/energyPlc';
|
||||||
export default {
|
export default {
|
||||||
name: 'EnergyPlcConnectAdd',
|
name: 'EnergyPlcConnectAdd',
|
||||||
props: {
|
props: {
|
||||||
objList: {
|
objList: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => []
|
default: () => [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
form: {
|
form: {
|
||||||
id: '',
|
id: '',
|
||||||
plcId: '',
|
plcId: '',
|
||||||
bindObjectId: '',
|
bindObjectId: '',
|
||||||
bindObjectType: ''
|
bindObjectType: '',
|
||||||
},
|
},
|
||||||
objIds: [],// 回显数组
|
objIds: [], // 回显数组
|
||||||
plcList: [],
|
plcList: [],
|
||||||
isEdit: false, //是否是编辑
|
isEdit: false, //是否是编辑
|
||||||
rules: {
|
rules: {
|
||||||
plcId: [{ required: true, message: '关联表名不能为空', trigger: 'change' }],
|
plcId: [
|
||||||
bindObjectId: [{ required: true, message: '对象不能为空', trigger: 'change' }]
|
{ required: true, message: '关联表名不能为空', trigger: 'change' },
|
||||||
}
|
],
|
||||||
}
|
bindObjectId: [
|
||||||
},
|
{ required: true, message: '对象不能为空', trigger: 'change' },
|
||||||
methods: {
|
],
|
||||||
init(id) {
|
},
|
||||||
getEnergyPlcAll().then((res) => {
|
};
|
||||||
this.plcList = res.data || []
|
},
|
||||||
})
|
methods: {
|
||||||
if (id) {
|
init(id) {
|
||||||
this.isEdit = true
|
getEnergyPlcAll().then((res) => {
|
||||||
this.form.id = id
|
this.plcList = res.data || [];
|
||||||
getEnergyPlcConnect( id ).then((res) => {
|
});
|
||||||
if (res.code === 0) {
|
if (id) {
|
||||||
this.form = res.data
|
this.isEdit = true;
|
||||||
this.objIds = this.changeDetSelect(this.form.bindObjectId, this.objList)
|
this.form.id = id;
|
||||||
}
|
getEnergyPlcConnect(id).then((res) => {
|
||||||
})
|
if (res.code === 0) {
|
||||||
} else {
|
this.form = res.data;
|
||||||
this.isEdit = false
|
this.objIds = this.changeDetSelect(
|
||||||
this.form.id = ''
|
this.form.bindObjectId,
|
||||||
}
|
this.objList
|
||||||
},
|
);
|
||||||
// 递归处理分类回显问题
|
}
|
||||||
changeDetSelect(key, treeData) {
|
});
|
||||||
let arr = [] // 递归时操作的数组
|
} else {
|
||||||
let returnArr = [] // 存放结果的数组
|
this.isEdit = false;
|
||||||
let depth = 0 // 定义全局层级
|
this.form.id = '';
|
||||||
// 定义递归函数
|
}
|
||||||
function childrenEach(childrendData, depthN) {
|
},
|
||||||
for (var j = 0; j < childrendData.length; j++) {
|
// 递归处理分类回显问题
|
||||||
depth = depthN
|
changeDetSelect(key, treeData) {
|
||||||
arr[depthN] = childrendData[j].id
|
let arr = []; // 递归时操作的数组
|
||||||
if (childrendData[j].id == key) {
|
let returnArr = []; // 存放结果的数组
|
||||||
returnArr = arr.slice(0, depthN + 1)
|
let depth = 0; // 定义全局层级
|
||||||
break
|
// 定义递归函数
|
||||||
} else {
|
function childrenEach(childrendData, depthN) {
|
||||||
if (childrendData[j].children) {
|
for (var j = 0; j < childrendData.length; j++) {
|
||||||
depth++
|
depth = depthN;
|
||||||
childrenEach(childrendData[j].children, depth)
|
arr[depthN] = childrendData[j].id;
|
||||||
}
|
if (childrendData[j].id == key) {
|
||||||
}
|
returnArr = arr.slice(0, depthN + 1);
|
||||||
}
|
break;
|
||||||
return returnArr
|
} else {
|
||||||
}
|
if (childrendData[j].children) {
|
||||||
return childrenEach(treeData, depth)
|
depth++;
|
||||||
},
|
childrenEach(childrendData[j].children, depth);
|
||||||
selectObj(val) {
|
}
|
||||||
this.form.bindObjectId = val[val.length-1]
|
}
|
||||||
this.form.bindObjectType = val.length-1
|
}
|
||||||
},
|
return returnArr;
|
||||||
submitForm() {
|
}
|
||||||
this.$refs['form'].validate((valid) => {
|
return childrenEach(treeData, depth);
|
||||||
if (valid) {
|
},
|
||||||
if (this.isEdit) {
|
selectObj(val) {
|
||||||
// 编辑
|
this.form.bindObjectId = val[val.length - 1];
|
||||||
updateEnergyPlcConnect({...this.form}).then((res) => {
|
this.form.bindObjectType = val.length - 1;
|
||||||
if (res.code === 0) {
|
},
|
||||||
this.$modal.msgSuccess("操作成功");
|
submitForm() {
|
||||||
this.$emit('successSubmit')
|
this.$refs['form'].validate((valid) => {
|
||||||
}
|
if (valid) {
|
||||||
})
|
if (this.isEdit) {
|
||||||
} else {
|
// 编辑
|
||||||
createEnergyPlcConnect({...this.form}).then((res) => {
|
updateEnergyPlcConnect({ ...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 {
|
createEnergyPlcConnect({ ...this.form }).then((res) => {
|
||||||
return false
|
if (res.code === 0) {
|
||||||
}
|
this.$modal.msgSuccess('操作成功');
|
||||||
})
|
this.$emit('successSubmit');
|
||||||
},
|
}
|
||||||
formClear() {
|
});
|
||||||
this.form.id = ''
|
}
|
||||||
this.form.plcId = ''
|
} else {
|
||||||
this.form.bindObjectId = ''
|
return false;
|
||||||
this.form.bindObjectType = ''
|
}
|
||||||
this.objIds = []
|
});
|
||||||
this.isEdit = false
|
},
|
||||||
}
|
formClear() {
|
||||||
}
|
this.form.id = '';
|
||||||
}
|
this.form.plcId = '';
|
||||||
|
this.form.bindObjectId = '';
|
||||||
|
this.form.bindObjectType = '';
|
||||||
|
this.objIds = [];
|
||||||
|
this.isEdit = false;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
<style>
|
|
||||||
.cascaderParent .el-cascader-panel .el-scrollbar:first-child .el-radio {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
</style>
|
|
@ -1,236 +1,270 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
|
<!-- 搜索工作栏 -->
|
||||||
<!-- 搜索工作栏 -->
|
<search-bar
|
||||||
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
|
:formConfigs="formConfig"
|
||||||
<!-- 列表 -->
|
ref="searchBarForm"
|
||||||
<base-table :page="queryParams.pageNo" :limit="queryParams.pageSize" :table-props="tableProps" :table-data="list"
|
@headBtnClick="buttonClick" />
|
||||||
:max-height="tableH">
|
<!-- 列表 -->
|
||||||
<method-btn v-if="tableBtn.length" slot="handleBtn" :width="160" label="操作" :method-list="tableBtn"
|
<base-table
|
||||||
@clickBtn="handleClick" />
|
:page="queryParams.pageNo"
|
||||||
</base-table>
|
:limit="queryParams.pageSize"
|
||||||
<pagination :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" :total="total"
|
:table-props="tableProps"
|
||||||
@pagination="getList" />
|
:table-data="list"
|
||||||
<!-- 新增 -->
|
:max-height="tableH">
|
||||||
<base-dialog :dialogTitle="addOrEditTitle" :dialogVisible="centervisible" @cancel="handleCancel"
|
<method-btn
|
||||||
@confirm="handleConfirm" :before-close="handleCancel" width='30%'>
|
v-if="tableBtn.length"
|
||||||
<energy-plc-connect-add ref="energyPlcConnect" :objList="objList" @successSubmit="successSubmit" />
|
slot="handleBtn"
|
||||||
</base-dialog>
|
:width="160"
|
||||||
<!-- 参数绑定/查看 -->
|
label="操作"
|
||||||
<energy-plc-param v-if="paramVisible" ref="plcParam" @closeDrawer="closeDrawer"
|
:method-list="tableBtn"
|
||||||
:energyTypeList="energyTypeList"></energy-plc-param>
|
@clickBtn="handleClick" />
|
||||||
</div>
|
</base-table>
|
||||||
|
<pagination
|
||||||
|
:page.sync="queryParams.pageNo"
|
||||||
|
:limit.sync="queryParams.pageSize"
|
||||||
|
:total="total"
|
||||||
|
@pagination="getList" />
|
||||||
|
<!-- 新增 -->
|
||||||
|
<base-dialog
|
||||||
|
:dialogTitle="addOrEditTitle"
|
||||||
|
:dialogVisible="centervisible"
|
||||||
|
@cancel="handleCancel"
|
||||||
|
@confirm="handleConfirm"
|
||||||
|
:before-close="handleCancel"
|
||||||
|
width="30%">
|
||||||
|
<energy-plc-connect-add
|
||||||
|
ref="energyPlcConnect"
|
||||||
|
:objList="objList"
|
||||||
|
@successSubmit="successSubmit" />
|
||||||
|
</base-dialog>
|
||||||
|
<!-- 参数绑定/查看 -->
|
||||||
|
<energy-plc-param
|
||||||
|
v-if="paramVisible"
|
||||||
|
ref="plcParam"
|
||||||
|
@closeDrawer="closeDrawer"
|
||||||
|
:energyTypeList="energyTypeList"></energy-plc-param>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getEnergyPlcConnectPage, deleteEnergyPlcConnect } from "@/api/base/energyPlcConnect";
|
import {
|
||||||
|
getEnergyPlcConnectPage,
|
||||||
|
deleteEnergyPlcConnect,
|
||||||
|
} from '@/api/base/energyPlcConnect';
|
||||||
// import { publicFormatter } from '@/utils/dict'
|
// import { publicFormatter } from '@/utils/dict'
|
||||||
import { getTree } from '@/api/base/factory'
|
import { getTree } from '@/api/analysis/energyAnalysis';
|
||||||
import { getEnergyTypeListAll } from '@/api/base/energyType'
|
import { getEnergyTypeListAll } from '@/api/base/energyType';
|
||||||
import EnergyPlcConnectAdd from './components/energyPlcConnectAdd'
|
import EnergyPlcConnectAdd from './components/energyPlcConnectAdd';
|
||||||
import EnergyPlcParam from './components/energyPlcParam'
|
import EnergyPlcParam from './components/energyPlcParam';
|
||||||
const tableProps = [
|
const tableProps = [
|
||||||
{
|
{
|
||||||
prop: 'objName',
|
prop: 'objName',
|
||||||
label: '对象'
|
label: '对象',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'objCode',
|
prop: 'objCode',
|
||||||
label: '对象编码',
|
label: '对象编码',
|
||||||
showOverflowtooltip: true
|
showOverflowtooltip: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'plcTableName',
|
prop: 'plcTableName',
|
||||||
label: '关联表名'
|
label: '关联表名',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'plcTableCode',
|
prop: 'plcTableCode',
|
||||||
label: '关联表编码',
|
label: '关联表编码',
|
||||||
minWidth: 150,
|
minWidth: 150,
|
||||||
showOverflowtooltip: true
|
showOverflowtooltip: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'cnName',
|
prop: 'cnName',
|
||||||
label: '标识名',
|
label: '标识名',
|
||||||
minWidth: 150,
|
minWidth: 150,
|
||||||
showOverflowtooltip: true
|
showOverflowtooltip: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'varNum',
|
prop: 'varNum',
|
||||||
label: '绑定参数数量'
|
label: '绑定参数数量',
|
||||||
}
|
},
|
||||||
]
|
];
|
||||||
export default {
|
export default {
|
||||||
name: "EnergyPlcConnect",
|
name: 'EnergyPlcConnect',
|
||||||
components: { EnergyPlcConnectAdd, EnergyPlcParam },
|
components: { EnergyPlcConnectAdd, EnergyPlcParam },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
formConfig: [
|
formConfig: [
|
||||||
{
|
{
|
||||||
type: 'input',
|
type: 'input',
|
||||||
label: '标识名',
|
label: '标识名',
|
||||||
placeholder: '标识名',
|
placeholder: '标识名',
|
||||||
param: 'cnName'
|
param: 'cnName',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'button',
|
type: 'button',
|
||||||
btnName: '查询',
|
btnName: '查询',
|
||||||
name: 'search',
|
name: 'search',
|
||||||
color: 'primary'
|
color: 'primary',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'separate'
|
type: 'separate',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: this.$auth.hasPermi('base:energy-plc-connect:create') ? 'button' : '',
|
type: this.$auth.hasPermi('base:energy-plc-connect:create')
|
||||||
btnName: '新增',
|
? 'button'
|
||||||
name: 'add',
|
: '',
|
||||||
color: 'success',
|
btnName: '新增',
|
||||||
plain: true
|
name: 'add',
|
||||||
}
|
color: 'success',
|
||||||
],
|
plain: true,
|
||||||
tableProps,
|
},
|
||||||
tableBtn: [
|
],
|
||||||
this.$auth.hasPermi('base:energy-plc-connect:bind')
|
tableProps,
|
||||||
? {
|
tableBtn: [
|
||||||
type: 'connect',
|
this.$auth.hasPermi('base:energy-plc-connect:bind')
|
||||||
btnName: '绑定'
|
? {
|
||||||
}
|
type: 'connect',
|
||||||
: undefined,
|
btnName: '绑定',
|
||||||
{
|
}
|
||||||
type: 'detail',
|
: undefined,
|
||||||
btnName: '详情'
|
{
|
||||||
},
|
type: 'detail',
|
||||||
this.$auth.hasPermi('base:energy-plc-connect:update')
|
btnName: '详情',
|
||||||
? {
|
},
|
||||||
type: 'edit',
|
this.$auth.hasPermi('base:energy-plc-connect:update')
|
||||||
btnName: '编辑'
|
? {
|
||||||
}
|
type: 'edit',
|
||||||
: undefined,
|
btnName: '编辑',
|
||||||
this.$auth.hasPermi('base:energy-plc-connect:delete')
|
}
|
||||||
? {
|
: undefined,
|
||||||
type: 'delete',
|
this.$auth.hasPermi('base:energy-plc-connect:delete')
|
||||||
btnName: '删除'
|
? {
|
||||||
}
|
type: 'delete',
|
||||||
: undefined
|
btnName: '删除',
|
||||||
].filter((v) => v),
|
}
|
||||||
tableH: this.tableHeight(260),
|
: undefined,
|
||||||
// 总条数
|
].filter((v) => v),
|
||||||
total: 0,
|
tableH: this.tableHeight(260),
|
||||||
// 班次基础信息列表
|
// 总条数
|
||||||
list: [],
|
total: 0,
|
||||||
// 弹出层标题
|
// 班次基础信息列表
|
||||||
addOrEditTitle: "",
|
list: [],
|
||||||
// 是否显示弹出层
|
// 弹出层标题
|
||||||
centervisible: false,
|
addOrEditTitle: '',
|
||||||
// 查询参数
|
// 是否显示弹出层
|
||||||
queryParams: {
|
centervisible: false,
|
||||||
pageNo: 1,
|
// 查询参数
|
||||||
pageSize: 20,
|
queryParams: {
|
||||||
cnName: null
|
pageNo: 1,
|
||||||
},
|
pageSize: 20,
|
||||||
paramVisible: false,
|
cnName: null,
|
||||||
energyTypeList: [],
|
},
|
||||||
objList: []
|
paramVisible: false,
|
||||||
};
|
energyTypeList: [],
|
||||||
},
|
objList: [],
|
||||||
created() {
|
};
|
||||||
window.addEventListener('resize', () => {
|
},
|
||||||
this.tableH = this.tableHeight(260)
|
created() {
|
||||||
})
|
window.addEventListener('resize', () => {
|
||||||
this.getList();
|
this.tableH = this.tableHeight(260);
|
||||||
},
|
});
|
||||||
mounted() {
|
this.getList();
|
||||||
// 获取能源列表
|
},
|
||||||
this.getEnergyTypeList()
|
mounted() {
|
||||||
// 获取对象树形结构
|
// 获取能源列表
|
||||||
this.getObjTree()
|
this.getEnergyTypeList();
|
||||||
},
|
// 获取对象树形结构
|
||||||
methods: {
|
this.getObjTree();
|
||||||
buttonClick(val) {
|
},
|
||||||
switch (val.btnName) {
|
methods: {
|
||||||
case 'search':
|
buttonClick(val) {
|
||||||
this.queryParams.pageNo = 1;
|
switch (val.btnName) {
|
||||||
this.queryParams.cnName = val.cnName
|
case 'search':
|
||||||
this.getList()
|
this.queryParams.pageNo = 1;
|
||||||
break
|
this.queryParams.cnName = val.cnName;
|
||||||
default:
|
this.getList();
|
||||||
this.addOrEditTitle = '新增'
|
break;
|
||||||
this.centervisible = true
|
default:
|
||||||
this.$nextTick(() => {
|
this.addOrEditTitle = '新增';
|
||||||
this.$refs.energyPlcConnect.init()
|
this.centervisible = true;
|
||||||
})
|
this.$nextTick(() => {
|
||||||
}
|
this.$refs.energyPlcConnect.init();
|
||||||
},
|
});
|
||||||
/** 查询列表 */
|
}
|
||||||
getList() {
|
},
|
||||||
getEnergyPlcConnectPage(this.queryParams).then(response => {
|
/** 查询列表 */
|
||||||
let arr = response.data.list || [];
|
getList() {
|
||||||
this.list = arr
|
getEnergyPlcConnectPage(this.queryParams).then((response) => {
|
||||||
this.total = response.data.total;
|
let arr = response.data.list || [];
|
||||||
});
|
this.list = arr;
|
||||||
},
|
this.total = response.data.total;
|
||||||
handleClick(val) {
|
});
|
||||||
console.log(val)
|
},
|
||||||
switch (val.type) {
|
handleClick(val) {
|
||||||
case 'edit':
|
console.log(val);
|
||||||
this.addOrEditTitle = '编辑'
|
switch (val.type) {
|
||||||
this.$nextTick(() => {
|
case 'edit':
|
||||||
this.$refs.energyPlcConnect.init(val.data.id)
|
this.addOrEditTitle = '编辑';
|
||||||
})
|
this.$nextTick(() => {
|
||||||
this.centervisible = true
|
this.$refs.energyPlcConnect.init(val.data.id);
|
||||||
break
|
});
|
||||||
case 'delete':
|
this.centervisible = true;
|
||||||
this.handleDelete(val.data)
|
break;
|
||||||
break
|
case 'delete':
|
||||||
case 'detail':
|
this.handleDelete(val.data);
|
||||||
this.paramVisible = true
|
break;
|
||||||
this.$nextTick(() => {
|
case 'detail':
|
||||||
this.$refs.plcParam.init(val.data, 'detail')
|
this.paramVisible = true;
|
||||||
})
|
this.$nextTick(() => {
|
||||||
break
|
this.$refs.plcParam.init(val.data, 'detail');
|
||||||
default:
|
});
|
||||||
this.paramVisible = true
|
break;
|
||||||
this.$nextTick(() => {
|
default:
|
||||||
this.$refs.plcParam.init(val.data, 'connect')
|
this.paramVisible = true;
|
||||||
})
|
this.$nextTick(() => {
|
||||||
}
|
this.$refs.plcParam.init(val.data, 'connect');
|
||||||
},
|
});
|
||||||
handleCancel() {
|
}
|
||||||
this.$refs.energyPlcConnect.formClear()
|
},
|
||||||
this.centervisible = false
|
handleCancel() {
|
||||||
this.addOrEditTitle = ''
|
this.$refs.energyPlcConnect.formClear();
|
||||||
},
|
this.centervisible = false;
|
||||||
handleConfirm() {
|
this.addOrEditTitle = '';
|
||||||
this.$refs.energyPlcConnect.submitForm()
|
},
|
||||||
},
|
handleConfirm() {
|
||||||
successSubmit() {
|
this.$refs.energyPlcConnect.submitForm();
|
||||||
this.handleCancel()
|
},
|
||||||
this.getList()
|
successSubmit() {
|
||||||
},
|
this.handleCancel();
|
||||||
/** 删除按钮操作 */
|
this.getList();
|
||||||
handleDelete(row) {
|
},
|
||||||
this.$modal.confirm('是否确认删除对象为"' + row.objName + '"的数据项?').then(function () {
|
/** 删除按钮操作 */
|
||||||
return deleteEnergyPlcConnect(row.id);
|
handleDelete(row) {
|
||||||
}).then(() => {
|
this.$modal
|
||||||
this.queryParams.pageNo = 1;
|
.confirm('是否确认删除对象为"' + row.objName + '"的数据项?')
|
||||||
this.getList();
|
.then(function () {
|
||||||
this.$modal.msgSuccess("删除成功");
|
return deleteEnergyPlcConnect(row.id);
|
||||||
}).catch(() => { });
|
})
|
||||||
},
|
.then(() => {
|
||||||
closeDrawer() {
|
this.queryParams.pageNo = 1;
|
||||||
this.getList()
|
this.getList();
|
||||||
},
|
this.$modal.msgSuccess('删除成功');
|
||||||
getEnergyTypeList() {
|
})
|
||||||
getEnergyTypeListAll().then((res) => {
|
.catch(() => {});
|
||||||
this.energyTypeList = res.data || []
|
},
|
||||||
})
|
closeDrawer() {
|
||||||
},
|
this.getList();
|
||||||
getObjTree() {
|
},
|
||||||
getTree().then(res => {
|
getEnergyTypeList() {
|
||||||
this.objList = res.data || []
|
getEnergyTypeListAll().then((res) => {
|
||||||
})
|
this.energyTypeList = res.data || [];
|
||||||
}
|
});
|
||||||
}
|
},
|
||||||
|
getObjTree() {
|
||||||
|
getTree().then((res) => {
|
||||||
|
this.objList = res.data || [];
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,329 +1,422 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-form ref="form" :rules="rules" label-width="100px" :model="form">
|
<el-form
|
||||||
<el-row>
|
ref="form"
|
||||||
<el-col :span="12">
|
:rules="rules"
|
||||||
<el-form-item label="能源类型" prop="name">
|
label-width="100px"
|
||||||
<el-input v-model="form.name"></el-input>
|
:model="form">
|
||||||
</el-form-item>
|
<el-row>
|
||||||
</el-col>
|
<el-col :span="12">
|
||||||
<el-col :span="12">
|
<el-form-item
|
||||||
<el-form-item label="类型编码" prop="code">
|
label="能源类型"
|
||||||
<el-input v-model="form.code" disabled></el-input>
|
prop="name">
|
||||||
</el-form-item>
|
<el-select
|
||||||
</el-col>
|
v-model="form.name"
|
||||||
</el-row>
|
placeholder="请选择"
|
||||||
<el-row>
|
style="width: 100%">
|
||||||
<el-col :span="12">
|
<el-option
|
||||||
<el-form-item label="单位" prop="unit">
|
v-for="item in getDictDatas(DICT_TYPE.ENERGY_TYPE)"
|
||||||
<el-select v-model="form.unit" placeholder="请选择" style="width: 100%;">
|
:key="item.value"
|
||||||
<el-option v-for="item in getDictDatas(DICT_TYPE.ENERGY_UNIT)" :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
|
||||||
<el-form-item label="计价方式" prop="pricingMethod">
|
label="类型编码"
|
||||||
<el-select v-model="form.pricingMethod" placeholder="请选择" style="width: 100%;">
|
prop="code">
|
||||||
<el-option label="时间段" :value='0'></el-option>
|
<el-input
|
||||||
<el-option label="使用量" :value='1'></el-option>
|
v-model="form.code"
|
||||||
<el-option label="固定价位" :value='2'></el-option>
|
disabled></el-input>
|
||||||
</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" v-show="form.pricingMethod === 2">
|
<el-form-item
|
||||||
<el-form-item label="单价(元)" prop="pricingMethod">
|
label="单位"
|
||||||
<el-input-number v-model="form.singlePrice" :precision="2" :min="0" :max="999999999"
|
prop="unit">
|
||||||
style="width: 100%;"></el-input-number>
|
<el-select
|
||||||
</el-form-item>
|
v-model="form.unit"
|
||||||
</el-col>
|
placeholder="请选择"
|
||||||
<el-col :span="12" v-show="form.pricingMethod === 1">
|
filterable
|
||||||
<el-form-item label="计量维度" prop="dim">
|
style="width: 100%">
|
||||||
<el-select v-model="form.dim" placeholder="请选择" style="width: 100%;">
|
<el-option
|
||||||
<el-option label="月" :value='4'></el-option>
|
v-for="item in getDictDatas(DICT_TYPE.UNIT_DICT)"
|
||||||
<el-option label="年" :value='5'></el-option>
|
:key="item.value"
|
||||||
</el-select>
|
:label="item.label"
|
||||||
</el-form-item>
|
:value="item.value"></el-option>
|
||||||
</el-col>
|
</el-select>
|
||||||
<el-col :span="24" v-show="form.pricingMethod === 0">
|
</el-form-item>
|
||||||
<el-form-item label="时间段" prop="pricingMethod">
|
</el-col>
|
||||||
<base-table :key='timeKye' :table-props="tableProps1" :table-data="tableData1"
|
<el-col :span="12">
|
||||||
:add-button-show="addButtonShow" @emitButtonClick="emitButtonClick1" @emitFun="inputChange1">
|
<el-form-item
|
||||||
<method-btn v-if="tableBtn.length" slot="handleBtn" :width="80" label="操作" :method-list="tableBtn"
|
label="计价方式"
|
||||||
@clickBtn="handleClick1" />
|
prop="pricingMethod">
|
||||||
</base-table>
|
<el-select
|
||||||
</el-form-item>
|
v-model="form.pricingMethod"
|
||||||
</el-col>
|
placeholder="请选择"
|
||||||
<el-col :span="24" v-show="form.pricingMethod === 1">
|
style="width: 100%">
|
||||||
<el-form-item label="使用量" prop="pricingMethod">
|
<el-option
|
||||||
<base-table :key='usedKye' :table-props="tableProps2" :table-data="tableData2"
|
label="时间段"
|
||||||
:add-button-show="addButtonShow" @emitButtonClick="emitButtonClick2" @emitFun="inputChange2">
|
:value="0"></el-option>
|
||||||
<method-btn v-if="tableBtn.length" slot="handleBtn" :width="80" label="操作" :method-list="tableBtn"
|
<el-option
|
||||||
@clickBtn="handleClick2" />
|
label="使用量"
|
||||||
</base-table>
|
:value="1"></el-option>
|
||||||
</el-form-item>
|
<el-option
|
||||||
</el-col>
|
label="固定价位"
|
||||||
</el-row>
|
:value="2"></el-option>
|
||||||
<el-row>
|
</el-select>
|
||||||
<el-col :span="12">
|
</el-form-item>
|
||||||
<el-form-item label="是否推送" prop="push">
|
</el-col>
|
||||||
<el-switch v-model="form.push"></el-switch>
|
</el-row>
|
||||||
</el-form-item>
|
<el-row>
|
||||||
</el-col>
|
<el-col
|
||||||
<el-col :span="12">
|
:span="12"
|
||||||
<el-form-item label="描述" prop="description">
|
v-show="form.pricingMethod === 2">
|
||||||
<el-input v-model="form.description"></el-input>
|
<el-form-item
|
||||||
</el-form-item>
|
label="单价(元)"
|
||||||
</el-col>
|
prop="pricingMethod">
|
||||||
</el-row>
|
<el-input-number
|
||||||
</el-form>
|
v-model="form.singlePrice"
|
||||||
|
:precision="2"
|
||||||
|
:min="0"
|
||||||
|
:max="999999999"
|
||||||
|
style="width: 100%"></el-input-number>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col
|
||||||
|
:span="12"
|
||||||
|
v-show="form.pricingMethod === 1">
|
||||||
|
<el-form-item
|
||||||
|
label="计量维度"
|
||||||
|
prop="dim">
|
||||||
|
<el-select
|
||||||
|
v-model="form.dim"
|
||||||
|
placeholder="请选择"
|
||||||
|
style="width: 100%">
|
||||||
|
<el-option
|
||||||
|
label="月"
|
||||||
|
:value="4"></el-option>
|
||||||
|
<el-option
|
||||||
|
label="年"
|
||||||
|
:value="5"></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col
|
||||||
|
:span="24"
|
||||||
|
v-show="form.pricingMethod === 0">
|
||||||
|
<el-form-item
|
||||||
|
label="时间段"
|
||||||
|
prop="pricingMethod">
|
||||||
|
<base-table
|
||||||
|
:key="timeKye"
|
||||||
|
:table-props="tableProps1"
|
||||||
|
:table-data="tableData1"
|
||||||
|
:add-button-show="addButtonShow"
|
||||||
|
@emitButtonClick="emitButtonClick1"
|
||||||
|
@emitFun="inputChange1">
|
||||||
|
<method-btn
|
||||||
|
v-if="tableBtn.length"
|
||||||
|
slot="handleBtn"
|
||||||
|
:width="80"
|
||||||
|
label="操作"
|
||||||
|
:method-list="tableBtn"
|
||||||
|
@clickBtn="handleClick1" />
|
||||||
|
</base-table>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col
|
||||||
|
:span="24"
|
||||||
|
v-show="form.pricingMethod === 1">
|
||||||
|
<el-form-item
|
||||||
|
label="使用量"
|
||||||
|
prop="pricingMethod">
|
||||||
|
<base-table
|
||||||
|
:key="usedKye"
|
||||||
|
:table-props="tableProps2"
|
||||||
|
:table-data="tableData2"
|
||||||
|
:add-button-show="addButtonShow"
|
||||||
|
@emitButtonClick="emitButtonClick2"
|
||||||
|
@emitFun="inputChange2">
|
||||||
|
<method-btn
|
||||||
|
v-if="tableBtn.length"
|
||||||
|
slot="handleBtn"
|
||||||
|
:width="80"
|
||||||
|
label="操作"
|
||||||
|
:method-list="tableBtn"
|
||||||
|
@clickBtn="handleClick2" />
|
||||||
|
</base-table>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item
|
||||||
|
label="描述"
|
||||||
|
prop="description">
|
||||||
|
<el-input v-model="form.description"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { getEnergyType, updateEnergyType, createEnergyType, getEnergyTypeCode } from '@/api/base/energyType'
|
import {
|
||||||
import inputArea from './InputArea.vue'
|
getEnergyType,
|
||||||
import timePickerArea from './TimePickerArea.vue'
|
updateEnergyType,
|
||||||
|
createEnergyType,
|
||||||
|
getEnergyTypeCode,
|
||||||
|
} from '@/api/base/energyType';
|
||||||
|
import inputArea from './InputArea.vue';
|
||||||
|
import timePickerArea from './TimePickerArea.vue';
|
||||||
const tableProps1 = [
|
const tableProps1 = [
|
||||||
{
|
{
|
||||||
prop: 'startTime',
|
prop: 'startTime',
|
||||||
label: '开始时间',
|
label: '开始时间',
|
||||||
subcomponent: timePickerArea
|
subcomponent: timePickerArea,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'endTime',
|
prop: 'endTime',
|
||||||
label: '结束时间',
|
label: '结束时间',
|
||||||
subcomponent: timePickerArea
|
subcomponent: timePickerArea,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'price',
|
prop: 'price',
|
||||||
label: '单价(元)',
|
label: '单价(元)',
|
||||||
subcomponent: inputArea
|
subcomponent: inputArea,
|
||||||
}
|
},
|
||||||
]
|
];
|
||||||
const tableProps2 = [
|
const tableProps2 = [
|
||||||
{
|
{
|
||||||
prop: 'startUsed',
|
prop: 'startUsed',
|
||||||
label: '下限值',
|
label: '下限值',
|
||||||
// subcomponent: inputArea
|
// subcomponent: inputArea
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'endUsed',
|
prop: 'endUsed',
|
||||||
label: '上限量',
|
label: '上限量',
|
||||||
subcomponent: inputArea
|
subcomponent: inputArea,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'price',
|
prop: 'price',
|
||||||
label: '单价(元)',
|
label: '单价(元)',
|
||||||
subcomponent: inputArea
|
subcomponent: inputArea,
|
||||||
}
|
},
|
||||||
]
|
];
|
||||||
export default {
|
export default {
|
||||||
name: 'energyTypeAdd',
|
name: 'energyTypeAdd',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
form: {
|
form: {
|
||||||
id: '',
|
id: '',
|
||||||
name: '',
|
name: '',
|
||||||
code: '',
|
code: '',
|
||||||
unit: '',
|
unit: '',
|
||||||
singlePrice: 0,
|
singlePrice: 0,
|
||||||
pricingMethod: 2,
|
pricingMethod: 2,
|
||||||
dim: '',
|
dim: '',
|
||||||
push: false,
|
description: '',
|
||||||
description: ''
|
},
|
||||||
},
|
isEdit: false, //是否是编辑
|
||||||
isEdit: false, //是否是编辑
|
rules: {
|
||||||
rules: {
|
name: [
|
||||||
name: [{ required: true, message: '能源类型不能为空', trigger: 'blur' }],
|
{ required: true, message: '能源类型不能为空', trigger: 'blur' },
|
||||||
pricingMethod: [{ required: true, message: '计价方式不能为空', trigger: 'change' }]
|
],
|
||||||
},
|
pricingMethod: [
|
||||||
timeKye: 0,
|
{ required: true, message: '计价方式不能为空', trigger: 'change' },
|
||||||
usedKye: 0,
|
],
|
||||||
tableProps1,
|
},
|
||||||
tableProps2,
|
timeKye: 0,
|
||||||
tableData1: [],
|
usedKye: 0,
|
||||||
tableData2: [],
|
tableProps1,
|
||||||
tableBtn: [
|
tableProps2,
|
||||||
{
|
tableData1: [],
|
||||||
type: 'delete',
|
tableData2: [],
|
||||||
name: '删除'
|
tableBtn: [
|
||||||
}
|
{
|
||||||
],
|
type: 'delete',
|
||||||
addButtonShow: '新增'
|
name: '删除',
|
||||||
}
|
},
|
||||||
},
|
],
|
||||||
methods: {
|
addButtonShow: '新增',
|
||||||
init(id) {
|
};
|
||||||
if (id) {
|
},
|
||||||
this.isEdit = true
|
methods: {
|
||||||
this.form.id = id
|
init(id) {
|
||||||
getEnergyType(id).then((res) => {
|
if (id) {
|
||||||
if (res.code === 0) {
|
this.isEdit = true;
|
||||||
this.form.name = res.data.name
|
this.form.id = id;
|
||||||
this.form.code = res.data.code
|
getEnergyType(id).then((res) => {
|
||||||
this.form.unit = res.data.unit
|
if (res.code === 0) {
|
||||||
this.form.pricingMethod = res.data.pricingMethod
|
this.form.name = res.data.name;
|
||||||
this.form.push = res.data.push ? true : false
|
this.form.code = res.data.code;
|
||||||
this.form.description = res.data.description
|
this.form.unit = res.data.unit;
|
||||||
switch (this.form.pricingMethod) {
|
this.form.pricingMethod = res.data.pricingMethod;
|
||||||
case 0:
|
this.form.description = res.data.description;
|
||||||
this.tableData1 = res.data.segPriceList || []
|
switch (this.form.pricingMethod) {
|
||||||
break;
|
case 0:
|
||||||
case 1:
|
this.tableData1 = res.data.segPriceList || [];
|
||||||
this.tableData2 = res.data.usedPriceList || []
|
break;
|
||||||
this.form.dim = res.data.dim
|
case 1:
|
||||||
break;
|
this.tableData2 = res.data.usedPriceList || [];
|
||||||
default:
|
this.form.dim = res.data.dim;
|
||||||
this.form.singlePrice = res.data.singlePrice || 0
|
break;
|
||||||
}
|
default:
|
||||||
}
|
this.form.singlePrice = res.data.singlePrice || 0;
|
||||||
})
|
}
|
||||||
console.log(this.form)
|
}
|
||||||
} else {
|
});
|
||||||
this.isEdit = false
|
console.log(this.form);
|
||||||
this.form.id = ''
|
} else {
|
||||||
getEnergyTypeCode().then((res) => {
|
this.isEdit = false;
|
||||||
this.form.code = res.data
|
this.form.id = '';
|
||||||
})
|
getEnergyTypeCode().then((res) => {
|
||||||
}
|
this.form.code = res.data;
|
||||||
},
|
});
|
||||||
// 输入框失去焦点
|
}
|
||||||
inputChange1(val) {
|
},
|
||||||
this.tableData1[val._pageIndex - 1][val.prop] = val[val.prop]
|
// 输入框失去焦点
|
||||||
if ((this.tableData1.length > val._pageIndex) && val.prop === 'endTime') {
|
inputChange1(val) {
|
||||||
this.tableData1[val._pageIndex].startTime = val[val.prop]
|
this.tableData1[val._pageIndex - 1][val.prop] = val[val.prop];
|
||||||
}
|
if (this.tableData1.length > val._pageIndex && val.prop === 'endTime') {
|
||||||
this.timeKye++
|
this.tableData1[val._pageIndex].startTime = val[val.prop];
|
||||||
},
|
}
|
||||||
inputChange2(val) {
|
this.timeKye++;
|
||||||
// 上限值必须大于下限值
|
},
|
||||||
if (!!val.endUsed && (val.endUsed <= val.startUsed)) {
|
inputChange2(val) {
|
||||||
this.$modal.msgError('上限值不能等于或者小于下限值')
|
// 上限值必须大于下限值
|
||||||
return false
|
if (!!val.endUsed && val.endUsed <= val.startUsed) {
|
||||||
}
|
this.$modal.msgError('上限值不能等于或者小于下限值');
|
||||||
this.tableData2[val._pageIndex - 1][val.prop] = val[val.prop]
|
return false;
|
||||||
if ((this.tableData2.length > val._pageIndex) && val.prop === 'endUsed') {
|
}
|
||||||
this.tableData2[val._pageIndex].startUsed = val[val.prop]
|
this.tableData2[val._pageIndex - 1][val.prop] = val[val.prop];
|
||||||
}
|
if (this.tableData2.length > val._pageIndex && val.prop === 'endUsed') {
|
||||||
this.usedKye++
|
this.tableData2[val._pageIndex].startUsed = val[val.prop];
|
||||||
},
|
}
|
||||||
// 增加
|
this.usedKye++;
|
||||||
emitButtonClick1() {
|
},
|
||||||
let n = this.tableData1.length
|
// 增加
|
||||||
let obj = {}
|
emitButtonClick1() {
|
||||||
obj.startTime = n === 0 ? '' : this.tableData1[n - 1].endTime
|
let n = this.tableData1.length;
|
||||||
obj.endTime = ''
|
let obj = {};
|
||||||
obj.price = 0
|
obj.startTime = n === 0 ? '' : this.tableData1[n - 1].endTime;
|
||||||
this.tableData1.push(obj)
|
obj.endTime = '';
|
||||||
},
|
obj.price = 0;
|
||||||
emitButtonClick2() {
|
this.tableData1.push(obj);
|
||||||
let n = this.tableData2.length
|
},
|
||||||
let obj = {}
|
emitButtonClick2() {
|
||||||
obj.startUsed = n === 0 ? 0 : this.tableData2[n - 1].endUsed
|
let n = this.tableData2.length;
|
||||||
obj.endUsed = 0
|
let obj = {};
|
||||||
obj.price = 0
|
obj.startUsed = n === 0 ? 0 : this.tableData2[n - 1].endUsed;
|
||||||
this.tableData2.push(obj)
|
obj.endUsed = 0;
|
||||||
},
|
obj.price = 0;
|
||||||
// 删除
|
this.tableData2.push(obj);
|
||||||
handleClick1(val) {
|
},
|
||||||
this.tableData1.splice(val.data._pageIndex - 1, 1)
|
// 删除
|
||||||
this.timeKye++
|
handleClick1(val) {
|
||||||
},
|
this.tableData1.splice(val.data._pageIndex - 1, 1);
|
||||||
handleClick2(val) {
|
this.timeKye++;
|
||||||
this.tableData2.splice(val.data._pageIndex - 1, 1)
|
},
|
||||||
this.usedKye++
|
handleClick2(val) {
|
||||||
},
|
this.tableData2.splice(val.data._pageIndex - 1, 1);
|
||||||
submitForm() {
|
this.usedKye++;
|
||||||
this.$refs['form'].validate((valid) => {
|
},
|
||||||
if (valid) {
|
submitForm() {
|
||||||
switch (this.form.pricingMethod) {
|
this.$refs['form'].validate((valid) => {
|
||||||
case 0:// 时间段
|
if (valid) {
|
||||||
if (this.tableData1.length === 0) {
|
switch (this.form.pricingMethod) {
|
||||||
this.$modal.msgError('时间段表格数据不能为空')
|
case 0: // 时间段
|
||||||
return false
|
if (this.tableData1.length === 0) {
|
||||||
} else {
|
this.$modal.msgError('时间段表格数据不能为空');
|
||||||
this.tableData1.map(item => {
|
return false;
|
||||||
if (item.price <= 0) {
|
} else {
|
||||||
this.$modal.msgError('单价有误请检查,请检查')
|
this.tableData1.map((item) => {
|
||||||
return false
|
if (item.price <= 0) {
|
||||||
}
|
this.$modal.msgError('单价有误请检查,请检查');
|
||||||
})
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
});
|
||||||
case 1:// 使用量
|
}
|
||||||
if (this.tableData2.length === 0) {
|
break;
|
||||||
this.$modal.msgError('使用量表格数据不能为空')
|
case 1: // 使用量
|
||||||
return false
|
if (this.tableData2.length === 0) {
|
||||||
} else {
|
this.$modal.msgError('使用量表格数据不能为空');
|
||||||
this.tableData1.map(item => {
|
return false;
|
||||||
if (item.price <= 0) {
|
} else {
|
||||||
this.$modal.msgError('单价有误请检查,请检查')
|
this.tableData1.map((item) => {
|
||||||
return false
|
if (item.price <= 0) {
|
||||||
}
|
this.$modal.msgError('单价有误请检查,请检查');
|
||||||
})
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
});
|
||||||
default:// 固定单价
|
}
|
||||||
if (!this.form.singlePrice) {
|
break;
|
||||||
this.$modal.msgError('单价有误请检查,请检查')
|
default: // 固定单价
|
||||||
return false
|
if (!this.form.singlePrice) {
|
||||||
}
|
this.$modal.msgError('单价有误请检查,请检查');
|
||||||
}
|
return false;
|
||||||
console.log(this.form)
|
}
|
||||||
if (this.isEdit) {
|
}
|
||||||
// 编辑
|
console.log(this.form);
|
||||||
updateEnergyType({
|
if (this.isEdit) {
|
||||||
id: this.form.id,
|
// 编辑
|
||||||
code: this.form.code,
|
updateEnergyType({
|
||||||
name: this.form.name,
|
id: this.form.id,
|
||||||
unit: this.form.unit,
|
code: this.form.code,
|
||||||
pricingMethod: this.form.pricingMethod,
|
name: this.form.name,
|
||||||
description: this.form.description,
|
unit: this.form.unit,
|
||||||
dim: this.form.pricingMethod === 1 ? this.form.dim : '',
|
pricingMethod: this.form.pricingMethod,
|
||||||
singlePrice: this.form.pricingMethod === 2 ? this.form.singlePrice : '',
|
description: this.form.description,
|
||||||
segPriceList: this.form.pricingMethod === 0 ? this.tableData1 : [],
|
dim: this.form.pricingMethod === 1 ? this.form.dim : '',
|
||||||
usedPriceList: this.form.pricingMethod === 1 ? this.tableData2 : [],
|
singlePrice:
|
||||||
push: this.form.push ? 1 : 0
|
this.form.pricingMethod === 2 ? this.form.singlePrice : '',
|
||||||
}).then((res) => {
|
segPriceList:
|
||||||
if (res.code === 0) {
|
this.form.pricingMethod === 0 ? this.tableData1 : [],
|
||||||
this.$modal.msgSuccess("操作成功");
|
usedPriceList:
|
||||||
this.$emit('successSubmit')
|
this.form.pricingMethod === 1 ? this.tableData2 : [],
|
||||||
}
|
}).then((res) => {
|
||||||
})
|
if (res.code === 0) {
|
||||||
} else {
|
this.$modal.msgSuccess('操作成功');
|
||||||
createEnergyType({
|
this.$emit('successSubmit');
|
||||||
code: this.form.code,
|
}
|
||||||
name: this.form.name,
|
});
|
||||||
unit: this.form.unit,
|
} else {
|
||||||
pricingMethod: this.form.pricingMethod,
|
createEnergyType({
|
||||||
description: this.form.description,
|
code: this.form.code,
|
||||||
dim: this.form.pricingMethod === 1 ? this.form.dim : '',
|
name: this.form.name,
|
||||||
singlePrice: this.form.pricingMethod === 2 ? this.form.singlePrice : '',
|
unit: this.form.unit,
|
||||||
segPriceList: this.form.pricingMethod === 0 ? this.tableData1 : [],
|
pricingMethod: this.form.pricingMethod,
|
||||||
usedPriceList: this.form.pricingMethod === 1 ? this.tableData2 : [],
|
description: this.form.description,
|
||||||
push: this.form.push ? 1 : 0
|
dim: this.form.pricingMethod === 1 ? this.form.dim : '',
|
||||||
}).then((res) => {
|
singlePrice:
|
||||||
if (res.code === 0) {
|
this.form.pricingMethod === 2 ? this.form.singlePrice : '',
|
||||||
this.$modal.msgSuccess("操作成功");
|
segPriceList:
|
||||||
this.$emit('successSubmit')
|
this.form.pricingMethod === 0 ? this.tableData1 : [],
|
||||||
}
|
usedPriceList:
|
||||||
})
|
this.form.pricingMethod === 1 ? this.tableData2 : [],
|
||||||
}
|
}).then((res) => {
|
||||||
} else {
|
if (res.code === 0) {
|
||||||
return false
|
this.$modal.msgSuccess('操作成功');
|
||||||
}
|
this.$emit('successSubmit');
|
||||||
})
|
}
|
||||||
},
|
});
|
||||||
formClear() {
|
}
|
||||||
this.$refs.form.resetFields()
|
} else {
|
||||||
this.form.singlePrice = 0
|
return false;
|
||||||
this.isEdit = false
|
}
|
||||||
this.timeKye = 0
|
});
|
||||||
this.usedKye = 0
|
},
|
||||||
this.tableData1 = []
|
formClear() {
|
||||||
this.tableData2 = []
|
this.$refs.form.resetFields();
|
||||||
}
|
this.form.singlePrice = 0;
|
||||||
}
|
this.isEdit = false;
|
||||||
}
|
this.timeKye = 0;
|
||||||
|
this.usedKye = 0;
|
||||||
|
this.tableData1 = [];
|
||||||
|
this.tableData2 = [];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,224 +1,191 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
|
<!-- 搜索工作栏 -->
|
||||||
<!-- 搜索工作栏 -->
|
<search-bar
|
||||||
<search-bar
|
:formConfigs="formConfig"
|
||||||
:formConfigs="formConfig"
|
ref="searchBarForm"
|
||||||
ref="searchBarForm"
|
:removeBlue="true"
|
||||||
@headBtnClick="buttonClick"
|
@headBtnClick="buttonClick" />
|
||||||
/>
|
<!-- 列表 -->
|
||||||
<!-- 列表 -->
|
<base-table
|
||||||
<base-table
|
:page="queryParams.pageNo"
|
||||||
:page="queryParams.pageNo"
|
:limit="queryParams.pageSize"
|
||||||
:limit="queryParams.pageSize"
|
:table-props="tableProps"
|
||||||
:table-props="tableProps"
|
:table-data="list"
|
||||||
:table-data="list"
|
:max-height="tableH">
|
||||||
:max-height="tableH"
|
<method-btn
|
||||||
>
|
v-if="tableBtn.length"
|
||||||
<method-btn
|
slot="handleBtn"
|
||||||
v-if="tableBtn.length"
|
:width="80"
|
||||||
slot="handleBtn"
|
label="操作"
|
||||||
:width="80"
|
:method-list="tableBtn"
|
||||||
label="操作"
|
@clickBtn="handleClick" />
|
||||||
:method-list="tableBtn"
|
</base-table>
|
||||||
@clickBtn="handleClick"
|
<!-- 新增 -->
|
||||||
/>
|
<base-dialog
|
||||||
</base-table>
|
:dialogTitle="addOrEditTitle"
|
||||||
<pagination
|
:dialogVisible="centervisible"
|
||||||
:page.sync="queryParams.pageNo"
|
@cancel="handleCancel"
|
||||||
:limit.sync="queryParams.pageSize"
|
@confirm="handleConfirm"
|
||||||
:total="total"
|
:before-close="handleCancel">
|
||||||
@pagination="getList"
|
<energy-type-add
|
||||||
/>
|
ref="energyType"
|
||||||
<!-- 新增 -->
|
@successSubmit="successSubmit" />
|
||||||
<base-dialog
|
</base-dialog>
|
||||||
:dialogTitle="addOrEditTitle"
|
</div>
|
||||||
:dialogVisible="centervisible"
|
|
||||||
@cancel="handleCancel"
|
|
||||||
@confirm="handleConfirm"
|
|
||||||
:before-close="handleCancel"
|
|
||||||
>
|
|
||||||
<energy-type-add ref="energyType" @successSubmit="successSubmit" />
|
|
||||||
</base-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getEnergyTypePage, deleteEnergyType } from "@/api/base/energyType";
|
import { getEnergyTypePage, deleteEnergyType } from '@/api/base/energyType';
|
||||||
import { publicFormatter } from '@/utils/dict'
|
import { publicFormatter } from '@/utils/dict';
|
||||||
import InnerTable from './components/InnerTable'
|
import InnerTable from './components/InnerTable';
|
||||||
import EnergyTypeAdd from './components/energyTypeAdd'
|
import EnergyTypeAdd from './components/energyTypeAdd';
|
||||||
const tableProps = [
|
const tableProps = [
|
||||||
{
|
{
|
||||||
prop: 'code',
|
prop: 'code',
|
||||||
label: '类型编码',
|
label: '类型编码',
|
||||||
showOverflowtooltip: true,
|
showOverflowtooltip: true,
|
||||||
minWidth: 150
|
minWidth: 150,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'name',
|
prop: 'name',
|
||||||
label: '能源类型'
|
label: '能源类型',
|
||||||
},
|
filter: publicFormatter('energy_type'),
|
||||||
{
|
},
|
||||||
prop: 'unit',
|
{
|
||||||
label: '单位',
|
prop: 'unit',
|
||||||
filter: publicFormatter('energy_unit')
|
label: '单位',
|
||||||
},
|
filter: publicFormatter('unit_dict'),
|
||||||
{
|
},
|
||||||
prop: 'pricingMethod',
|
{
|
||||||
label: '计价方式'
|
prop: 'pricingMethod',
|
||||||
},
|
label: '计价方式',
|
||||||
{
|
},
|
||||||
prop: 'push',
|
{
|
||||||
label: '是否推送',
|
prop: 'price',
|
||||||
filter: publicFormatter('push')
|
label: '价格(元)',
|
||||||
},
|
subcomponent: InnerTable,
|
||||||
{
|
},
|
||||||
prop: 'price',
|
];
|
||||||
label: '价格(元)',
|
|
||||||
subcomponent: InnerTable
|
|
||||||
}
|
|
||||||
]
|
|
||||||
export default {
|
export default {
|
||||||
name: "EnergyType",
|
name: 'EnergyType',
|
||||||
components: { EnergyTypeAdd },
|
components: { EnergyTypeAdd },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
formConfig: [
|
formConfig: [
|
||||||
{
|
{
|
||||||
type: 'input',
|
type: this.$auth.hasPermi('base:energy-type:create') ? 'button' : '',
|
||||||
label: '能源类型',
|
btnName: '新增',
|
||||||
placeholder: '能源类型',
|
name: 'add',
|
||||||
param: 'name'
|
color: 'success',
|
||||||
},
|
plain: true,
|
||||||
{
|
},
|
||||||
type: 'button',
|
],
|
||||||
btnName: '查询',
|
tableProps,
|
||||||
name: 'search',
|
tableBtn: [
|
||||||
color: 'primary'
|
this.$auth.hasPermi('base:energy-type:update')
|
||||||
},
|
? {
|
||||||
{
|
type: 'edit',
|
||||||
type: this.$auth.hasPermi('base:energy-type:create') ? 'separate' : '',
|
btnName: '编辑',
|
||||||
},
|
}
|
||||||
{
|
: undefined,
|
||||||
type: this.$auth.hasPermi('base:energy-type:create') ? 'button' : '',
|
this.$auth.hasPermi('base:energy-type:delete')
|
||||||
btnName: '新增',
|
? {
|
||||||
name: 'add',
|
type: 'delete',
|
||||||
color: 'success',
|
btnName: '删除',
|
||||||
plain: true
|
}
|
||||||
}
|
: undefined,
|
||||||
],
|
].filter((v) => v),
|
||||||
tableProps,
|
tableH: this.tableHeight(220),
|
||||||
tableBtn: [
|
pricingMethodList: [
|
||||||
this.$auth.hasPermi('base:energy-type:update')
|
{ value: 0, label: '分时间段计价' },
|
||||||
? {
|
{ value: 1, label: '分使用量计价' },
|
||||||
type: 'edit',
|
{ value: 2, label: '单一计价' },
|
||||||
btnName: '编辑'
|
],
|
||||||
}
|
// 总条数
|
||||||
: undefined,
|
total: 0,
|
||||||
this.$auth.hasPermi('base:energy-type:delete')
|
// 班次基础信息列表
|
||||||
? {
|
list: [],
|
||||||
type: 'delete',
|
// 弹出层标题
|
||||||
btnName: '删除'
|
addOrEditTitle: '',
|
||||||
}
|
// 是否显示弹出层
|
||||||
: undefined
|
centervisible: false,
|
||||||
].filter((v) => v),
|
// 查询参数
|
||||||
tableH: this.tableHeight(260),
|
queryParams: {
|
||||||
pricingMethodList: [
|
pageNo: 1,
|
||||||
{value: 0,label: '分时间段计价'},
|
pageSize: 100,
|
||||||
{value: 1,label: '分使用量计价'},
|
},
|
||||||
{value: 2,label: '单一计价'}
|
};
|
||||||
],
|
},
|
||||||
// 总条数
|
created() {
|
||||||
total: 0,
|
window.addEventListener('resize', () => {
|
||||||
// 班次基础信息列表
|
this.tableH = this.tableHeight(220);
|
||||||
list: [],
|
});
|
||||||
// 弹出层标题
|
this.getList();
|
||||||
addOrEditTitle: "",
|
},
|
||||||
// 是否显示弹出层
|
methods: {
|
||||||
centervisible: false,
|
buttonClick() {
|
||||||
// 查询参数
|
this.addOrEditTitle = '新增';
|
||||||
queryParams: {
|
this.centervisible = true;
|
||||||
pageNo: 1,
|
this.$nextTick(() => {
|
||||||
pageSize: 20,
|
this.$refs.energyType.init();
|
||||||
name: null,
|
});
|
||||||
code: null
|
},
|
||||||
}
|
/** 查询列表 */
|
||||||
};
|
getList() {
|
||||||
},
|
getEnergyTypePage(this.queryParams).then((response) => {
|
||||||
created() {
|
let arr = response.data.list || [];
|
||||||
window.addEventListener('resize', () => {
|
arr &&
|
||||||
this.tableH = this.tableHeight(260)
|
arr.map((item) => {
|
||||||
})
|
this.pricingMethodList.map((i) => {
|
||||||
this.getList();
|
if (item.pricingMethod === i.value) {
|
||||||
},
|
item.pricingMethod = i.label;
|
||||||
methods: {
|
}
|
||||||
buttonClick(val) {
|
});
|
||||||
switch (val.btnName) {
|
});
|
||||||
case 'search':
|
this.list = arr;
|
||||||
this.queryParams.pageNo = 1;
|
this.total = response.data.total;
|
||||||
this.queryParams.name = val.name
|
});
|
||||||
this.queryParams.code = val.code
|
},
|
||||||
this.getList()
|
handleClick(val) {
|
||||||
break
|
switch (val.type) {
|
||||||
default:
|
case 'edit':
|
||||||
this.addOrEditTitle = '新增'
|
this.addOrEditTitle = '编辑';
|
||||||
this.centervisible = true
|
this.$nextTick(() => {
|
||||||
this.$nextTick(() => {
|
this.$refs.energyType.init(val.data.id);
|
||||||
this.$refs.energyType.init()
|
});
|
||||||
})
|
this.centervisible = true;
|
||||||
}
|
break;
|
||||||
},
|
default:
|
||||||
/** 查询列表 */
|
this.handleDelete(val.data);
|
||||||
getList() {
|
}
|
||||||
getEnergyTypePage(this.queryParams).then(response => {
|
},
|
||||||
let arr = response.data.list || [];
|
handleCancel() {
|
||||||
arr&&arr.map(item => {
|
this.$refs.energyType.formClear();
|
||||||
this.pricingMethodList.map(i => {
|
this.centervisible = false;
|
||||||
if (item.pricingMethod === i.value) {
|
this.addOrEditTitle = '';
|
||||||
item.pricingMethod = i.label
|
},
|
||||||
}
|
handleConfirm() {
|
||||||
})
|
this.$refs.energyType.submitForm();
|
||||||
})
|
},
|
||||||
this.list = arr
|
successSubmit() {
|
||||||
this.total = response.data.total;
|
this.handleCancel();
|
||||||
});
|
this.getList();
|
||||||
},
|
},
|
||||||
handleClick(val) {
|
/** 删除按钮操作 */
|
||||||
switch (val.type) {
|
handleDelete(row) {
|
||||||
case 'edit':
|
this.$modal
|
||||||
this.addOrEditTitle = '编辑'
|
.confirm('是否确认删除能源类型为"' + row.name + '"的数据项?')
|
||||||
this.$nextTick(() => {
|
.then(function () {
|
||||||
this.$refs.energyType.init(val.data.id)
|
return deleteEnergyType(row.id);
|
||||||
})
|
})
|
||||||
this.centervisible = true
|
.then(() => {
|
||||||
break
|
this.queryParams.pageNo = 1;
|
||||||
default:
|
this.getList();
|
||||||
this.handleDelete(val.data)
|
this.$modal.msgSuccess('删除成功');
|
||||||
}
|
})
|
||||||
},
|
.catch(() => {});
|
||||||
handleCancel() {
|
},
|
||||||
this.$refs.energyType.formClear()
|
},
|
||||||
this.centervisible = false
|
|
||||||
this.addOrEditTitle = ''
|
|
||||||
},
|
|
||||||
handleConfirm() {
|
|
||||||
this.$refs.energyType.submitForm()
|
|
||||||
},
|
|
||||||
successSubmit() {
|
|
||||||
this.handleCancel()
|
|
||||||
this.getList()
|
|
||||||
},
|
|
||||||
/** 删除按钮操作 */
|
|
||||||
handleDelete(row) {
|
|
||||||
this.$modal.confirm('是否确认删除能源类型为"' + row.name + '"的数据项?').then(function() {
|
|
||||||
return deleteEnergyType(row.id);
|
|
||||||
}).then(() => {
|
|
||||||
this.queryParams.pageNo = 1;
|
|
||||||
this.getList();
|
|
||||||
this.$modal.msgSuccess("删除成功");
|
|
||||||
}).catch(() => {});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,282 +1,360 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-form ref="form" :rules="rules" label-width="110px" :model="form">
|
<el-form
|
||||||
<el-row>
|
ref="form"
|
||||||
<el-col :span="12">
|
:rules="rules"
|
||||||
<el-form-item label="抄表方式" prop="method">
|
label-width="110px"
|
||||||
<el-select v-model="form.method" placeholder="请选择" style="width: 100%;" @change="changeMethod">
|
:model="form">
|
||||||
<el-option
|
<el-row>
|
||||||
v-for="item in getDictDatas(DICT_TYPE.METHOD)"
|
<el-col :span="12">
|
||||||
:key="item.value"
|
<el-form-item
|
||||||
:label="item.label"
|
label="抄表方式"
|
||||||
:value="item.value">
|
prop="method">
|
||||||
</el-option>
|
<el-select
|
||||||
</el-select>
|
v-model="form.method"
|
||||||
</el-form-item>
|
placeholder="请选择"
|
||||||
</el-col>
|
style="width: 100%"
|
||||||
<el-col :span="12" v-if='form.method == 1'>
|
@change="changeMethod">
|
||||||
<el-form-item label="监控对象" prop="objectId">
|
<el-option
|
||||||
<el-cascader
|
v-for="item in getDictDatas(DICT_TYPE.METHOD)"
|
||||||
style='width: 100%;'
|
:key="item.value"
|
||||||
v-model="objIds"
|
:label="item.label"
|
||||||
:options="objList"
|
:value="item.value"></el-option>
|
||||||
:props="{ checkStrictly: true, value: 'id', label: 'name' }"
|
</el-select>
|
||||||
popper-class="cascaderParent"
|
</el-form-item>
|
||||||
@change="selectObj"
|
</el-col>
|
||||||
clearable></el-cascader>
|
<el-col
|
||||||
</el-form-item>
|
:span="12"
|
||||||
</el-col>
|
v-if="form.method == 1">
|
||||||
<el-col :span="12" v-if='form.method == 2'>
|
<el-form-item
|
||||||
<el-form-item label="水/气表名" prop="tableName">
|
label="监控对象"
|
||||||
<el-select v-model="form.tableName" placeholder="请选择" style="width: 100%;">
|
prop="objectId">
|
||||||
<el-option
|
<el-cascader
|
||||||
v-for="item in getDictDatas(DICT_TYPE.TABLE_NAME)"
|
style="width: 100%"
|
||||||
:key="item.value"
|
v-model="objIds"
|
||||||
:label="item.label"
|
:options="objList"
|
||||||
:value="item.value">
|
:props="{ checkStrictly: true, value: 'id', label: 'name' }"
|
||||||
</el-option>
|
popper-class="cascaderParent"
|
||||||
</el-select>
|
@change="selectObj"
|
||||||
</el-form-item>
|
clearable></el-cascader>
|
||||||
</el-col>
|
</el-form-item>
|
||||||
<el-col :span="12">
|
</el-col>
|
||||||
<el-form-item label="监控能源类型" prop="energyTypeId">
|
<el-col
|
||||||
<el-select v-model="form.energyTypeId" placeholder="请选择" style="width: 100%;" filterable @change="toggleType">
|
:span="12"
|
||||||
<el-option
|
v-if="form.method == 2">
|
||||||
v-for="item in this.energyTypeList"
|
<el-form-item
|
||||||
:key="item.id"
|
label="能源表名"
|
||||||
:label="item.name"
|
prop="tableName">
|
||||||
:value="item.id">
|
<el-select
|
||||||
</el-option>
|
v-model="form.tableName"
|
||||||
</el-select>
|
placeholder="请选择"
|
||||||
</el-form-item>
|
style="width: 100%">
|
||||||
</el-col>
|
<el-option
|
||||||
<el-col :span="12" v-if='form.method == 1'>
|
v-for="item in getDictDatas(DICT_TYPE.TABLE_NAME)"
|
||||||
<el-form-item label="监控模式" prop="type">
|
:key="item.value"
|
||||||
<el-select v-model="form.type" placeholder="请选择" style="width: 100%;" @change="typeChange">
|
:label="item.label"
|
||||||
<el-option label="合并" :value= "1" ></el-option>
|
:value="item.value"></el-option>
|
||||||
<el-option label="详细" :value= "2" ></el-option>
|
</el-select>
|
||||||
</el-select>
|
</el-form-item>
|
||||||
</el-form-item>
|
</el-col>
|
||||||
</el-col>
|
<el-col :span="12">
|
||||||
<el-col :span="12" v-if='form.method == 1'>
|
<el-form-item
|
||||||
<el-form-item label="监控详细参数" prop="type" v-if="form.type === 2">
|
label="监控能源类型"
|
||||||
<el-select v-model="form.plcParamId" placeholder="请选择" style="width: 100%;" @change="selectDetail">
|
prop="energyTypeId">
|
||||||
<el-option
|
<el-select
|
||||||
v-for="item in detailList"
|
v-model="form.energyTypeId"
|
||||||
:key="item.id"
|
placeholder="请选择"
|
||||||
:label="item.name"
|
style="width: 100%"
|
||||||
:value="item.id">
|
filterable
|
||||||
</el-option>
|
@change="toggleType">
|
||||||
</el-select>
|
<el-option
|
||||||
</el-form-item>
|
v-for="item in this.energyTypeList"
|
||||||
</el-col>
|
:key="item.id"
|
||||||
<el-col :span="12">
|
:label="item.name"
|
||||||
<el-form-item label="指标类型" prop="limitType">
|
:value="item.id"></el-option>
|
||||||
<el-select v-model="form.limitType" placeholder="请选择" style="width: 100%;" :disabled='form.method == 2'>
|
</el-select>
|
||||||
<el-option
|
</el-form-item>
|
||||||
v-for="item in getDictDatas(DICT_TYPE.MONITOR_INDEX_TYPE)"
|
</el-col>
|
||||||
:key="item.value"
|
<el-col
|
||||||
:label="item.label"
|
:span="12"
|
||||||
:value="item.value">
|
v-if="form.method == 1">
|
||||||
</el-option>
|
<el-form-item
|
||||||
</el-select>
|
label="监控模式"
|
||||||
</el-form-item>
|
prop="type">
|
||||||
</el-col>
|
<el-select
|
||||||
<el-col :span="12">
|
v-model="form.type"
|
||||||
<el-form-item label="消耗量阈值">
|
placeholder="请选择"
|
||||||
<el-input-number v-model="form.minValue" placeholder="最小值" :max="9999999" style="width: 50%;"></el-input-number>
|
style="width: 100%"
|
||||||
<el-input-number v-model="form.maxValue" placeholder="最大值" :max="9999999" style="width: 50%;"></el-input-number>
|
@change="typeChange">
|
||||||
</el-form-item>
|
<el-option
|
||||||
</el-col>
|
label="合并"
|
||||||
</el-row>
|
:value="1"></el-option>
|
||||||
</el-form>
|
<el-option
|
||||||
|
label="详细"
|
||||||
|
:value="2"></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col
|
||||||
|
:span="12"
|
||||||
|
v-if="form.method == 1">
|
||||||
|
<el-form-item
|
||||||
|
label="监控详细参数"
|
||||||
|
prop="type"
|
||||||
|
v-if="form.type === 2">
|
||||||
|
<el-select
|
||||||
|
v-model="form.plcParamId"
|
||||||
|
placeholder="请选择"
|
||||||
|
style="width: 100%"
|
||||||
|
@change="selectDetail">
|
||||||
|
<el-option
|
||||||
|
v-for="item in detailList"
|
||||||
|
:key="item.id"
|
||||||
|
:label="item.name"
|
||||||
|
:value="item.id"></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item
|
||||||
|
label="指标类型"
|
||||||
|
prop="limitType">
|
||||||
|
<el-select
|
||||||
|
v-model="form.limitType"
|
||||||
|
placeholder="请选择"
|
||||||
|
style="width: 100%"
|
||||||
|
:disabled="form.method == 2">
|
||||||
|
<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-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="消耗量阈值">
|
||||||
|
<el-input-number
|
||||||
|
v-model="form.minValue"
|
||||||
|
placeholder="最小值"
|
||||||
|
:max="9999999"
|
||||||
|
style="width: 50%"></el-input-number>
|
||||||
|
<el-input-number
|
||||||
|
v-model="form.maxValue"
|
||||||
|
placeholder="最大值"
|
||||||
|
:max="9999999"
|
||||||
|
style="width: 50%"></el-input-number>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { getEnergyLimit, updateEnergyLimit, createEnergyLimit, getEnergyParamList } from '@/api/monitoring/energyLimit'
|
import {
|
||||||
|
getEnergyLimit,
|
||||||
|
updateEnergyLimit,
|
||||||
|
createEnergyLimit,
|
||||||
|
getEnergyParamList,
|
||||||
|
} from '@/api/monitoring/energyLimit';
|
||||||
export default {
|
export default {
|
||||||
name: 'energyLimitAdd',
|
name: 'energyLimitAdd',
|
||||||
props: {
|
props: {
|
||||||
energyTypeList: {
|
energyTypeList: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
default: () => {
|
default: () => {
|
||||||
return []
|
return [];
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
objList: {
|
objList: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => []
|
default: () => [],
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
form: {
|
form: {
|
||||||
id: '',
|
id: '',
|
||||||
method: '1',
|
method: '1',
|
||||||
objectId: '',
|
objectId: '',
|
||||||
objectType: '',
|
objectType: '',
|
||||||
energyTypeId: '',
|
energyTypeId: '',
|
||||||
type: '',
|
type: '',
|
||||||
plcParamId: '',
|
plcParamId: '',
|
||||||
limitType: '',
|
limitType: '',
|
||||||
minValue: 0,
|
minValue: 0,
|
||||||
maxValue: 0
|
maxValue: 0,
|
||||||
},
|
},
|
||||||
objIds: [],// 回显数组
|
objIds: [], // 回显数组
|
||||||
isEdit: false, //是否是编辑
|
isEdit: false, //是否是编辑
|
||||||
rules: {
|
rules: {
|
||||||
method: [{ required: true, message: '抄表方式不能为空', trigger: 'change' }],
|
method: [
|
||||||
objectId: [{ required: true, message: '监控对象不能为空', trigger: 'change' }],
|
{ required: true, message: '抄表方式不能为空', trigger: 'change' },
|
||||||
energyTypeId: [{ required: true, message: '能源类型不能为空', trigger: 'change' }],
|
],
|
||||||
type: [{ required: true, message: '监控模式不能为空', trigger: 'change' }],
|
objectId: [
|
||||||
limitType: [{ required: true, message: '指标类型不能为空', trigger: 'change' }]
|
{ required: true, message: '监控对象不能为空', trigger: 'change' },
|
||||||
},
|
],
|
||||||
detailList: []
|
energyTypeId: [
|
||||||
}
|
{ required: true, message: '能源类型不能为空', trigger: 'change' },
|
||||||
},
|
],
|
||||||
methods: {
|
type: [
|
||||||
init(id) {
|
{ required: true, message: '监控模式不能为空', trigger: 'change' },
|
||||||
if (id) {
|
],
|
||||||
this.isEdit = true
|
limitType: [
|
||||||
this.form.id = id
|
{ required: true, message: '指标类型不能为空', trigger: 'change' },
|
||||||
getEnergyLimit( id ).then((res) => {
|
],
|
||||||
if (res.code === 0) {
|
},
|
||||||
this.form = res.data
|
detailList: [],
|
||||||
this.form.plcParamId = res.data.plcParamId || ''
|
};
|
||||||
this.form.method = this.form.method ? this.form.method + '' : ''
|
},
|
||||||
this.form.limitType = this.form.limitType ? this.form.limitType + '' : ''
|
methods: {
|
||||||
this.objIds = this.changeDetSelect(this.form.objectId, this.objList)
|
init(id) {
|
||||||
if (this.form.type === 2) {
|
if (id) {
|
||||||
this.getDetailList()
|
this.isEdit = true;
|
||||||
}
|
this.form.id = id;
|
||||||
}
|
getEnergyLimit(id).then((res) => {
|
||||||
})
|
if (res.code === 0) {
|
||||||
} else {
|
this.form = res.data;
|
||||||
this.isEdit = false
|
this.form.plcParamId = res.data.plcParamId || '';
|
||||||
this.form.id = ''
|
this.form.method = this.form.method ? this.form.method + '' : '';
|
||||||
}
|
this.form.limitType = this.form.limitType
|
||||||
},
|
? this.form.limitType + ''
|
||||||
// 切换方式
|
: '';
|
||||||
changeMethod() {
|
this.objIds = this.changeDetSelect(
|
||||||
if(this.form.method === '2'){
|
this.form.objectId,
|
||||||
this.form.limitType = "2"
|
this.objList
|
||||||
}else{
|
);
|
||||||
this.form.limitType = ''
|
if (this.form.type === 2) {
|
||||||
}
|
this.getDetailList();
|
||||||
},
|
}
|
||||||
// 监控详细参数
|
}
|
||||||
getDetailList() {
|
});
|
||||||
getEnergyParamList({
|
} else {
|
||||||
objId: this.form.objectId,
|
this.isEdit = false;
|
||||||
energyTypeId: this.form.energyTypeId
|
this.form.id = '';
|
||||||
}).then((res) => {
|
}
|
||||||
if (res.code === 0) {
|
},
|
||||||
this.detailList = res.data
|
// 切换方式
|
||||||
} else {
|
changeMethod() {
|
||||||
this.detailList = []
|
if (this.form.method === '2') {
|
||||||
}
|
this.form.limitType = '2';
|
||||||
})
|
} else {
|
||||||
},
|
this.form.limitType = '';
|
||||||
typeChange(val) {
|
}
|
||||||
console.log(this.form)
|
},
|
||||||
this.form.plcParamId = ''
|
// 监控详细参数
|
||||||
if (val === 2) {
|
getDetailList() {
|
||||||
if (this.form.objectId && this.form.energyTypeId) {
|
getEnergyParamList({
|
||||||
this.getDetailList()
|
objId: this.form.objectId,
|
||||||
}
|
energyTypeId: this.form.energyTypeId,
|
||||||
}
|
}).then((res) => {
|
||||||
},
|
if (res.code === 0) {
|
||||||
toggleType() {
|
this.detailList = res.data;
|
||||||
if (this.form.energyTypeId && this.form.type) {
|
} else {
|
||||||
this.getDetailList()
|
this.detailList = [];
|
||||||
this.form.plcParamId = ''
|
}
|
||||||
}
|
});
|
||||||
},
|
},
|
||||||
// 递归处理分类回显问题
|
typeChange(val) {
|
||||||
changeDetSelect(key, treeData) {
|
console.log(this.form);
|
||||||
let arr = [] // 递归时操作的数组
|
this.form.plcParamId = '';
|
||||||
let returnArr = [] // 存放结果的数组
|
if (val === 2) {
|
||||||
let depth = 0 // 定义全局层级
|
if (this.form.objectId && this.form.energyTypeId) {
|
||||||
// 定义递归函数
|
this.getDetailList();
|
||||||
function childrenEach(childrendData, depthN) {
|
}
|
||||||
for (var j = 0; j < childrendData.length; j++) {
|
}
|
||||||
depth = depthN
|
},
|
||||||
arr[depthN] = childrendData[j].id
|
toggleType() {
|
||||||
if (childrendData[j].id == key) {
|
if (this.form.energyTypeId && this.form.type) {
|
||||||
returnArr = arr.slice(0, depthN + 1)
|
this.getDetailList();
|
||||||
break
|
this.form.plcParamId = '';
|
||||||
} else {
|
}
|
||||||
if (childrendData[j].children) {
|
},
|
||||||
depth++
|
// 递归处理分类回显问题
|
||||||
childrenEach(childrendData[j].children, depth)
|
changeDetSelect(key, treeData) {
|
||||||
}
|
let arr = []; // 递归时操作的数组
|
||||||
}
|
let returnArr = []; // 存放结果的数组
|
||||||
}
|
let depth = 0; // 定义全局层级
|
||||||
return returnArr
|
// 定义递归函数
|
||||||
}
|
function childrenEach(childrendData, depthN) {
|
||||||
return childrenEach(treeData, depth)
|
for (var j = 0; j < childrendData.length; j++) {
|
||||||
},
|
depth = depthN;
|
||||||
selectObj(val) {
|
arr[depthN] = childrendData[j].id;
|
||||||
this.form.objectId = val[val.length-1]
|
if (childrendData[j].id == key) {
|
||||||
this.form.objectType = val.length-1
|
returnArr = arr.slice(0, depthN + 1);
|
||||||
if (this.form.energyTypeId && this.form.type) {
|
break;
|
||||||
this.getDetailList()
|
} else {
|
||||||
this.form.plcParamId = ''
|
if (childrendData[j].children) {
|
||||||
}
|
depth++;
|
||||||
},
|
childrenEach(childrendData[j].children, depth);
|
||||||
selectDetail() {
|
}
|
||||||
this.$forceUpdate()
|
}
|
||||||
},
|
}
|
||||||
submitForm() {
|
return returnArr;
|
||||||
this.$refs['form'].validate((valid) => {
|
}
|
||||||
if (valid) {
|
return childrenEach(treeData, depth);
|
||||||
if (this.form.type === 2 && !this.form.plcParamId) {
|
},
|
||||||
this.$modal.msgError("监控模式为详细时,详细参数为必填");
|
selectObj(val) {
|
||||||
return false
|
this.form.objectId = val[val.length - 1];
|
||||||
}
|
this.form.objectType = val.length - 1;
|
||||||
if (this.form.minValue && this.form.maxValue) {
|
if (this.form.energyTypeId && this.form.type) {
|
||||||
if (this.form.minValue > this.form.maxValue) {
|
this.getDetailList();
|
||||||
this.$modal.msgError("消耗量阈值,最小值不能大于最大值");
|
this.form.plcParamId = '';
|
||||||
return false
|
}
|
||||||
}
|
},
|
||||||
}
|
selectDetail() {
|
||||||
this.form.minValue = this.form.minValue || 0
|
this.$forceUpdate();
|
||||||
this.form.maxValue = this.form.maxValue || 0
|
},
|
||||||
if (this.isEdit) {
|
submitForm() {
|
||||||
// 编辑
|
this.$refs['form'].validate((valid) => {
|
||||||
updateEnergyLimit({...this.form}).then((res) => {
|
if (valid) {
|
||||||
if (res.code === 0) {
|
if (this.form.type === 2 && !this.form.plcParamId) {
|
||||||
this.$modal.msgSuccess("操作成功");
|
this.$modal.msgError('监控模式为详细时,详细参数为必填');
|
||||||
this.$emit('successSubmit')
|
return false;
|
||||||
}
|
}
|
||||||
})
|
if (this.form.minValue && this.form.maxValue) {
|
||||||
} else {
|
if (this.form.minValue > this.form.maxValue) {
|
||||||
createEnergyLimit({...this.form}).then((res) => {
|
this.$modal.msgError('消耗量阈值,最小值不能大于最大值');
|
||||||
if (res.code === 0) {
|
return false;
|
||||||
this.$modal.msgSuccess("操作成功");
|
}
|
||||||
this.$emit('successSubmit')
|
}
|
||||||
}
|
this.form.minValue = this.form.minValue || 0;
|
||||||
})
|
this.form.maxValue = this.form.maxValue || 0;
|
||||||
}
|
if (this.isEdit) {
|
||||||
} else {
|
// 编辑
|
||||||
return false
|
updateEnergyLimit({ ...this.form }).then((res) => {
|
||||||
}
|
if (res.code === 0) {
|
||||||
})
|
this.$modal.msgSuccess('操作成功');
|
||||||
},
|
this.$emit('successSubmit');
|
||||||
formClear() {
|
}
|
||||||
this.$refs.form.resetFields()
|
});
|
||||||
this.form.type = ''
|
} else {
|
||||||
this.form.plcParamId = ''
|
createEnergyLimit({ ...this.form }).then((res) => {
|
||||||
this.form.minValue = null
|
if (res.code === 0) {
|
||||||
this.form.maxValue = null
|
this.$modal.msgSuccess('操作成功');
|
||||||
this.objIds = ''
|
this.$emit('successSubmit');
|
||||||
this.detailList = []
|
}
|
||||||
this.isEdit = false
|
});
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
formClear() {
|
||||||
|
this.$refs.form.resetFields();
|
||||||
|
this.form.type = '';
|
||||||
|
this.form.plcParamId = '';
|
||||||
|
this.form.minValue = null;
|
||||||
|
this.form.maxValue = null;
|
||||||
|
this.objIds = '';
|
||||||
|
this.detailList = [];
|
||||||
|
this.isEdit = false;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
.cascaderParent .el-cascader-panel .el-scrollbar:first-child .el-radio {
|
.cascaderParent .el-cascader-panel .el-scrollbar:first-child .el-radio {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -1,269 +1,278 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
|
<!-- 搜索工作栏 -->
|
||||||
<!-- 搜索工作栏 -->
|
<search-bar
|
||||||
<search-bar
|
:formConfigs="formConfig"
|
||||||
:formConfigs="formConfig"
|
ref="searchBarForm"
|
||||||
ref="searchBarForm"
|
@headBtnClick="buttonClick" />
|
||||||
@headBtnClick="buttonClick"
|
<!-- 列表 -->
|
||||||
/>
|
<base-table
|
||||||
<!-- 列表 -->
|
:page="queryParams.pageNo"
|
||||||
<base-table
|
:limit="queryParams.pageSize"
|
||||||
:page="queryParams.pageNo"
|
:table-props="tableProps"
|
||||||
:limit="queryParams.pageSize"
|
:table-data="list"
|
||||||
:table-props="tableProps"
|
:max-height="tableH">
|
||||||
:table-data="list"
|
<method-btn
|
||||||
:max-height="tableH"
|
v-if="tableBtn.length"
|
||||||
>
|
slot="handleBtn"
|
||||||
<method-btn
|
:width="80"
|
||||||
v-if="tableBtn.length"
|
label="操作"
|
||||||
slot="handleBtn"
|
:method-list="tableBtn"
|
||||||
:width="80"
|
@clickBtn="handleClick" />
|
||||||
label="操作"
|
</base-table>
|
||||||
:method-list="tableBtn"
|
<pagination
|
||||||
@clickBtn="handleClick"
|
:page.sync="queryParams.pageNo"
|
||||||
/>
|
:limit.sync="queryParams.pageSize"
|
||||||
</base-table>
|
:total="total"
|
||||||
<pagination
|
@pagination="getList" />
|
||||||
:page.sync="queryParams.pageNo"
|
<!-- 新增 -->
|
||||||
:limit.sync="queryParams.pageSize"
|
<base-dialog
|
||||||
:total="total"
|
:dialogTitle="addOrEditTitle"
|
||||||
@pagination="getList"
|
:dialogVisible="centervisible"
|
||||||
/>
|
@cancel="handleCancel"
|
||||||
<!-- 新增 -->
|
@confirm="handleConfirm"
|
||||||
<base-dialog
|
:before-close="handleCancel"
|
||||||
:dialogTitle="addOrEditTitle"
|
width="50%">
|
||||||
:dialogVisible="centervisible"
|
<energy-limit-add
|
||||||
@cancel="handleCancel"
|
ref="energyLimit"
|
||||||
@confirm="handleConfirm"
|
@successSubmit="successSubmit"
|
||||||
:before-close="handleCancel"
|
:energyTypeList="energyTypeList"
|
||||||
width='50%'
|
:objList="objList" />
|
||||||
>
|
</base-dialog>
|
||||||
<energy-limit-add ref="energyLimit" @successSubmit="successSubmit" :energyTypeList="energyTypeList" :objList="objList"/>
|
</div>
|
||||||
</base-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getEnergyLimitPage, deleteEnergyLimit } from "@/api/monitoring/energyLimit";
|
import {
|
||||||
import { getEnergyTypeListAll } from "@/api/base/energyType";
|
getEnergyLimitPage,
|
||||||
import { getTree } from '@/api/base/factory'
|
deleteEnergyLimit,
|
||||||
import { publicFormatter } from '@/utils/dict'
|
} from '@/api/monitoring/energyLimit';
|
||||||
import EnergyLimitAdd from './components/energyLimitAdd'
|
import { getEnergyTypeListAll } from '@/api/base/energyType';
|
||||||
|
import { getTree } from '@/api/base/factory';
|
||||||
|
import { publicFormatter } from '@/utils/dict';
|
||||||
|
import EnergyLimitAdd from './components/energyLimitAdd';
|
||||||
const tableProps = [
|
const tableProps = [
|
||||||
{
|
{
|
||||||
prop: 'method',
|
prop: 'method',
|
||||||
label: '抄表方式',
|
label: '抄表方式',
|
||||||
filter: publicFormatter('method')
|
filter: publicFormatter('method'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'objName',
|
prop: 'objName',
|
||||||
label: '监控对象'
|
label: '监控对象',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'objCode',
|
prop: 'objCode',
|
||||||
label: '对象编码'
|
label: '对象编码',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'tableName',
|
prop: 'tableName',
|
||||||
label: '水/气表名',
|
label: '能源表名',
|
||||||
filter: publicFormatter('table_name')
|
filter: publicFormatter('table_name'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'energyType',
|
prop: 'energyType',
|
||||||
label: '能源类型'
|
label: '能源类型',
|
||||||
},
|
filter: publicFormatter('energy_type'),
|
||||||
{
|
},
|
||||||
prop: 'type',
|
{
|
||||||
label: '监控模式',
|
prop: 'type',
|
||||||
filter: (val) => (val != null ? ['合并', '详细'][val-1] : '-'),
|
label: '监控模式',
|
||||||
},
|
filter: (val) => (val != null ? ['合并', '详细'][val - 1] : '-'),
|
||||||
{
|
},
|
||||||
prop: 'plcParamName',
|
{
|
||||||
label: '监控参数'
|
prop: 'plcParamName',
|
||||||
},
|
label: '监控参数',
|
||||||
{
|
},
|
||||||
prop: 'limitType',
|
{
|
||||||
label: '指标类型',
|
prop: 'limitType',
|
||||||
filter: publicFormatter('monitor_index_type')
|
label: '指标类型',
|
||||||
},
|
filter: publicFormatter('monitor_index_type'),
|
||||||
{
|
},
|
||||||
prop: 'limitValue',
|
{
|
||||||
label: '阈值'
|
prop: 'limitValue',
|
||||||
}
|
label: '阈值',
|
||||||
]
|
},
|
||||||
|
];
|
||||||
export default {
|
export default {
|
||||||
name: "EnergyLimit",
|
name: 'EnergyLimit',
|
||||||
components: { EnergyLimitAdd },
|
components: { EnergyLimitAdd },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
formConfig: [
|
formConfig: [
|
||||||
{
|
{
|
||||||
type: 'select',
|
type: 'select',
|
||||||
label: '能源类型',
|
label: '能源类型',
|
||||||
selectOptions: [],
|
selectOptions: [],
|
||||||
param: 'energyTypeId'
|
param: 'energyTypeId',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'select',
|
type: 'select',
|
||||||
label: '指标类型',
|
label: '指标类型',
|
||||||
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: 'limitType'
|
param: 'limitType',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'button',
|
type: 'button',
|
||||||
btnName: '查询',
|
btnName: '查询',
|
||||||
name: 'search',
|
name: 'search',
|
||||||
color: 'primary'
|
color: 'primary',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'separate'
|
type: 'separate',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: this.$auth.hasPermi('monitoring:energy-limit:create') ? 'button' : '',
|
type: this.$auth.hasPermi('monitoring:energy-limit:create')
|
||||||
btnName: '新增',
|
? 'button'
|
||||||
name: 'add',
|
: '',
|
||||||
color: 'success',
|
btnName: '新增',
|
||||||
plain: true
|
name: 'add',
|
||||||
}
|
color: 'success',
|
||||||
],
|
plain: true,
|
||||||
tableProps,
|
},
|
||||||
tableBtn: [
|
],
|
||||||
this.$auth.hasPermi('monitoring:energy-limit:update')
|
tableProps,
|
||||||
? {
|
tableBtn: [
|
||||||
type: 'edit',
|
this.$auth.hasPermi('monitoring:energy-limit:update')
|
||||||
btnName: '编辑'
|
? {
|
||||||
}
|
type: 'edit',
|
||||||
: undefined,
|
btnName: '编辑',
|
||||||
this.$auth.hasPermi('monitoring:energy-limit:delete')
|
}
|
||||||
? {
|
: undefined,
|
||||||
type: 'delete',
|
this.$auth.hasPermi('monitoring:energy-limit:delete')
|
||||||
btnName: '删除'
|
? {
|
||||||
}
|
type: 'delete',
|
||||||
: undefined
|
btnName: '删除',
|
||||||
].filter((v) => v),
|
}
|
||||||
tableH: this.tableHeight(260),
|
: undefined,
|
||||||
// 总条数
|
].filter((v) => v),
|
||||||
total: 0,
|
tableH: this.tableHeight(260),
|
||||||
// 班次基础信息列表
|
// 总条数
|
||||||
list: [],
|
total: 0,
|
||||||
// 弹出层标题
|
// 班次基础信息列表
|
||||||
addOrEditTitle: "",
|
list: [],
|
||||||
// 是否显示弹出层
|
// 弹出层标题
|
||||||
centervisible: false,
|
addOrEditTitle: '',
|
||||||
// 查询参数
|
// 是否显示弹出层
|
||||||
queryParams: {
|
centervisible: false,
|
||||||
pageNo: 1,
|
// 查询参数
|
||||||
pageSize: 20,
|
queryParams: {
|
||||||
energyTypeId: null,
|
pageNo: 1,
|
||||||
limitType: null
|
pageSize: 20,
|
||||||
},
|
energyTypeId: null,
|
||||||
energyTypeList: [],
|
limitType: null,
|
||||||
typeList: [
|
},
|
||||||
{label: '合并', value: '1'},
|
energyTypeList: [],
|
||||||
{label: '详细', value: '2'}
|
typeList: [
|
||||||
],
|
{ label: '合并', value: '1' },
|
||||||
objList: []
|
{ label: '详细', value: '2' },
|
||||||
};
|
],
|
||||||
},
|
objList: [],
|
||||||
created() {
|
};
|
||||||
window.addEventListener('resize', () => {
|
},
|
||||||
this.tableH = this.tableHeight(260)
|
created() {
|
||||||
})
|
window.addEventListener('resize', () => {
|
||||||
this.getList();
|
this.tableH = this.tableHeight(260);
|
||||||
this.getTypeList()
|
});
|
||||||
// 获取对象树形结构
|
this.getList();
|
||||||
this.getObjTree()
|
this.getTypeList();
|
||||||
},
|
// 获取对象树形结构
|
||||||
methods: {
|
this.getObjTree();
|
||||||
getTypeList() {
|
},
|
||||||
getEnergyTypeListAll().then((res) => {
|
methods: {
|
||||||
this.formConfig[0].selectOptions = res.data || []
|
getTypeList() {
|
||||||
this.energyTypeList = res.data || []
|
getEnergyTypeListAll().then((res) => {
|
||||||
})
|
this.formConfig[0].selectOptions = res.data || [];
|
||||||
},
|
this.energyTypeList = res.data || [];
|
||||||
buttonClick(val) {
|
});
|
||||||
switch (val.btnName) {
|
},
|
||||||
case 'search':
|
buttonClick(val) {
|
||||||
this.queryParams.pageNo = 1;
|
switch (val.btnName) {
|
||||||
this.queryParams.energyTypeId = val.energyTypeId
|
case 'search':
|
||||||
this.queryParams.limitType = val.limitType
|
this.queryParams.pageNo = 1;
|
||||||
this.getList()
|
this.queryParams.energyTypeId = val.energyTypeId;
|
||||||
break
|
this.queryParams.limitType = val.limitType;
|
||||||
default:
|
this.getList();
|
||||||
this.addOrEditTitle = '新增'
|
break;
|
||||||
this.centervisible = true
|
default:
|
||||||
this.$nextTick(() => {
|
this.addOrEditTitle = '新增';
|
||||||
this.$refs.energyLimit.init()
|
this.centervisible = true;
|
||||||
})
|
this.$nextTick(() => {
|
||||||
}
|
this.$refs.energyLimit.init();
|
||||||
},
|
});
|
||||||
/** 查询列表 */
|
}
|
||||||
getList() {
|
},
|
||||||
getEnergyLimitPage(this.queryParams).then(response => {
|
/** 查询列表 */
|
||||||
let arr = response.data.list || [];
|
getList() {
|
||||||
arr&&arr.map(item => {
|
getEnergyLimitPage(this.queryParams).then((response) => {
|
||||||
this.typeList.map(i => {
|
let arr = response.data.list || [];
|
||||||
if (item.type === i.value) {
|
arr &&
|
||||||
item.type = i.label
|
arr.map((item) => {
|
||||||
}
|
this.typeList.map((i) => {
|
||||||
})
|
if (item.type === i.value) {
|
||||||
if (item.minValue && item.maxValue) {
|
item.type = i.label;
|
||||||
item.limitValue = item.minValue + '-' + item.maxValue
|
}
|
||||||
} else if(item.minValue){
|
});
|
||||||
item.limitValue = '最小值' + item.minValue
|
if (item.minValue && item.maxValue) {
|
||||||
}else if(item.maxValue){
|
item.limitValue = item.minValue + '-' + item.maxValue;
|
||||||
item.limitValue = '最大值' + item.maxValue
|
} else if (item.minValue) {
|
||||||
} else {
|
item.limitValue = '最小值' + item.minValue;
|
||||||
item.limitValue = ''
|
} else if (item.maxValue) {
|
||||||
}
|
item.limitValue = '最大值' + item.maxValue;
|
||||||
})
|
} else {
|
||||||
this.list = arr
|
item.limitValue = '';
|
||||||
this.total = response.data.total;
|
}
|
||||||
});
|
});
|
||||||
},
|
this.list = arr;
|
||||||
handleClick(val) {
|
this.total = response.data.total;
|
||||||
switch (val.type) {
|
});
|
||||||
case 'edit':
|
},
|
||||||
this.addOrEditTitle = '编辑'
|
handleClick(val) {
|
||||||
this.$nextTick(() => {
|
switch (val.type) {
|
||||||
this.$refs.energyLimit.init(val.data.id)
|
case 'edit':
|
||||||
})
|
this.addOrEditTitle = '编辑';
|
||||||
this.centervisible = true
|
this.$nextTick(() => {
|
||||||
break
|
this.$refs.energyLimit.init(val.data.id);
|
||||||
default:
|
});
|
||||||
this.handleDelete(val.data)
|
this.centervisible = true;
|
||||||
}
|
break;
|
||||||
},
|
default:
|
||||||
handleCancel() {
|
this.handleDelete(val.data);
|
||||||
this.$refs.energyLimit.formClear()
|
}
|
||||||
this.centervisible = false
|
},
|
||||||
this.addOrEditTitle = ''
|
handleCancel() {
|
||||||
},
|
this.$refs.energyLimit.formClear();
|
||||||
handleConfirm() {
|
this.centervisible = false;
|
||||||
this.$refs.energyLimit.submitForm()
|
this.addOrEditTitle = '';
|
||||||
},
|
},
|
||||||
successSubmit() {
|
handleConfirm() {
|
||||||
this.handleCancel()
|
this.$refs.energyLimit.submitForm();
|
||||||
this.getList()
|
},
|
||||||
},
|
successSubmit() {
|
||||||
/** 删除按钮操作 */
|
this.handleCancel();
|
||||||
handleDelete(row) {
|
this.getList();
|
||||||
this.$modal.confirm('是否确认删除监控对象为"' + row.objName + '"的数据项?').then(function() {
|
},
|
||||||
return deleteEnergyLimit(row.id);
|
/** 删除按钮操作 */
|
||||||
}).then(() => {
|
handleDelete(row) {
|
||||||
this.queryParams.pageNo = 1;
|
this.$modal
|
||||||
this.getList();
|
.confirm('是否确认删除监控对象为"' + row.objName + '"的数据项?')
|
||||||
this.$modal.msgSuccess("删除成功");
|
.then(function () {
|
||||||
}).catch(() => {});
|
return deleteEnergyLimit(row.id);
|
||||||
},
|
})
|
||||||
getObjTree() {
|
.then(() => {
|
||||||
getTree().then(res => {
|
this.queryParams.pageNo = 1;
|
||||||
this.objList = res.data || []
|
this.getList();
|
||||||
})
|
this.$modal.msgSuccess('删除成功');
|
||||||
}
|
})
|
||||||
}
|
.catch(() => {});
|
||||||
|
},
|
||||||
|
getObjTree() {
|
||||||
|
getTree().then((res) => {
|
||||||
|
this.objList = res.data || [];
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user