Authored by 鲁尚清

Merge branch 'master' of http://192.168.1.136:82/monitor_v3/hg-monitor-web into …

…master-v32-lushangqing
... ... @@ -43,6 +43,7 @@
sessionStorage.setItem('workflow', res1[0].workflow);
sessionStorage.setItem('mp3', res2[0].mp3);
sessionStorage.setItem('jimuReport', res1[0].jimuReport);
sessionStorage.setItem('cmdbWeb', res1[0].cmdbWeb);
})
});
layui.config({
... ...
... ... @@ -6,7 +6,7 @@
<el-table-column v-if="showSelection && columns.length > 0" type="selection" width="55" />
<el-table-column v-for="item in columns" :prop="item.prop" :label="item.label" :sortable="item.sortable == undefined ? false : item.sortable" :align="item.align == undefined ? 'center' : item.align "
:width="item.width">
:width="getWidth(item.width)">
<template #default="scope">
<slot :row="scope.row" :prop="item.prop" :column="item">
<div v-if="typeof(item.render) == 'function'" >
... ...
... ... @@ -72,6 +72,10 @@ export default {
type: Boolean,
default: false
},
maxWidth:{
type: Number,
default: window.innerWidth
},
},
data() {
... ... @@ -80,11 +84,35 @@ export default {
setup(props, {attrs, slots, emit}) {
let currentPage = Vue.ref(1);
let pageSize = Vue.ref(props.pageSize);
// let sizeArr = props.pageSizes;
// if(sizeArr && sizeArr.length > 0){
// pageSize.value = sizeArr[0]
// }
// console.log('======',pageSize.value);
/**
* 获取宽度
* <p>
* 作者: Wang
* 时间:2021/11/16 16:19
*/
let getWidth = (width) =>{
let maxWidth = (function (){
let cols = props.columns;
if(cols && cols.length > 0){
// 求和
let w = 0;
cols.forEach(function (v) {
w += parseFloat(v.width) ;
})
if(w < props.maxWidth){
return props.maxWidth / w * width;
}
}
return width;
})();
return maxWidth;
}
let callback = () =>{
... ... @@ -143,7 +171,8 @@ export default {
handleSizeChange,
handleCurrentChange,
prePage,
nextPage
nextPage,
getWidth
}
}
}
... ...
... ... @@ -148,11 +148,29 @@ global.openGraphEditor = (topoId) =>{
* 打开资产列表
* @param topoId
*/
global.openCmdbAssets = (resId) =>{
let url = `${sessionStorage.getItem('graphEditorOrigin')}/jgraph/grapheditor/index.html?access_token=${localStorage.getItem('access_token')}&id=${resId}`;
global.openCmdbAssets = (resTypeId, resId, proxy) => {
let preUrl = sessionStorage.getItem('cmdbWeb');
if(!preUrl){
global.showMsg("获取CMDB系统地址失败,请配置!","error");
return;
}
let height = window.innerHeight;
let width = window.innerWidth;
window.open(url,"_blank",`toolbar=no, location=no, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=no, width=${width}, height=${height}`);
// 获取资源类型对应的cmddb的资源类型
proxy.$http.get(`/api-web/v32/res/cmdb/${resTypeId}`, {}, function (res) {
if (res && res.success) {
let obj = res.object;
let cmdVal = obj.cmdbValue;
let url =`${preUrl}/#/CI/configuration-item/detail?objId=${cmdVal}&id=${resId}`
window.open(url,"_blank",`left=100,fullscreen,toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=${width}, height=${height}`);
} else {
proxy.$global.showMsg('没有查询到关联数据,请配置!', "error");
}
});
}
/**
... ...
... ... @@ -8,12 +8,13 @@ let http = {
},
reqErr: function (xhr) {
try{
http.proxy.$global.showMsg("服务异常,请联系管理员!","error");
let isUnauthorized = xhr.statusText == 'Unauthorized'
if (isUnauthorized || (xhr && xhr.responseJSON && xhr.responseJSON.resp_code && xhr.responseJSON.resp_code == '401')) {
// 登录超时,刷新当前页面===>跳转到登录页面
// window.location.reload();
window.top.location.href = localStorage.getItem('loginUrl');
window.top.location.reload();
//window.top.location.href = localStorage.getItem('loginUrl');
} else {
http.proxy.$global.showMsg("服务异常,请联系管理员!","error");
}
}catch (e){
}
... ... @@ -53,7 +54,7 @@ let http = {
errFunc();
}
// console.log("==>", requestUrl, xhr, textStatus)
http.reqErr(textStatus.status);
http.reqErr(xhr);
},
success: function (data, textStatus, jqXHR) {
if (callback) {
... ... @@ -99,7 +100,7 @@ let http = {
loading.close();
}
// console.log("==>", requestUrl, xhr, textStatus)
http.reqErr(textStatus.status);
http.reqErr(xhr);
if (errFunc) {
errFunc();
... ... @@ -147,7 +148,7 @@ let http = {
error: function (xhr, textStatus) {
loading.close();
// console.log("==>", requestUrl, xhr, textStatus)
http.reqErr(textStatus.status);
http.reqErr(xhr);
http.proxy.$global.showMsg("上传失败,请您确认文件是否存在!","error");
},
... ...
... ... @@ -46,6 +46,7 @@
sessionStorage.setItem('workflow', res1[0].workflow);
sessionStorage.setItem('mp3', res2[0].mp3);
sessionStorage.setItem('jimuReport', res1[0].jimuReport);
sessionStorage.setItem('cmdbWeb', res1[0].cmdbWeb);
})
});
layui.config({
... ...
<el-progress type="dashboard" :percentage="percentage" :status="status">
<template #default="{ percentage }">
<span class="percentage-value">{{ percentage }}%</span>
<span class="percentage-label">{{percentageText}}</span>
</template>
</el-progress>
<!--
<el-progress
:text-inside="true"
:stroke-width="20"
:percentage="50"
status="exception" >
<span>Content</span>
</el-progress>
-->
<div style="display: flex;flex-wrap: nowrap">
<div style="width: calc(100% - 50px)">
<el-progress
:text-inside="true"
:stroke-width="20"
:percentage="textValue"
:status="status">
<span>{{textValue == '' ? ' ' : textValue }} %</span>
</el-progress>
</div>
<div style="width: 50px">{{textString == '' ? ' - ' : textString }} </div>
</div>
... ...
... ... @@ -4,21 +4,25 @@ export default {
components: {},
props: {
// 百分比数字,例如:50%,percentage= 50
percentage: {
textValue: {
type: Number,
default: 0
},
// 展示文字
percentageText: {
type: String,
default: ''
},
// 状态 success/exception/warning
status: {
type: String,
default: 'success'
},
resId: {
type: String,
default: ''
},
// 文本
textString: {
type: String,
default: 0
},
},
data() {
return {
... ...
<div>
<el-dropdown>
<span class="el-dropdown-link" @click="openDetail">
{{resName}}
{{textString}}
<el-icon class="el-icon--right">
<arrow-down/>
</el-icon>
... ... @@ -9,13 +9,13 @@
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item v-if="start" title="收藏" @click="showDialog(true)">
<i class="iconfont icon-shoucang" style="color: #FEB61E"/>
<i class="iconfont icon-shoucang" style="color: #FEB61E"/>收藏
</el-dropdown-item>
<el-dropdown-item v-if="topo" title="拓扑" @click="openTopoPage">
<i class="iconfont icon-wangluotuopu" style="color: #FEB61E"/>
<i class="iconfont icon-wangluotuopu" style="color: #FEB61E"/>拓扑
</el-dropdown-item>
<el-dropdown-item v-if="assets" title="资产" @click="openCmdbAssets">
<i class="iconfont icon-assets" style="color: #FEB61E"/>
<i class="iconfont icon-assets" style="color: #FEB61E"/>资产
</el-dropdown-item>
</el-dropdown-menu>
</template>
... ... @@ -23,17 +23,14 @@
<cm-dialog title="收藏" width="500px" :showDialogVisible="dialogFlg" @hidedialog="showDialog" @okfunc="saveStart">
<template v-slot>
<div style="padding: 10px" style="display: flex">
<div v-for="(v,k) in fieldsValueObj[currentRow.id].props" style="width: 50%">
<div style="text-align: left;padding-left: 10px;">{{v}}</div>
<el-select v-model="favIds" multiple placeholder="请选择" style="margin: 3px">
<el-option v-for="(item ,index) in favData"
:key="index"
:label="item.name"
:value="item.value" >
</el-option>
</el-select>
</div>
<div style="text-align: center;">
<el-select v-model="favIds" multiple placeholder="请选择" style="margin: 3px">
<el-option v-for="(item ,index) in favData"
:key="index"
:label="item.name"
:value="item.value" >
</el-option>
</el-select>
</div>
</template>
</cm-dialog>
... ...
... ... @@ -4,7 +4,7 @@ export default {
components: {},
props: {
// 资源名称
resName: {
textString: {
type: String,
default: 0
},
... ... @@ -25,6 +25,10 @@ export default {
type: String,
default: ''
},
resTypeId: {
type: String,
default: ''
},
},
data() {
... ... @@ -45,15 +49,13 @@ export default {
* 时间:2021/11/9 18:30
*/
let showDialog = (flg) => {
dialogFlg.value = flg;
if (favData.value.length == 0) {
// 加载收藏文件列表
proxy.$http.get(`/api-web/favorites/treeSelectData`, {}, function (res) {
if (res && res.data && res.data.length > 0) {
let arr = [];
let getChilds = (arr) => {
arr.forEach(function (v) {
let getChilds = (list) => {
list.forEach(function (v) {
if (v.children && v.children.length > 0) {
getChilds(v.children);
} else {
... ... @@ -61,10 +63,15 @@ export default {
}
})
}
getChilds(res.data);
favData.value = arr;
dialogFlg.value = flg;
} else {
proxy.$global.showMsg("没有查询到收藏夹,请先添加!","warning")
}
});
} else {
dialogFlg.value = flg;
}
}
... ... @@ -76,12 +83,12 @@ export default {
*/
let saveStart = () => {
if (props.resId == '') {
proxy.$global.showMsg("资源Id不存在,确认!")
proxy.$global.showMsg("资源编号不存在,请确认!","warning")
return;
}
let params = {
favIds: favIds,
favIds: favIds.value.join(','),
resId: props.resId
}
proxy.$http.post(`/api-web/favorites/save/fav`, params, function (res) {
... ... @@ -95,14 +102,14 @@ export default {
let openTopoPage = () => {
if (props.resId == '') {
proxy.$global.showMsg("资源Id不存在,确认!")
proxy.$global.showMsg("资源编号不存在,请确认!","warning")
return;
}
// 查询topoId
proxy.$http.get(`/api-web/mxgraph/generateByResId`, {resId: props.resId}, function (res) {
if (response && response.success) {
let topoId = response.str;
if (res && res.success) {
let topoId = res.str;
proxy.$global.openGraphEditor(topoId)
} else {
proxy.$global.showMsg('生成资源拓扑失败!', "error");
... ... @@ -111,12 +118,26 @@ export default {
}
let openDetail = () => {
if (props.resId == '') {
proxy.$global.showMsg("资源编号不存在,请确认!","warning")
return;
}
}
let openCmdbAssets = () => {
proxy.$global.openCmdbAssets(props.resId);
if (props.resId == '') {
proxy.$global.showMsg("资源编号不存在,请确认!","warning")
return;
}
if (props.resTypeId == '') {
proxy.$global.showMsg("资源类型不存在,请确认!","warning")
return;
}
proxy.$global.openCmdbAssets(props.resTypeId, props.resId, proxy);
}
return {
... ...
<el-tag :type="type" effect="dark">
{{ text }}
<el-tag :type="type" checked effect="dark">
{{ textString == '' ? ' - ' : textString}}
</el-tag>
... ...
... ... @@ -4,13 +4,17 @@ export default {
components: {},
props: {
// 类型 danger success warning
// 类型 danger success warning info
type: {
type: String,
default: 'success'
default: 'info'
},
// 文本
text: {
textString: {
type: String,
default: '未知'
},
resId: {
type: String,
default: ''
},
... ...
... ... @@ -36,7 +36,7 @@ let configPageEdit = (columns, currentNode) => {
// 获取属性标识的配置
let code = row.colType;
if (fieldsObj.value[code] && Object.keys(fieldsObj.value[code]).length > 0) {
if (fieldsObj.value[code] && Object.keys(fieldsObj.value[code]).length > 0 && code != 'CMDB') {
row.colTypeExtend = '';
return;
}
... ...
... ... @@ -30,10 +30,20 @@
<cm-table-page :columns="obj.columns" :dataList="obj.maps" @loaddata="getPage" :showIndex="true"
:showBorder="true" :currentPage="currentPage" :total="total" :loading="false"
:showPage="true" :height="(height - 95)">
:showPage="true" :height="(height - 95)" :maxWidth="max">
<template #default="{row,prop,column}">
<a href="javascript:void(0)" v-if="prop == 'resPositon' || prop == 'cabinetNo'" style="border-bottom: solid 1px blue;margin-bottom: 3px;height: 30px;font-size: 15px;" @click="cellClick(row,prop,column)">{{row[prop].value}}</a>
<el-link v-else :underline="false" @click="item.click(scope.row)">{{row[prop].value}}</el-link>
<a href="javascript:void(0)" v-if="prop == 'resPositon' || prop == 'cabinetNo'" style="border-bottom: solid 1px blue;margin-bottom: 3px;height: 30px;font-size: 15px;" @click="cellClick(row,prop,column)">{{row[prop].value == undefined ? '' : row[prop].value }}</a>
<component v-else-if="row[prop] && row[prop].props && row[prop].props.colComponents " v-bind:is="row[prop].props.colComponents"
:resId="row.resId"
:textValue="row[prop].value"
:resTypeId="currentNode.id"
:textString="row[prop].value"></component>
<el-link v-else :underline="false" @click="item.click(scope.row)">{{row[prop].value == undefined ? '' : row[prop].value }}</el-link>
</template>
</cm-table-page>
</div>
... ...
... ... @@ -65,6 +65,13 @@ export default {
let total = Vue.ref(0);
// 计算减去左侧树的宽度
let max = (function (){
let right = window.innerWidth;
let treeWidth = (right / 24) * 4;
return right - treeWidth ;
})();
// 获取左侧树结构
let loadTree = () => {
proxy.$http.get("/api-web/v32/res/list/tree", {}, function (res) {
... ... @@ -151,6 +158,7 @@ export default {
openCabinet,
cabinetNoSrc,
total,
max,
// 配置页面
showConfig, configObj, showConfigDialog
... ...