feat:列表页 列上 添加详情预览

This commit is contained in:
wangwenrui
2020-01-06 19:03:38 +08:00
parent 0a5c4cba89
commit efdf6e666d
6 changed files with 187 additions and 37 deletions

View File

@@ -6,7 +6,7 @@
<button type="button" v-if="alertRule.id != ''" @click="del" class="nz-btn nz-btn-size-normal nz-btn-style-light">
<span class="top-tool-btn-txt">{{$t('overall.delete')}}</span>
</button>
<button type="button" @click="save" class="nz-btn nz-btn-size-normal nz-btn-style-normal">
<button type="button" @click="saveOrToEdit" class="nz-btn nz-btn-size-normal nz-btn-style-normal">
<span v-if="rightBox.isEdit" class="top-tool-btn-txt">{{$t('overall.save')}}</span>
<span v-else class="top-tool-btn-txt">{{$t('overall.edit')}}</span>
</button>

View File

@@ -6,8 +6,9 @@
<button type="button" v-if="module.id != ''" @click="del" class="nz-btn nz-btn-size-normal nz-btn-style-light">
<span class="top-tool-btn-txt">{{$t('overall.delete')}}</span>
</button>
<button type="button" @click="save" class="nz-btn nz-btn-size-normal nz-btn-style-normal">
<span class="top-tool-btn-txt">{{$t('overall.save')}}</span>
<button type="button" @click="saveOrToEdit" class="nz-btn nz-btn-size-normal nz-btn-style-normal">
<span v-if="rightBox.isEdit" class="top-tool-btn-txt">{{$t('overall.save')}}</span>
<span v-else class="top-tool-btn-txt">{{$t('overall.edit')}}</span>
</button>
<button type="button" @click="esc" class="nz-btn nz-btn-size-normal nz-btn-style-light nz-btn-style-square">
@@ -42,31 +43,36 @@
<el-scrollbar class="right-box-form-box">
<el-form class="right-box-form" :model="module" label-position="top" :rules="rules" ref="moduleForm">
<el-form-item :label='$t("project.project.project")' prop="project">
<el-select value-key="id" popper-class="config-dropdown" v-model="module.project" placeholder="" size="small">
<el-select v-if="rightBox.isEdit" value-key="id" popper-class="config-dropdown" v-model="module.project" placeholder="" size="small">
<el-option v-for="item in projectList" :key="item.id" :label="item.name" :value="item"></el-option>
</el-select>
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{module.project.name}}</div>
</el-form-item>
<el-form-item :label='$t("project.module.moduleName")' prop="name">
<el-input placeholder="" maxlength="64" show-word-limit v-model="module.name" size="small"></el-input>
<el-input v-if="rightBox.isEdit" placeholder="" maxlength="64" show-word-limit v-model="module.name" size="small"></el-input>
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{module.name}}</div>
</el-form-item>
<el-form-item :label='$t("project.module.description")' prop="remark">
<el-input type="textarea" placeholder="" maxlength="1024" show-word-limit v-model="module.remark" size="small"></el-input>
<el-input v-if="rightBox.isEdit" type="textarea" placeholder="" maxlength="1024" show-word-limit v-model="module.remark" size="small"></el-input>
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{module.remark}}</div>
</el-form-item>
<div class="right-box-form-tip">
<div class="right-box-form-tip" v-if="rightBox.isEdit">
{{$t('project.module.tip.defaultEndpointSet')}}
<div class="line-100"></div>
{{$t('project.module.tip.relation')}}
</div>
<el-form-item :label='$t("project.endpoint.port")' prop="port">
<el-input placeholder="" v-model.number="module.port" size="small"></el-input>
<el-input v-if="rightBox.isEdit" placeholder="" v-model.number="module.port" size="small"></el-input>
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{module.port}}</div>
</el-form-item>
<el-form-item :label='$t("project.endpoint.path")' prop="path">
<el-input placeholder="" v-model="module.path" size="small"></el-input>
<el-input v-if="rightBox.isEdit" placeholder="" v-model="module.path" size="small"></el-input>
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{module.path}}</div>
</el-form-item>
<el-form-item class="right-box-form-param">
<template slot="label">
<span>{{$t('project.endpoint.param')}}</span>
<div class="right-box-form-btns">
<div class="right-box-form-btns" v-if="rightBox.isEdit">
<button style="display: none;">第一个button会出现意料之外的hover样式找不到原因只好加个不可见的button规避问题</button>
<button type="button" @click="clearAllParam" class="nz-btn nz-btn-size-small nz-btn-style-light">
<span class="top-tool-btn-txt">{{$t('overall.clearAll')}}</span>
@@ -77,7 +83,7 @@
</div>
</template>
<div class="param-box param-box-module">
<div class="param-box-row" v-for="(item, index) in module.paramObj">
<div class="param-box-row" v-for="(item, index) in module.paramObj" v-if="rightBox.isEdit">
<el-form-item class="param-box-row-key" :rules="{required: true, message: $t('validate.required'), trigger: 'blur'}" :prop="'paramObj.' + index + '.key'">
<el-input placeholder="key" size="mini" v-model="item.key"></el-input>
</el-form-item>
@@ -87,7 +93,11 @@
</el-form-item>
<span class="param-box-row-symbol" @click="removeParam(index)"><i class="nz-icon nz-icon-minus-square"></i></span>
</div>
<div class="param-box-row" v-for="(item, index) in module.paramObj" v-if="!rightBox.isEdit">
<div class="right-box-form-content-txt">{{item.key}}={{item.value}}</div>
</div>
</div>
</el-form-item>
</el-form>
@@ -180,7 +190,8 @@
return {
rightBox: {
show: false,
title: ''
title: '',
isEdit:false
},
rules: {
name: [
@@ -197,8 +208,9 @@
}
},
methods: {
show(show) {
show(show,isEdit) {
this.rightBox.show = show;
this.rightBox.isEdit=isEdit
},
/*关闭弹框*/
@@ -238,7 +250,14 @@
}
});
},
saveOrToEdit: function() {
if (!this.rightBox.isEdit) {
this.rightBox.isEdit = true;
this.rightBox.title = this.$t("project.module.editModule") + " ID" + this.module.id;
} else {
this.save();
}
},
/*删除*/
del() {
this.$confirm(this.$t("tip.confirmDelete"), {
@@ -317,9 +336,10 @@
watch: {
module: {
immediate: true,
deep:true,
handler(n, o) {
if (n && n.id) {
this.rightBox.title = this.$t("project.module.editModule") + " ID" + n.id;
this.rightBox.title =this.rightBox.isEdit? this.$t("project.module.editModule") + " ID" + n.id : this.$t("project.module.module") + " ID" + n.id ;
} else {
this.rightBox.title = this.$t("project.module.createModule");
}

View File

@@ -6,8 +6,9 @@
<button type="button" v-if="project.id != ''" @click="del" class="nz-btn nz-btn-size-normal nz-btn-style-light">
<span class="top-tool-btn-txt">{{$t('overall.delete')}}</span>
</button>
<button type="button" @click="save" class="nz-btn nz-btn-size-normal nz-btn-style-normal">
<span class="top-tool-btn-txt">{{$t('overall.save')}}</span>
<button type="button" @click="saveOrToEdit" class="nz-btn nz-btn-size-normal nz-btn-style-normal">
<span v-if="rightBox.isEdit" class="top-tool-btn-txt">{{$t('overall.save')}}</span>
<span v-else class="top-tool-btn-txt">{{$t('overall.edit')}}</span>
</button>
<button type="button" @click="esc" class="nz-btn nz-btn-size-normal nz-btn-style-light nz-btn-style-square">
<span class="top-tool-btn-txt"><i class="el-icon-close"></i></span>
@@ -21,10 +22,12 @@
<el-scrollbar class="right-box-form-box">
<el-form class="right-box-form" :model="project" label-position="top" :rules="rules" ref="projectForm">
<el-form-item :label='$t("project.project.projectName")' prop="name">
<el-input size="mini" maxlength="64" show-word-limit v-model="project.name"></el-input>
<el-input v-if="rightBox.isEdit" size="mini" maxlength="64" show-word-limit v-model="project.name"></el-input>
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{project.name}}</div>
</el-form-item>
<el-form-item :label='$t("project.project.description")'>
<el-input size="mini" type="textarea" maxlength="1024" show-word-limit v-model="project.remark"></el-input>
<el-input v-if="rightBox.isEdit" size="mini" type="textarea" maxlength="1024" show-word-limit v-model="project.remark"></el-input>
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{project.remark}}</div>
</el-form-item>
</el-form>
</el-scrollbar>
@@ -48,7 +51,8 @@
rightBox: {
show: false,
title: '',
isCreate: false
isCreate: false,
isEdit:false
},
rules: {
name: [
@@ -58,8 +62,9 @@
}
},
methods: {
show(show) {
show(show,isEdit) {
this.rightBox.show = show;
this.rightBox.isEdit=isEdit;
},
/*关闭弹框*/
@@ -99,7 +104,14 @@
}
});
},
saveOrToEdit: function() {
if (!this.rightBox.isEdit) {
this.rightBox.isEdit = true;
this.rightBox.title = this.$t("project.module.editProject") + " ID" + this.project.id;
} else {
this.save();
}
},
/*删除*/
del() {
this.$confirm(this.$t("tip.confirmDelete"), {
@@ -124,7 +136,7 @@
immediate: true,
handler(n, o) {
if (n && n.id) {
this.rightBox.title = this.$t("project.project.editProject") + " ID" + n.id;
this.rightBox.title =this.rightBox.isEdit? this.$t("project.project.editProject") + " ID" + n.id : this.$t("project.project.project") + " ID" + n.id;
} else {
this.rightBox.title = this.$t("project.project.createProject");
}

View File

@@ -81,7 +81,11 @@
<span v-else-if="item.prop == 'type'">
<template v-for="type in typeData" v-if="type.key == scope.row[item.prop]">{{type.value}}</template>
</span>
<span v-else-if="item.prop == 'linkObject' && scope.row[item.prop]">{{scope.row.type != 3 && scope.row.linkObject ? scope.row[item.prop].name : scope.row[item.prop].host}}</span>
<!-- <span v-else-if="item.prop == 'linkObject' && scope.row[item.prop]">{{scope.row.type != 3 && scope.row.linkObject ? scope.row[item.prop].name : scope.row[item.prop].host}}</span>-->
<div v-else-if="item.prop == 'linkObject'">
<span v-if="(scope.row['type'] == 1 || scope.row['type'] == 2) && scope.row[item.prop]" class="account-list-option" @click="viewAlertType(scope.row['type'],scope.row[item.prop])">{{scope.row[item.prop].name}}</span>
<span v-if="scope.row['type'] == 3 && scope.row[item.prop]" class="account-list-option" @click="viewAlertType(scope.row['type'],scope.row[item.prop].id)">{{scope.row[item.prop].host}}</span>
</div>
<span v-else>{{scope.row[item.prop]}}</span>
</template>
</el-table-column>
@@ -89,6 +93,9 @@
<Pagination :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination>
</div>
<alert-config-box :parentAlertRule="alertRule" @reload="getTableData" ref="alertConfigBox"></alert-config-box>
<project-box :project="viewProjectData" ref="projectBox"></project-box>
<module-box :module="viewModuleData" @reload="" ref="moduleBox"></module-box>
<asset-edit-unit :edit-unit-show='viewAsset' @refreshData="" @sendStateData="" ref="assetEditUnit"></asset-edit-unit>
</div>
</template>
@@ -219,7 +226,10 @@ export default {
show: true,
}
],
tableData: []
tableData: [],
viewProjectData:null,
viewModuleData:null,
viewAsset:false,
}
},
methods: {
@@ -309,6 +319,45 @@ export default {
}
}
this.getTableData();
},
viewAlertType:function(type,typeObj){
console.log(typeObj)
this.closeViews();
switch (type) {
case 1:
this.viewProjectData=typeObj;
this.$refs.projectBox.show(true);
break;
case 2:
this.fillProject(typeObj);
let tempObj=JSON.parse(typeObj.param)
this.$set(typeObj, 'paramObj', []);
for (let k in tempObj) {
typeObj.paramObj.push({key: k, value: tempObj[k]});
}
this.viewModuleData=typeObj;
this.$refs.moduleBox.show(true);
break;
case 3:
this.viewAsset=true;
this.$refs.assetEditUnit.getAssetData(typeObj);
this.$refs.assetEditUnit.tabView=true;
break;
}
},
fillProject:function(module){
this.$get('project', {"id":module.projectId}).then(response => {
if (response.code == 200) {
module.project = response.data.list[0];
}
})
},
closeViews:function(){
this.$refs.alertConfigBox.show(false,false);
this.$refs.projectBox.show(false,false);
this.$refs.moduleBox.show(false,false);
this.viewAsset=false;
}
},
mounted() {

View File

@@ -185,10 +185,13 @@
:label="item.label"
>
<template slot-scope="scope" :column="item">
<div v-if="item.prop == 'type'" class="account-list-options">
<span v-if="scope.row[item.prop] == 1" class="account-list-option">Project</span>
<span v-if="scope.row[item.prop] == 2" class="account-list-option">Module</span>
<span v-if="scope.row[item.prop] == 3" class="account-list-option">Device</span>
<span v-if="item.prop == 'alertRule'" class="account-list-option" @click="viewRule(scope.row[item.prop].id)">
{{scope.row[item.prop].alertName}}
</span>
<div v-else-if="item.prop == 'type'" class="account-list-options">
<span v-if="scope.row[item.prop] == 1" >Project</span>
<span v-if="scope.row[item.prop] == 2" >Module</span>
<span v-if="scope.row[item.prop] == 3" >Device</span>
</div>
<span v-else-if="item.prop == 'severity'">
<span v-if="scope.row[item.prop] == 'high'"><i class="el-icon-arrow-up"></i>&nbsp;{{severityData[1].value}}</span>
@@ -196,8 +199,8 @@
<span v-if="scope.row[item.prop] == 'low'"><i class="el-icon-arrow-down"></i>&nbsp;{{severityData[2].value}}</span>
</span>
<div v-else-if="item.prop == 'linkObject'">
<span v-if="(scope.row['type'] == 1 || scope.row['type'] == 2) && scope.row[item.prop]" class="account-list-option">{{scope.row[item.prop].name}}</span>
<span v-if="scope.row['type'] == 3 && scope.row[item.prop]" class="account-list-option">{{scope.row[item.prop].host}}</span>
<span v-if="(scope.row['type'] == 1 || scope.row['type'] == 2) && scope.row[item.prop]" class="account-list-option" @click="viewAlertType(scope.row['type'],scope.row[item.prop])">{{scope.row[item.prop].name}}</span>
<span v-if="scope.row['type'] == 3 && scope.row[item.prop]" class="account-list-option" @click="viewAlertType(scope.row['type'],scope.row[item.prop].id)">{{scope.row[item.prop].host}}</span>
</div>
<div v-else-if="item.prop == 'state'">
<span class="account-list-option">
@@ -211,7 +214,10 @@
</el-table>
<Pagination :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination>
</div>
<alert-config-box :parentAlertRule="viewRuleData" @reload="" ref="alertConfigBox"></alert-config-box>
<project-box :project="viewProjectData" ref="projectBox"></project-box>
<module-box :module="viewModuleData" @reload="" ref="moduleBox"></module-box>
<asset-edit-unit :edit-unit-show='viewAssetState' @refreshData="" @sendStateData="" ref="assetEditUnit"></asset-edit-unit>
</div>
</template>
@@ -226,9 +232,14 @@ export default {
total:13
},
tableTitle: [
{
label:'ID',
prop:'id',
show:false
},
{
label: this.$t("alert.alertName"),
prop: 'alertName',
prop: 'alertRule',
show: true
}, {
label: this.$t("alert.list.type"),
@@ -303,7 +314,11 @@ export default {
value: this.$t("alert.config.low")
}
],
tableData: []
tableData: [],
viewRuleData:null,
viewProjectData:null,
viewModuleData:null,
viewAssetState:false,
}
},
methods: {
@@ -343,6 +358,54 @@ export default {
}
}
this.getAlertList();
},
viewRule:function(id){
this.closeViews();
this.$get('alert/rule', {"id":id}).then(response => {
if (response.code == 200) {
this.viewRuleData = response.data.list[0];
this.$refs.alertConfigBox.show(true);
}
})
},
viewAlertType:function(type,typeObj){
console.log(typeObj)
this.closeViews();
switch (type) {
case 1:
this.viewProjectData=typeObj;
this.$refs.projectBox.show(true);
break;
case 2:
this.fillProject(typeObj);
let tempObj=JSON.parse(typeObj.param)
this.$set(typeObj, 'paramObj', []);
for (let k in tempObj) {
typeObj.paramObj.push({key: k, value: tempObj[k]});
}
this.viewModuleData=typeObj;
this.$refs.moduleBox.show(true);
break;
case 3:
this.viewAssetState=true;
this.$refs.assetEditUnit.getAssetData(typeObj);
this.$refs.assetEditUnit.tabView=true;
break;
}
},
fillProject:function(module){
this.$get('project', {"id":module.projectId}).then(response => {
if (response.code == 200) {
module.project = response.data.list[0];
}
})
},
closeViews:function(){
this.$refs.alertConfigBox.show(false,false);
this.$refs.projectBox.show(false,false);
this.$refs.moduleBox.show(false,false);
this.viewAssetState=false;
}
},
mounted() {

View File

@@ -79,7 +79,7 @@
:label="item.label"
>
<template slot-scope="scope" :column="item">
<span v-if="item.prop == 'asset' && scope.row[item.prop]">{{scope.row[item.prop].host}}</span>
<span v-if="item.prop == 'asset' && scope.row[item.prop]" @click="viewAsset(scope.row[item.prop].id)">{{scope.row[item.prop].host}}</span>
<span v-else-if="item.prop == 'param'">
<span v-for="p in scope.row.paramObj">{{p.key}}={{p.value}}</span>
</span>
@@ -103,6 +103,7 @@
<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="" @sendStateData="" ref="assetEditUnit"></asset-edit-unit>
</div>
</template>
@@ -211,6 +212,7 @@
disabled: false
}],
},
viewAssetState:false,
}
},
methods: {
@@ -422,8 +424,12 @@
let seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
},
viewAsset:function(id){
this.viewAssetState=true;
this.$refs.assetEditUnit.getAssetData(id);
this.$refs.assetEditUnit.tabView=true;
}
},
created() {
this.currentProject = this.$store.state.currentProject;