...
|
...
|
@@ -18,36 +18,33 @@ export default { |
|
|
let defaultNode=Vue.ref(true);//默认节点
|
|
|
let resType=Vue.ref('');//选中的树节点值
|
|
|
let handleNodeClick=(data,node)=>{
|
|
|
//点击树节点,根据某个字段获取列表 todo
|
|
|
console.log("*(*(*(*",data,node)
|
|
|
proxy.$global.showMsg(data.id,'warning')
|
|
|
//点击树节点,根据某个字段获取列表
|
|
|
resType.value=data.value;
|
|
|
defaultNode.value=false;
|
|
|
getDataList();
|
|
|
}
|
|
|
|
|
|
let providerData=Vue.ref([]);//厂商
|
|
|
let systemData=Vue.ref([]);//系统
|
|
|
let resSyncStateData=Vue.ref([]);//资源处理状态
|
|
|
let search = Vue.ref({
|
|
|
keyword: '',
|
|
|
pageNum: 1,
|
|
|
pageSize: 20,
|
|
|
resSyncState:'',
|
|
|
system: '',
|
|
|
provider:'',
|
|
|
});
|
|
|
//表格字段
|
|
|
let tableData = Vue.ref({
|
|
|
count:0,
|
|
|
dataList: [{
|
|
|
id:1,
|
|
|
resName:'资源一'
|
|
|
},{
|
|
|
id:2,
|
|
|
resName:'资源34'
|
|
|
}],
|
|
|
dataList: [],
|
|
|
columns: [
|
|
|
{
|
|
|
prop: 'resName',
|
|
|
label: '资源名称',
|
|
|
sortable: true,
|
|
|
align: 'center',
|
|
|
width: '250'
|
|
|
width: '200'
|
|
|
},
|
|
|
{
|
|
|
prop: 'resTypeName',
|
...
|
...
|
@@ -56,31 +53,98 @@ export default { |
|
|
align: 'center',
|
|
|
width: '200'
|
|
|
}, {
|
|
|
prop: 'host',
|
|
|
label: 'IP地址',
|
|
|
prop: 'resCategory',
|
|
|
label: '资源分类',
|
|
|
sortable: true,
|
|
|
align: 'center',
|
|
|
width: '200'
|
|
|
}, {
|
|
|
prop: 'type',
|
|
|
label: '日志来源',
|
|
|
width: '100'
|
|
|
},
|
|
|
{
|
|
|
prop: 'ip',
|
|
|
label: 'ip',
|
|
|
sortable: true,
|
|
|
align: 'center',
|
|
|
width: '200'
|
|
|
},
|
|
|
{
|
|
|
prop: 'program',
|
|
|
label: '日志类型',
|
|
|
prop: 'port',
|
|
|
label: '端口',
|
|
|
sortable: true,
|
|
|
align: 'center',
|
|
|
},
|
|
|
{
|
|
|
prop: 'os',
|
|
|
label: '操作系统类型',
|
|
|
sortable: true,
|
|
|
align: 'center',
|
|
|
width: '130'
|
|
|
},
|
|
|
{
|
|
|
prop: 'provider',
|
|
|
label: '厂商',
|
|
|
sortable: true,
|
|
|
align: 'center',
|
|
|
width: '100'
|
|
|
},
|
|
|
{
|
|
|
prop: 'state',
|
|
|
label: '资源处理状态',
|
|
|
sortable: true,
|
|
|
align: 'center',
|
|
|
width: '130',
|
|
|
render:function (row){
|
|
|
let str='已同步';
|
|
|
if(row.state=='1'){
|
|
|
str='纳入监控';
|
|
|
}else if(row.state=='2'){
|
|
|
str='忽略';
|
|
|
}else{
|
|
|
str='已同步';
|
|
|
}
|
|
|
return `<span>${str}</span>`
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
prop: 'syncType',
|
|
|
label: 'cmdb数据同步类型',
|
|
|
sortable: true,
|
|
|
align: 'center',
|
|
|
width: '200',
|
|
|
render:function (row){
|
|
|
let str='自动同步';
|
|
|
if(row.syncType=='1'){
|
|
|
str='手动同步';
|
|
|
}else if(row.syncType=='2'){
|
|
|
str='自动覆盖同步';
|
|
|
}else if(row.syncType=='3'){
|
|
|
str='手动覆盖同步';
|
|
|
}else{
|
|
|
str='自动同步';
|
|
|
}
|
|
|
return `<span>${str}</span>`
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
prop: 'resSyncDate',
|
|
|
label: '资源处理时间',
|
|
|
sortable: true,
|
|
|
align: 'center',
|
|
|
width: '200'
|
|
|
},
|
|
|
{
|
|
|
prop: 'message',
|
|
|
label: '日志内容',
|
|
|
prop: 'syncDate',
|
|
|
label: 'CMDB数据同步时间',
|
|
|
sortable: true,
|
|
|
align: 'center',
|
|
|
width: '200'
|
|
|
},
|
|
|
{
|
|
|
prop: 'remark',
|
|
|
label: '备注',
|
|
|
sortable: true,
|
|
|
align: 'center',
|
|
|
width: '200'
|
|
|
}
|
|
|
]
|
|
|
})
|
|
|
let dialog = Vue.ref({
|
...
|
...
|
@@ -94,6 +158,10 @@ export default { |
|
|
}
|
|
|
let hideDialog = (flg) => {
|
|
|
dialog.value.show = flg;
|
|
|
if(!flg){
|
|
|
// selectionData.value=[];
|
|
|
getDataList();
|
|
|
}
|
|
|
}
|
|
|
//全选事件
|
|
|
let selectionData=Vue.ref([]);//选择的数据
|
...
|
...
|
@@ -106,6 +174,7 @@ export default { |
|
|
dialog.value.tableData.dataList= row;
|
|
|
dialog.value.tableData.columns=tableData.value.columns;
|
|
|
dialog.value.tableData.getRowKeys= 'id';
|
|
|
dialog.value.tableData.resType= resType.value;
|
|
|
let arr=[];
|
|
|
row.map(item=>{
|
|
|
arr.push(item.id)
|
...
|
...
|
@@ -126,18 +195,84 @@ export default { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//同步 todo
|
|
|
//同步
|
|
|
let handleRefresh = (flag,row) =>{
|
|
|
let ids=[];
|
|
|
let isAll=false;
|
|
|
if(flag==1){
|
|
|
//单个同步 row-->对象
|
|
|
ids.push(row.id);
|
|
|
isAll=true;
|
|
|
}else{
|
|
|
//多选同步 selectionData.value-->数组
|
|
|
if(selectionData.value.length>0){
|
|
|
//...
|
|
|
selectionData.value.map(item=>{
|
|
|
ids.push(item.id)
|
|
|
})
|
|
|
isAll=true;
|
|
|
}else{
|
|
|
proxy.$global.showMsg('请选择数据','warning')
|
|
|
isAll=false;
|
|
|
}
|
|
|
}
|
|
|
let idList='';
|
|
|
if(ids.length>0){
|
|
|
idList=ids.join(',');
|
|
|
}
|
|
|
let param={
|
|
|
resType:resType.value,
|
|
|
idList:idList
|
|
|
}
|
|
|
if(isAll){
|
|
|
proxy.$http.get(`/api-web/cmdbSync/sync`, param, function (res) {
|
|
|
if (res && res.success) {
|
|
|
proxy.$global.showMsg('同步成功','success');
|
|
|
selectionData.value=[];
|
|
|
}else{
|
|
|
proxy.$global.showMsg('同步失败','error');
|
|
|
}
|
|
|
getDataList();
|
|
|
});
|
|
|
}else{
|
|
|
proxy.$global.confirm('确认同步该资源类型下所有资源?', function () {
|
|
|
proxy.$http.get(`/api-web/cmdbSync/sync`, param, function (res) {
|
|
|
if (res && res.success) {
|
|
|
proxy.$global.showMsg('同步成功','success');
|
|
|
selectionData.value=[];
|
|
|
}else{
|
|
|
proxy.$global.showMsg('同步失败','error');
|
|
|
}
|
|
|
getDataList();
|
|
|
});
|
|
|
})
|
|
|
}
|
|
|
|
|
|
}
|
|
|
//忽略
|
|
|
let handleIgnore=()=>{
|
|
|
//多选忽略 selectionData.value-->数组
|
|
|
if(selectionData.value.length>0){
|
|
|
let idList='';
|
|
|
let idArr=[]
|
|
|
selectionData.value.map(item=>{
|
|
|
idArr.push(item.id)
|
|
|
})
|
|
|
if(idArr.length>0){
|
|
|
idList=idArr.join(',')
|
|
|
}
|
|
|
proxy.$http.get(`/api-web/cmdbSync/ignore`, {idList:idList}, function (res) {
|
|
|
if (res && res.success) {
|
|
|
proxy.$global.showMsg('忽略成功','success');
|
|
|
selectionData.value=[];
|
|
|
}else{
|
|
|
proxy.$global.showMsg('忽略失败','error');
|
|
|
}
|
|
|
getDataList();
|
|
|
});
|
|
|
}else{
|
|
|
proxy.$global.showMsg('请选择数据','warning')
|
|
|
}
|
|
|
|
|
|
}
|
|
|
//编辑返回数据
|
|
|
let callbackedit=(obj)=>{
|
...
|
...
|
@@ -157,35 +292,55 @@ export default { |
|
|
proxy.$http.post(`/api-web/attribute/getTree`, {}, function (res) {
|
|
|
if (res && res.data) {
|
|
|
treeData.value = res.data;
|
|
|
getDataList();//获取列表数据
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
// 获取列表 todo
|
|
|
// 获取列表
|
|
|
let getDataList = () => {
|
|
|
if(defaultNode.value){
|
|
|
if(defaultNode.value && treeData.value[0]){
|
|
|
resType.value=treeData.value[0].children[0].value;
|
|
|
}
|
|
|
let params={
|
|
|
resType:resType.value,
|
|
|
pageNum: search.value.pageNum,
|
|
|
pageSize: search.value.pageSize,
|
|
|
keyword:search.value.keyword
|
|
|
}
|
|
|
proxy.$http.post(`/api-web/`, params, function (res) {
|
|
|
if (res && res.object) {
|
|
|
tableData.value.dataList = res.object;
|
|
|
tableData.value.count = parseInt(res.object.total);
|
|
|
page: search.value.pageNum,
|
|
|
limit: search.value.pageSize,
|
|
|
keyword:search.value.keyword,
|
|
|
provider:search.value.provider,//厂商
|
|
|
system:search.value.system,//系统 linux
|
|
|
resSyncState:search.value.resSyncState,//资源处理状态 0 监控同步成功
|
|
|
}
|
|
|
proxy.$http.get(`/api-web/cmdbSync/getPage`, params, function (res) {
|
|
|
if (res && res.data) {
|
|
|
tableData.value.dataList = res.data;
|
|
|
tableData.value.count = parseInt(res.count);
|
|
|
} else {
|
|
|
tableData.value.dataList = [];
|
|
|
tableData.value.count = 0;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
//获取字典接口
|
|
|
let getDdicCode=(code)=>{
|
|
|
proxy.$http.post(`/api-web/manage/ddic/findSucDdics/`+code, {}, function (res) {
|
|
|
if (res && res.data) {
|
|
|
if(code == 'resSyncState'){
|
|
|
resSyncStateData.value=res.data;
|
|
|
}else if(code == 'provider'){
|
|
|
providerData.value=res.data;
|
|
|
}else if(code == 'os'){
|
|
|
systemData.value=res.data;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 挂载完
|
|
|
Vue.onMounted(() => {
|
|
|
// getDataList();//获取列表数据
|
|
|
getResData();//获取资源树数据
|
|
|
getDdicCode('resSyncState');
|
|
|
getDdicCode('provider');
|
|
|
getDdicCode('os');
|
|
|
})
|
|
|
|
|
|
|
...
|
...
|
@@ -209,7 +364,12 @@ export default { |
|
|
handleRefresh,
|
|
|
callbackedit,
|
|
|
goResDetail,
|
|
|
resType
|
|
|
resType,
|
|
|
getDdicCode,
|
|
|
providerData,
|
|
|
systemData,
|
|
|
resSyncStateData,
|
|
|
handleIgnore
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|