Authored by 王涛

乙方运维

... ... @@ -5,8 +5,8 @@
<template #footer v-if="showFooter">
<span class="dialog-footer">
<el-button @click="hideElDialog">{{cancelText}}</el-button>
<el-button type="primary" @click="okFunc">{{okText}}</el-button>
<el-button @click="hideElDialog" v-if="showCancelBtn">{{cancelText}}</el-button>
<el-button type="primary" @click="okFunc" v-if="showOkBtn">{{okText}}</el-button>
</span>
</template>
</el-dialog>
... ...
... ... @@ -15,11 +15,21 @@ export default {
type: String,
default: "新建"
},
// 展示取消按钮
showCancelBtn: {
type: Boolean,
default: true
},
// 取消文本
cancelText: {
type: String,
default: "取消"
},
// 展示确定按钮
showOkBtn: {
type: Boolean,
default: true
},
// 确定文本
okText: {
type: String,
... ...
<cm-dialog title="文件上传" width="500px" :showDialogVisible="show" @hidedialog="hidedialog" @okfunc="uploadFile" okText="上传">
<cm-dialog v-if="!isInset" title="文件上传" width="500px" :showDialogVisible="show" @hidedialog="hidedialog" @okfunc="uploadFile" okText="上传">
<template v-slot>
<el-upload
... ... @@ -6,9 +6,10 @@
ref="upload"
:http-request="getFile"
:multiple="true"
:before-upload="beforeUpload"
:auto-upload="false">
<template #trigger>
<el-button size="small" type="primary">选择文件</el-button>
<el-button size="small" type="primary">{{btnText}}</el-button>
</template>
支持格式:
<el-tooltip placement="top" effect="light">
... ... @@ -25,3 +26,14 @@
</el-upload>
</template>
</cm-dialog>
<!--页面嵌套方式-->
<el-upload
v-if="isInset"
:show-file-list="false"
:before-upload="beforeUpload"
:multiple="false"
:http-request="getInsetFile"
:auto-upload="true">
<el-button size="small" type="primary">上传照片</el-button>
</el-upload>
... ...
... ... @@ -6,6 +6,15 @@ export default {
template: '',
components: {},
props: {
// 嵌套方式
isInset: {
type: Boolean,
default: false
},
btnText:{
type: String,
default: '选择文件'
},
showDialogVisible: {
type: Boolean,
default: false
... ... @@ -126,6 +135,17 @@ export default {
let uploadFile = () => {
proxy.$refs.upload.submit()
}
// 提交前的验证
let beforeUpload = (file) =>{
return emit('beforeUpload',res.file)
}
let getInsetFile = (param) =>{
let fileObj = param.file
emit('callback',fileObj)
}
// 监听编辑状态
Vue.watch(
() => props.showDialogVisible, (newValue, oldVlaue) => {
... ... @@ -142,10 +162,12 @@ export default {
return {
getInsetFile,
getFile,
show,
uploadFile,
hidedialog
hidedialog,
beforeUpload
}
}
}
... ...
... ... @@ -104,10 +104,38 @@ global.getQueryVariable = (variable) => {
return (false);
}
/**
* 文件预览
* @param path
*/
global.viewer = (path) =>{
window.open("/src/lib/extend/pdfjs/web/viewer.html?test=" + encodeURIComponent(path));
}
/**
* 将文件转成base64
* @param file
* @returns {Promise<String>}
*/
global.getBase64 = (file) =>{
return new Promise(function(resolve, reject) {
let reader = new FileReader();
let imgResult = "";
reader.readAsDataURL(file);
reader.onload = function() {
imgResult = reader.result;
};
reader.onerror = function(error) {
reject(error);
};
reader.onloadend = function() {
resolve(imgResult);
};
});
}
// 组件默认大小
global.elementSize = 'small';
... ...
// 业务类型管理
layui.define(['table', 'form', 'admin', 'layer', 'laytpl', 'common', 'view', 'sessions', 'commonDetail', 'treeTable', 'xmSelect', 'userlist', 'reslist'], function (exports) {
var $ = layui.$;
var form = layui.form;
var layer = layui.layer;
var admin = layui.admin;
var table = layui.table;
var treeTable = layui.treeTable;
var xmSelect = layui.xmSelect;
var laytpl = layui.laytpl;
var view = layui.view;
var common = layui.common;
var commonDetail = layui.commonDetail;
var domainName = common.domainName;
// 业务类型展示表格
var busTypeTable;
// 对外暴露的接口
exports('bustype', function (data) {
var sessions = layui.sessions;
var accessToken = sessions.getToken()['access_token'];
var cutoverId = '', targetType = '';
if (data && data.cutoverId) {
cutoverId = data.cutoverId;
targetType = data.targetType;
}
var mode = (data && data.mode) ? data.mode : '';
var username = (data && data.username) ? data.username : '';
//展示类型
var showTypeList=[];
var dataBusType=[];
initShowType();
// 查询条件
var conditions = {busTypeName: ''};
// 加载遮罩
var loading;
var checkList = common.checkPermission(accessToken);
loadBusTypeTable();
// 查询条件框回车查询事件
$('#condition-bustype-name').keydown(function (e) {
if (e.keyCode === 13) {
loadBusTypeTable();
return false;
}
});
//查询按钮点击事件 joke add 20210428
$('#bustypeQueryBtn').on('click',function () {
loadBusTypeTable();
});
// 删除按钮删除事件
$('#btn-bustype-delete').click(function () {
var checks = busTypeTable.checkStatus(false);
var busId = $.map(checks, function (item) {
return item.busId;
});
deleteBusTypeByIds(busId);
});
//授权按钮事件
$("#btn-bustype-authorization").click(function () {
var checks = busTypeTable.checkStatus(false);
var busId = [];
var j = 0;
var number = 0;
for (var i = 0; i < checks.length; i++) {
if (checks[i].children != null) {
j++;
number = checks[i].children.length;
}
}
if (j = 1 && checks.length - number == 1) {
busId = checks[0].busId;
} else {
busId = $.map(checks, function (item) {
return item.busId;
});
}
if (busId.length == 0) {
layer.msg('请先选择数据', {icon: 0, timeout: 3000});
return;
} else if (busId.length == 1) {
busId = busId[0];
} else {
busId = busId.toString();
}
authorizationIndex(busId)
})
var cols = []
if (!mode) {
cols.push({
type: 'checkbox'
})
}
cols = cols.concat([{
type: 'numbers', title: '序号', align: 'center', width: 70
}, {
field: 'busTypeName', title: '名称', align: 'left',
templet:
'<div>' +
' <span' +
' data-code="{{d.busTypeCode}}"' +
' class="layui-table-link btn-bustype-edit">{{d.busTypeName}}' +
' </span>' +
'</div>'
}, {
field: 'nickname', title: '负责人', align: 'center'
}, {
field: 'busTypeDesc', title: '业务类型描述', align: 'left'
}, {
field: 'isUse', title: '是否使用', align: 'center', width: 120,
templet: function (d) {
switch (d.isUse) {
case 0:
return '否';
case 1:
return '是';
default:
return '';
}
}
}, {
field: 'important', title: '重要程度', align: 'center', width: 120,
templet: function (d) {
switch (d.important) {
case 1:
return '核心';
case 2:
return '重要';
case 3:
return '一般';
case 9:
return '虚拟业务';
default:
return '';
}
}
}, {
field: 'sort', title: '排序', align: 'right', width: 120,
}])
if (!mode) {
cols.push({
title: '操作', align: 'center', fixed: 'right', width: '10%',
templet: function (d) {
if (d.isLeaf) {
return '' +
'<div>' +
'<button data-id="' + d.busId + '" lay-tips="删除" type="button" class="layui-btn layui-btn-xs layui-btn-normal btn-bustype-delete"><i class="layui-icon layui-icon-delete"></i></button>' +
'<button data-id="' + d.busId + '" lay-tips="资源分配" type="button" class="layui-btn layui-btn-xs layui-btn-normal btn-bustype-res-config"><i class="layui-icon layui-icon-menu-fill"></i></button>' +
'<button data-id="' + d.busId + '" lay-tips="授权" type="button" class="layui-btn layui-btn-xs layui-btn-normal btn-bustype-authorize"><i class="layui-icon layui-icon-auz"></i></button>' +
'<button data-id="' + d.busId + '" lay-tips="乙方运维配置" type="button" class="layui-btn layui-btn-xs layui-btn-normal btn-bustype-yf-config"><i class="layui-icon layui-icon-auz"></i></button>' +
'</div>'
} else {
return '' +
'<div class="layui-row">' +
'<button data-id="' + d.busId + '" lay-tips="删除" type="button" class="layui-btn layui-btn-xs layui-btn-normal btn-bustype-delete"><i class="layui-icon layui-icon-delete"></i></button>' +
'<button data-id="' + d.busId + '" lay-tips="授权" type="button" class="layui-btn layui-btn-xs layui-btn-normal btn-bustype-authorize"><i class="layui-icon layui-icon-auz"></i></button>' +
'</div>'
}
}
});
} else {
cols.push({field: 'showType', title: '展示类型', align: 'center',sort:true,width:210,
templet: function (d) {
if(d.parentId == '0' && dataBusType.indexOf(d.busId)>-1){
return '';
}else{
//初始化select内容
var html='<div><select lay-ignore data-index="99" name="showType" class="layui-input resourceType_showType" style="min-width: 150px;display:inline">';
$.each(showTypeList,function (i,v) {
if(d.showType == v.value){
html += '<option value="' + v.value + '" selected>' + v.name + '</option> '
}else{
html += '<option value="' + v.value + '">' + v.name + '</option> '
}
});
html+='</select></div>';
return html;
}
}
});
cols.push({
title: '操作', align: 'center', fixed: 'right', width: '10%',
templet: function (d) {
if (d.userCount) {
return '' +
'<div class="layui-row">' +
'<button data-id="' + d.busId + '" type="button" class="layui-btn layui-btn-xs btn-bustype-bind hide" lay-tips="未授权,点击授权"><i class="layui-icon layui-icon-link"></i> 添加授权</button>' +
'<button data-id="' + d.busId + '" type="button" style="margin-left: 0" class="layui-btn layui-btn-xs layui-btn-danger btn-bustype-unbind" lay-tips="已授权,点击解除授权"><i class="layui-icon layui-icon-unlink"></i> 解除授权</button>' +
'</div>';
} else {
return '' +
'<div class="layui-row">' +
'<button data-id="' + d.busId + '" type="button" class="layui-btn layui-btn-xs btn-bustype-bind" lay-tips="未授权,点击授权"><i class="layui-icon layui-icon-link"></i> 添加授权</button>' +
'<button data-id="' + d.busId + '" type="button" style="margin-left: 0" class="layui-btn layui-btn-xs layui-btn-danger btn-bustype-unbind hide" lay-tips="已授权,点击解除授权"><i class="layui-icon layui-icon-unlink"></i> 解除授权</button>' +
'</div>';
}
}
});
}
/**
* 加载业务类型表格
*/
function loadBusTypeTable() {
conditions = {
busTypeName: $('#condition-bustype-name').val() ? $('#condition-bustype-name').val().trim() : '',
access_token: accessToken,
cutoverId: cutoverId,
targetType: targetType,
username: username,
page: -1,
limit: -1
};
conditions.limit = -1;
admin.req({
url: domainName + '/api-web/manage/bustype/page',
data: conditions
}).done(function (response) {
$.each(response.data,function (i,v) {
dataBusType.push(v.parentId);
})
// 设置总数
$('#span-bustype-total').html('共 ' + response.data.length + ' 个业务');
// 渲染表格
busTypeTable = treeTable.render({
elem: '#bustype-table',
data: response.data,
page: {
layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'],
theme: '#1E9FFF'
},
tree: {
iconIndex: mode ? 1 : 2, // 折叠图标显示在第几列
isPidData: true, // 是否是id、pid形式数据
idName: 'busId', // id字段名称
pidName: 'parentId', // pid字段名称
onlyIconControl: true // 仅允许点击图标折叠
},
cols: cols
});
//回填数据
if (data && data.username) {
if (data.username.length == 1) {
$.ajax({
type: "get",
url: domainName + "/api-web/manage/bustype/getBusTypeByUser?access_token=" + accessToken + "&username=" + data.username[0],
success: function (res) {
if (res && res.success) {
var busTypeData = res.data;
busTypeTable.setChecked(busTypeData.map(item => item.busId))
}
},
})
}
}
// 点击编号编辑事件
$('.btn-bustype-edit').click(function () {
if ($.inArray('back:bustype:update', checkList) == -1) {
layer.msg('暂无权限!', {icon: 7, time: 3000});
return;
}
var busTypeCode = $(this).data('code');
saveBusType(busTypeCode);
});
// 删除事件
$('.btn-bustype-delete').click(function () {
var busId = $(this).data('id');
deleteBusTypeByIds([busId]);
});
// 授权事件
$('.btn-bustype-authorize').click(function () {
loading = layer.load(2);
var busId = $(this).data('id')
authorizationIndex(busId)
});
// 乙方运维配置
$('.btn-bustype-yf-config').click(function () {
// TODO
layer.open({
type: 2
,title: "乙方运维配置"
,closeBtn: false
,area: ['80%', '60%']
,shade: 0.8
, btn:["关闭"]
,id: 'operationMaintenance-config' //设定一个id,防止重复弹出
,content:`/vue3/index.html#/operationMaintenance/config`
,yes: function(index, layero){
layer.closeAll();
return false;
}
});
});
$('.btn-bustype-bind').unbind('click').on('click', function () {
var $this = $(this);
var busId = $this.data('id')
layer.load(2);
admin.req({
url: domainName + '/api-web/manage/bustype/bindUser/' + busId,
data: {username},
success(response) {
layer.closeAll('loading');
if (response && response.success) {
$this.addClass('hide');
$this.parent().find('.btn-bustype-unbind').removeClass('hide')
var $child = $('tr[data-pid="' + busId + '"] .btn-bustype-bind');
$child.addClass('hide')
$child.parent().find('.btn-bustype-unbind').removeClass('hide')
} else {
layer.msg('授权失败!', {icon: 2});
}
},
error() {
layer.closeAll('loading');
}
})
});
$('.btn-bustype-unbind').unbind('click').on('click', function () {
var $this = $(this);
var busId = $this.data('id')
layer.load(2);
admin.req({
url: domainName + '/api-web/manage/bustype/unBindUser/' + busId,
data: {username},
success(response) {
layer.closeAll('loading');
if (response && response.success) {
$this.addClass('hide');
$this.parent().find('.btn-bustype-bind').removeClass('hide')
} else {
layer.msg('取消授权失败!', {icon: 2});
}
},
error() {
layer.closeAll('loading');
}
})
});
// 资源分配事件
// $('.btn-bustype-res-config').click(function () {
// var busId = $(this).data('id');
// var bustypeReslist = layui.reslist({busId: busId, idSuffix: 1})
// // 展示资源页面layerindex
// var bustypeReslayerIndex;
// common.openWin("template/res/reslist", "当前绑定的资源", {busId: busId, idSuffix: 1}, ["完成", "取消"], function () {
// layer.close(bustypeReslayerIndex);
// }, null, ['80%', '90%'],
// function (layero, layerIndex) {
// bustypeReslayerIndex = layerIndex;
// // 新增按钮
// $("#bustype-reslist-add").click(function () {
// var reslist = layui.reslist();
// // 添加绑定页面的layerindex
// var addResLayerIndex;
// common.openWin("template/res/reslist", "添加绑定", {}, ["添加", "取消"], function () {
// loading = layer.load(2);
// // 当前选中的资源
// var checks = reslist.getData();
// // 之前已经选择过的资源
// var oldResIdList = [];
// admin.req({
// url: domainName + '/api-web/manage/bustype/resourceList/' + busId,
// async: false,
// error: function () {
// layer.close(loading);
// }
// }).done(function (response) {
// $.each(response.data, function (index, value) {
// oldResIdList.push(value.resId);
// });
// });
// // 需要进行插入的资源
// var inserts = [];
// var insertCount = 0;
// var isExistCount = 0;
// $.each(checks, function (index, value) {
// if (oldResIdList.indexOf(value.resId) === -1) {
// inserts.push(value.resId);
// insertCount++;
// } else {
// isExistCount++;
// }
// });
// if (inserts.length === 0) {
// layer.msg('所选的都已存在,无需重复添加!', {icon: 7, time: 5000});
// layer.close(loading);
// return;
// }
// // 发送请求添加绑定
// admin.req({
// url: domainName + '/api-web/manage/bustype/addResource/' + busId + '?access_token=' + accessToken,
// type: 'POST',
// contentType: 'application/json',
// data: JSON.stringify(inserts),
// error: function () {
// layer.close(loading);
// }
// }).done(function (response) {
// layer.close(loading);
// if (response.success) {
// layer.msg('添加绑定成功!此次添加了' + insertCount + '个新资源' + (isExistCount > 0 ? ',有' + isExistCount + '个已经存在。' : ''), {icon: 1, time: 5000});
// layer.close(addResLayerIndex);
// bustypeReslist.reloadResTable();
// } else {
// layer.msg('添加绑定失败!', {icon: 2, time: 3000});
// }
// });
// }, null, ['90%', '80%'], function (layero, layerIndex) {
// addResLayerIndex = layerIndex
// });
// });
// // 取消绑定按钮
// $("#bustype-reslist-unbind").click(function () {
// // 需要取消绑定的资源id集合
// var deletes = [];
// $.each(bustypeReslist.getData(), function (index, value) {
// deletes.push(value.resId);
// });
// admin.req({
// url: domainName + '/api-web/manage/bustype/deleteResource/' + busId + '?access_token=' + accessToken,
// type: 'POST',
// contentType: 'application/json',
// data: JSON.stringify(deletes)
// }).done(function (response) {
// if (response.success) {
// layer.msg('取消绑定成功!', {icon: 1, time: 3000});
// bustypeReslist.reloadResTable();
// } else {
// layer.msg('取消绑定失败!', {icon: 2, time: 3000});
// }
// });
// });
// });
// });
//资源分配
$('.btn-bustype-res-config').click(function () {
if ($.inArray('back:bustype:resource', checkList) == -1) {
layer.closeAll();
layer.msg('暂无权限!', {icon: 7, time: 3000});
return;
}
var busId = $(this).data('id');
layer.open({
title: '当前绑定的资源',
type: 1,
content: $('#bustype-reslist-table').html(),
btn: ['完成'],
area: ['80%', '90%'],
success: function () {
// 表格
var resType = 'all';
$("#bustype_reslist_resListBizTypes").attr("disabled",true);
form.render();
//绑定业务下拉选择数据
common.bizTypeSelect("bustype_reslist_resListBizTypes",function () {
$("#bustype_reslist_resListBizTypes").val(busId);
form.render("select");
});
//绑定资源类型下拉选择
common.resTypeSelect("bustype_reslist_restype",function () {
form.render("select");
});
//回车搜索
$('#bustype_reslist_keyword').keydown(function (e) {
if (e.keyCode === 13) {
reloadTable(resType);
}
});
//选择框搜索事件
bindSelectEvent();
//渲染表格
table.render({
elem: '#bustype_reslist_resListTable'
, url: common.domainName + '/api-web/home/res-list/' + resType
, where: {
access_token: accessToken,
resName: $("#bustype_reslist_keyword").val(),
busId: busId,
resHealth: $("#bustype_reslist_resStatus").val()
}
, height: 'full-300'
, cellMinWidth: 80
, page: {
layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
, theme: '#1E9FFF'
}
, limit: common.limit
, limits: common.limits
, cols: [[
{type: 'checkbox'},
{type: 'numbers', title: '序号', align: 'center'}
, {field: 'resName', title: '资源名称', minWidth: 300, align: 'center'}
, {field: 'ip', title: 'IP地址', align: 'center'}
, {field: 'admin', title: '负责人', align: 'center'}
, {field: 'resTypeName', title: '资源类型', align: 'center'}
, {field: 'healthDesc', title: '资源状态', align: 'center'}
]]
});
//绑定下拉搜索事件
function bindSelectEvent() {
// 资源状态
form.on('select(bustype_reslist_resStatus)', function(data){
reloadTable(resType);
});
// 资源类型
form.on('select(bustype_reslist_restype)', function(data){
resType = data.value;
reloadTable(resType);
});
}
//刷新表格
function reloadTable(resType) {
table.reload('bustype_reslist_resListTable', {
url: common.domainName + '/api-web/home/res-list/' + (resType ? resType : 'all'),
where: {
access_token: accessToken,
resName: $("#bustype_reslist_keyword").val(),
busId: busId,
resHealth: $("#bustype_reslist_resStatus").val()
}
});
}
// 新增按钮
$("#bustype-reslist-add").click(function () {
var reslist = layui.reslist();
// 添加绑定页面的layerindex
var addResLayerIndex;
common.openWin("template/res/reslist", "添加绑定", {}, ["添加", "取消"], function () {
loading = layer.load(2);
// 当前选中的资源
var checks = reslist.getData();
if (checks.length ==0) {
layer.msg('请先选择资源后,再进行添加!', {icon: 7, time: 3000});
layer.close(loading);
return;
}
// 之前已经选择过的资源
var oldResIdList = [];
admin.req({
url: domainName + '/api-web/manage/bustype/resourceList/' + busId,
async: false,
error: function () {
layer.close(loading);
}
}).done(function (response) {
$.each(response.data, function (index, value) {
oldResIdList.push(value.resId);
});
});
// 需要进行插入的资源
var inserts = [];
var insertCount = 0;
var isExistCount = 0;
var resTypes=[];
var parentIds=[];
$.each(checks, function (index, value) {
if (oldResIdList.indexOf(value.resId) === -1) {
resTypes.push(value.resType);
parentIds.push(value.parentId);
inserts.push(value.resId);
insertCount++;
} else {
isExistCount++;
}
});
if (inserts.length === 0) {
layer.msg('所选的都已存在,无需重复添加!', {icon: 7, time: 5000});
layer.close(loading);
return;
}
var ArrIndex=[];
if(resTypes.length>0){
var identify=0;
$.each(resTypes,function (i,v) {
if(v=='MIDDLEWARE_WEBLOGIC' && parentIds[i]==''){
identify=1;
ArrIndex.push(i);
}
});
if(identify==1){
//询问框
layer.confirm('选择的资源中包含weblogic控制台,是否将控制台下的服务一起分配到当前业务下?', {
btn: ['是','否'] //按钮
}, function(){//是
//获得控制台下所有服务的resID
//如果选择将控制台下的服务一起分配到当前业务下
var arrResIds=[];
$.each(ArrIndex,function (i,v) {
arrResIds.push(inserts[v]);
})
var map={
resIds: arrResIds.toString()
};
admin.req({
url: common.domainName + '/api-web/bResource/resourceByResId?access_token='+accessToken,
type:'post',
data:JSON.stringify(map),
contentType: "application/json;charset=utf-8",
async:false,
error: function () {
layer.msg('获取控制台下所有服务失败', {icon: 2});
layer.close(layer.index);
}
}).done(function (response) {
if(response.success && response.data && response.data.length>0){
$.each(response.data,function (i,v) {
inserts.push(v.resId);
insertCount++;
});
}
inserts=Array.from(new Set(inserts));
isExistCount = insertCount-inserts;
add(addResLayerIndex,inserts,busId,insertCount,isExistCount,resType);
layer.close(layer.index);
})
}, function(){//否
add(addResLayerIndex,inserts,busId,insertCount,isExistCount,resType);
layer.close(layer.index);
});
}else{
add(addResLayerIndex,inserts,busId,insertCount,isExistCount,resType);
}
}
}, null, ['90%', '80%'], function (layero, layerIndex) {
addResLayerIndex = layerIndex
});
});
// 取消绑定按钮
$("#bustype-reslist-unbind").click(function () {
// 需要取消绑定的资源id集合
var deletes = [];
var resTypes=[];
var parentIds=[];
$.each(table.checkStatus('bustype_reslist_resListTable').data, function (index, value) {
deletes.push(value.resId);
resTypes.push(value.resType);
parentIds.push(value.parentId);
});
if(deletes.length<1){
layer.msg('请选择要解除绑定的数据!', {icon: 7, time: 3000});
layer.close(loading);
return;
}
var ArrIndex=[];
if(resTypes.length>0){
var identify=0;
$.each(resTypes,function (i,v) {
if(v=='MIDDLEWARE_WEBLOGIC' && parentIds[i]==''){
identify=1;
ArrIndex.push(i);
}
});
if(identify==1){
//询问框
layer.confirm('选择的资源中包含weblogic控制台,是否将控制台下的服务一起取消?', {
btn: ['是','否'] //按钮
}, function(){//是
//获得控制台下所有服务的resID
//如果选择将控制台下的服务一起取消
var arrResIds=[];
$.each(ArrIndex,function (i,v) {
arrResIds.push(deletes[v]);
})
var map={
resIds: arrResIds.toString()
};
admin.req({
url: common.domainName + '/api-web/bResource/resourceByResId?access_token='+accessToken,
type:'post',
data:JSON.stringify(map),
contentType: "application/json;charset=utf-8",
async:false,
error: function () {
layer.msg('获取控制台下所有服务失败', {icon: 2});
layer.close(layer.index);
}
}).done(function (response) {
if(response.success && response.data && response.data.length>0){
$.each(response.data,function (i,v) {
deletes.push(v.resId);
});
}
deletes=Array.from(new Set(deletes));
del(busId,deletes,resType);
layer.close(layer.index);
})
}, function(){//否
del(busId,deletes,resType);
layer.close(layer.index);
});
}else{
del(busId,deletes,resType);
}
}
});
},
yes: function (index) {
layer.close(index);
}
});
});
});
}
//授权页面
function authorizationIndex(busId) {
if ($.inArray('back:bustype:impower', checkList) == -1) {
layer.closeAll();
layer.msg('暂无权限!', {icon: 7, time: 3000});
return;
}
var params = {
oldUsers: [],
bindUrl: '/api-web/manage/bustype/bindUser/' + busId,
unBindUrl: '/api-web/manage/bustype/unBindUser/' + busId
};
// 获取当前资源类型的权限用于回显
admin.req({
url: domainName + '/api-web/manage/bustype/getUsersByBusId',
async: false,
data: {
busId: busId
}
}).done(function (response) {
$.each(response.data, function (index, value) {
params.oldUsers.push(value.userAccount);
})
return false;
});
layer.close(loading);
var userlist;
layer.open({
title: '授权',
id: 'busType-role-config-layer',
type: 1,
area: ['80%', '90%'],
btn: ['关闭'],
scrollbar: false,
success: function () {
view(this.id).render('/template/user/userlist').done(function () {
userlist = layui.userlist(params);
});
},
yes: function (index, layero) {
layer.close(index);
}
});
}
// 新增按钮
$('#bustype-create').click(function () {
if ($.inArray('back:bustype:save', checkList) == -1) {
layer.msg('暂无权限!', {icon: 7, time: 3000});
return;
}
saveBusType();
});
// 刷新表格按钮
$('#btn-bustype-reload-table').click(function () {
loadBusTypeTable();
});
/**
* 新增或者编辑业务类型
*
* @param busTypeCode 业务类型编号
*/
function saveBusType(busTypeCode) {
// 打开(新增/编辑)窗口
common.openWin('/baseconfig/bustype/add', '<a class="layui-icon layui-icon-edit win_title_icon"></a>' + busTypeCode ? '编辑' : '新增',
{busTypeCode: busTypeCode}, ['保存', '取消'], function () {
$('#btn-bustype-submit').click();
}, null, ['40%', 'auto']);
}
function deleteBusTypeByIds(busIds) {
if ($.inArray('back:bustype:delete', checkList) == -1) {
layer.msg('暂无权限!', {icon: 7, time: 3000});
return;
}
if (busIds.length == 0) {
layer.msg('请先选择数据,再点击删除。', {icon: 0, timeout: 3000});
return;
}
layer.confirm('确认要删除吗?', {icon: 3, title: '提示'}, function () {
loading = layer.load(2);
admin.req({
url: domainName + '/api-web/manage/bustype/deleteByIds?access_token=' + accessToken,
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(busIds),
success: function () {
layer.close(loading);
},
error: function () {
layer.close(loading);
}
}).done(function (response) {
if (response.success) {
layer.msg('删除成功!', {icon: 1, time: 3000});
loadBusTypeTable();
} else {
layer.msg('删除失败!', {icon: 2, time: 3000});
}
});
});
}
//添加绑定
function add(addResLayerIndex,inserts,busId,insertCount,isExistCount,resType) {
// 发送请求添加绑定
admin.req({
url: domainName + '/api-web/manage/bustype/addResource/' + busId + '?access_token=' + accessToken,
type: 'POST',
async: false,
contentType: 'application/json',
data: JSON.stringify(inserts),
error: function () {
layer.close(layer.index);
}
}).done(function (response) {
layer.close(loading);
if (response.success) {
layer.msg('添加绑定成功!此次添加了' + insertCount + '个新资源' + (isExistCount > 0 ? ',有' + isExistCount + '个已经存在。' : ''), {icon: 1, time: 5000});
layer.close(addResLayerIndex);
reloadTable(resType,busId);
} else {
layer.msg('添加绑定失败!', {icon: 2, time: 3000});
}
});
}
//取消绑定
function del(busId,deletes,resType) {
admin.req({
url: domainName + '/api-web/manage/bustype/deleteResource/' + busId + '?access_token=' + accessToken,
type: 'POST',
async: false,
contentType: 'application/json',
data: JSON.stringify(deletes)
}).done(function (response) {
if (response.success) {
layer.msg('取消绑定成功!', {icon: 1, time: 3000});
reloadTable(resType,busId);
} else {
layer.msg('取消绑定失败!', {icon: 2, time: 3000});
}
});
}
//获取展示类型的字典数据
function initShowType(){
if(mode){//如果不展示字段就不去请求
admin.req({
url: domainName + '/api-web/manage/ddic/findSucDdics/DETAILS_POWER'
, method: 'POST'
, async: false
, success: function (res) {
$.each(res.data, function (i, v) {
showTypeList.push({
name: v.ddicName
,value: v.ddicCode.substring(v.ddicCode.lastIndexOf("_")+1,v.ddicCode.length)
})
});
}
});
}
}
//刷新表格
function reloadTable(resType,busId) {
table.reload('bustype_reslist_resListTable', {
url: common.domainName + '/api-web/home/res-list/' + (resType ? resType : 'all'),
where: {
access_token: accessToken,
resName: $("#bustype_reslist_keyword").val(),
busId: busId,
resHealth: $("#bustype_reslist_resStatus").val()
}
});
}
//获取选中的数据
function getCheckData() {
if(mode){
//获取改变的值
var str='';
var $tr=$('#bustype-table').next().find('tbody tr');
$.each($tr,function (i,v) {
var $btn=$(this).find('.btn-bustype-unbind');
var showType=$(this).find('.resourceType_showType') && $(this).find('.resourceType_showType').eq(0) && $(this).find('.resourceType_showType').eq(0).val() ? $(this).find('.resourceType_showType').eq(0).val():'<';
if(!$btn.hasClass('hide')){
str += $btn.attr("data-id")+'_'+showType+',';
}
});
if(str!=''){
str=str.substring(0,str.length-1);
}
return str;
}else{
return busTypeTable.checkStatus(false);
}
}
return {getData: getCheckData};
});
});
... ...
... ... @@ -7,12 +7,17 @@
<div id="score" style="width: 600px;height:400px;"></div>
</el-col>
</el-row>
<div style="display: flex;flex-wrap: nowrap">
<div>
<cm-dialog :title="title" width="60%" :showDialogVisible="dialogVisible" :showFooter="true">
</div>
</div>
<cm-dialog :title="title" width="60%" :showDialogVisible="dialogVisible" :showFooter="true" @hidedialog="closeDetail" :showOkBtn="false">
<template v-slot>
<cm-table-page :columns="columns" :dataList="dataList" @loaddata="getPage" :showIndex="true"
:showBorder="true"
:showPage="false" :height="(height - 54)/3"></cm-table-page>
:showPage="false" :height="height - 100"></cm-table-page>
</template>
</cm-dialog>
... ...
... ... @@ -26,13 +26,12 @@ export default {
let title = Vue.ref('');
let dataList = Vue.ref([]);
let columns = Vue.ref([{
prop: 'item',
label: '分类',
sortable: true,
},{
prop: 'score',
prop: 'standardScore',
label: '分值',
sortable: true,
},{
... ... @@ -40,7 +39,7 @@ export default {
label: '打分人',
sortable: true,
},{
prop: 'nickname',
prop: 'score',
label: '得分',
sortable: true,
},{
... ... @@ -101,20 +100,26 @@ export default {
}
let detail = (v) =>{
let name = v.name;
let month = parseInt(name)
title.value = name + "各项评分";
dialogVisible.value = true
// let params = {
// projectId: props.projectId,
// year: props.treeNode.label
// }
// proxy.$http.get("/api-web/bOpsScore/bOpsScoreDetails", params, function (res) {
//
// });
let params = {
projectId: props.projectId,
opsYear: props.treeNode.label,
opsMonth:month
}
proxy.$http.post("/api-web/bOpsScoreDetails/page", params, function (res) {
if(res && res.code == 0){
closeDetail(true);
dataList.value = res.data;
}
});
}
let closeDetail = (flg) => {
dialogVisible.value = flg
}
// 柱状图
... ... @@ -175,7 +180,8 @@ export default {
title,
dialogVisible,
columns,
dataList
dataList,
closeDetail
}
}
}
... ...
... ... @@ -61,19 +61,14 @@
</el-form-item>
</el-col>
<el-col :span="8">
<el-image style="width: 200px; height: 200px" :src="ruleForm.headImgUrl"></el-image>
<el-image style="width: 200px; height: 200px" :src="imageUrl"></el-image>
<el-upload
class="upload-demo"
:show-file-list="false"
action=""
:on-preview="handlePreview"
:on-remove="handleRemove"
:before-remove="beforeRemove"
:http-request="uploadFile"
multiple
:limit="3"
:on-exceed="handleExceed"
>
:before-upload="beforeAvatarUpload"
:multiple="false"
:http-request="getFile"
:auto-upload="true">
<el-button size="small" type="primary">上传照片</el-button>
</el-upload>
</el-col>
... ...
... ... @@ -23,6 +23,7 @@ export default {
let height = Vue.ref(window.innerHeight - 130);
const {proxy} = Vue.getCurrentInstance();
let imageUrl = Vue.ref('');
let ruleForm = Vue.ref({
nickname: '',
... ... @@ -66,6 +67,31 @@ export default {
});
}
let getFile = (param) =>{
let fileObj = param.file
getBase64(fileObj).then(res => {
console.log(res)
});
imageUrl.value = URL.createObjectURL(fileObj)
}
let beforeAvatarUpload = (file) =>{
const isJPG = file.type.indexOf('image/') != -1
if (!isJPG) {
proxy.$global.showMsg('您上传的不是图片文件,请选择图片!','error');
}
return isJPG
}
// // 挂载完
Vue.onMounted(() => {
getPage();
... ... @@ -77,8 +103,11 @@ export default {
});
return {
imageUrl,
ruleForm,
saveUser
saveUser,
getFile,
beforeAvatarUpload,
}
}
}
... ...