Authored by 王涛

Merge branch 'master-mj-yuanjinpengnew' into 'master-mj'

fix:山西特色功能优化、日志视图迁移、巡检统计、选件归档迁移



See merge request !1115
Showing 22 changed files with 2315 additions and 73 deletions
... ... @@ -264,7 +264,36 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect
})
} else {
//附件为文档类型
common.fileviewer(filepath)
var loadIndex = layer.load(1, {shade: [0.3], content: ''});
let name = Base64.encode(filepath, true);
admin.req({
url: domainName + `/api-web/openoffice/convertPdfMJ?pathBase64=${name}`,
type: 'get'
}).done(function (res) {
layer.close(loadIndex);
if (res && res.success) {
let win = window.parent;
if (win) {
window.parent.postMessage({
type: "previewFile",
message: {
params: {
url: res.str
}
}
}, '*')
}
} else {
layer.confirm("文档不支持预览,是否下载!", function () {
const url = domainName + `/api-web/openoffice/download/${id}?accessToken=${accessToken}`;
window.open(url)
});
layer.close(loadIndex);
}
}).error(function (error) {
layer.close(loadIndex);
console.log(error)
})
}
})
}
... ...
... ... @@ -75,7 +75,36 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions'], function
})
} else {
//附件为文档类型
common.fileviewer(filepath)
var loadIndex = layer.load(1, {shade: [0.3], content: ''});
let name = Base64.encode(filepath, true);
admin.req({
url: domainName + `/api-web/openoffice/convertPdfMJ?pathBase64=${name}`,
type: 'get'
}).done(function (res) {
layer.close(loadIndex);
if (res && res.success) {
let win = window.parent;
if (win) {
window.parent.postMessage({
type: "previewFile",
message: {
params: {
url: res.str
}
}
}, '*')
}
} else {
layer.confirm("文档不支持预览,是否下载!", function () {
const url = domainName + `/api-web/openoffice/download/${id}?accessToken=${accessToken}`;
window.open(url)
});
layer.close(loadIndex);
}
}).error(function (error) {
layer.close(loadIndex);
console.log(error)
})
}
})
... ...
... ... @@ -313,7 +313,36 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect
})
} else {
//附件为文档类型
common.fileviewer(filepath)
var loadIndex = layer.load(1, {shade: [0.3], content: ''});
let name = Base64.encode(filepath, true);
admin.req({
url: domainName + `/api-web/openoffice/convertPdfMJ?pathBase64=${name}`,
type: 'get'
}).done(function (res) {
layer.close(loadIndex);
if (res && res.success) {
let win = window.parent;
if (win) {
window.parent.postMessage({
type: "previewFile",
message: {
params: {
url: res.str
}
}
}, '*')
}
} else {
layer.confirm("文档不支持预览,是否下载!", function () {
const url = domainName + `/api-web/openoffice/download/${id}?accessToken=${accessToken}`;
window.open(url)
});
layer.close(loadIndex);
}
}).error(function (error) {
layer.close(loadIndex);
console.log(error)
})
}
})
}
... ...
... ... @@ -76,7 +76,36 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions'], function
})
} else {
//附件为文档类型
common.fileviewer(filepath)
var loadIndex = layer.load(1, {shade: [0.3], content: ''});
let name = Base64.encode(filepath, true);
admin.req({
url: domainName + `/api-web/openoffice/convertPdfMJ?pathBase64=${name}`,
type: 'get'
}).done(function (res) {
layer.close(loadIndex);
if (res && res.success) {
let win = window.parent;
if (win) {
window.parent.postMessage({
type: "previewFile",
message: {
params: {
url: res.str
}
}
}, '*')
}
} else {
layer.confirm("文档不支持预览,是否下载!", function () {
const url = domainName + `/api-web/openoffice/download/${id}?accessToken=${accessToken}`;
window.open(url)
});
layer.close(loadIndex);
}
}).error(function (error) {
layer.close(loadIndex);
console.log(error)
})
}
})
... ...
/**
@Name:dropdown 下拉菜单组件
@License:MIT
*/
layui.define(['jquery', 'laytpl','lay'], function(exports){
"use strict";
var $ = layui.$
,laytpl = layui.laytpl
,hint = layui.hint()
,device = layui.device()
,clickOrMousedown = (device.mobile ? 'click' : 'mousedown')
//模块名
,MOD_NAME = 'dropdown'
,MOD_INDEX = 'layui_'+ MOD_NAME +'_index' //模块索引名
//外部接口
,dropdown = {
config: {}
,index: layui[MOD_NAME] ? (layui[MOD_NAME].index + 10000) : 0
//设置全局项
,set: function(options){
var that = this;
that.config = $.extend({}, that.config, options);
return that;
}
//事件
,on: function(events, callback){
return layui.onevent.call(this, MOD_NAME, events, callback);
}
}
//操作当前实例
,thisModule = function(){
var that = this
,options = that.config
,id = options.id;
thisModule.that[id] = that; //记录当前实例对象
return {
config: options
//重置实例
,reload: function(options){
that.reload.call(that, options);
}
}
}
//字符常量
,STR_ELEM = 'layui-dropdown', STR_HIDE = 'layui-hide', STR_DISABLED = 'layui-disabled', STR_NONE = 'layui-none'
,STR_ITEM_UP = 'layui-menu-item-up', STR_ITEM_DOWN = 'layui-menu-item-down', STR_MENU_TITLE = 'layui-menu-body-title', STR_ITEM_GROUP = 'layui-menu-item-group', STR_ITEM_PARENT = 'layui-menu-item-parent', STR_ITEM_DIV = 'layui-menu-item-divider', STR_ITEM_CHECKED = 'layui-menu-item-checked', STR_ITEM_CHECKED2 = 'layui-menu-item-checked2', STR_MENU_PANEL = 'layui-menu-body-panel', STR_MENU_PANEL_L = 'layui-menu-body-panel-left'
,STR_GROUP_TITLE = '.'+ STR_ITEM_GROUP + '>.'+ STR_MENU_TITLE
//构造器
,Class = function(options){
var that = this;
that.index = ++dropdown.index;
that.config = $.extend({}, that.config, dropdown.config, options);
that.init();
};
//默认配置
Class.prototype.config = {
trigger: 'click' //事件类型
,content: '' //自定义菜单内容
,className: '' //自定义样式类名
,style: '' //设置面板 style 属性
,show: false //是否初始即显示菜单面板
,isAllowSpread: true //是否允许菜单组展开收缩
,isSpreadItem: true //是否初始展开子菜单
,data: [] //菜单数据结构
,delay: 300 //延迟关闭的毫秒数,若 trigger 为 hover 时才生效
};
//重载实例
Class.prototype.reload = function(options){
var that = this;
that.config = $.extend({}, that.config, options);
that.init(true);
};
//初始化准备
Class.prototype.init = function(rerender){
var that = this
,options = that.config
,elem = options.elem = $(options.elem);
//若 elem 非唯一
if(elem.length > 1){
layui.each(elem, function(){
dropdown.render($.extend({}, options, {
elem: this
}));
});
return that;
}
//若重复执行 render,则视为 reload 处理
if(!rerender && elem[0] && elem.data(MOD_INDEX)){;
var newThat = thisModule.getThis(elem.data(MOD_INDEX));
if(!newThat) return;
return newThat.reload(options);
};
//初始化 id 参数
options.id = ('id' in options) ? options.id : that.index;
if(options.show) that.render(rerender); //初始即显示
that.events(); //事件
};
//渲染
Class.prototype.render = function(rerender){
var that = this
,options = that.config
,elemBody = $('body')
//默认菜单内容
,getDefaultView = function(){
var elemUl = $('<ul class="layui-menu layui-dropdown-menu"></ul>');
if(options.data.length > 0 ){
eachItemView(elemUl, options.data)
} else {
elemUl.html('<li class="layui-menu-item-none">no menu</li>');
}
return elemUl;
}
//遍历菜单项
,eachItemView = function(views, data){
//var views = [];
layui.each(data, function(index, item){
//是否存在子级
var isChild = item.child && item.child.length > 0
,isSpreadItem = ('isSpreadItem' in item) ? item.isSpreadItem : options.isSpreadItem
,title = item.templet
? laytpl(item.templet).render(item)
: (options.templet ? laytpl(options.templet).render(item) : item.title)
//初始类型
,type = function(){
if(isChild){
item.type = item.type || 'parent';
}
if(item.type){
return ({
group: 'group'
,parent: 'parent'
,'-': '-'
})[item.type] || 'parent';
}
return '';
}();
if(type !== '-' && (!item.title && !item.id && !isChild)) return;
//列表元素
var viewLi = $(['<li'+ function(){
var className = {
group: 'layui-menu-item-group'+ (
options.isAllowSpread ? (
isSpreadItem ? ' layui-menu-item-down' : ' layui-menu-item-up'
) : ''
)
,parent: STR_ITEM_PARENT
,'-': 'layui-menu-item-divider'
};
if(isChild || type){
return ' class="'+ className[type] +'"';
}
return '';
}() +'>'
//标题区
,function(){
//是否超文本
var viewText = ('href' in item) ? (
'<a href="'+ item.href +'" target="'+ (item.target || '_self') +'">'+ title +'</a>'
) : title;
//是否存在子级
if(isChild){
return '<div class="'+ STR_MENU_TITLE +'">'+ viewText + function(){
if(type === 'parent'){
return '<i class="layui-icon layui-icon-right"></i>';
} else if(type === 'group' && options.isAllowSpread){
return '<i class="layui-icon layui-icon-'+ (isSpreadItem ? 'up' : 'down') +'"></i>';
} else {
return '';
}
}() +'</div>'
}
return '<div class="'+ STR_MENU_TITLE +'">'+ viewText +'</div>';
}()
,'</li>'].join(''));
viewLi.data('item', item);
//子级区
if(isChild){
var elemPanel = $('<div class="layui-panel layui-menu-body-panel"></div>')
,elemUl = $('<ul></ul>');
if(type === 'parent'){
elemPanel.append(eachItemView(elemUl, item.child));
viewLi.append(elemPanel);
} else {
viewLi.append(eachItemView(elemUl, item.child));
}
}
views.append(viewLi);
});
return views;
}
//主模板
,TPL_MAIN = ['<div class="layui-dropdown layui-border-box layui-panel layui-anim layui-anim-downbit">'
,'</div>'].join('');
//如果是右键事件,则每次触发事件时,将允许重新渲染
if(options.trigger === 'contextmenu' || lay.isTopElem(options.elem[0])) rerender = true;
//判断是否已经打开了下拉菜单面板
if(!rerender && options.elem.data(MOD_INDEX +'_opened')) return;
//记录模板对象
that.elemView = $(TPL_MAIN);
that.elemView.append(options.content || getDefaultView());
//初始化某些属性
if(options.className) that.elemView.addClass(options.className);
if(options.style) that.elemView.attr('style', options.style);
//记录当前执行的实例索引
dropdown.thisId = options.id;
//插入视图
that.remove(); //移除非当前绑定元素的面板
elemBody.append(that.elemView);
options.elem.data(MOD_INDEX +'_opened', true);
//坐标定位
that.position();
thisModule.prevElem = that.elemView; //记录当前打开的元素,以便在下次关闭
thisModule.prevElem.data('prevElem', options.elem); //将当前绑定的元素,记录在打开元素的 data 对象中
//阻止全局事件
that.elemView.find('.layui-menu').on(clickOrMousedown, function(e){
layui.stope(e);
});
//触发菜单列表事件
that.elemView.find('.layui-menu li').on('click', function(e){
var othis = $(this)
,data = othis.data('item') || {}
,isChild = data.child && data.child.length > 0;
if(!isChild && data.type !== '-'){
that.remove();
typeof options.click === 'function' && options.click(data, othis);
}
});
//触发菜单组展开收缩
that.elemView.find(STR_GROUP_TITLE).on('click', function(e){
var othis = $(this)
,elemGroup = othis.parent()
,data = elemGroup.data('item') || {}
if(data.type === 'group' && options.isAllowSpread){
thisModule.spread(elemGroup);
}
});
//如果是鼠标移入事件,则鼠标移出时自动关闭
if(options.trigger === 'mouseenter'){
that.elemView.on('mouseenter', function(){
clearTimeout(thisModule.timer);
}).on('mouseleave', function(){
that.delayRemove();
});
}
};
//位置定位
Class.prototype.position = function(obj){
var that = this
,options = that.config;
lay.position(options.elem[0], that.elemView[0], {
position: options.position
,e: that.e
,clickType: options.trigger === 'contextmenu' ? 'right' : null
,align: options.align || null
});
};
//删除视图
Class.prototype.remove = function(){
var that = this
,options = that.config
,elemPrev = thisModule.prevElem;
//若存在已打开的面板元素,则移除
if(elemPrev){
elemPrev.data('prevElem') && (
elemPrev.data('prevElem').data(MOD_INDEX +'_opened', false)
);
elemPrev.remove();
}
};
//延迟删除视图
Class.prototype.delayRemove = function(){
var that = this
,options = that.config;
clearTimeout(thisModule.timer);
thisModule.timer = setTimeout(function(){
that.remove();
}, options.delay);
};
//事件
Class.prototype.events = function(){
var that = this
,options = that.config;
//如果传入 hover,则解析为 mouseenter
if(options.trigger === 'hover') options.trigger = 'mouseenter';
//解除上一个事件
if(that.prevElem) that.prevElem.off(options.trigger, that.prevElemCallback);
//记录被绑定的元素及回调
that.prevElem = options.elem;
that.prevElemCallback = function(e){
clearTimeout(thisModule.timer);
that.e = e;
that.render();
e.preventDefault();
//组件打开完毕的时间
typeof options.ready === 'function' && options.ready(that.elemView, options.elem, that.e.target);
};
//触发元素事件
options.elem.on(options.trigger, that.prevElemCallback);
//如果是鼠标移入事件
if(options.trigger === 'mouseenter'){
//直行鼠标移出事件
options.elem.on('mouseleave', function(){
that.delayRemove();
});
}
};
//记录所有实例
thisModule.that = {}; //记录所有实例对象
//获取当前实例对象
thisModule.getThis = function(id){
var that = thisModule.that[id];
if(!that) hint.error(id ? (MOD_NAME +' instance with ID \''+ id +'\' not found') : 'ID argument required');
return that;
};
//设置菜单组展开和收缩状态
thisModule.spread = function(othis){
//菜单组展开和收缩
var elemIcon = othis.children('.'+ STR_MENU_TITLE).find('.layui-icon');
if(othis.hasClass(STR_ITEM_UP)){
othis.removeClass(STR_ITEM_UP).addClass(STR_ITEM_DOWN);
elemIcon.removeClass('layui-icon-down').addClass('layui-icon-up');
} else {
othis.removeClass(STR_ITEM_DOWN).addClass(STR_ITEM_UP);
elemIcon.removeClass('layui-icon-up').addClass('layui-icon-down')
}
};
//全局事件
;!function(){
var _WIN = $(window)
,_DOC = $(document);
//自适应定位
_WIN.on('resize', function(){
if(!dropdown.thisId) return;
var that = thisModule.getThis(dropdown.thisId);
if(!that) return;
if(!that.elemView[0] || !$('.'+ STR_ELEM)[0]){
return false;
}
var options = that.config;
if(options.trigger === 'contextmenu'){
that.remove();
} else {
that.position();
}
});
//点击任意处关闭
_DOC.on(clickOrMousedown, function(e){
if(!dropdown.thisId) return;
var that = thisModule.getThis(dropdown.thisId)
if(!that) return;
var options = that.config;
//如果触发的是绑定的元素,或者属于绑定元素的子元素,则不关闭
//满足条件:当前绑定的元素不是 body document,或者不是鼠标右键事件
if(!(lay.isTopElem(options.elem[0]) || options.trigger === 'contextmenu')){
if(
e.target === options.elem[0] ||
options.elem.find(e.target)[0] ||
e.target === that.elemView[0] ||
(that.elemView && that.elemView.find(e.target)[0])
) return;
}
that.remove();
});
//基础菜单的静态元素事件
var ELEM_LI = '.layui-menu:not(.layui-dropdown-menu) li';
_DOC.on('click', ELEM_LI, function(e){
var othis = $(this)
,parent = othis.parents('.layui-menu').eq(0)
,isChild = othis.hasClass(STR_ITEM_GROUP) || othis.hasClass(STR_ITEM_PARENT)
,filter = parent.attr('lay-filter') || parent.attr('id')
,options = lay.options(this);
//非触发元素
if(othis.hasClass(STR_ITEM_DIV)) return;
//非菜单组
if(!isChild){
//选中
parent.find('.'+ STR_ITEM_CHECKED).removeClass(STR_ITEM_CHECKED); //清除选中样式
parent.find('.'+ STR_ITEM_CHECKED2).removeClass(STR_ITEM_CHECKED2); //清除父级菜单选中样式
othis.addClass(STR_ITEM_CHECKED); //添加选中样式
othis.parents('.'+ STR_ITEM_PARENT).addClass(STR_ITEM_CHECKED2); //添加父级菜单选中样式
//触发事件
layui.event.call(this, MOD_NAME, 'click('+ filter +')', options);
}
});
//基础菜单的展开收缩事件
_DOC.on('click', (ELEM_LI + STR_GROUP_TITLE), function(e){
var othis = $(this)
,elemGroup = othis.parents('.'+ STR_ITEM_GROUP +':eq(0)')
,options = lay.options(elemGroup[0]);
if(('isAllowSpread' in options) ? options.isAllowSpread : true){
thisModule.spread(elemGroup);
};
});
//判断子级菜单是否超出屏幕
var ELEM_LI_PAR = '.layui-menu .'+ STR_ITEM_PARENT
_DOC.on('mouseenter', ELEM_LI_PAR, function(e){
var othis = $(this)
,elemPanel = othis.find('.'+ STR_MENU_PANEL);
if(!elemPanel[0]) return;
var rect = elemPanel[0].getBoundingClientRect();
//是否超出右侧屏幕
if(rect.right > _WIN.width()){
elemPanel.addClass(STR_MENU_PANEL_L);
//不允许超出左侧屏幕
rect = elemPanel[0].getBoundingClientRect();
if(rect.left < 0){
elemPanel.removeClass(STR_MENU_PANEL_L);
}
}
//是否超出底部屏幕
if(rect.bottom > _WIN.height()){
elemPanel.eq(0).css('margin-top', -(rect.bottom - _WIN.height()));
};
}).on('mouseleave', ELEM_LI_PAR, function(e){
var othis = $(this)
,elemPanel = othis.children('.'+ STR_MENU_PANEL);
elemPanel.removeClass(STR_MENU_PANEL_L);
elemPanel.css('margin-top', 0);
});
}();
//重载实例
dropdown.reload = function(id, options){
var that = thisModule.getThis(id);
if(!that) return this;
that.reload(options);
return thisModule.call(that);
};
//核心入口
dropdown.render = function(options){
var inst = new Class(options);
return thisModule.call(inst);
};
exports(MOD_NAME, dropdown);
});
... ...
... ... @@ -57,7 +57,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect
});
}
//通知类型
form.on('radio(docType)', function (data) {
form.on('select(slt-docType)', function (data) {
if(data.value == '1'){
$("#period").show();
$("#backDiv").show();
... ... @@ -335,7 +335,36 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect
})
} else {
//附件为文档类型
common.fileviewer(filepath)
var loadIndex = layer.load(1, {shade: [0.3], content: ''});
let name = Base64.encode(filepath, true);
admin.req({
url: domainName + `/api-web/openoffice/convertPdfMJ?pathBase64=${name}`,
type: 'get'
}).done(function (res) {
layer.close(loadIndex);
if (res && res.success) {
let win = window.parent;
if (win) {
window.parent.postMessage({
type: "previewFile",
message: {
params: {
url: res.str
}
}
}, '*')
}
} else {
layer.confirm("文档不支持预览,是否下载!", function () {
const url = domainName + `/api-web/openoffice/download/${id}?accessToken=${accessToken}`;
window.open(url)
});
layer.close(loadIndex);
}
}).error(function (error) {
layer.close(loadIndex);
console.log(error)
})
}
})
}
... ... @@ -374,13 +403,17 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect
$("#backDiv").show();
$("#resultDiv").show();
}
$("input[type='radio'][name='docType'][value = '"+res.object.docType+"']").attr("checked",true);
/* $("input[type='radio'][name='docType'][value = '"+res.object.docType+"']").attr("checked",true);
$("input[type='radio'][name='docType']").attr('disabled','disabled');
$("input[type='radio'][name='docType']").attr('disabled','disabled');*/
//$("select[name='docType'][value = '"+res.object.docType+"']").attr("checked",true);
$("#slt-docType").attr('disabled','disabled');
form.render('select');
})
}else{
$("input[type='radio'][name='docType']").removeAttr('disabled');
$("#slt-docType").removeAttr('disabled');
form.render('select');
}
}
... ...
... ... @@ -76,7 +76,36 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions'], function
})
} else {
//附件为文档类型
common.fileviewer(filepath)
var loadIndex = layer.load(1, {shade: [0.3], content: ''});
let name = Base64.encode(filepath, true);
admin.req({
url: domainName + `/api-web/openoffice/convertPdfMJ?pathBase64=${name}`,
type: 'get'
}).done(function (res) {
layer.close(loadIndex);
if (res && res.success) {
let win = window.parent;
if (win) {
window.parent.postMessage({
type: "previewFile",
message: {
params: {
url: res.str
}
}
}, '*')
}
} else {
layer.confirm("文档不支持预览,是否下载!", function () {
const url = domainName + `/api-web/openoffice/download/${id}?accessToken=${accessToken}`;
window.open(url)
});
layer.close(loadIndex);
}
}).error(function (error) {
layer.close(loadIndex);
console.log(error)
})
}
})
... ...
... ... @@ -270,7 +270,36 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect
})
} else {
//附件为文档类型
common.fileviewer(filepath)
var loadIndex = layer.load(1, {shade: [0.3], content: ''});
let name = Base64.encode(filepath, true);
admin.req({
url: domainName + `/api-web/openoffice/convertPdfMJ?pathBase64=${name}`,
type: 'get'
}).done(function (res) {
layer.close(loadIndex);
if (res && res.success) {
let win = window.parent;
if (win) {
window.parent.postMessage({
type: "previewFile",
message: {
params: {
url: res.str
}
}
}, '*')
}
} else {
layer.confirm("文档不支持预览,是否下载!", function () {
const url = domainName + `/api-web/openoffice/download/${id}?accessToken=${accessToken}`;
window.open(url)
});
layer.close(loadIndex);
}
}).error(function (error) {
layer.close(loadIndex);
console.log(error)
})
}
})
}
... ...
... ... @@ -76,7 +76,36 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions'], function
})
} else {
//附件为文档类型
common.fileviewer(filepath)
var loadIndex = layer.load(1, {shade: [0.3], content: ''});
let name = Base64.encode(filepath, true);
admin.req({
url: domainName + `/api-web/openoffice/convertPdfMJ?pathBase64=${name}`,
type: 'get'
}).done(function (res) {
layer.close(loadIndex);
if (res && res.success) {
let win = window.parent;
if (win) {
window.parent.postMessage({
type: "previewFile",
message: {
params: {
url: res.str
}
}
}, '*')
}
} else {
layer.confirm("文档不支持预览,是否下载!", function () {
const url = domainName + `/api-web/openoffice/download/${id}?accessToken=${accessToken}`;
window.open(url)
});
layer.close(loadIndex);
}
}).error(function (error) {
layer.close(loadIndex);
console.log(error)
})
}
})
... ...
layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect', 'laydate', 'upload'], function (exports) {
var $ = layui.$;
var form = layui.form;
... ... @@ -161,7 +160,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect
var fileName = []
uploadInst = upload.render({
elem: '#attachment', //绑定元素
url: common.domainName + '/api-web/machineRoom/meetingApply/upload?accessToken='+accessToken,
url: common.domainName + '/api-web/machineRoom/meetingApply/upload?accessToken=' + accessToken,
data: param,
multiple: true,
auto: false, //选择文件后不自动上传
... ... @@ -171,9 +170,9 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect
choose: function (obj) {
//选择文件后回调
var files = this.files = obj.pushFile();
if(typeof(files)!=undefined){
if(Object.getOwnPropertyNames(files).length>2){
$("#attachment").attr("disabled","disabled");
if (typeof (files) != undefined) {
if (Object.getOwnPropertyNames(files).length > 2) {
$("#attachment").attr("disabled", "disabled");
layer.msg('目前最多支持上传三个文件!', {
icon: 7, time: 3000
});
... ... @@ -265,7 +264,38 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect
})
} else {
//附件为文档类型
common.fileviewer(filepath)
//common.fileviewer(filepath)
var loadIndex = layer.load(1, {shade: [0.3], content: ''});
let name = Base64.encode(filepath, true);
admin.req({
url: domainName + `/api-web/openoffice/convertPdfMJ?pathBase64=${name}`,
type: 'get'
}).done(function (res) {
layer.close(loadIndex);
if (res && res.success) {
let win = window.parent;
if (win) {
window.parent.postMessage({
type: "previewFile",
message: {
params: {
url: res.str
}
}
}, '*')
}
} else {
layer.confirm("文档不支持预览,是否下载!", function () {
const url = domainName + `/api-web/openoffice/download/${id}?accessToken=${accessToken}`;
window.open(url)
layer.close(loadIndex);
});
}
}).error(function (error) {
layer.close(loadIndex);
console.log(error)
})
}
})
}
... ...
... ... @@ -76,13 +76,42 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions'], function
})
} else {
//附件为文档类型
common.fileviewer(filepath)
var loadIndex = layer.load(1, {shade: [0.3], content: ''});
let name = Base64.encode(filepath, true);
admin.req({
url: domainName + `/api-web/openoffice/convertPdfMJ?pathBase64=${name}`,
type: 'get'
}).done(function (res) {
layer.close(loadIndex);
if (res && res.success) {
let win = window.parent;
if (win) {
window.parent.postMessage({
type: "previewFile",
message: {
params: {
url: res.str
}
}
}, '*')
}
} else {
layer.confirm("文档不支持预览,是否下载!", function () {
const url = domainName + `/api-web/openoffice/download/${id}?accessToken=${accessToken}`;
window.open(url)
layer.close(loadIndex);
});
}
}).error(function (error) {
layer.close(loadIndex);
console.log(error)
})
}
})
$('.attachment-download-btn').on('click',function () {
var id = $(this).data('id')
var suffix = $(this).data('suffix')
var url = domainName + `/api-web/openoffice/download/${id}?accessToken=` + accessToken
window.open(url)
})
... ...
layui.define(['tree', 'treeTable', 'table', 'form', 'laydate', 'admin', 'layer', 'laytpl', 'common', 'sessions', 'xmSelect', "commonDetail", 'view', 'dropdown','echarts'], function (exports) {
var $ = layui.$;
var form = layui.form;
var layer = layui.layer;
var laydate = layui.laydate;
var laytpl = layui.laytpl;
var common = layui.common;
var domainName = common.domainName;
var dropdown = layui.dropdown;
var admin = layui.admin;
var tree = layui.tree;
var table = layui.table;
var tableChild = layui.tableChild;
var treeTable = layui.treeTable;
exports('newLogIndex', function () {
var resTypeVal = "";
var accessToken = localStorage.getItem("accessToken");
var selectBusType = [];
console.log('====日志加载中====');
initDropDateTime();
resTypeInit();
renderDefaultLogType();
initTable();
loadChart();
// HOST_X86SERVER(服务器)、数据库(DATABASE_)、
// 中间件(MIDDLEWARE_WEBLOGIC)对应一体化的业务
// NETSAFE_(安全设备)对应一体化的安全
// NETHARDWARE_(网络设备)对应一体化的网络
function renderPage(){
loadChart();
//上述方法等价于
table.reload('logTable', {
where: getParams()
, page: {
layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
, theme: '#1E9FFF'
}
}); //只重载数据
}
function renderDefaultLogType(resType){
if(!resType){
resType = "HOST_X86SERVER";
resTypeVal = resType;
}
$("."+resType).attr("useing", "useing")
.css("background-color", "#1E9FFF")
.css("color", "grey");
}
function resTypeInit() {
xmSelect.render({
el: '#resTypeList',
name: 'resType',
tips: '类型',
//监听方法
on: function (data) {
var isAdd = data.isAdd;
$(".alaysis").css("background-color", "grey")
.css("color", "white")
.removeAttr("selected").removeAttr("useing");
if (isAdd) {
resTypeVal = data.change[0]["value"];
renderPage();
renderDefaultLogType(resTypeVal);
} else {
resTypeVal = "";
}
},
radio: true,
filterable: true,
clickClose: true,
data: [
{'name': '服务器', 'value': 'HOST_X86SERVER', selected: true},
{'name': '数据库', 'value': 'DATABASE_'},
{'name': '中间件', 'value': 'MIDDLEWARE_WEBLOGIC'},
{'name': '安全设备', 'value': 'NETSAFE_'},
{'name': '网络设备', 'value': 'NETHARDWARE_'},
]
});
}
$(".alaysis").click(function(){
var $this = $(this);
//$(".alaysis[selected=selected]");
if($this.attr("useing") == "useing"){
$this.css("color","white");
if($this.attr("selected") == "selected"){
$this.removeAttr("selected").css("color","grey");
}else{
$(".alaysis[useing='useing']").removeAttr("selected").css("color","grey");
$this.attr("selected","selected").css("color","white");
}
renderPage();
}
})
$('#log-search').on('click',function () {
// 获取选中的资源类型
renderPage();
});
function getParams() {
var $logTypeSelected = $(".alaysis[selected=selected]");
var logTypeVal = "";
if($logTypeSelected){
logTypeVal = $logTypeSelected.attr("logType");
}
logTypeVal = logTypeVal?logTypeVal:"";
console.log(logTypeVal);
return {
type:$('#searchDataType').val(),
access_token: accessToken,
restype: resTypeVal,
bustype: selectBusType.join(','),
timeRange: $('#searchDataRange').val(),
keyWords: $('#searchKeyWords').val(),
logType: logTypeVal
}
}
// 计柱状图表
function loadChart() {
$("#log-echarts").empty();
document.getElementById('log-echarts').setAttribute('_echarts_instance_', '')
var myChart = echarts.init(document.getElementById('log-echarts'));
var option;
var yMax = 500;
var dataShadow = [];
var loading = layer.load(2);
admin.req({
url: domainName + '/api-web/log/detail/getBarData'
, data: getParams()
, success(response) {
layer.close(loading)
if(response.success){
var map = response.map;
var x = [];
var data = [];
if(map){
x = map.dataAxis;
data = map.data;
if(data.length<1){
var html = "<div style='padding-top:100px;text-align: center;font-size: 20px'><span style='color: red'>无数据</span></div>"
$("#log-echarts").html(html);
}
}
setOption(x,data);
}
}
, error(error) {
/*layer.close(loading)*/
}
})
function setOption(dataAxis,data){
for (var i = 0; i < data.length; i++) {
dataShadow.push(yMax);
}
option = {
title: {
text: '',
subtext: ''
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
},
formatter(params){
return params[0].name +":"+params[0].value+"条";
}
},
toolbox: {
show: true,
left: 'right',
top: 'top',
feature: {
mark: {show: true},
magicType: {show: true, type: ['line', 'bar', 'tiled']},
saveAsImage: {show: true}
}
},
grid:{
x:75,
y:50,
x2:20,
y2:50
},
xAxis: {
data: dataAxis,
axisLabel: {
inside: false,
show:true,
textStyle: {
color: '#000'
},
rotate:60
},
axisTick: {
show: false
},
axisLine: {
show: false
}
//,z: 10
},
yAxis: {
axisLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
textStyle: {
color: '#999'
},
formatter:'{value}条'
}
},
/*dataZoom: [
{
type: 'inside'
}
],*/
series: [
{
type: 'bar',
showBackground: true,
itemStyle: {
color: new echarts.graphic.LinearGradient(
0, 0, 0, 1,
[
{offset: 0, color: '#83bff6'},
{offset: 0.5, color: '#188df0'},
{offset: 1, color: '#188df0'}
]
)
},
label: {
show: false,
position: 'insideBottom',
color: '#FFFFFF',
formatter: function (params) {
let txtArry = params.name.split('');
let rs = "";
for (var i = 0; i < txtArry.length; i++) {
rs += txtArry[i] + "\n";
}
return rs;
}
},
emphasis: {
show:false,
focus: 'series',
itemStyle: {
color: new echarts.graphic.LinearGradient(
0, 0, 0, 1,
[
{offset: 0, color: '#2378f7'},
{offset: 0.7, color: '#2378f7'},
{offset: 1, color: '#83bff6'}
]
)
}
},
data: data
}
]
};
myChart.setOption(option)
}
}
function formartContents(item) {
var contents = item.contents;
var itemhtml = '';
if (contents) {
try {
var json = JSON.parse(contents);
Object.keys(json).forEach(function (key) {
itemhtml += `<div class="log-item"><div class="item-left">${key}</div><div class="item-right">${json[key]}</div></div>`;
})
}catch (e) {
}
}
var html = `
<div class="log-content-line1">
<div style="width: 25%"><span>IP : </span>${item.host == null ? '-' : item.host}</div>
<div style="width: 25%"><span>类型 : </span>${item.type == null ? '-' : item.type}</div>
<div style="width: 50%"><span>标签 : </span><span>${item.tags == null || !item.tags? '-' : item.tags
}</span></div>
</div>
<div class="log-content-line2">${item.msg == null ? item.contents : item.msg}</div>
<div class="log-content-line3" style="display: none">${itemhtml}</div>`;
return html;
}
/**
* 加载日志数据
*/
function initTable() {
var cols = [
{type: 'numbers', title: '序号', align: 'center'},
{field: 'datetime', title: '时间', width: 180, height: '60px', align: 'center', sort: false},
{
field: 'contents1', title: '事件', align: 'center', sort: false, templet: function (d) {
return formartContents(d);
}
}
];
table.render({
elem: '#logTable'
, url: domainName + '/api-web/log/detail/listPage'
, where: getParams()
, cellMinWidth: 80
, page: {
layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
, theme: '#1E9FFF'
}
, autoSort: false
, limit: common.limit
, limits: common.limits
, loading:false
, cols: [cols]
, done: function (res) {
}
});
//监听行单击事件(双击事件为:rowDouble)
table.on('row(log-table-filter)', function (obj) {
var data = obj.data;
$(obj.tr[0]).find('td').eq(2).find('.log-content-line3').toggle();
//标注选中样式
obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click');
});
}
function dateFormat(fmt, date) {
let ret;
const opt = {
"Y+": date.getFullYear().toString(), // 年
"m+": (date.getMonth() + 1).toString(), // 月
"d+": date.getDate().toString(), // 日
"H+": date.getHours().toString(), // 时
"M+": date.getMinutes().toString(), // 分
"S+": date.getSeconds().toString() // 秒
// 有其他格式化字符需求可以继续添加,必须转化成字符串
};
for (let k in opt) {
ret = new RegExp("(" + k + ")").exec(fmt);
if (ret) {
fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
};
};
return fmt;
}
$("#time-select").click(function () {
$(".layui-dropdown").css("display","block");
})
// 加载搜索时间选择
function initDropDateTime() {
$(".layui-dropdown").css("display","block");
function setDataVal(start,end,value) {
if(start && start != null && end && end != null){
value = dateFormat("YYYY-mm-dd HH:MM:SS", start) +" - " + dateFormat("YYYY-mm-dd HH:MM:SS", end);
}
$('#time-select-span').text(value);
$('#searchDataRange').val(value);
$(".layui-dropdown").css("display","none");
}
// 加载默认时间
var initdata = new Date();
initdata.setDate(initdata.getDate() - 1);
setDataVal(initdata,new Date());
$('#searchDataType').val('d');
var defaultLeft = '';
var dataTimeRange = false;
var dataTimeDropdown = dropdown.render({
elem: '#time-select'
, content: ['<div class="layui-tab layui-tab-brief" lay-filter="overview_time_tab">'
, '<ul class="layui-tab-title">'
, '<li class="layui-this">快速选择</li>'
, '<li>自定义时间段</li>'
, '</ul>'
, '<div class="layui-tab-content">'
, '<div class="layui-tab-item layui-text layui-show"><div class="display-flex" ><div class="time-tools border-left" ><div data-type="m" data-size="5">最近5分钟</div><div data-type="m" data-size="15">最近15分钟</div><div data-type="h" data-size="1">最近1小时</div><div data-type="h" data-size="3">最近3小时</div><div data-type="h" data-size="6">最近6小时</div><div data-type="h" data-size="12">最近12小时</div><div data-type="h" data-size="24">最近24小时</div></div><div class="time-tools"><div data-type="d" data-size="3">最近3天</div><div data-type="d" data-size="7">最近7天</div><div data-type="d" data-size="15">最近15天</div><div data-type="M" data-size="1">最近1个月</div><div data-type="M" data-size="3">最近3个月</div><div data-type="M" data-size="6">最近6个月</div><div data-type="y" data-size="1">最近1年</div></div><!--<div class="time-tools"><div data-type="td">今天</div><div data-type="yd">昨天</div><div data-type="tw">本周</div><div data-type="lw">上周</div><div data-type="tm">本月</div><div data-type="lm">上月</div><div data-type="ty">今年</div></div>--></div></div>'
, '<div class="layui-tab-item" id="time"><div class="site-demo-laydate"><div class="layui-inline" id="datetimeRange"></div></div></div>'
, '</div>'
, '</div>'].join('')
, style: 'min-width: 370px; height: auto; padding: 0 15px;margin-left:15px; box-shadow: 1px 1px 30px rgb(0 0 0 / 12%);'
, click: function (data, othis) {
$(".layui-dropdown").css("display","block");
}
, ready: function () {
$('.time-tools div').on('click', function () {
var that = $(this);
// data-type="m" data-size="15"
var type = that.attr('data-type');
var size = that.attr('data-size');
// 当前时间
var endTime = new Date();
// 开始时间
var startTime = new Date();
if(type == 'm'){
// 分钟
startTime.setMinutes(startTime.getMinutes() - size);
} else if(type == 'h'){
// 小时
startTime.setHours(startTime.getHours() - size);
} else if(type == 'd'){
// 天
startTime.setDate(startTime.getDate() - size);
} else if(type == 'M'){
// 月
startTime.setMonth(startTime.getMonth() - size);
} else if(type == 'y'){
// 年
startTime.setFullYear(startTime.getFullYear() - size);
}
$('#searchDataType').val(type);
setDataVal(startTime,endTime);
});
layui.use('element', function (element) {
element.render('tab');
// tab页切换事件
element.on('tab(overview_time_tab)', function (data) {
if (defaultLeft == '') {
defaultLeft = $('.layui-dropdown').css('left')
}
if (data.index == 1) {
loadDataTime();
} else {
//loadQuickMenu();
$('.layui-dropdown').css({'left': defaultLeft});
}
});
});
}
});
var loadDataTime = function () {
$('#datetimeRange .layui-laydate-range').remove();
// 日期
laydate.render({
elem: '#datetimeRange'
, position: 'static'
, type: 'datetime'
, range: true
, btns:['clear', 'confirm']
, ready: function (date) {
$('.layui-dropdown').css({'left': 'calc(100% - 620px)'});
}
, done: function (value, date, endDate) {
$('#time-select-span').text(value);
$('#searchDataRange').val(value);
setDataVal(null,null,value);
$('#searchDataType').val('d');
}
});
}
}
});
});
... ...
... ... @@ -243,7 +243,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect
var fileName = []
uploadInst = upload.render({
elem: '#attachment', //绑定元素
url: common.domainName + '/api-web/recoveryverify/upload?accessToken='+accessToken,
url: common.domainName + '/api-web/recoveryverify/upload?accessToken=' + accessToken,
data: param,
multiple: true,
auto: false, //选择文件后不自动上传
... ... @@ -253,7 +253,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect
choose: function (obj) {
//选择文件后回调
var files = this.files = obj.pushFile();
if (typeof(files) != undefined) {
if (typeof (files) != undefined) {
if (Object.getOwnPropertyNames(files).length > 2) {
$("#attachment").attr("disabled", "disabled");
layer.msg('目前最多支持上传三个文件!', {
... ... @@ -347,7 +347,36 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect
})
} else {
//附件为文档类型
common.fileviewer(filepath)
var loadIndex = layer.load(1, {shade: [0.3], content: ''});
let name = Base64.encode(filepath, true);
admin.req({
url: domainName + `/api-web/openoffice/convertPdfMJ?pathBase64=${name}`,
type: 'get'
}).done(function (res) {
layer.close(loadIndex);
if (res && res.success) {
let win = window.parent;
if (win) {
window.parent.postMessage({
type: "previewFile",
message: {
params: {
url: res.str
}
}
}, '*')
}
} else {
layer.confirm("文档不支持预览,是否下载!", function () {
const url = domainName + `/api-web/openoffice/download/${id}?accessToken=${accessToken}`;
window.open(url)
});
layer.close(loadIndex);
}
}).error(function (error) {
layer.close(loadIndex);
console.log(error)
})
}
})
}
... ... @@ -388,7 +417,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect
vu = "恢复服务器";
break;
}
tr += '<tr data-id="' + v.id + '" data-recordId="'+v.recordId+'" data-usefulness="'+v.usefulness+'" >' +
tr += '<tr data-id="' + v.id + '" data-recordId="' + v.recordId + '" data-usefulness="' + v.usefulness + '" >' +
'<td>' + vu + '</td>' +
'<td>' + v.ip + '</td>' +
'<td>' + v.os + '</td>' +
... ... @@ -434,8 +463,8 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect
'id': id,
'recordId': recordId
}
devicesBak.forEach(e=>{
if(deviceObj.id ==e.id){
devicesBak.forEach(e => {
if (deviceObj.id == e.id) {
devicesBak.pop(e);
devicesBak.push(deviceObj);
}
... ... @@ -452,7 +481,6 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'xmSelect
}
})
}
}
... ...
... ... @@ -76,7 +76,36 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions'], function
})
} else {
//附件为文档类型
common.fileviewer(filepath)
var loadIndex = layer.load(1, {shade: [0.3], content: ''});
let name = Base64.encode(filepath, true);
admin.req({
url: domainName + `/api-web/openoffice/convertPdfMJ?pathBase64=${name}`,
type: 'get'
}).done(function (res) {
layer.close(loadIndex);
if (res && res.success) {
let win = window.parent;
if (win) {
window.parent.postMessage({
type: "previewFile",
message: {
params: {
url: res.str
}
}
}, '*')
}
} else {
layer.confirm("文档不支持预览,是否下载!", function () {
const url = domainName + `/api-web/openoffice/download/${id}?accessToken=${accessToken}`;
window.open(url)
});
layer.close(loadIndex);
}
}).error(function (error) {
layer.close(loadIndex);
console.log(error)
})
}
})
... ...
... ... @@ -76,7 +76,36 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions'], function
})
} else {
//附件为文档类型
common.fileviewer(filepath)
var loadIndex = layer.load(1, {shade: [0.3], content: ''});
let name = Base64.encode(filepath, true);
admin.req({
url: domainName + `/api-web/openoffice/convertPdfMJ?pathBase64=${name}`,
type: 'get'
}).done(function (res) {
layer.close(loadIndex);
if (res && res.success) {
let win = window.parent;
if (win) {
window.parent.postMessage({
type: "previewFile",
message: {
params: {
url: res.str
}
}
}, '*')
}
} else {
layer.confirm("文档不支持预览,是否下载!", function () {
const url = domainName + `/api-web/openoffice/download/${id}?accessToken=${accessToken}`;
window.open(url)
});
layer.close(loadIndex);
}
}).error(function (error) {
layer.close(loadIndex);
console.log(error)
})
}
})
... ...
... ... @@ -35,7 +35,7 @@ layui.define(['laytpl', 'layer'], function (exports) {
* @param isError 是否异常触发
*/
const errorHandel = (status, res,isError) => {
if(res.success){
if(res.success || isError==false){
return true;
}
console.log(' =================================')
... ...
... ... @@ -9,9 +9,14 @@
<div class="layui-form-item">
<div class="layui-inline inline-onethird">
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>文件类型</label>
<div class="layui-input-block">
<input type="radio" lay-filter="docType" name="docType" value="0" title="应急预案" checked>
<input type="radio" lay-filter="docType" name="docType" value="1" title="演练报告">
<div class="layui-input-inline">
<select name="docType" id="slt-docType"
lay-filter="slt-docType" >
<option value="0">应急预案</option>
<option value="1">演练报告</option>
</select>
<!-- <input type="radio" lay-filter="docType" name="docType" value="0" title="应急预案" checked>
<input type="radio" lay-filter="docType" name="docType" value="1" title="演练报告">-->
</div>
</div>
<div class="layui-inline inline-onethird">
... ... @@ -116,8 +121,8 @@
</div>
<div class="layui-form-item">
<label class="layui-form-label textarea-label" style="text-overflow: clip;width: 160px"><span
style="color: red;font-size: 16px">*</span>预案内容/演练内容</label>
<label class="layui-form-label textarea-label" style="text-overflow: clip;"><span
style="color: red;font-size: 16px">*</span>内容</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="emergencyContent" maxlength="500"
placeholder="预案内容/演练内容" lay-verify="required"></textarea>
... ... @@ -158,8 +163,8 @@
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label textarea-label" style="text-overflow: clip;width: 160px"><span
style="color: red;font-size: 16px">*</span>预案缺陷/演练汇总</label>
<label class="layui-form-label textarea-label" style="text-overflow: clip;"><span
style="color: red;font-size: 16px">*</span>缺陷/汇总</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="defect" maxlength="100" placeholder="方案缺陷/演练汇总"></textarea>
</div>
... ...
... ... @@ -9,7 +9,7 @@
<input hidden name="id" id="id" lay-verify="checkReportIsExist">
<div class="layui-form-item" >
<div class="layui-inline inline-onethird">
<label class="layui-form-label">报表类型</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>报表类型</label>
<div class="layui-input-inline">
<select name="docType" id="slt-docType"
lay-filter="slt-docType" >
... ... @@ -19,7 +19,7 @@
</div>
</div>
<div class="layui-inline inline-onethird">
<label class="layui-form-label">操作类型</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>操作类型</label>
<div class="layui-input-inline">
<select name="actionType" id="slt-actionType"
lay-filter="slt-actionType" >
... ... @@ -30,7 +30,7 @@
</div>
</div>
<div class="layui-inline inline-onethird">
<label class="layui-form-label">设备型号</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>设备型号</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="deviceModel" id="deviceModel" lay-verify="required">
</div>
... ... @@ -38,7 +38,7 @@
</div>
<div class="layui-form-item">
<div class="layui-inline inline-onethird">
<label class="layui-form-label">机房</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>机房</label>
<div class="layui-input-inline">
<select name="machineRoomId" id="slt-staffadd-machine"
lay-filter="slt-staffadd-machine" lay-verify="required">
... ... @@ -47,7 +47,7 @@
</div>
</div>
<div class="layui-inline inline-onethird">
<label class="layui-form-label">选择单位</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>选择单位</label>
<div class="layui-input-inline">
<select name="manufacturerId" id="slt-staffadd-group"
lay-filter="slt-staffadd-group" lay-verify="required">
... ... @@ -57,7 +57,7 @@
</div>
</div>
<div class="layui-inline inline-onethird">
<label class="layui-form-label">申请人</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>申请人</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="applyUser" id="applyUser" lay-verify="required">
</div>
... ... @@ -65,19 +65,19 @@
</div>
<div class="layui-form-item">
<div class="layui-inline inline-onethird">
<label class="layui-form-label">联系方式</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>联系方式</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="phone" id="phone" lay-verify="required|phone">
</div>
</div>
<div class="layui-inline inline-onethird">
<label class="layui-form-label">进入时间</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>进入时间</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="enterTime" id="enterTime" lay-verify="required">
</div>
</div>
<div class="layui-inline inline-onethird">
<label class="layui-form-label">出来时间</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>出来时间</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="outTime" id="outTime" lay-verify="required">
</div>
... ... @@ -85,7 +85,7 @@
</div>
<div class="layui-form-item" >
<div class="layui-inline inline-onethird">
<label class="layui-form-label">现物理位置</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>现物理位置</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="localPlace" id= "localPlace" lay-verify="required">
</div>
... ... @@ -97,7 +97,7 @@
</div>
</div>
<div class="layui-inline inline-onethird">
<label class="layui-form-label">值班人</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>值班人</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="watchkeeper" id= "watchkeeper" lay-verify="required">
</div>
... ... @@ -105,26 +105,26 @@
</div>
<div class="layui-form-item">
<div class="layui-inline inline-onethird">
<label class="layui-form-label">设备负责人(甲方)</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>设备负责人</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="machineRoomLeader" id="machineRoomLeader" lay-verify="required">
</div>
</div>
<div class="layui-inline inline-onethird">
<label class="layui-form-label">总集成</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>总集成</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="integration" id="integration" lay-verify="required">
</div>
</div>
<div class="layui-inline inline-onethird">
<label class="layui-form-label">运维负责人</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>运维负责人</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="operationUser" id="operationUser" lay-verify="required">
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label textarea-label">进入事由</label>
<label class="layui-form-label textarea-label"><span style="color: red;font-size: 16px">*</span>进入事由</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="reason" id="reason" lay-verify="required"></textarea>
</div>
... ...
... ... @@ -9,13 +9,13 @@
<input hidden name="id" id="id" lay-verify="checkReportIsExist">
<div class="layui-form-item">
<div class="layui-inline inline-onethird">
<label class="layui-form-label">合同编号</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>合同编号</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="contractId" maxlength="25" id="contractId" lay-verify="required">
</div>
</div>
<div class="layui-inline inline-onethird">
<label class="layui-form-label">调整要求</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>调整要求</label>
<div class="layui-input-inline">
<select name="adjustType" id="slt-adjustType-group"
lay-filter="slt-adjustType-group" >
... ... @@ -24,7 +24,7 @@
</div>
</div>
<div class="layui-inline inline-onethird">
<label class="layui-form-label">城市A</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>城市A</label>
<div class="layui-input-inline">
<select name="localCity" id="slt-localCity-group"
lay-filter="slt-localCity-group">
... ... @@ -35,7 +35,7 @@
</div>
<div class="layui-form-item">
<div class="layui-inline inline-onethird">
<label class="layui-form-label">城市Z</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>城市Z</label>
<div class="layui-input-inline">
<select name="targetCity" id="slt-targetCity-group"
lay-filter="slt-targetCity-group">
... ... @@ -44,13 +44,13 @@
</div>
</div>
<div class="layui-inline inline-onethird">
<label class="layui-form-label">申请单位</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>申请单位</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="applyCity" id="applyCity" lay-verify="required">
</div>
</div>
<div class="layui-inline inline-onethird">
<label class="layui-form-label">业务类型</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>业务类型</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="busyType" id="busyType" lay-verify="required">
</div>
... ... @@ -58,19 +58,19 @@
</div>
<div class="layui-form-item">
<div class="layui-inline inline-onethird">
<label class="layui-form-label">端口速率</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>端口速率</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="portSpeed" id="portSpeed" lay-verify="required">
</div>
</div>
<div class="layui-inline inline-onethird">
<label class="layui-form-label">线路速率</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>线路速率</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="electricSpeed" id="electricSpeed" lay-verify="required">
</div>
</div>
<div class="layui-inline inline-onethird">
<label class="layui-form-label">调整时间</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>调整时间</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="adjustTime" id="adjustTime" lay-verify="required">
</div>
... ...
... ... @@ -9,7 +9,7 @@
<input hidden name="id" id="id" lay-verify="checkReportIsExist">
<div class="layui-form-item">
<div class="layui-inline inline-onethird">
<label class="layui-form-label">机房</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>机房</label>
<div class="layui-input-inline">
<select name="machineRoomId" id="slt-staffadd-machine" lay-verify="required"
lay-filter="slt-staffadd-machine">
... ... @@ -18,7 +18,7 @@
</div>
</div>
<div class="layui-inline inline-onethird">
<label class="layui-form-label">选择单位</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>选择单位</label>
<div class="layui-input-inline">
<select name="manufacturerId" id="slt-staffadd-group"
lay-filter="slt-staffadd-group" lay-verify="required">
... ... @@ -28,7 +28,7 @@
</div>
</div>
<div class="layui-inline inline-onethird">
<label class="layui-form-label">申请人</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>申请人</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="applyUser" id="applyUser" lay-verify="required">
</div>
... ... @@ -36,19 +36,19 @@
</div>
<div class="layui-form-item">
<div class="layui-inline inline-onethird">
<label class="layui-form-label">联系方式</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>联系方式</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="phone" id="phone" lay-verify="required|phone">
</div>
</div>
<div class="layui-inline inline-onethird">
<label class="layui-form-label">进入时间</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>进入时间</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="enterTime" id="enterTime" lay-verify="required">
</div>
</div>
<div class="layui-inline inline-onethird">
<label class="layui-form-label">出来时间</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>出来时间</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="outTime" id="outTime" lay-verify="required">
</div>
... ... @@ -56,19 +56,19 @@
</div>
<div class="layui-form-item">
<div class="layui-inline inline-onethird">
<label class="layui-form-label">机房负责人(甲方)</label>
<label class="layui-form-label" ><span style="color: red;font-size: 16px">*</span>机房负责人</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="machineRoomLeader" id="machineRoomLeader" lay-verify="required">
</div>
</div>
<div class="layui-inline inline-onethird">
<label class="layui-form-label">项目管理员(甲方)</label>
<label class="layui-form-label" ><span style="color: red;font-size: 16px">*</span>项目管理员</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="projectLeader" id="projectLeader" lay-verify="required">
</div>
</div>
<div class="layui-inline inline-onethird">
<label class="layui-form-label">运维负责人</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>运维负责人</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="operationUser" id="operationUser" lay-verify="required">
</div>
... ... @@ -76,20 +76,20 @@
</div>
<div class="layui-form-item" >
<div class="layui-inline inline-half">
<label class="layui-form-label">携带物品</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>携带物品</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="belongings" id="belongings" lay-verify="required">
</div>
</div>
<div class="layui-inline inline-half">
<label class="layui-form-label">值班人</label>
<label class="layui-form-label"><span style="color: red;font-size: 16px">*</span>值班人</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="watchkeeper" id= "watchkeeper" lay-verify="required">
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label textarea-label">进入事由</label>
<label class="layui-form-label textarea-label"><span style="color: red;font-size: 16px">*</span>进入事由</label>
<div class="layui-input-block">
<textarea class="layui-textarea" name="reason" id="reason" lay-verify="required"></textarea>
</div>
... ...
<title>日志视图</title>
<style>
.display-flex{
display: flex;
}
.log-header {
border-bottom: solid 1px #C9C9C9;
margin-bottom: 6px;
}
.log-header .title {
width: 200px;
font-weight: bold;
}
.log-header .tools {
width: calc(100% - 200px);
text-align: right;
}
.dropDownbtn{
width: 100%;
border-top-right-radius: 0px;
border-right: 1px solid #C9C9C9;;
border-bottom-right-radius: 0px;
}
.dropDownbtn:hover{
border: 1px solid #C9C9C9;
/* border-top-right-radius: 2px;
border-right: solid 1px #009688;
border-right: none;
border-bottom-right-radius: 2px;*/
}
.log-search-input input{
border: 1px solid #C9C9C9;
/*border-left: none;*/
margin-top: -1px;
margin-left: -2px;
border-right: none;
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
}
.log-search-input input:hover{
border: 1px solid #C9C9C9;
}
.time-select{
position: relative;
width: 350px;
}
.time-select button{
width: 100%;
border: 1px solid #C9C9C9;
margin-left: -3px;
border-top-left-radius: 0px;
border-bottom-left-radius: 0px;
}
.time-select button:hover{
border: 1px solid #C9C9C9;
}
.time-tools{
flex-direction: column;
width: 50%;
text-align: center;
}
.border-left{
border-right: 1px solid #C9C9C9;;
}
.time-tools div{
margin: 2px 5px;
border-radius: 2px;
}
.time-tools div:hover{
background: #C9C9C9;
}
div[lay-id="logTable"] .layui-table-cell{
height: auto;
}
.log-item{
display: flex;
flex-direction: row;
}
.log-item .item-left{
text-align: right;
border-right: solid 1px gainsboro;
padding-right: 10px;
width: 15%;
}
.log-item .item-right{
text-align: left;
padding-left: 10px;
width: 85%;
max-width: 85%;
word-wrap:break-word;
word-break: break-all;
}
.layui-card-header {
line-height: initial;
}
.log-content-line1{
display: flex;
flex-direction: row
}
.log-content-line1 div{
width: 33%;
text-align: left;
font-weight: 100;
color: #000;
}
.log-content-line1 div span{
}
.log-content-line2{
text-align: left;
word-wrap:break-word;
word-break: break-all;
}
.log-content-line3{
display: none;
border-top: dashed 1px grey;
}
</style>
<article class="page-container">
<div class="page-panel">
<div class="main">
<div class="layui-card">
<div class="layui-card-header">
<form class="layui-form layui-card-header" lay-filter="form_log_condition" onsubmit="return false;">
<input type="hidden" id="searchDataRange">
<input type="hidden" id="searchDataType">
<!--<div class="display-flex log-header">
<div class="title">新搜索</div>
<div class="layui-inline layui-btn-group time-group tools" id="createTimeBtn" >
<button type="button" class="layui-btn layui-btn-primary layui-btn-sm">新建</button>
<button type="button" class="layui-btn layui-btn-primary layui-btn-sm">打开</button>
<button type="button" class="layui-btn layui-btn-primary layui-btn-sm">保存</button>
</div>
</div>-->
<!---->
<div class="layui-row">
<div class="layui-col-md2">
<div style="width: 120px" id="resTypeList"></div>
<!--<select id="resTypeList" name="modules" lay-search="">
<option value="">直接选择或搜索选择</option>
<option value="HOST_X86SERVER">服务器</option>
<option value="DATABASE_">数据库</option>
<option value="MIDDLEWARE_WEBLOGIC">中间件</option>
<option value="NETSAFE_">安全设备</option>
<option value="NETHARDWARE_">网络设备</option>
</select>-->
</div>
<div class="layui-col-md9">
<div class="layui-row">
<div class="layui-col-md8">
<input type="text" id="searchKeyWords" name="historywarningkw" placeholder="输入关键字,回车搜索" autocomplete="off" class="layui-input">
</div>
<div class="layui-col-md4">
<div class="layui-btn layui-btn-primary" style="margin-bottom: 8px;border-left: 0px" id="time-select">
<span id="time-select-span">
</span>
</div>
</div>
</div>
</div>
<div class="layui-col-md1">
<button class="layui-btn layui-btn-normal" style="margin-bottom: 8px;margin-left: 10px" id="log-search">
搜索
</button>
</div>
</div>
<div class="layui-row">
<div class="layui-col-md12">
<div class="layui-btn-group">
<button type="button" style="background-color: grey" class="layui-btn layui-btn-xs alaysis NETHARDWARE_" logType="Alarm">自身告警情况</button>
<button type="button" style="background-color: grey" class="layui-btn layui-btn-xs alaysis NETHARDWARE_" logType="TrapAlarm">设备Trap告警</button>
<button type="button" style="background-color: grey" class="layui-btn layui-btn-xs alaysis NETHARDWARE_" logType="ConfigChange">网络配置情况</button>
<button type="button" style="background-color: grey" class="layui-btn layui-btn-xs alaysis HOST_X86SERVER" logType="OsAccountAuthOperation">运行账号及权限</button>
<button type="button" style="background-color: grey" class="layui-btn layui-btn-xs alaysis HOST_X86SERVER" logType="AccountLogin">账号登录</button>
<button type="button" style="background-color: grey" class="layui-btn layui-btn-xs alaysis DATABASE_" logType="BatchDelete">批量删除</button>
<button type="button" style="background-color: grey" class="layui-btn layui-btn-xs alaysis DATABASE_" logType="TableSpaceDelete">表空间删除</button>
<button type="button" style="background-color: grey" class="layui-btn layui-btn-xs alaysis MIDDLEWARE_WEBLOGIC" logType="AccountLogin">登录信息</button>
<button type="button" style="background-color: grey" class="layui-btn layui-btn-xs alaysis NETSAFE_" logType="AbnormalAccess">非正常访问</button>
<button type="button" style="background-color: grey" class="layui-btn layui-btn-xs alaysis NETSAFE_" logType="ConfigChange">策略变动</button>
</div>
</div>
</div>
</form>
</div>
<div class="layui-card" style="min-height: 200px">
<div class="layui-card-body">
<div style="display: flex;height: 200px" class="layui-card-echart">
<div style="flex-grow: 1">
<div class="pie-chart" id="log-echarts"></div>
</div>
</div>
</div>
</div>
<div class="layui-card">
<div class="layui-card-body">
<div style="display: flex" class="layui-card-echart">
<div style="flex-grow: 1">
<div style="display: flex;flex-direction: row">
<div style="width: 200px;display: inline-flex">
</div>
</div>
<!--<div class="layui-row alaysis NETHARDWARE_" style="display: none">
<div class="layui-col-md12">
<div class="layui-btn-group">
<button type="button" class="layui-btn layui-btn-xs">自身告警情况</button>
<button type="button" class="layui-btn layui-btn-xs">设备Trap告警</button>
<button type="button" class="layui-btn layui-btn-xs">网络配置情况</button>
</div>
</div>
</div>
<div class="layui-row alaysis HOST_X86SERVER" style="display: none">
<div class="layui-col-md12">
<div class="layui-btn-group">
<button type="button" class="layui-btn layui-btn-xs">运行账号及权限</button>
<button type="button" class="layui-btn layui-btn-xs">账号登录</button>
</div>
</div>
</div>
<div class="layui-row alaysis DATABASE_" style="display: none">
<div class="layui-col-md12">
<div class="layui-btn-group">
<button type="button" class="layui-btn layui-btn-xs">批量删除</button>
<button type="button" class="layui-btn layui-btn-xs">表空间删除</button>
</div>
</div>
</div>
<div class="layui-row alaysis MIDDLEWARE_WEBLOGIC" style="display: none">
<div class="layui-col-md12">
<div class="layui-btn-group">
<button type="button" class="layui-btn layui-btn-xs">登录信息</button>
</div>
</div>
</div>
<div class="layui-row alaysis NETSAFE_" style="display: none">
<div class="layui-col-md12">
<div class="layui-btn-group">
<button type="button" class="layui-btn layui-btn-xs">非正常访问</button>
<button type="button" class="layui-btn layui-btn-xs">策略变动</button>
</div>
</div>
</div>-->
<table id="logTable" lay-filter="log-table-filter"></table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</article>
<script type="text/html" id="expandAll">
<div class="detailView">
{{# layui.each(d, function(index, item){ }}
<div style="border-bottom: #c1b8b8 dashed 1px;margin-top: 5px;margin-left: 10%">
<div style="display: inline-block;width: 30%;height: 25px;line-height: 25px;">{{index}}</div>
<div style="display: inline-block;width: 60%;height: 25px;line-height: 25px;">{{item}}</div>
</div>
{{# }) }}
</div>
</script>
<script>
layui.use('newLogIndex', function (fn) {
fn();
});
</script>
... ...
/**
@Name:dropdown 下拉菜单组件
@License:MIT
*/
layui.define(['jquery', 'laytpl','lay'], function(exports){
"use strict";
var $ = layui.$
,laytpl = layui.laytpl
,hint = layui.hint()
,device = layui.device()
,clickOrMousedown = (device.mobile ? 'click' : 'mousedown')
//模块名
,MOD_NAME = 'dropdown'
,MOD_INDEX = 'layui_'+ MOD_NAME +'_index' //模块索引名
//外部接口
,dropdown = {
config: {}
,index: layui[MOD_NAME] ? (layui[MOD_NAME].index + 10000) : 0
//设置全局项
,set: function(options){
var that = this;
that.config = $.extend({}, that.config, options);
return that;
}
//事件
,on: function(events, callback){
return layui.onevent.call(this, MOD_NAME, events, callback);
}
}
//操作当前实例
,thisModule = function(){
var that = this
,options = that.config
,id = options.id;
thisModule.that[id] = that; //记录当前实例对象
return {
config: options
//重置实例
,reload: function(options){
that.reload.call(that, options);
}
}
}
//字符常量
,STR_ELEM = 'layui-dropdown', STR_HIDE = 'layui-hide', STR_DISABLED = 'layui-disabled', STR_NONE = 'layui-none'
,STR_ITEM_UP = 'layui-menu-item-up', STR_ITEM_DOWN = 'layui-menu-item-down', STR_MENU_TITLE = 'layui-menu-body-title', STR_ITEM_GROUP = 'layui-menu-item-group', STR_ITEM_PARENT = 'layui-menu-item-parent', STR_ITEM_DIV = 'layui-menu-item-divider', STR_ITEM_CHECKED = 'layui-menu-item-checked', STR_ITEM_CHECKED2 = 'layui-menu-item-checked2', STR_MENU_PANEL = 'layui-menu-body-panel', STR_MENU_PANEL_L = 'layui-menu-body-panel-left'
,STR_GROUP_TITLE = '.'+ STR_ITEM_GROUP + '>.'+ STR_MENU_TITLE
//构造器
,Class = function(options){
var that = this;
that.index = ++dropdown.index;
that.config = $.extend({}, that.config, dropdown.config, options);
that.init();
};
//默认配置
Class.prototype.config = {
trigger: 'click' //事件类型
,content: '' //自定义菜单内容
,className: '' //自定义样式类名
,style: '' //设置面板 style 属性
,show: false //是否初始即显示菜单面板
,isAllowSpread: true //是否允许菜单组展开收缩
,isSpreadItem: true //是否初始展开子菜单
,data: [] //菜单数据结构
,delay: 300 //延迟关闭的毫秒数,若 trigger 为 hover 时才生效
};
//重载实例
Class.prototype.reload = function(options){
var that = this;
that.config = $.extend({}, that.config, options);
that.init(true);
};
//初始化准备
Class.prototype.init = function(rerender){
var that = this
,options = that.config
,elem = options.elem = $(options.elem);
//若 elem 非唯一
if(elem.length > 1){
layui.each(elem, function(){
dropdown.render($.extend({}, options, {
elem: this
}));
});
return that;
}
//若重复执行 render,则视为 reload 处理
if(!rerender && elem[0] && elem.data(MOD_INDEX)){;
var newThat = thisModule.getThis(elem.data(MOD_INDEX));
if(!newThat) return;
return newThat.reload(options);
};
//初始化 id 参数
options.id = ('id' in options) ? options.id : that.index;
if(options.show) that.render(rerender); //初始即显示
that.events(); //事件
};
//渲染
Class.prototype.render = function(rerender){
var that = this
,options = that.config
,elemBody = $('body')
//默认菜单内容
,getDefaultView = function(){
var elemUl = $('<ul class="layui-menu layui-dropdown-menu"></ul>');
if(options.data.length > 0 ){
eachItemView(elemUl, options.data)
} else {
elemUl.html('<li class="layui-menu-item-none">no menu</li>');
}
return elemUl;
}
//遍历菜单项
,eachItemView = function(views, data){
//var views = [];
layui.each(data, function(index, item){
//是否存在子级
var isChild = item.child && item.child.length > 0
,isSpreadItem = ('isSpreadItem' in item) ? item.isSpreadItem : options.isSpreadItem
,title = item.templet
? laytpl(item.templet).render(item)
: (options.templet ? laytpl(options.templet).render(item) : item.title)
//初始类型
,type = function(){
if(isChild){
item.type = item.type || 'parent';
}
if(item.type){
return ({
group: 'group'
,parent: 'parent'
,'-': '-'
})[item.type] || 'parent';
}
return '';
}();
if(type !== '-' && (!item.title && !item.id && !isChild)) return;
//列表元素
var viewLi = $(['<li'+ function(){
var className = {
group: 'layui-menu-item-group'+ (
options.isAllowSpread ? (
isSpreadItem ? ' layui-menu-item-down' : ' layui-menu-item-up'
) : ''
)
,parent: STR_ITEM_PARENT
,'-': 'layui-menu-item-divider'
};
if(isChild || type){
return ' class="'+ className[type] +'"';
}
return '';
}() +'>'
//标题区
,function(){
//是否超文本
var viewText = ('href' in item) ? (
'<a href="'+ item.href +'" target="'+ (item.target || '_self') +'">'+ title +'</a>'
) : title;
//是否存在子级
if(isChild){
return '<div class="'+ STR_MENU_TITLE +'">'+ viewText + function(){
if(type === 'parent'){
return '<i class="layui-icon layui-icon-right"></i>';
} else if(type === 'group' && options.isAllowSpread){
return '<i class="layui-icon layui-icon-'+ (isSpreadItem ? 'up' : 'down') +'"></i>';
} else {
return '';
}
}() +'</div>'
}
return '<div class="'+ STR_MENU_TITLE +'">'+ viewText +'</div>';
}()
,'</li>'].join(''));
viewLi.data('item', item);
//子级区
if(isChild){
var elemPanel = $('<div class="layui-panel layui-menu-body-panel"></div>')
,elemUl = $('<ul></ul>');
if(type === 'parent'){
elemPanel.append(eachItemView(elemUl, item.child));
viewLi.append(elemPanel);
} else {
viewLi.append(eachItemView(elemUl, item.child));
}
}
views.append(viewLi);
});
return views;
}
//主模板
,TPL_MAIN = ['<div class="layui-dropdown layui-border-box layui-panel layui-anim layui-anim-downbit">'
,'</div>'].join('');
//如果是右键事件,则每次触发事件时,将允许重新渲染
if(options.trigger === 'contextmenu' || lay.isTopElem(options.elem[0])) rerender = true;
//判断是否已经打开了下拉菜单面板
if(!rerender && options.elem.data(MOD_INDEX +'_opened')) return;
//记录模板对象
that.elemView = $(TPL_MAIN);
that.elemView.append(options.content || getDefaultView());
//初始化某些属性
if(options.className) that.elemView.addClass(options.className);
if(options.style) that.elemView.attr('style', options.style);
//记录当前执行的实例索引
dropdown.thisId = options.id;
//插入视图
that.remove(); //移除非当前绑定元素的面板
elemBody.append(that.elemView);
options.elem.data(MOD_INDEX +'_opened', true);
//坐标定位
that.position();
thisModule.prevElem = that.elemView; //记录当前打开的元素,以便在下次关闭
thisModule.prevElem.data('prevElem', options.elem); //将当前绑定的元素,记录在打开元素的 data 对象中
//阻止全局事件
that.elemView.find('.layui-menu').on(clickOrMousedown, function(e){
layui.stope(e);
});
//触发菜单列表事件
that.elemView.find('.layui-menu li').on('click', function(e){
var othis = $(this)
,data = othis.data('item') || {}
,isChild = data.child && data.child.length > 0;
if(!isChild && data.type !== '-'){
that.remove();
typeof options.click === 'function' && options.click(data, othis);
}
});
//触发菜单组展开收缩
that.elemView.find(STR_GROUP_TITLE).on('click', function(e){
var othis = $(this)
,elemGroup = othis.parent()
,data = elemGroup.data('item') || {}
if(data.type === 'group' && options.isAllowSpread){
thisModule.spread(elemGroup);
}
});
//如果是鼠标移入事件,则鼠标移出时自动关闭
if(options.trigger === 'mouseenter'){
that.elemView.on('mouseenter', function(){
clearTimeout(thisModule.timer);
}).on('mouseleave', function(){
that.delayRemove();
});
}
};
//位置定位
Class.prototype.position = function(obj){
var that = this
,options = that.config;
lay.position(options.elem[0], that.elemView[0], {
position: options.position
,e: that.e
,clickType: options.trigger === 'contextmenu' ? 'right' : null
,align: options.align || null
});
};
//删除视图
Class.prototype.remove = function(){
var that = this
,options = that.config
,elemPrev = thisModule.prevElem;
//若存在已打开的面板元素,则移除
if(elemPrev){
elemPrev.data('prevElem') && (
elemPrev.data('prevElem').data(MOD_INDEX +'_opened', false)
);
elemPrev.remove();
}
};
//延迟删除视图
Class.prototype.delayRemove = function(){
var that = this
,options = that.config;
clearTimeout(thisModule.timer);
thisModule.timer = setTimeout(function(){
that.remove();
}, options.delay);
};
//事件
Class.prototype.events = function(){
var that = this
,options = that.config;
//如果传入 hover,则解析为 mouseenter
if(options.trigger === 'hover') options.trigger = 'mouseenter';
//解除上一个事件
if(that.prevElem) that.prevElem.off(options.trigger, that.prevElemCallback);
//记录被绑定的元素及回调
that.prevElem = options.elem;
that.prevElemCallback = function(e){
clearTimeout(thisModule.timer);
that.e = e;
that.render();
e.preventDefault();
//组件打开完毕的时间
typeof options.ready === 'function' && options.ready(that.elemView, options.elem, that.e.target);
};
//触发元素事件
options.elem.on(options.trigger, that.prevElemCallback);
//如果是鼠标移入事件
if(options.trigger === 'mouseenter'){
//直行鼠标移出事件
options.elem.on('mouseleave', function(){
that.delayRemove();
});
}
};
//记录所有实例
thisModule.that = {}; //记录所有实例对象
//获取当前实例对象
thisModule.getThis = function(id){
var that = thisModule.that[id];
if(!that) hint.error(id ? (MOD_NAME +' instance with ID \''+ id +'\' not found') : 'ID argument required');
return that;
};
//设置菜单组展开和收缩状态
thisModule.spread = function(othis){
//菜单组展开和收缩
var elemIcon = othis.children('.'+ STR_MENU_TITLE).find('.layui-icon');
if(othis.hasClass(STR_ITEM_UP)){
othis.removeClass(STR_ITEM_UP).addClass(STR_ITEM_DOWN);
elemIcon.removeClass('layui-icon-down').addClass('layui-icon-up');
} else {
othis.removeClass(STR_ITEM_DOWN).addClass(STR_ITEM_UP);
elemIcon.removeClass('layui-icon-up').addClass('layui-icon-down')
}
};
//全局事件
;!function(){
var _WIN = $(window)
,_DOC = $(document);
//自适应定位
_WIN.on('resize', function(){
if(!dropdown.thisId) return;
var that = thisModule.getThis(dropdown.thisId);
if(!that) return;
if(!that.elemView[0] || !$('.'+ STR_ELEM)[0]){
return false;
}
var options = that.config;
if(options.trigger === 'contextmenu'){
that.remove();
} else {
that.position();
}
});
//点击任意处关闭
_DOC.on(clickOrMousedown, function(e){
if(!dropdown.thisId) return;
var that = thisModule.getThis(dropdown.thisId)
if(!that) return;
var options = that.config;
//如果触发的是绑定的元素,或者属于绑定元素的子元素,则不关闭
//满足条件:当前绑定的元素不是 body document,或者不是鼠标右键事件
if(!(lay.isTopElem(options.elem[0]) || options.trigger === 'contextmenu')){
if(
e.target === options.elem[0] ||
options.elem.find(e.target)[0] ||
e.target === that.elemView[0] ||
(that.elemView && that.elemView.find(e.target)[0])
) return;
}
that.remove();
});
//基础菜单的静态元素事件
var ELEM_LI = '.layui-menu:not(.layui-dropdown-menu) li';
_DOC.on('click', ELEM_LI, function(e){
var othis = $(this)
,parent = othis.parents('.layui-menu').eq(0)
,isChild = othis.hasClass(STR_ITEM_GROUP) || othis.hasClass(STR_ITEM_PARENT)
,filter = parent.attr('lay-filter') || parent.attr('id')
,options = lay.options(this);
//非触发元素
if(othis.hasClass(STR_ITEM_DIV)) return;
//非菜单组
if(!isChild){
//选中
parent.find('.'+ STR_ITEM_CHECKED).removeClass(STR_ITEM_CHECKED); //清除选中样式
parent.find('.'+ STR_ITEM_CHECKED2).removeClass(STR_ITEM_CHECKED2); //清除父级菜单选中样式
othis.addClass(STR_ITEM_CHECKED); //添加选中样式
othis.parents('.'+ STR_ITEM_PARENT).addClass(STR_ITEM_CHECKED2); //添加父级菜单选中样式
//触发事件
layui.event.call(this, MOD_NAME, 'click('+ filter +')', options);
}
});
//基础菜单的展开收缩事件
_DOC.on('click', (ELEM_LI + STR_GROUP_TITLE), function(e){
var othis = $(this)
,elemGroup = othis.parents('.'+ STR_ITEM_GROUP +':eq(0)')
,options = lay.options(elemGroup[0]);
if(('isAllowSpread' in options) ? options.isAllowSpread : true){
thisModule.spread(elemGroup);
};
});
//判断子级菜单是否超出屏幕
var ELEM_LI_PAR = '.layui-menu .'+ STR_ITEM_PARENT
_DOC.on('mouseenter', ELEM_LI_PAR, function(e){
var othis = $(this)
,elemPanel = othis.find('.'+ STR_MENU_PANEL);
if(!elemPanel[0]) return;
var rect = elemPanel[0].getBoundingClientRect();
//是否超出右侧屏幕
if(rect.right > _WIN.width()){
elemPanel.addClass(STR_MENU_PANEL_L);
//不允许超出左侧屏幕
rect = elemPanel[0].getBoundingClientRect();
if(rect.left < 0){
elemPanel.removeClass(STR_MENU_PANEL_L);
}
}
//是否超出底部屏幕
if(rect.bottom > _WIN.height()){
elemPanel.eq(0).css('margin-top', -(rect.bottom - _WIN.height()));
};
}).on('mouseleave', ELEM_LI_PAR, function(e){
var othis = $(this)
,elemPanel = othis.children('.'+ STR_MENU_PANEL);
elemPanel.removeClass(STR_MENU_PANEL_L);
elemPanel.css('margin-top', 0);
});
}();
//重载实例
dropdown.reload = function(id, options){
var that = thisModule.getThis(id);
if(!that) return this;
that.reload(options);
return thisModule.call(that);
};
//核心入口
dropdown.render = function(options){
var inst = new Class(options);
return thisModule.call(inst);
};
exports(MOD_NAME, dropdown);
});
... ...