|
|
export default {
|
|
|
name: 'basicEnvironmentAdd',
|
|
|
template: '',
|
|
|
components: {},
|
|
|
props:['propsData','isDisplay'],
|
|
|
data () {
|
|
|
return {
|
|
|
columns:[
|
|
|
{
|
|
|
prop: 'resTypeName',
|
|
|
label: '资源类型',
|
|
|
sortable: true,
|
|
|
align: 'center',
|
|
|
width:'120'
|
|
|
},
|
|
|
{
|
|
|
prop: 'resName',
|
|
|
label: '资源名称',
|
|
|
sortable: true,
|
|
|
align: 'center',
|
|
|
},
|
|
|
{
|
|
|
prop: 'ipAddr',
|
|
|
label: 'ip地址',
|
|
|
sortable: true,
|
|
|
align: 'center',
|
|
|
width:'150'
|
|
|
},
|
|
|
|
|
|
{
|
|
|
prop: 'kpiName',
|
|
|
label: '指标名称',
|
|
|
sortable: true,
|
|
|
align: 'center',
|
|
|
width:'180'
|
|
|
},
|
|
|
{
|
|
|
prop: 'flag',
|
|
|
label: '指标标识',
|
|
|
sortable: true,
|
|
|
align: 'center',
|
|
|
width:'150'
|
|
|
}
|
|
|
]
|
|
|
|
|
|
}
|
|
|
},
|
|
|
computed: {},
|
|
|
setup(props){
|
|
|
const {proxy} = Vue.getCurrentInstance();
|
|
|
let id = proxy.$global.getQueryVariable('configId') ;
|
|
|
let config = Vue.ref(id == false ? null : id);
|
|
|
let count=Vue.ref(0);
|
|
|
let tableDataList = Vue.ref([]);
|
|
|
let resTypeArr = Vue.ref();
|
|
|
let kpiTypeArr = Vue.ref([]);
|
|
|
let busTypeArr = Vue.ref([]);
|
|
|
let keyWords= Vue.ref('');
|
|
|
let resTypeList = Vue.ref([]);
|
|
|
let kpiList = Vue.ref([]);
|
|
|
let busTypeList = Vue.ref([]);
|
|
|
let bizId=Vue.ref();//所属业务id
|
|
|
let targetId=Vue.ref();//所属模块id
|
|
|
let page=Vue.ref(1);//当前页
|
|
|
let pageSize=Vue.ref(10);//每页显示条数
|
|
|
//是否是详情页面
|
|
|
let isDetail=Vue.ref(false);
|
|
|
let titleName=Vue.ref('基础环境配置');
|
|
|
let modleId=Vue.ref();//模块id
|
|
|
let faultConfId=Vue.ref();
|
|
|
let bizName=Vue.ref();
|
|
|
let name=Vue.ref();
|
|
|
let baseVisible=Vue.ref(false);
|
|
|
let isLoading=Vue.ref(false);
|
|
|
|
|
|
// 监听编辑状态
|
|
|
Vue.watch(()=>props.isDisplay,(newValue, oldValue)=>{
|
|
|
console.log("base",newValue)
|
|
|
proxy.baseVisible=newValue;
|
|
|
if(newValue){
|
|
|
proxy.setBizId();
|
|
|
proxy.getEnvironmentData();
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
let init = () =>{
|
|
|
let params={
|
|
|
busId: proxy.bizId
|
|
|
}
|
|
|
proxy.$http.get("/api-web/fault/conf/resource/getResourceByBusId", params, function(res) {
|
|
|
if (res && res.data) {
|
|
|
proxy.resTypeList = res.data;
|
|
|
}
|
|
|
})
|
|
|
|
|
|
/* proxy.$http.get("/api-web/home/business/findAllBusType", {}, function(res) {
|
|
|
if (res && res.data) {
|
|
|
proxy.busTypeList = res.data;
|
|
|
}
|
|
|
})*/
|
|
|
}
|
|
|
let onReset = () => {
|
|
|
proxy.keyWords = '';
|
|
|
proxy.resTypeArr = '';
|
|
|
proxy.kpiTypeArr = [];
|
|
|
proxy.busTypeArr = [];
|
|
|
}
|
|
|
// 点击按钮搜索
|
|
|
let onBtnSearch = () => {
|
|
|
proxy.getEnvironmentData();
|
|
|
}
|
|
|
//获取接收到的传值 bizid
|
|
|
let setBizId=()=>{
|
|
|
console.log("props.propsData",props.propsData)
|
|
|
if(props.propsData){
|
|
|
proxy.bizId=props.propsData.bizId;
|
|
|
proxy.targetId=props.propsData.targetId;
|
|
|
proxy.busTypeArr=[props.propsData.bizId];
|
|
|
proxy.faultConfId=props.propsData.faultConfId;
|
|
|
proxy.bizName=props.propsData.bizName;
|
|
|
proxy.modleId=props.propsData.modleId;
|
|
|
proxy.name=props.propsData.name;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
//资源类型改变查找基础列表
|
|
|
let changeRes=(val)=>{
|
|
|
console.log(val)
|
|
|
proxy.getEnvironmentData();
|
|
|
|
|
|
}
|
|
|
//重新加载表格数据
|
|
|
let loadTableDataList = ({page, limit}) => {
|
|
|
proxy.page=page;
|
|
|
proxy.pageSize=limit;
|
|
|
proxy.getEnvironmentData()
|
|
|
}
|
|
|
//获取基础环境资源列表数据
|
|
|
let getEnvironmentData=()=>{
|
|
|
let params={
|
|
|
busId:proxy.bizId,
|
|
|
resId:proxy.resTypeArr,
|
|
|
page:proxy.page,
|
|
|
pageSize:proxy.pageSize
|
|
|
|
|
|
}
|
|
|
|
|
|
proxy.$http.get('/api-web/fault/base/config/page',params,function (res){
|
|
|
|
|
|
if(res && res.data){
|
|
|
proxy.count = res.count;
|
|
|
proxy.tableDataList=res.data;
|
|
|
// proxy.$emit('baseCount',proxy.count);
|
|
|
}
|
|
|
})
|
|
|
|
|
|
|
|
|
}
|
|
|
//单个添加基础环境
|
|
|
let addRes=(row,index)=>{
|
|
|
let baseList=row;
|
|
|
|
|
|
let params={
|
|
|
targetId:proxy.targetId,
|
|
|
baseList:[baseList]
|
|
|
}
|
|
|
|
|
|
proxy.$http.post('/api-web/fault/conf/base/batchAddBaseInfo',params,function (res){
|
|
|
if(res && res.success){
|
|
|
proxy.$global.showMsg('添加成功','success');
|
|
|
proxy.targetId=res.str;
|
|
|
proxy.saveModel();
|
|
|
// proxy.applicationMonitorVisible=false;
|
|
|
}else{
|
|
|
proxy.$global.showMsg('添加失败','warning');
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
}
|
|
|
//全部添加
|
|
|
let saveAlldata=()=>{
|
|
|
if(proxy.count==0){
|
|
|
proxy.$global.showMsg('暂无配置','warning');
|
|
|
}else{
|
|
|
proxy.isLoading=true;
|
|
|
let params={
|
|
|
busId:proxy.bizId,
|
|
|
targetId:proxy.targetId,
|
|
|
}
|
|
|
proxy.$http.post('/api-web/fault/conf/base/saveOrUpdate',params,function (res){
|
|
|
if(res && res.success){
|
|
|
if(res.count==0){
|
|
|
proxy.$global.showMsg(res.msg,'warning');
|
|
|
}else{
|
|
|
proxy.$global.showMsg('添加成功','success');
|
|
|
proxy.targetId=res.str;
|
|
|
proxy.saveModel();
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
proxy.$global.showMsg('基础环境保存失败','warning')
|
|
|
|
|
|
}
|
|
|
proxy.isLoading=false;
|
|
|
|
|
|
},function (err){
|
|
|
proxy.isLoading=false;
|
|
|
|
|
|
})
|
|
|
}
|
|
|
|
|
|
}
|
|
|
//表格全选事件
|
|
|
let selectionChange=(val)=>{
|
|
|
proxy.tableDataList.map((v,i)=>{
|
|
|
|
|
|
v.checked=false;
|
|
|
|
|
|
})
|
|
|
let selectData=val;
|
|
|
if(selectData.length>0){
|
|
|
selectData.map((item,index)=>{
|
|
|
proxy.tableDataList.map((v,i)=>{
|
|
|
if(item.id==v.id){
|
|
|
v.checked=true;
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
|
|
|
}else{
|
|
|
proxy.tableDataList.map((v,i)=>{
|
|
|
v.checked=false;
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
//添加选中的
|
|
|
let saveAll=()=>{
|
|
|
let baseListSelectData=[];
|
|
|
proxy.tableDataList.map(item=>{
|
|
|
if(item.checked){
|
|
|
baseListSelectData.push(item)
|
|
|
}
|
|
|
|
|
|
})
|
|
|
if(baseListSelectData.length==0){
|
|
|
proxy.$global.showMsg('请选择配置','warning');
|
|
|
}else{
|
|
|
proxy.isLoading=true;
|
|
|
|
|
|
let params={
|
|
|
targetId:proxy.targetId,
|
|
|
baseList:baseListSelectData
|
|
|
}
|
|
|
|
|
|
proxy.$http.post('/api-web/fault/conf/base/batchAddBaseInfo',params,function (res){
|
|
|
if(res && res.success){
|
|
|
proxy.$global.showMsg('添加成功','success');
|
|
|
proxy.targetId=res.str;
|
|
|
proxy.saveModel();
|
|
|
// proxy.applicationMonitorVisible=false;
|
|
|
}else{
|
|
|
proxy.$global.showMsg('添加失败','warning');
|
|
|
|
|
|
}
|
|
|
proxy.isLoading=false;
|
|
|
|
|
|
})
|
|
|
}
|
|
|
|
|
|
}
|
|
|
//关闭弹框
|
|
|
let closeDialog=()=>{
|
|
|
let obj={
|
|
|
targetId:proxy.targetId,
|
|
|
faultConfId:proxy.faultConfId,
|
|
|
|
|
|
}
|
|
|
proxy.$emit('callbackBase',obj);
|
|
|
}
|
|
|
return {
|
|
|
isLoading,
|
|
|
closeDialog,
|
|
|
addRes,
|
|
|
saveAlldata,
|
|
|
saveAll,
|
|
|
selectionChange,
|
|
|
titleName,
|
|
|
faultConfId,
|
|
|
bizName,
|
|
|
name,
|
|
|
modleId,
|
|
|
baseVisible,
|
|
|
getEnvironmentData,
|
|
|
loadTableDataList,
|
|
|
page,
|
|
|
pageSize,
|
|
|
isDetail,
|
|
|
changeRes,
|
|
|
setBizId,
|
|
|
bizId,
|
|
|
targetId,
|
|
|
config,
|
|
|
count,
|
|
|
tableDataList,
|
|
|
kpiList,
|
|
|
busTypeList,
|
|
|
keyWords,
|
|
|
resTypeArr,
|
|
|
kpiTypeArr,
|
|
|
busTypeArr,
|
|
|
resTypeList,
|
|
|
init,
|
|
|
onReset,
|
|
|
onBtnSearch
|
|
|
}
|
|
|
|
|
|
},
|
|
|
methods: {
|
|
|
|
|
|
//取消节点列表配置
|
|
|
cancleList(){
|
|
|
this.baseVisible=false;
|
|
|
|
|
|
},
|
|
|
//保存节点添加配置
|
|
|
saveList(){
|
|
|
this.baseVisible=false;
|
|
|
},
|
|
|
|
|
|
//删除表格指标
|
|
|
deleteItem(item){
|
|
|
let that=this;
|
|
|
this.$global.confirm("确认删除指标吗?", function () {
|
|
|
let params = {
|
|
|
id: item.id
|
|
|
}
|
|
|
that.$http.get('/api-web/fault/conf/base/deleteById', params, function (res) {
|
|
|
if (res) {
|
|
|
that.$global.showMsg('删除成功');
|
|
|
that.getEnvironmentData();
|
|
|
|
|
|
}
|
|
|
that.$emit('callbackDelete', item)
|
|
|
|
|
|
})
|
|
|
})
|
|
|
|
|
|
},
|
|
|
//保存模块
|
|
|
saveModel(){
|
|
|
let that=this;
|
|
|
let params={
|
|
|
type:'base',
|
|
|
targetId:this.targetId,
|
|
|
state:'1',
|
|
|
id:this.modleId,
|
|
|
faultConfig:{
|
|
|
id:this.faultConfId,
|
|
|
name:this.name,
|
|
|
bizId: this.bizId,
|
|
|
bizName:this.bizName,
|
|
|
createBy:localStorage.getItem("lgn")
|
|
|
}
|
|
|
}
|
|
|
this.$http.post('/api-web/fault/conf/detail/saveConfigDetail',params,function (res){
|
|
|
if(res && res.success){
|
|
|
that.targetId=res.map.configDetail.targetId;
|
|
|
that.faultConfId=res.map.configDetail.faultConfig.id;
|
|
|
|
|
|
// that.$global.showMsg('保存成功','success')
|
|
|
// that.switchModel();
|
|
|
that.baseVisible=false;
|
|
|
|
|
|
}else{
|
|
|
that.$global.showMsg('模块保存失败','warning')
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
mounted () {
|
|
|
|
|
|
this.setBizId();
|
|
|
this.init();
|
|
|
this.getEnvironmentData();
|
|
|
},
|
|
|
unmounted () {}
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|