feat: endpoint-query 增加save chart功能

1.endpoint-query 增加save chart功能
This commit is contained in:
陈劲松
2020-02-10 16:50:34 +08:00
parent 634f21ad42
commit 42a7d3edd6
5 changed files with 93 additions and 16 deletions

View File

@@ -730,6 +730,9 @@ li{
position: absolute; position: absolute;
right: 0; right: 0;
} }
.config-dropdown, .chart-box-dropdown {
z-index: 2950 !important;
}
.config-dropdown-btn i { .config-dropdown-btn i {
font-size: 12px; font-size: 12px;
} }

View File

@@ -375,7 +375,6 @@ export default {
editData(chartId) { editData(chartId) {
// 获取该id下chart的相关信息 // 获取该id下chart的相关信息
const chart = this.dataList.find(item => item.id === chartId); const chart = this.dataList.find(item => item.id === chartId);
console.info("aaa",chart)
if (chart) { if (chart) {
this.$emit('on-edit-chart', chart); this.$emit('on-edit-chart', chart);
} }

View File

@@ -48,7 +48,7 @@
} }
.z-top { .z-top {
z-index: 49; z-index: 2900;
} }
</style> </style>
<template key="chartBox"> <template key="chartBox">
@@ -105,7 +105,7 @@
<el-col :span="5"> <el-col :span="5">
<div class="grid-content "> <div class="grid-content ">
<el-form-item prop="type"> <el-form-item prop="type">
<el-select class="right-box-row-with-btn" value-key="chartType" popper-class="" v-model="chart.type" placeholder="" size="mini"> <el-select class="right-box-row-with-btn" value-key="chartType" popper-class="chart-box-dropdown" v-model="chart.type" placeholder="" size="mini">
<el-option v-for="item in chartTypeList" :key="item.id" :label="item.name" :value="item.id"> <el-option v-for="item in chartTypeList" :key="item.id" :label="item.name" :value="item.id">
<span class="panel-dropdown-label-txt" >{{item.name}}</span> <span class="panel-dropdown-label-txt" >{{item.name}}</span>
</el-option> </el-option>
@@ -119,7 +119,7 @@
<el-col :span="5"> <el-col :span="5">
<div class="grid-content "> <div class="grid-content ">
<el-form-item prop="span"> <el-form-item prop="span">
<el-select class="right-box-row-with-btn" value-key="chartSpan" popper-class="" v-model="chart.span" placeholder="" size="mini"> <el-select class="right-box-row-with-btn" value-key="chartSpan" popper-class="chart-box-dropdown" v-model="chart.span" placeholder="" size="mini">
<el-option v-for="item in spanList" :key="item" :label="'span-' + item" :value="item"> <el-option v-for="item in spanList" :key="item" :label="'span-' + item" :value="item">
<span class="panel-dropdown-label-txt" > span-{{item}}</span> <span class="panel-dropdown-label-txt" > span-{{item}}</span>
</el-option> </el-option>
@@ -555,15 +555,34 @@
}, },
// 创建打开 // 创建打开
createData(panelId, elementInfo) { createData(panelId, elementInfo) {
//console.info('bbb', elementInfo)
if (panelId == -1) { if (panelId == -1) {
this.panelId = this.panelData[0].id; this.panelId = this.panelData[0].id;
} else { } else {
this.panelId = panelId; this.panelId = panelId;
} }
if (elementInfo) { if (elementInfo) {
this.$nextTick(() => { if (elementInfo.elements.length > 1) {
this.$refs.chartTag[0].setMdata(elementInfo.elements[0]);
}); this.$nextTick(() => {
this.elements = [];
elementInfo.elements.forEach((item, index) => {
this.elements.push(index);
});
let dSet = this.$refs.chartTag;
this.$nextTick(() => {
dSet.forEach((item, index) => {
console.info('bbb', elementInfo.elements[index])
item.setMdata(elementInfo.elements[index]);
});
});
});
} else {
this.$nextTick(() => {
this.$refs.chartTag[0].setMdata(elementInfo.elements[0]);
});
}
} }
this.isedit = false; this.isedit = false;
this.initInfo(); // 初始化图表信息 this.initInfo(); // 初始化图表信息

View File

@@ -347,7 +347,7 @@ export default {
// 编辑已有图表状态时,先填充数据 // 编辑已有图表状态时,先填充数据
setMdata(data) { setMdata(data) {
//console.info('metricSetData', JSON.stringify(data)); console.info('metricSetData', JSON.stringify(data));
this.setDataFlag = true; this.setDataFlag = true;
this.target = Object.assign({}, data); this.target = Object.assign({}, data);
//this.pointer = //this.pointer =

View File

@@ -7,7 +7,11 @@
.project .nz-table .el-table__row td:first-of-type { .project .nz-table .el-table__row td:first-of-type {
padding-left: 0; padding-left: 0;
} }
</style>
<style scope>
.chart-bottom {
text-align: center;
}
</style> </style>
<template> <template>
<div class="project"> <div class="project">
@@ -202,11 +206,6 @@
</el-table> </el-table>
</div> </div>
<module-box :currentProject="currentProject" :module="editModule" @reload="getModuleList" ref="moduleBox"></module-box>
<edit-endpoint-box :currentProject="currentProject" :currentModule="currentModule" :endpoint="editEndpoint" @reload="getEndpointTableData" ref="editEndpointBox"></edit-endpoint-box>
<add-endpoint-box :currentProject="currentProject" :currentModule="currentModule" @reload="getEndpointTableData" ref="addEndpointBox"></add-endpoint-box>
<asset-edit-unit :edit-unit-show='viewAssetState' @refreshData="getEndpointTableData" @sendStateData="tabControl" ref="assetEditUnit"></asset-edit-unit>
<element-set <element-set
v-clickoutside="elementsetHide" v-clickoutside="elementsetHide"
:table-title="endpointTableTitle" :table-title="endpointTableTitle"
@@ -239,14 +238,28 @@
</div> </div>
</div> </div>
<div class="line-area " ref="viewGraphChart" id="viewGraphChart"></div> <div class="line-area " ref="viewGraphChart" id="viewGraphChart"></div>
<div class="line-100 margin-t-20 margin-b-30"></div>
<div class="chart-bottom">
<button class="nz-btn nz-btn-size-large nz-btn-style-normal nz-btn-min-width-82" @click="saveChart">{{$t('dashboard.metric.saveChart')}}</button>
</div>
</el-dialog> </el-dialog>
<module-box :currentProject="currentProject" :module="editModule" @reload="getModuleList" ref="moduleBox"></module-box>
<edit-endpoint-box :currentProject="currentProject" :currentModule="currentModule" :endpoint="editEndpoint" @reload="getEndpointTableData" ref="editEndpointBox"></edit-endpoint-box>
<add-endpoint-box :currentProject="currentProject" :currentModule="currentModule" @reload="getEndpointTableData" ref="addEndpointBox"></add-endpoint-box>
<asset-edit-unit :edit-unit-show='viewAssetState' @refreshData="getEndpointTableData" @sendStateData="tabControl" ref="assetEditUnit"></asset-edit-unit>
<chart-box ref="addChartModal" :panel-data="panelData" @on-create-success="createSuccess"></chart-box>
</div> </div>
</template> </template>
<script> <script>
import echarts from 'echarts'; import echarts from 'echarts';
import chartBox from "../dashboard/chartBox";
export default { export default {
name: "project2", name: "project2",
components: {
'chart-box': chartBox
},
data() { data() {
let temp=this; let temp=this;
return { return {
@@ -578,10 +591,45 @@
}, },
useUTC: false,//使用本地时间 useUTC: false,//使用本地时间
series: [] series: []
} },
panelData: [], //chart-box的panel下拉框数据
} }
}, },
methods: { methods: {
saveChart() { //新增chart
this.$refs.addChartModal.setTitle(this.$t("dashboard.panel.createChartTitle"));
this.$refs.addChartModal.show(true);
let metricInfo = {};
metricInfo.elements = [];
console.info("aaa", this.selectedEndpoints)
for(let i = 0; i < this.selectedEndpoints.length; i++) {
let type = '';
if (this.selectedEndpoints[i].type == '1') {
type = 'expert';
} else if (this.selectedEndpoints[i].type == '2') {
type = 'normal';
}
metricInfo.elements.push({expression: this.selectedEndpoints[i].element, type: type});
}
this.$refs.addChartModal.createData(-1, metricInfo);
},
createSuccess(type, response, param, panel) {
this.$confirm(this.$t("dashboard.metric.goPanelTip"),this.$t("tip.saveSuccess"), {
confirmButtonText: this.$t("tip.yes"),
cancelButtonText: this.$t("tip.no"),
type: 'success'
}).then(() => {
//this.$store.state.assetData.moduleData = 'panel';
this.$store.state.showPanel.id = panel.id;
this.$store.state.showPanel.name = panel.name;
this.$router.push({
path: "/panel",
query: {
t: +new Date()
}
});
});
},
elementsetShow(s, e) { elementsetShow(s, e) {
var eventfixed = { var eventfixed = {
shezhi: 0, shezhi: 0,
@@ -857,7 +905,7 @@
} }
temp=temp.charAt(temp.length-1) == ","?temp.substr(0,temp.length-1):temp; temp=temp.charAt(temp.length-1) == ","?temp.substr(0,temp.length-1):temp;
temp+="}"; temp+="}";
let edpQueryData={element:temp,value:result.value[1]} let edpQueryData={element:temp,value:result.value[1],type:(result.metric.type?result.metric.type:'2')};
this.endpointQueryTabData.push(edpQueryData); this.endpointQueryTabData.push(edpQueryData);
} }
this.tableShow=3; this.tableShow=3;
@@ -1015,6 +1063,13 @@
return 'disabledCheck' return 'disabledCheck'
} }
}, },
getPanelData() { //获取panel数据
this.$get('panel?pageNo=1&pageSize=-1').then(response => {
if (response.code === 200) {
this.panelData = response.data.list;
}
});
},
}, },
created() { created() {
this.currentProject = this.$store.state.currentProject; this.currentProject = this.$store.state.currentProject;
@@ -1022,6 +1077,7 @@
this.getMetricsTableData(); this.getMetricsTableData();
}, },
mounted() { mounted() {
this.getPanelData();
setTimeout(()=>{ setTimeout(()=>{
this.getEndpointTableData(); this.getEndpointTableData();
}, 200); }, 200);