You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
HENGCHENG/DSWeb/js/TGridCommonWmsOutList.js

1160 lines
44 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

function TGridCommon(id,formName,headArgs,widthArgs,alignArgs,sortArgs,typeArgs){
var self = this;
var gridObj;//grid object
this.formName = formName;//form name
this.id = id;//TGridCommon object id
this.totalPageCount;//Total Count
this.responseUrl;//Ajax Request Url
this.over = false;
this.menu = null;//Menu object
this.pageShowCount = 15;
var shield;//
this.headArgs = headArgs;//Header
this.widthArgs = widthArgs;//Width
this.alignArgs = alignArgs;//Align
this.sortArgs = sortArgs;//Sort
this.typeArgs = typeArgs;//Type
this.attHeaderArgs = [];
this.skin;
this.imageUrl;
this.page;
this.pageSwitch;
this.condition;
this.subGridArgs = [];
this.request;
this.sourceType;
this.openUrl;
this.openType;
this.openSet;
this.isDoubleClick = false;
this.isShowHeader = false;
this.searchVal = "";
this.multipleSearchVal = "";
this.isHiddenColumn = false;
this.isOnEditCell = false;
this.isOnCheckBox = false;
this.isDBClickEvent = false;
this.isOnEditCell = false;
this.hiddenIndex;
this.loadafter = false;
this.pagerName;
this.pagerInfo;
this.isAttchHeader = false;
this.isSort = false;
this.sortValue;
this.sortType;
//find object
this.$ = function(id){
return document.getElementById(id);
};
//initialization grid
this.initGrid = function(){
self.gridObj = new dhtmlXGridObject(self.id);
self.gridObj.setImagePath(self.imageUrl);
self.gridObj.setSkin(self.skin);
self.gridObj.setHeader(self.headArgs.toString());
self.gridObj.setInitWidths(self.widthArgs.toString());
self.gridObj.setColAlign(self.alignArgs.toString());
self.gridObj.setColSorting(self.sortArgs.toString());
self.gridObj.setColTypes(self.typeArgs.toString());
if(self.isShowHeader){
self.gridObj.setNoHeader(self.isShowHeader);
}
if(self.isHiddenColumn){
self.gridObj.setColumnHidden(self.hiddenIndex,true);
}
if(self.isAttchHeader){
self.gridObj.attachHeader(self.attHeaderArgs);
}
self.gridObj.enableAlterCss("odd_row","even_row");
self.gridObj.init();
};
this.after = function(){
};
this.sortEventFun = function(){
};
this.reload = function(){
self.initGrid();
self.bind();
};
//grid bind
this.bind = function(){
//self.responseUrl + "?handle=list&i_page&show_page="+self.pageShowCount.toString()+"&cur_page=1&condition="+self.condition
//self.responseUrl + "?handle=list"+self.condition
if(self.loadafter){
self.gridObj.load(self.request,self.after,self.sourceType);
}else{
self.gridObj.load(self.request,self.sourceType);
}
};
this.setAttachHeader = function(args){
self.attHeaderArgs = args;
}
this.loadinfo = function(){
};
this.showHeader = function(isShow){
self.isShowHeader = isShow;
};
this.setSortValue = function(sort,type){
self.sortValue = sort;
self.sortType = type;
};
this.hiddenColumn = function(index,isHidden){
self.isHiddenColumn = isHidden;
self.hiddenIndex = index;
}
//json load request url
this.setRequest = function(request){
self.request = request;
};
this.getRequest = function(){
return self.request;
};
//source type
this.setSourceType = function(strSourceType){
self.sourceType = strSourceType;
};
//skin
this.setSkin = function(strSkin){
self.skin = strSkin;
};
//imageUrl
this.setImageUrl = function(strImageUrl){
self.imageUrl = strImageUrl;
};
//Response Url
this.setResponseUrl = function(url){
self.responseUrl = url;
};
this.setPageShowCount=function(ShowCount){
self.pageShowCount=ShowCount;
}
//
this.setIsPage = function(isOpen){
self.pageSwitch = isOpen;
};
//refresh grid
this.refresh = function(){
self.initGrid();
};
//load sub grid
this.clickShowSubGrid = function(subGridObj){
self.gridObj.attachEvent("onRowDblClicked", function(rId,cInd){
subGridObj.bind();
});
};
this.getGridObj = function(){
return self.gridObj;
}
this.setSubGrid = function(subGrid){
self.subGridArgs = subGrid;
};
//window open url
this.setOpenUrl = function(openUrl){
self.openUrl = openUrl;
};
//window open type
this.setOpenType = function(strType){
self.openType = strType;
};
//window open set
this.setOpenSet = function(strSet){
self.openSet = strSet;
};
this.dbclickPop = function(){
//set status
self.isDoubleClick = true;
self.gridObj.attachEvent("onRowDblClicked", function(rId,cInd){
window.open (self.openUrl+rId,self.openType,self.openSet);
});
};
this.clickEvent = function(){
// if(self.gridObj != null){
//
// alert();
// }else{
// alert("Object is null");
// }
};
this.dbclickEvent = function(){
};
this.onEditEvent = function(){
};
this.onCheckBox = function(){
};
this.onEditCellEvent = function(){
};
this.clickRefrash = function(){
self.initGrid();
};
this.setPagerName = function(objName){
self.pagerName = objName;
};
this.setPagerInfo = function(objInfo){
self.pagerInfo = objInfo;
}
this.setPagerCount = function(count){
self.pageShowCount = count;
}
this.getGridRowID = function(gridObj){
var selRowID = mygrid_recv.getSelectedRowId();
var selGroup = new Array();
if(selRowID.indexOf(",") > 0){
selGroup = selRowID.split(",");
}else{
if(selRowID != null){
selGroup.push(selRowID);
}
}
return selGroup;
};
this.enableMultiselect = function(bValue){
self.gridObj.enableMultiselect(bValue);
};
this.getObjByClassName = function(eleClassName){
var getEleClass = [];//定义一个数组
var myclass = new RegExp("\\b"+eleClassName+"\\b");//创建一个正则表达式对像
var elem = document.body.all.tags("DIV");//获取文档里所有的元素
for(var h=0;h<elem.length;h++)
{
var classes = elem[h].className;//获取class对像
if (myclass.test(classes)){
getEleClass.push(elem[h]);//正则比较取到想要的CLASS对像
}
}
return getEleClass;//返回数组
}
//get total page count
this.getTotalPage = function(){
var urlVal = self.responseUrl + "?handle=page&val="+self.newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
};
//Get Guid
this.newGuid = function(){
var guid = "";
for (var i = 1; i <= 32; i++){
var n = Math.floor(Math.random()*16.0).toString(16);
guid += n;
if((i==8)||(i==12)||(i==16)||(i==20))
guid += "-";
}
return guid.toUpperCase();
};
//初始化页面
this.initPage = function(){
self.pager = new PagerView('pager');
var urlVal = self.responseUrl + "?handle=page&val="+self.newGuid();//alert(self.responseUrl + "?handle=page&val="+self.newGuid());
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
self.totalPageCount = loadVal;
self.pager.itemCount = self.totalPageCount;
self.pager.size = self.pageShowCount;
self.pager.index = 1;
self.pager.onclick = function(index){
document.getElementById('info').innerHTML = '现在翻到第' + index + '页';
self.request = self.responseUrl + "?handle=list&show_page="+self.pager.size.toString()+"&cur_page="+index;
setTimeout(function(){
self.initGrid();
self.bind();
if(self.isDoubleClick){
self.dbclickPop();
}
},300);
};
self.pager.render();
};
this.initCommonPager = function(handleName,idQuery){
if(self.pagerName != null){
self.pager = new PagerView(self.pagerName);
}else{
self.pager = new PagerView('pager');
}
var urlVal = "";
if(self.searchVal.length > 1){
//urlVal = self.responseUrl + "?handle=" + handleName + "page&search=" + escape(self.searchVal) + idQuery + "&val=" + self.newGuid();
if (self.multipleSearchVal.length > 1) {
urlVal = self.responseUrl + "?handle=" + handleName + "page&search=" + escape(self.searchVal) + self.multipleSearchVal + idQuery + "&val=" + self.newGuid();
} else {
urlVal = self.responseUrl + "?handle=" + handleName + "page&search=" + escape(self.searchVal) + idQuery + "&val=" + self.newGuid();
}
}else{
//urlVal = self.responseUrl + "?handle=" + handleName + "page" + idQuery + "&val=" + self.newGuid();
if (self.multipleSearchVal.length > 1) {
urlVal = self.responseUrl + "?handle=" + handleName + "page" + self.multipleSearchVal + idQuery + "&val=" + self.newGuid();
} else {
urlVal = self.responseUrl + "?handle=" + handleName + "page" + idQuery + "&val=" + self.newGuid();
}
}
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
self.totalPageCount = loadVal;
self.pager.itemCount = self.totalPageCount;
self.pager.size = self.pageShowCount;
self.pager.index = 1;
self.pager.onclick = function(index){
if(self.pagerInfo != null){
document.getElementById(self.pagerInfo).innerHTML = '现在翻到第' + index + '页';
}else{
document.getElementById('info').innerHTML = '现在翻到第' + index + '页';
}
if(self.searchVal.length > 1){
self.request = self.responseUrl + "?handle="+handleName+"&show_page="+self.pager.size.toString()+"&cur_page="+index+idQuery+"&search="+escape(self.searchVal);
}else{
self.request = self.responseUrl + "?handle="+handleName+"&show_page="+self.pager.size.toString()+"&cur_page="+index+idQuery;
}
setTimeout(function(){
self.initGrid();
self.bind();
self.clickEvent();
if(self.isDoubleClick){
self.dbclickPop();
}
if(self.isOnEditCell){
self.onEditEvent();
}
if(self.isOnCheckBox){
self.onCheckBox();
}
if(self.isOnEditCell){
self.onEditCellEvent();
}
},300);
};
self.pager.render();
}
//初始化页面
this.initPageByHandle = function(handleName) {
var lsurl = "";
self.pager = new PagerView('pager');
var urlVal = "";
if (self.searchVal.length > 1) {
if (self.multipleSearchVal.length > 1) {
urlVal = self.responseUrl + "?handle=" + handleName + "page&search=" + escape(self.searchVal) + self.multipleSearchVal + "&val=" + self.newGuid();
} else {
urlVal = self.responseUrl + "?handle=" + handleName + "page&search=" + escape(self.searchVal) + "&val=" + self.newGuid();
}
} else {
if (self.multipleSearchVal.length > 1) {
urlVal = self.responseUrl + "?handle=" + handleName + "page" + self.multipleSearchVal + "&val=" + self.newGuid();
} else {
urlVal = self.responseUrl + "?handle=" + handleName + "page&val=" + self.newGuid();
}
}
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
self.totalPageCount = loadVal;
self.pager.itemCount = self.totalPageCount;
self.pager.size = self.pageShowCount;
self.pager.index = 1;
self.pager.onclick = function(index) {
document.getElementById('info').innerHTML = '现在翻到第' + index + '页';
if (self.searchVal.length > 1) {
var tempSortValue = "";
var tempSortIndex = "";
if (self.sortValue != null && self.sortType != null) {
tempSortValue = "&sort=" + self.sortValue;
tempSortIndex = "&sortindex=" + self.sortType;
// if(self.request.indexOf("&sort=") >= 0){
// var beginString = self.request.substr(0,self.request.indexOf("&sort="));
// var endString = self.request.substr(self.request.indexOf("&sort="),self.request.length - self.request.indexOf("&sort="));
// var midString = endString.substr(1,endString.length - 1);
// var midSecondStr = "";
// if(midString.indexOf("&") >= 0){
// midSecondStr = midString.substr(midString.indexOf("&"),midString.length-midString.indexOf("&"));
// }
//
// self.request = beginString+tempSortValue+midSecondStr;
// }
//
// if(self.request.indexOf("&sortindex=") >= 0){
// var beginString = self.request.substr(0,self.request.indexOf("&sortindex="));
// var endString = self.request.substr(self.request.indexOf("&sortindex="),self.request.length - self.request.indexOf("&sortindex="));
// var midString = endString.substr(1,endString.length - 1);
// var midSecondStr = "";
// if(midString.indexOf("&") >= 0){
// midSecondStr = midString.substr(midString.indexOf("&"),midString.length-midString.indexOf("&"));
// }
//
// self.request = beginString+tempSortIndex+midSecondStr;
// }
lsurl = self.responseUrl + "?show_page=" + self.pager.size.toString() + "&cur_page=" + index + "&search=" + escape(self.searchVal) + tempSortValue + tempSortIndex;
//self.request = self.responseUrl + "?handle=" + handleName + "&show_page=" + self.pager.size.toString() + "&cur_page=" + index + "&search=" + escape(self.searchVal) + tempSortValue + tempSortIndex;
if (self.multipleSearchVal.length > 1) {
self.request = self.responseUrl + "?handle=" + handleName + "&show_page=" + self.pager.size.toString() + "&cur_page=" + index + "&search=" + escape(self.searchVal) + tempSortValue + tempSortIndex + self.multipleSearchVal;
} else {
self.request = self.responseUrl + "?handle=" + handleName + "&show_page=" + self.pager.size.toString() + "&cur_page=" + index + "&search=" + escape(self.searchVal) + tempSortValue + tempSortIndex;
}
} else {
lsurl = self.responseUrl + "?show_page=" + self.pager.size.toString() + "&cur_page=" + index + "&search=" + escape(self.searchVal);
//self.request = self.responseUrl + "?handle=" + handleName + "&show_page=" + self.pager.size.toString() + "&cur_page=" + index + "&search=" + escape(self.searchVal);
if (self.multipleSearchVal.length > 1) {
self.request = self.responseUrl + "?handle=" + handleName + "&show_page=" + self.pager.size.toString() + "&cur_page=" + index + "&search=" + escape(self.searchVal) + self.multipleSearchVal;
} else {
self.request = self.responseUrl + "?handle=" + handleName + "&show_page=" + self.pager.size.toString() + "&cur_page=" + index + "&search=" + escape(self.searchVal);
}
}
} else {
var tempSortValue = "";
var tempSortIndex = "";
if (self.sortValue != null && self.sortType != null) {
tempSortValue = "&sort=" + self.sortValue;
tempSortIndex = "&sortindex=" + self.sortType;
// if(self.request.indexOf("&sort=") >= 0){
// var beginString = self.request.substr(0,self.request.indexOf("&sort="));
// var endString = self.request.substr((self.request.indexOf("&sort=")),(self.request.length - self.request.indexOf("&sort=")));
// var midString = endString.substr(1,endString.length - 1);
// var midSecondStr = "";
// if(midString.indexOf("&") >= 0){
// midSecondStr = midString.substr(midString.indexOf("&"),midString.length-midString.indexOf("&"));
// }
//
// self.request = beginString+tempSortValue+midSecondStr;
// }
//
// if(self.request.indexOf("&sortindex=") >= 0){
// var beginString = self.request.substr(0,self.request.indexOf("&sortindex="));
// var endString = self.request.substr(self.request.indexOf("&sortindex="),self.request.length - self.request.indexOf("&sortindex="));
// var midString = endString.substr(1,endString.length - 1);
// var midSecondStr = "";
// if(midString.indexOf("&") >= 0){
// midSecondStr = midString.substr(midString.indexOf("&"),midString.length-midString.indexOf("&"));
// }
//
// self.request = beginString+tempSortIndex+midSecondStr;
// }
lsurl = self.responseUrl + "?show_page=" + self.pager.size.toString() + "&cur_page=" + index + tempSortValue + tempSortIndex;
//self.request = self.responseUrl + "?handle=" + handleName + "&show_page=" + self.pager.size.toString() + "&cur_page=" + index + tempSortValue + tempSortIndex;
if (self.multipleSearchVal.length > 1) {
self.request = self.responseUrl + "?handle=" + handleName + "&show_page=" + self.pager.size.toString() + "&cur_page=" + index + tempSortValue + tempSortIndex + self.multipleSearchVal;
} else {
self.request = self.responseUrl + "?handle=" + handleName + "&show_page=" + self.pager.size.toString() + "&cur_page=" + index + tempSortValue + tempSortIndex;
}
} else {
lsurl = self.responseUrl + "?show_page=" + self.pager.size.toString() + "&cur_page=" + index;
//self.request = self.responseUrl + "?handle=" + handleName + "&show_page=" + self.pager.size.toString() + "&cur_page=" + index;
if (self.multipleSearchVal.length > 1) {
self.request = self.responseUrl + "?handle=" + handleName + "&show_page=" + self.pager.size.toString() + "&cur_page=" + index + self.multipleSearchVal;
} else {
self.request = self.responseUrl + "?handle=" + handleName + "&show_page=" + self.pager.size.toString() + "&cur_page=" + index;
}
}
}
setTimeout(function() {
self.initGrid();
self.bind();
self.clickEvent();
self.onEditEvent();
if (self.isDoubleClick) {
self.dbclickPop();
}
if (self.isDBClickEvent) {
self.dbclickEvent();
}
if (self.isOnEditCell) {
self.onEditCellEvent();
}
if (self.isSort) {
self.sortEventFun();
}
if (self.isOnCheckBox) {
self.onCheckBox();
}
}, 300);
};
self.pager.render();
};
//初始化页面
this.initPageByGID = function(handleName,idQuery){
self.pager = new PagerView('pager');
var urlVal = "";
if(self.searchVal.length > 1){
urlVal = self.responseUrl + "?handle="+handleName+"page&search="+escape(self.searchVal)+idQuery+"&val="+self.newGuid();//alert(self.responseUrl + "?handle=page&val="+self.newGuid());
}else{
urlVal = self.responseUrl + "?handle="+handleName+"page"+idQuery+"&val="+self.newGuid();
}
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
self.totalPageCount = loadVal;
self.pager.itemCount = self.totalPageCount;
self.pager.size = self.pageShowCount;
self.pager.index = 1;
self.pager.onclick = function(index){
document.getElementById('info').innerHTML = '现在翻到第' + index + '页';
if(self.searchVal.length > 1){
//self.request = self.responseUrl + "?handle=" + handleName + "&show_page=" + self.pager.size.toString() + "&cur_page=" + index + idQuery + "&search=" + escape(self.searchVal);
if (self.multipleSearchVal.length > 1) {
self.request = self.responseUrl + "?handle=" + handleName + "&show_page=" + self.pager.size.toString() + "&cur_page=" + index + idQuery + "&search=" + escape(self.searchVal) + self.multipleSearchVal;
} else {
self.request = self.responseUrl + "?handle=" + handleName + "&show_page=" + self.pager.size.toString() + "&cur_page=" + index + idQuery + "&search=" + escape(self.searchVal);
}
}else{
//self.request = self.responseUrl + "?handle=" + handleName + "&show_page=" + self.pager.size.toString() + "&cur_page=" + index + idQuery;
if (self.multipleSearchVal.length > 1) {
self.request = self.responseUrl + "?handle=" + handleName + "&show_page=" + self.pager.size.toString() + "&cur_page=" + index + idQuery + self.multipleSearchVal;
} else {
self.request = self.responseUrl + "?handle=" + handleName + "&show_page=" + self.pager.size.toString() + "&cur_page=" + index + idQuery;
}
}
setTimeout(function(){
self.initGrid();
self.bind();
self.clickEvent();
if(self.isDoubleClick){
self.dbclickPop();
}
if(self.isOnEditCell){
self.onEditEvent();
}
if(self.isOnCheckBox){
self.onCheckBox();
}
if(self.isOnEditCell){
self.onEditCellEvent();
}
},300);
};
self.pager.render();
};
//save grid column setting change(include: name,width,index)
this.saveColumnSetting = function(){
var colCount = this.gridObj.getColumnsNum();
var jsonFeeObj = "";
jsonFeeObj = "{\"$type\":\"DSWeb.Models.JsonColumnGroupEntity, DSWeb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\",\"ShowCount\":"+pageShowCount+",\"JsonColumnEntities\":[";
var tempGroupJson = "";
for(var i=0;i<colCount;i++){
var tempJson = "";
var rId = this.gridObj.getRowId(i);
tempJson += "\"$type\":\"DSWeb.Models.JsonColumnEntity, DSWeb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\",";
tempJson += "\"col1\":\"\",";//gid
tempJson += "\"col2\":\""+i.toString()+"\",";//column name
tempJson += "\"col3\":\""+this.gridObj.getColumnLabel(i)+"\",";//column description
tempJson += "\"col4\":\""+i.toString()+"\",";//index
tempJson += "\"col5\":\""+this.gridObj.getColWidth(i)+"\",";//width
tempJson += "\"col6\":-1";
tempJson = "{"+tempJson+"}";
if(i == colCount - 1){
tempGroupJson += tempJson;
}else{
tempGroupJson += tempJson+",";
}
}
jsonFeeObj += tempGroupJson;
jsonFeeObj += "]}";
$("hid_setting").value = jsonFeeObj;
jsonFeeObj = null;
//alert(jsonFeeObj);
var myForm = document.getElementById("form1");
myForm.submit() ;
};
this.initMenu = function(id){
this.$(id).oncontextmenu = function(ev){
showMenu(ev);
return false;
};
document.onmousedown = function(){if(!self.over)hideMenu();};
};
//显示右键菜单
this.showMenu = function(){
self.menu = null;
ev = ev || window.event;
hideMenu();
var e = ev.srcElement || ev.target;
if(e.tagName=="TH") return;
var x = ev.pageX || ev.clientX + document.documentElement.scrollLeft;
var y = ev.pageY || ev.clientY + document.documentElement.scrollTop;
self.menu = document.createElement("DIV");
self.menu.className = "menu";
self.menu.style.left = x+4+"px";
self.menu.style.top = y+"px";
document.body.appendChild(self.menu);
//alert(e.parentNode.getElementsByTagName("DIV")[1].innerHTML);
var dvGroup = e.parentNode.getElementsByTagName("DIV");
var dvGroupCount = dvGroup.length;
var id ="";
if(dvGroupCount == 1){
id = dvGroup[0].innerHTML;
}
if(id.trim().length < 1){
hideMenu();
return;
}
var sname = document.location.pathname.substring(7,location.pathname.length).toString();
var s = "<div class=\"dvMenu\" >修改标题</div><div class=\"dvMenu\" onclick=\"editColumnSetting('dvColumnSet')\">编辑显示</div>";
self.menu.innerHTML = s;
self.menu.onmouseover = function(){self.over=true;};
self.menu.onmouseout = function(){self.over=false;};
};
//hide menu object
this.hideMenu = function(){
if(self.menu){
document.body.removeChild(self.menu);
self.menu = null;
}
};
//IS NUMBER
this.IsNum = function(val){
var re = /^[-\+]?\d+(\.\d+)?$/;
if (!re.test(val)){
return false;
}else{
return true;
}
};
this.setSearch = function(val){
self.searchVal = val;
};
this.setMultiple = function(val){
self.multipleSearchVal = val;
};
//is exist object
var docEle = function() {
return document.getElementById(arguments[0]) || false;
};
this.openNewDiv = function(){
var m = "mask";
if (docEle(_id)) document.removeChild(docEle(_id));
if (docEle(m)) document.removeChild(docEle(m));
// 新激活图层
var newDiv = document.createElement("div");
newDiv.id = _id;
newDiv.style.position = "absolute";
newDiv.style.zIndex = "9999";
newDiv.style.width = "200px";
newDiv.style.height = "100px";
newDiv.style.top = "100px";
newDiv.style.left = (parseInt(document.body.scrollWidth) - 300) / 2 + "px"; // 屏幕居中
newDiv.style.background = "#EFEFEF";
newDiv.style.border = "1px solid #860001";
newDiv.style.padding = "5px";
newDiv.innerHTML = "<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;您已更改了视图设置 是否保存<br/><br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
document.body.appendChild(newDiv);
// mask图层
var newMask = document.createElement("div");
newMask.id = m;
newMask.style.position = "absolute";
newMask.style.zIndex = "1";
newMask.style.width = document.body.scrollWidth + "px";
newMask.style.height = document.body.scrollHeight + "px";
newMask.style.top = "0px";
newMask.style.left = "0px";
newMask.style.background = "#000";
newMask.style.filter = "alpha(opacity=40)";
newMask.style.opacity = "0.40";
document.body.appendChild(newMask);
// 关闭mask和新图层
var saveButton = document.createElement("a");
saveButton.href = "#";
saveButton.innerHTML = "确定";
saveButton.className="regular";
saveButton.onclick = function() {
this.saveColumnSetting();// save user grid column setting
}
newDiv.appendChild(saveButton);
//newDiv.innerHTML += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
var cancelButton = document.createElement("a");
cancelButton.href = "#";
cancelButton.innerHTML = "取消";
cancelButton.className="regular";
cancelButton.onclick = function() {
document.body.removeChild(docEle(_id));
document.body.removeChild(docEle(m));
cancelColumnSet();
return false;
}
newDiv.appendChild(cancelButton);
};
this.cancelColumnSet = function(){
self.gridObj = new dhtmlXGridObject(self.id);
self.gridObj.setImagePath(self.imageUrl);
self.gridObj.setSkin(self.skin);
self.gridObj.setHeader(self.headArgs.toString());
self.gridObj.setInitWidths(self.widthArgs.toString());
self.gridObj.setColAlign(self.alignArgs.toString());
self.gridObj.setColSorting(self.sortArgs.toString());
self.gridObj.setColTypes(self.typeArgs.toString());
self.gridObj.init();
setTimeout(function(){
mygrid_log.load(rspUrl + "?handle=list&show_page="+self.pageShowCount+"&cur_page=1","json");
},300);
this.initPage();
initMenu();
};
this.getUserGridSetting = function(){
var urlVal = self.responseUrl + "handle=setting&val="+newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
jsonPage = loadVal;
if(IsNum(jsonPage)){
jsonPageObj = null;
}else{
jsonPageObj = eval('(' + loadVal + ')');
}
};
this.editColumnSetting = function(){
hideMenu();
var m = "mask";
if (docEle(_id)) document.removeChild(docEle(_id));
if (docEle(m)) document.removeChild(docEle(m));
// 新激活图层
var newDiv = document.createElement("div");
newDiv.id = _id;
newDiv.style.position = "absolute";
newDiv.style.zIndex = "9999";
newDiv.style.width = "700px";
newDiv.style.height = "340px";
newDiv.style.top = "100px";
newDiv.style.left = (parseInt(document.body.scrollWidth) - 560) / 2 + "px"; // 屏幕居中
newDiv.style.background = "#EFEFEF";
newDiv.style.border = "1px solid #860001";
newDiv.style.padding = "5px";
getUserGridSetting();
var TargeVal = "";
if(jsonPageObj != null){
for(var i=0;i<jsonPageObj.columns.length;i++){
TargeVal += "<option value=\""+jsonPageObj.columns[i].name+"\">"+jsonPageObj.columns[i].description+"</option>";
}
}
var editObj = "<div style=\"float:left\"><select id=\"sel_LogColumns\" multiple=\"multiple\" style=\"width:200px;height:300px;\">"
+ "<option value=\"NAME\">日志名称</option><option value=\"LOGTYPE\">日志类型</option><option value=\"LOGTIME\">日志记录时间</option>"
+ "<option value=\"LOGCONTENT\">日志内容</option><option value=\"USERNAME\">操作人</option></select></div>"
+ "<div style=\"float:left; width:60px;height:210px;margin:0 auto;text-align:center;vertical-align:middle;line-height:300px; padding-top:90px\">"
+ "<div class=\"imgLeftButton\" onmousemove=\"this.className='imgLeftHoverButton'\" onmouseout=\"this.className='imgLeftButton'\" title=\"添加\" onclick=\"add()\"></div>"
+ "<div class=\"imgRightButton\" onmousemove=\"this.className='imgRightHoverButton'\" onmouseout=\"this.className='imgRightButton'\" title=\"移除\" onclick=\"remove()\"></div>"
+ "</div><div style=\"float:left;\"><select id=\"sel_VisiableColumns\" multiple=\"multiple\" style=\"width:200px;height:300px;\">"+TargeVal+"</select></div>"
+ "<div style=\"float:left; width:60px;height:210px;margin:0 auto;text-align:center;vertical-align:middle;line-height:300px; padding-top:90px\">"
+ "<div class=\"imgUpButton\" onmousemove=\"this.className='imgUpHoverButton'\" onmouseout=\"this.className='imgUpButton'\" title=\"向上\" onclick=\"up()\"></div>"
+ "<div class=\"imgDownButton\" onmousemove=\"this.className='imgDownHoverButton'\" onmouseout=\"this.className='imgDownButton'\" title=\"向下\" onclick=\"down()\"></div></div>"
+ "<div><div style=\"float:left\"><input type=\"text\" id=\"txt_rename\" style=\"height:20px;width:110px; \"/></div>"
+ "<div class=\"enterButton\" style=\"width:30px; \" onclick=\"saveRename()\">保存</div></div>"
+ "<div style=\"float:left; width:70px;\"><div class=\"enterButton\" onclick=\"pushRename()\">重命名</div></div>"
+ "<div style=\"float:left;width:100%;padding-left:120px;\"><div class=\"enterButton\" onclick=\"saveColumnHeader()\">保存</div><div class=\"enterButton\" onclick=\"cancelColumnHeader()\">取消</div></div>";
newDiv.innerHTML = editObj;
document.body.appendChild(newDiv);
// mask图层
var newMask = document.createElement("div");
newMask.id = m;
newMask.style.position = "absolute";
newMask.style.zIndex = "1";
newMask.style.width = document.body.scrollWidth + "px";
newMask.style.height = document.body.scrollHeight + "px";
newMask.style.top = "0px";
newMask.style.left = "0px";
newMask.style.background = "#000";
newMask.style.filter = "alpha(opacity=40)";
newMask.style.opacity = "0.40";
document.body.appendChild(newMask);
// 关闭mask和新图层
};
}
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); }
//pager view
function PagerView(id){
var selfp = this;
this.id = id;
this.container = null;
this.index = 1; // 当前页码, 从1开始
this.size = self.pageShowCount; // 每页显示记录数
this.maxButtons = 9; // 显示的分页按钮数量
this.itemCount = 0; // 记录总数
this.pageCount = 0; // 总页数
/**
* 控件使用者重写本方法, 获取翻页事件, 可用来向服务器端发起AJAX请求.
* @param index: 被点击的页码.
*/
this.onclick = function(index){
};
/**
* 内部方法.
*/
this._onclick = function(index){
selfp.index = index;
selfp.onclick(index);
selfp.render();
};
/**
* 在显示之前计算各种页码变量的值.
*/
this.calculate = function(){
selfp.pageCount = parseInt(Math.ceil(selfp.itemCount / selfp.size));
selfp.index = parseInt(selfp.index);
if(selfp.index > selfp.pageCount){
selfp.index = selfp.pageCount;
}
};
/**
* 渲染分页控件.
*/
this.render = function(){
if(selfp.id != undefined){
var div = document.getElementById(selfp.id);
div.view = selfp;
selfp.container = div;
}
selfp.calculate();
var start, end;
start = Math.max(1, selfp.index - parseInt(selfp.maxButtons/2));
end = Math.min(selfp.pageCount, start + selfp.maxButtons - 1);
start = Math.max(1, end - selfp.maxButtons + 1);
var str = "";
str += "<div class=\"PagerView\">\n";
if(selfp.pageCount > 1){
if(selfp.index != 1){
str += '<a href="javascript://1"><span>|&lt;</span></a>';
str += '<a href="javascript://' + (selfp.index-1) + '"><span>&lt;&lt;</span></a>';
}else{
str += '<span>|&lt;</span>';
str += '<span>&lt;&lt;</span>';
}
}
for(var i=start; i<=end; i++){
if(i == this.index){
str += '<span class="on">' + i + "</span>";
}else{
str += '<a href="javascript://' + i + '"><span>' + i + "</span></a>";
}
}
if(selfp.pageCount > 1){
if(selfp.index != selfp.pageCount){
str += '<a href="javascript://' + (selfp.index+1) + '"><span>&gt;&gt;</span></a>';
str += '<a href="javascript://' + selfp.pageCount + '"><span>&gt;|</span></a>';
}else{
str += '<span>&gt;&gt;</span>';
str += '<span>&gt;|</span>';
}
}
str += ' 一共' + selfp.pageCount + '页, ' + selfp.itemCount + '条记录 '+'&nbsp;&nbsp;&nbsp;每页显示:&nbsp;'+"<select id=\"cusShowCount\" style=\"width:70px;\" onchange=\"changeShowCount('cusShowCount')\">"+selfp.getPageOption(selfp.size)+"</select>";
str += "</div><!-- /.pagerView -->\n";
selfp.container.innerHTML = str;
var a_list = selfp.container.getElementsByTagName('a');
for(var i=0; i<a_list.length; i++){
a_list[i].onclick = function(){
var index = this.getAttribute('href');
if(index != undefined && index != ''){
index = parseInt(index.replace('javascript://', ''));
selfp._onclick(index)
}
return false;
};
}
};
this.getPageOption = function(size){
var pageCountArg = new Array();
pageCountArg.push(5);
pageCountArg.push(15);
pageCountArg.push(30);
pageCountArg.push(50);
pageCountArg.push(100);
pageCountArg.push(200);
var optionStr = "";
for(var i = 0;i<pageCountArg.length;i++){
if(size == parseInt(pageCountArg[i])){
optionStr += "<option value=\""+pageCountArg[i]+"\" selected=\"1\">"+pageCountArg[i]+"</option>";
}else{
optionStr += "<option value=\""+pageCountArg[i]+"\">"+pageCountArg[i]+"</option>";
}
}
return optionStr;
};
}
function el(id){
return document.getElementById(id);
}
function initMenu(gridObj){
el(gridObj).oncontextmenu = function(ev){
showMenu(ev);
return false;
};
document.onmousedown = function(){if(!over)hideMenu();};
};
var over = false;
var menu = null;
function showMenu(ev){
menu = null;
ev = ev || window.event;
hideMenu();
var e = ev.srcElement || ev.target;
if(e.tagName=="TH") return;
var x = ev.pageX || ev.clientX + document.documentElement.scrollLeft;
var y = ev.pageY || ev.clientY + document.documentElement.scrollTop;
menu = document.createElement("DIV");
menu.className = "menu";
menu.style.left = x+4+"px";
menu.style.top = y+"px";
document.body.appendChild(menu);
//alert(e.parentNode.getElementsByTagName("DIV")[1].innerHTML);
var dvGroup = e.parentNode.getElementsByTagName("DIV");
var dvGroupCount = dvGroup.length;
var id ="";
if(dvGroupCount == 1){
id = dvGroup[0].innerHTML;
}
if(id.trim().length < 1){
hideMenu();
return;
}
var sname = document.location.pathname.substring(7,location.pathname.length).toString();
var s = "<div class=\"dvMenu\" onclick=\"editColumnSetting('dvColumnSet')\">编辑显示</div>";
menu.innerHTML = s;
menu.onmouseover = function(){over=true;};
menu.onmouseout = function(){over=false;};
}
function hideMenu(){
if(menu){
document.body.removeChild(menu);
menu = null;
}
}
function editColumnSetting(_id) {
hideMenu();
var m = "mask";
if (docEle(_id)) document.removeChild(docEle(_id));
if (docEle(m)) document.removeChild(docEle(m));
// 新激活图层
var newDiv = document.createElement("div");
newDiv.id = _id;
newDiv.style.position = "absolute";
newDiv.style.zIndex = "9999";
newDiv.style.width = "700px";
newDiv.style.height = "340px";
newDiv.style.top = "100px";
newDiv.style.left = (parseInt(document.body.scrollWidth) - 560) / 2 + "px"; // 屏幕居中
newDiv.style.background = "#EFEFEF";
newDiv.style.border = "1px solid #860001";
newDiv.style.padding = "5px";
getUserGridSetting();
var TargeVal = "";
if(jsonPageObj != null){
for(var i=0;i<jsonPageObj.columns.length;i++){
TargeVal += "<option value=\""+jsonPageObj.columns[i].name+"\">"+jsonPageObj.columns[i].description+"</option>";
}
}
var editObj = "<div style=\"float:left\"><select id=\"sel_LogColumns\" multiple=\"multiple\" style=\"width:200px;height:300px;\">"
+ "<option value=\"NAME\">日志名称</option><option value=\"LOGTYPE\">日志类型</option><option value=\"LOGTIME\">日志记录时间</option>"
+ "<option value=\"LOGCONTENT\">日志内容</option><option value=\"USERNAME\">操作人</option></select></div>"
+ "<div style=\"float:left; width:60px;height:210px;margin:0 auto;text-align:center;vertical-align:middle;line-height:300px; padding-top:90px\">"
+ "<div class=\"imgLeftButton\" onmousemove=\"this.className='imgLeftHoverButton'\" onmouseout=\"this.className='imgLeftButton'\" title=\"添加\" onclick=\"add()\"></div>"
+ "<div class=\"imgRightButton\" onmousemove=\"this.className='imgRightHoverButton'\" onmouseout=\"this.className='imgRightButton'\" title=\"移除\" onclick=\"remove()\"></div>"
+ "</div><div style=\"float:left;\"><select id=\"sel_VisiableColumns\" multiple=\"multiple\" style=\"width:200px;height:300px;\">"+TargeVal+"</select></div>"
+ "<div style=\"float:left; width:60px;height:210px;margin:0 auto;text-align:center;vertical-align:middle;line-height:300px; padding-top:90px\">"
+ "<div class=\"imgUpButton\" onmousemove=\"this.className='imgUpHoverButton'\" onmouseout=\"this.className='imgUpButton'\" title=\"向上\" onclick=\"up()\"></div>"
+ "<div class=\"imgDownButton\" onmousemove=\"this.className='imgDownHoverButton'\" onmouseout=\"this.className='imgDownButton'\" title=\"向下\" onclick=\"down()\"></div></div>"
+ "<div><div style=\"float:left\"><input type=\"text\" id=\"txt_rename\" style=\"height:20px;width:110px; \"/></div>"
+ "<div class=\"enterButton\" style=\"width:30px; \" onclick=\"saveRename()\">保存</div></div>"
+ "<div style=\"float:left; width:70px;\"><div class=\"enterButton\" onclick=\"pushRename()\">重命名</div></div>"
+ "<div style=\"float:left;width:100%;padding-left:120px;\"><div class=\"enterButton\" onclick=\"saveColumnHeader()\">保存</div><div class=\"enterButton\" onclick=\"cancelColumnHeader()\">取消</div></div>";
newDiv.innerHTML = editObj;
document.body.appendChild(newDiv);
// mask图层
var newMask = document.createElement("div");
newMask.id = m;
newMask.style.position = "absolute";
newMask.style.zIndex = "1";
newMask.style.width = document.body.scrollWidth + "px";
newMask.style.height = document.body.scrollHeight + "px";
newMask.style.top = "0px";
newMask.style.left = "0px";
newMask.style.background = "#000";
newMask.style.filter = "alpha(opacity=40)";
newMask.style.opacity = "0.40";
document.body.appendChild(newMask);
// 关闭mask和新图层
}
var docEle = function() {
return document.getElementById(arguments[0]) || false;
}
function openNewDiv(_id) {
var m = "mask";
if (docEle(_id)) document.removeChild(docEle(_id));
if (docEle(m)) document.removeChild(docEle(m));
// 新激活图层
var newDiv = document.createElement("div");
newDiv.id = _id;
newDiv.style.position = "absolute";
newDiv.style.zIndex = "9999";
newDiv.style.width = "200px";
newDiv.style.height = "100px";
newDiv.style.top = "100px";
newDiv.style.left = (parseInt(document.body.scrollWidth) - 300) / 2 + "px"; // 屏幕居中
newDiv.style.background = "#EFEFEF";
newDiv.style.border = "1px solid #860001";
newDiv.style.padding = "5px";
newDiv.innerHTML = "<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;您已更改了视图设置 是否保存<br/><br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
document.body.appendChild(newDiv);
// mask图层
var newMask = document.createElement("div");
newMask.id = m;
newMask.style.position = "absolute";
newMask.style.zIndex = "1";
newMask.style.width = document.body.scrollWidth + "px";
newMask.style.height = document.body.scrollHeight + "px";
newMask.style.top = "0px";
newMask.style.left = "0px";
newMask.style.background = "#000";
newMask.style.filter = "alpha(opacity=40)";
newMask.style.opacity = "0.40";
document.body.appendChild(newMask);
// 关闭mask和新图层
var saveButton = document.createElement("a");
saveButton.href = "#";
saveButton.innerHTML = "确定";
saveButton.className="regular";
saveButton.onclick = function() {
change();
//document.body.removeChild(docEle(_id));
//document.body.removeChild(docEle(m));
//return false;
}
newDiv.appendChild(saveButton);
//newDiv.innerHTML += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
var cancelButton = document.createElement("a");
cancelButton.href = "#";
cancelButton.innerHTML = "取消";
cancelButton.className="regular";
cancelButton.onclick = function() {
document.body.removeChild(docEle(_id));
document.body.removeChild(docEle(m));
unSaveGrid();
return false;
}
newDiv.appendChild(cancelButton);
}
function changeShowCount(){
}