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.
DS7/DSWeb/js/jsGridCodeSourceSet_2.js

941 lines
32 KiB
JavaScript

var mygrid_log2;
var pager2;
var jsonPage2;
var jsonPage2Obj2;
var pageTotal2;
var pageShowCount2 = 15;
var curPage2 = 1;
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); }
function $(id) {
return document.getElementById(id);
}
function initLog2() {
//getUserSetting
getUserGridSetting2();
mygrid_log2 = new dhtmlXGridObject('mygrid_container_log2');
mygrid_log2.setImagePath("../images/");
mygrid_log2.setSkin("xp");
//
var arrayHeader = new Array();
var arrayColWidth = new Array();
if (jsonPage2Obj2 != null) {
for (var i = 0; i < jsonPage2Obj2.columns.length; i++) {
arrayHeader.push(jsonPage2Obj2.columns[i].description.trim());
arrayColWidth.push(jsonPage2Obj2.columns[i].width);
}
var strHeader = arrayHeader.toString();
var strWidth = arrayColWidth.toString();
pageShowCount2 = jsonPage2Obj2.show;
mygrid_log2.setHeader(strHeader);
mygrid_log2.setInitWidths(strWidth);
}
else {
mygrid_log2.setHeader("<input type=\"checkbox\" id=\"ck_all_2\" onclick=\"checkall_2()\" />,市场来源大类,市场来源细类");
mygrid_log2.setInitWidths("30,300,300");
}
mygrid_log2.setColAlign("center,left,left");
mygrid_log2.setColSorting("na,str,str");
mygrid_log2.setColTypes("ch,ro,ro");
mygrid_log2.init();
//
// var combos = mygrid_log2.getCombo(3);
// combos.put("正本","正本");
// combos.put("电放","电放");
//
mygrid_log2.load("CodeSourceSetGridSource_2.aspx?handle=list&show_page=" + pageShowCount2 + "&cur_page=1&hid_strSel=" + $("hid_strSel").value, "json");
//
setTimeout(function() {
initPage2();
createGrid2();
}, 300);
}
function createGrid2() {
this.mygrid_log2.attachEvent("onRowDblClicked", function(rId, cInd) {
var URLs = "../ParameterSet/CodeSourceDetailInfo.aspx?SOURCEID=" + $("hdSOURCEID").value + "&SOURCENAME=" + $("hdSOURCE").value + "&handle=edit&id=" + rId;
ret = window.open(URLs, "_blank", "height=150px, width=600px,center:yes,help:no,toolbar=no,menubar=no,scrollbars=no,resizable=0,location=no,status=no,Top= " + (screen.height / 2 - 100) + ",Left= " + (screen.width / 2 - 250));
});
}
function getUserGridSetting2() {
var urlVal = "CodeSourceSetGridSource_2.aspx?handle=setting&val=" + newGuid2() + "&hid_strSel=" + $("hid_strSel").value;
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
jsonPage2 = loadVal;
if (IsNum(jsonPage2)) {
jsonPage2Obj2 = null;
} else {
jsonPage2Obj2 = eval('(' + loadVal + ')');
}
}
function pager2View2(id) {
var self = this;
this.id = id;
this.container = null;
this.index = 1; // 当前页码, 从1开始
this.size = pageShowCount2; // 每页显示记录数
this.maxButtons = 9; // 显示的分页按钮数量
this.itemCount = 0; // 记录总数
this.pageCount = 0; // 总页数
/**
* 控件使用者重写本方法, 获取翻页事件, 可用来向服务器端发起AJAX请求.
* @param index: 被点击的页码.
*/
this.onclick = function(index) {
};
/**
* 内部方法.
*/
this._onclick = function(index) {
self.index = index;
self.onclick(index);
self.render();
};
/**
* 在显示之前计算各种页码变量的值.
*/
this.calculate = function() {
self.pageCount = parseInt(Math.ceil(self.itemCount / self.size));
self.index = parseInt(self.index);
if (self.index > self.pageCount) {
self.index = self.pageCount;
}
};
/**
* 渲染分页控件.
*/
this.render = function() {
if (self.id != undefined) {
var div = document.getElementById(self.id);
div.view = self;
self.container = div;
}
self.calculate();
var start, end;
start = Math.max(1, self.index - parseInt(self.maxButtons / 2));
end = Math.min(self.pageCount, start + self.maxButtons - 1);
start = Math.max(1, end - self.maxButtons + 1);
var str = "";
str += "<div class=\"pager2View2\">\n";
if (self.pageCount > 1) {
if (self.index != 1) {
str += '<a href="javascript://1"><span>|&lt;</span></a>';
str += '<a href="javascript://' + (self.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 (self.pageCount > 1) {
if (self.index != self.pageCount) {
str += '<a href="javascript://' + (self.index + 1) + '"><span>&gt;&gt;</span></a>';
str += '<a href="javascript://' + self.pageCount + '"><span>&gt;|</span></a>';
} else {
str += '<span>&gt;&gt;</span>';
str += '<span>&gt;|</span>';
}
}
str += ' 一共' + self.pageCount + '页, ' + self.itemCount + '条记录 ' + '&nbsp;&nbsp;&nbsp;每页显示:&nbsp;' + "<select id=\"cusShowCount2\" style=\"width:70px;\" onchange=\"change2ShowCount2('cusShowCount2')\">" + getPageOption2() + "</select>";
str += "</div><!-- /.pager2View2 -->\n";
self.container.innerHTML = str;
var a_list = self.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://', ''));
self._onclick(index)
}
return false;
};
}
};
}
//初始化页面
function initPage2() {
pager2 = new pager2View2('pager2');
var urlVal = "CodeSourceSetGridSource_2.aspx?handle=page&val=" + newGuid2() + "&hid_strSel=" + $("hid_strSel").value;
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
pageTotal2 = loadVal;
pager2.itemCount = pageTotal2;
pager2.size = pageShowCount2;
pager2.index = 1;
pager2.onclick = function(index) {
document.getElementById('info2').innerHTML = '现在翻到第' + index + '页';
getUserGridSetting2();
mygrid_log2 = new dhtmlXGridObject('mygrid_container_log2');
mygrid_log2.setImagePath("../images/");
mygrid_log2.setSkin("xp");
var arrayHeader = new Array();
var arrayColWidth = new Array();
if (jsonPage2Obj2 != null) {
for (var i = 0; i < jsonPage2Obj2.columns.length; i++) {
arrayHeader.push(jsonPage2Obj2.columns[i].description.trim());
arrayColWidth.push(jsonPage2Obj2.columns[i].width);
}
var strHeader = arrayHeader.toString();
var strWidth = arrayColWidth.toString();
pageShowCount2 = jsonPage2Obj2.show;
mygrid_log2.setHeader(strHeader);
mygrid_log2.setInitWidths(strWidth);
}
else {
mygrid_log2.setHeader("<input type=\"checkbox\" id=\"ck_all_2\" onclick=\"checkall_2()\" />,市场来源大类,市场来源细类");
mygrid_log2.setInitWidths("30,300,300");
}
mygrid_log2.setColAlign("center,left,left");
mygrid_log2.setColSorting("na,str,str");
mygrid_log2.setColTypes("ch,ro,ro");
mygrid_log2.init();
//
// var combos = mygrid_log2.getCombo(3);
// combos.put("正本","正本");
// combos.put("电放","电放");
//
/*
mygrid_log2.attachEvent("onCollectValues",function(ind)
{//ind为列索引
if (ind == 2 ) return ["正本","电放"];
})
*/
// mygrid_log2.enableDragAndDrop(true);
// mygrid_log2.enableDragOrder(true);
// mygrid_log2.enableColumnMove(true);
setTimeout(function() {
mygrid_log2.load("CodeSourceSetGridSource_2.aspx?handle=list&show_page=" + pager2.size.toString() + "&cur_page=" + index + "&hid_strSel=" + $("hid_strSel").value, "json");
}, 300);
initMenu2();
createGrid2();
};
pager2.render();
}
//获取GUID
function newGuid2() {
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();
}
function change2() {
var colCount = mygrid_log2.getColumnsNum();
var jsonFeeObj = "";
jsonFeeObj = "{\"$type\":\"DSWeb.Models.JsonColumnGroupEntity, DSWeb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\",\"ShowCount\":" + pageShowCount2 + ",\"JsonColumnEntities\":[";
var tempGroupJson = "";
for (var i = 0; i < colCount; i++) {
var tempJson = "";
var rId = mygrid_log2.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\":\"" + mygrid_log2.getColumnLabel(i) + "\","; //column description
tempJson += "\"col4\":\"" + i.toString() + "\","; //index
tempJson += "\"col5\":\"" + mygrid_log2.getColWidth(i) + "\","; //width
tempJson += "\"col6\":-1";
tempJson = "{" + tempJson + "}";
if (i == colCount - 1) {
tempGroupJson += tempJson;
} else {
tempGroupJson += tempJson + ",";
}
}
jsonFeeObj += tempGroupJson;
jsonFeeObj += "]}";
$("hid_setting2").value = jsonFeeObj;
jsonFeeObj = null;
//alert(jsonFeeObj);
var myForm = document.getElementById("form1");
myForm.submit();
}
function el2(id) {
return document.getElementById(id);
}
function initMenu2() {
el2("mygrid_container_log2").oncontextmenu = function(ev) {
showmenu2(ev);
return false;
};
document.onmousedown = function() { if (!over) hidemenu2(); };
};
var over2 = false;
var menu2 = null;
function showmenu2(ev) {
menu2 = null;
ev = ev || window.event;
hidemenu2();
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;
menu2 = document.createElement("DIV");
menu2.className = "menu2";
menu2.style.left = x + 4 + "px";
menu2.style.top = y + "px";
document.body.appendChild(menu2);
var dvGroup = e.parentNode.getElementsByTagName("DIV");
var dvGroupCount = dvGroup.length;
var id = "";
if (dvGroupCount == 1) {
id = dvGroup[0].innerHTML;
}
if (id.trim().length < 1) {
hidemenu2();
return;
}
var sname = document.location.pathname.substring(7, location.pathname.length).toString();
var s = "<div class=\"dvmenu2\" >修改标题</div><div class=\"dvmenu2\" onclick=\"editColumnSetting2('dvColumnSet')\">编辑显示</div>";
menu2.innerHTML = s;
menu2.onmouseover = function() { over2 = true; };
menu2.onmouseout = function() { over2 = false; };
}
function hidemenu2() {
if (menu2) {
document.body.removeChild(menu2);
menu2 = null;
}
}
function refresh2(sname) {
var req = getReq2();
req.open("GET", sname + "?refresh=1&id=", true);
req.send(null);
}
function showInfo2(id, sname) {
hidemenu2();
shideBody2();
el2("tit2").innerHTML = "查看用户的详细信息";
el2("bod2").innerHTML = "<img src='wait.gif' alt='loading...' />";
el2("bot2").innerHTML = "<input type='button' value='关闭' onclick='cancelShide2()' />";
var req = getReq2();
req.open("GET", sname + "?getinfo=1&id=" + id, true);
req.onreadystatechange = function() {
if (req.readyState == 4) {
el2("bod2").innerHTML = req.responseText;
}
};
req.send(null);
}
var shield2;
function shideBody2() {
shield2 = document.createElement("DIV");
shield2.id = "shield";
shield2.style.position = "absolute";
shield2.style.left = "0px";
shield2.style.top = "0px";
shield2.style.width = "100%";
shield2.style.height = document.documentElement.scrollHeight + "px";
shield2.style.background = "#333333";
shield2.style.textAlign = "center";
shield2.style.zIndex = "10";
shield2.style.filter = "alpha(opacity=0)";
shield2.style.opacity = 0;
document.body.appendChild(shield2);
this.setOpacity = function(obj, opacity) {
if (opacity >= 1) opacity = opacity / 100;
try { obj.style.opacity = opacity; } catch (e) { }
try {
if (obj.filters.length > 0 && obj.filters("alpha")) {
obj.filters("alpha").opacity = opacity * 150;
} else {
obj.style.filter = "alpha(opacity=\"" + (opacity * 150) + "\")";
}
} catch (e) { }
}
var c = 0;
this.doAlpha = function() {
if (++c > 20) { clearInterval(ad); return 0; }
setOpacity(shield2, c);
}
var ad = setInterval("doAlpha()", 1);
el2("divh2").style.display = "";
el2("divh2").style.marginTop = -75 + document.documentElement.scrollTop + "px";
}
function cancelShide2() {
if (el2("divh2")) {
el2("divh2").style.display = "none";
}
if (shield2) {
document.body.removeChild(shield2);
shield2 = null;
}
}
function getReq2() {
var oHttpReq = null;
if (window.ActiveXObject)
oHttpReq = new ActiveXObject("MSXML2.XMLHTTP");
else if (window.createRequest)
oHttpReq = window.createRequest();
else
oHttpReq = new XMLHttpRequest();
return oHttpReq;
}
function removerow2(e) {
e.style.backgroundColor = "#ff0000";
setTimeout(function() { e.style.backgroundColor = "#ffcccc"; }, 100);
setTimeout(function() { e.style.backgroundColor = "MistyRose"; }, 300);
setTimeout(function() { e.style.display = "none"; }, 450);
}
//是否为数字
function IsNum(val) {
var re = /^[-\+]?\d+(\.\d+)?$/;
if (!re.test(val)) {
return false;
} else {
return true;
}
}
function getPageOption2() {
var pageCountArg = new Array();
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 (pageShowCount2 == 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 change2ShowCount2(id) {
var selectObj = $(id);
var selVal = selectObj.options[selectObj.selectedIndex].value;
pageShowCount2 = selVal;
openNewDiv2();
}
var docEle2 = function() {
return document.getElementById(arguments[0]) || false;
}
function openNewDiv2(_id) {
var m = "mask";
if (docEle2(_id)) document.removeChild(docEle2(_id));
if (docEle2(m)) document.removeChild(docEle2(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() {
change2();
//document.body.removeChild(docEle2(_id));
//document.body.removeChild(docEle2(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(docEle2(_id));
document.body.removeChild(docEle2(m));
unSaveGrid2();
return false;
}
newDiv.appendChild(cancelButton);
}
function unSaveGrid2() {
mygrid_log2 = new dhtmlXGridObject('mygrid_container_log2');
mygrid_log2.setImagePath("../images/");
mygrid_log2.setSkin("xp");
mygrid_log2.setHeader("<input type=\"checkbox\" id=\"ck_all_2\" onclick=\"checkall_2()\" />,市场来源大类,市场来源细类");
mygrid_log2.setInitWidths("30,300,300");
mygrid_log2.setColAlign("center,left,left");
mygrid_log2.setColSorting("na,str,str");
mygrid_log2.setColTypes("ch,ro,ro");
mygrid_log2.init();
//
// var combos = mygrid_log2.getCombo(3);
// combos.put("正本","正本");
// combos.put("电放","电放");
setTimeout(function() {
mygrid_log2.load("CodeSourceSetGridSource_2.aspx?handle=list&show_page=" + pageShowCount2 + "&cur_page=1&hid_strSel=" + $("hid_strSel").value, "json");
}, 300);
initPage2();
initMenu2();
createGrid2();
}
function editColumnSetting2(_id) {
hidemenu2();
var m = "mask";
if (docEle2(_id)) document.removeChild(docEle2(_id));
if (docEle2(m)) document.removeChild(docEle2(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";
getUserGridSetting2();
var TargeVal = "";
if (jsonPage2Obj2 != null) {
for (var i = 0; i < jsonPage2Obj2.columns.length; i++) {
TargeVal += "<option value=\"" + jsonPage2Obj2.columns[i].name + "\">" + jsonPage2Obj2.columns[i].description + "</option>";
}
}
var editObj = "<div style=\"float:left\"><select id=\"sel_LogColumns2\" multiple=\"multiple\" style=\"width:200px;height:300px;\">"
+ "<option value=\"SOURCENAME\">市场来源大类</option>"
+ "<option value=\"SOURCEDETAIL\">市场来源细类</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=\"add2()\"></div>"
+ "<div class=\"imgRightButton\" onmousemove=\"this.className='imgRightHoverButton'\" onmouseout=\"this.className='imgRightButton'\" title=\"移除\" onclick=\"remove2()\"></div>"
+ "</div><div style=\"float:left;\"><select id=\"sel_VisiableColumns2\" 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=\"up2()\"></div>"
+ "<div class=\"imgDownButton\" onmousemove=\"this.className='imgDownHoverButton'\" onmouseout=\"this.className='imgDownButton'\" title=\"向下\" onclick=\"down2()\"></div></div>"
+ "<div><div style=\"float:left\"><input type=\"text\" id=\"txt_rename2\" style=\"height:20px;width:110px; \"/></div>"
+ "<div class=\"enterButton\" style=\"width:30px; \" onclick=\"saveRename2()\">保存</div></div>"
+ "<div style=\"float:left; width:70px;\"><div class=\"enterButton\" onclick=\"pushRename2()\">重命名</div></div>"
+ "<div style=\"float:left;width:100%;padding-left:120px;\"><div class=\"enterButton\" onclick=\"saveColumnHeader2()\">保存</div><div class=\"enterButton\" onclick=\"cancelColumnHeader2()\">取消</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 sourceObj2;
var targetObj2;
function add2() {
sourceObj2 = $("sel_LogColumns2");
targetObj2 = $("sel_VisiableColumns2");
for (var i = 0; i < sourceObj2.options.length; i++) {
if (sourceObj2.options[i].selected) {
if (!isExistVal2(targetObj2, sourceObj2.options[i].value)) {
var optionObj = document.createElement("option");
optionObj.text = sourceObj2.options[i].text;
optionObj.value = sourceObj2.options[i].value;
targetObj2.add(optionObj);
}
}
}
}
function remove2() {
sourceObj2 = $("sel_VisiableColumns2");
for (var i = 0; i < sourceObj2.options.length; i++) {
if (sourceObj2.options[i].selected) {
sourceObj2.remove(i);
i = -1;
}
}
}
function up2() {
sourceObj2 = $("sel_VisiableColumns2");
var cacheArg = new Array();
for (var i = 0; i < sourceObj2.options.length; i++) {
if (sourceObj2.options[i].selected) {
var optionObj = sourceObj2.options[i];
if (i > 1) {
sourceObj2.remove(i);
sourceObj2.add(optionObj, i - 1);
} else {
sourceObj2.remove(i);
sourceObj2.add(optionObj, 0);
}
}
}
}
function down2() {
sourceObj2 = $("sel_VisiableColumns2");
var cacheArg = new Array();
for (var i = 0; i < sourceObj2.options.length; i++) {
if (sourceObj2.options[i].selected) {
var optionObj = sourceObj2.options[i];
if (i < sourceObj2.options.length) {
sourceObj2.remove(i);
sourceObj2.add(optionObj, i + 1);
i = i + 1;
} else {
sourceObj2.remove(i);
sourceObj2.add(optionObj, sourceObj2.options.length);
}
}
}
}
function isExistVal2(tagObj, val) {
var isExist = false;
for (var i = 0; i < tagObj.options.length; i++) {
if (tagObj.options[i].value == val) {
isExist = true;
break;
}
}
return isExist;
}
function getColumnWidth2(gridObj, txtVal) {
var colWidth = 50;
var colCount = gridObj.getColumnsNum();
for (var i = 0; i < colCount; i++) {
var rId = mygrid_log2.getRowId(i);
var colLab = mygrid_log2.getColumnLabel(i);
if (colLab.trim() == txtVal) {
colWidth = mygrid_log2.getColWidth(i);
}
}
return colWidth;
}
function getColumnIndex2(tagObj, val) {
var colIndex = 0;
for (var i = 0; i < tagObj.options.length; i++) {
if (tagObj.options[i].value == val) {
colIndex = i;
break;
}
}
return colIndex;
}
function saveColumnHeader2() {
var sel_VisibleObj = $("sel_VisiableColumns2");
sourceObj2 = $("sel_LogColumns2");
if (sel_VisibleObj.options.length > 0) {
document.body.removeChild(docEle2("dvColumnSet"));
document.body.removeChild(docEle2("mask"));
} else {
document.body.removeChild(docEle2("dvColumnSet"));
document.body.removeChild(docEle2("mask"));
return
}
var jsonLogObj = "";
jsonLogObj = "{\"$type\":\"DSWeb.Models.JsonColumnGroupEntity, DSWeb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\",\"ShowCount\":" + pageShowCount2 + ",\"JsonColumnEntities\":[";
var tempGroupJson = "";
for (var i = 0; i < sourceObj2.options.length; i++) {
var tempJson = "";
tempJson += "\"$type\":\"DSWeb.Models.JsonColumnEntity, DSWeb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\",";
tempJson += "\"col1\":\"\","; //gid
tempJson += "\"col2\":\"" + sourceObj2.options[i].value + "\","; //column name
tempJson += "\"col3\":\"" + sourceObj2.options[i].text + "\","; //column description
tempJson += "\"col4\":\"" + getColumnIndex2(sel_VisibleObj, sourceObj2.options[i].value).toString() + "\","; //index
tempJson += "\"col5\":\"" + getColumnWidth2(mygrid_log2, sourceObj2.options[i].text) + "\","; //width
tempJson += "\"col6\":" + (isExistVal2(sel_VisibleObj, sourceObj2.options[i].value) ? 1 : 0).toString();
tempJson = "{" + tempJson + "}";
if (i == sourceObj2.options.length - 1) {
tempGroupJson += tempJson;
} else {
tempGroupJson += tempJson + ",";
}
}
jsonLogObj += tempGroupJson;
jsonLogObj += "]}";
$("hid_header2").value = jsonLogObj;
jsonFeeObj = null;
//alert(jsonFeeObj);
var myForm = document.getElementById("form1");
myForm.submit();
}
function cancelColumnHeader2() {
document.body.removeChild(docEle2("dvColumnSet"));
document.body.removeChild(docEle2("mask"));
}
var selIndex2 = -1;
function pushRename2() {
var selObj = $("sel_VisiableColumns2");
var iSelectCount = 0;
selIndex2 = 0;
for (var i = 0; i < selObj.options.length; i++) {
if (selObj.options[i].selected) {
iSelectCount++;
selIndex2 = i;
}
}
if (iSelectCount > 1) {
alert("请单选要重命名的项");
} else if (iSelectCount < 1) {
alert("未选中要重命名的项");
} else {
$("txt_rename2").value = selObj.options[selIndex2].text;
}
}
function saveRename2() {
var selObj = $("sel_VisiableColumns2");
var txtRenameVal = $("txt_rename2").value;
if (txtRenameVal.trim() != "") {
if (selIndex2 >= 0) {
var urlVal = "CodeSourceSetGridSource_2.aspx?handle=rename&old_header=" + escape(selObj.options[selIndex2].text.trim()) + "&new_header=" + escape(txtRenameVal.trim()) + "&val=" + newGuid2() + "&hid_strSel=" + $("hid_strSel").value;
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
var saveState = loadVal;
if (saveState == 1) {
selObj.options[selIndex2].text = txtRenameVal.trim();
}
else {
alert("重命名失败");
}
}
}
initLog2();
}
function time_custom2(a, b, order) {
a = a.split(":")
b = a.split(":")
if (a[0] == b[0])
return (a[1] > b[1] ? 1 : -1) * (order == "asc" ? 1 : -1);
else
return (a[0] > b[0] ? 1 : -1) * (order == "asc" ? 1 : -1);
}
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); }
//全选框
function checkall_2() {
var checkStatus = $("ck_all_2").checked;
if (checkStatus == 1) {
var iCount = mygrid_log2.getRowsNum();
for (var i = 0; i < iCount; i++) {
mygrid_log2.cellByIndex(i, 0).setValue(1);
}
}
else {
var iCount = mygrid_log2.getRowsNum();
for (var i = 0; i < iCount; i++) {
mygrid_log2.cellByIndex(i, 0).setValue(0);
}
}
}
//--------------------------------------------------------------------------------------------------------------------------------------
function imgAdd2ChangePic() {
var pic1 = document.getElementById("imgAdd2");
var start = pic1.src.lastIndexOf("/");
var str = pic1.src.substring(start + 1);
if (str == "order_modify.gif") {
pic1.src = "../images/order_cancel.gif";
//pic1.alt="我是B图片";
}
else if (str == "order_cancel.gif") {
pic1.src = "../images/order_modify.gif";
//pic1.alt="我是A图片";
}
}
function imgDel2ChangePic() {
var pic1 = document.getElementById("imgDel2");
var start = pic1.src.lastIndexOf("/");
var str = pic1.src.substring(start + 1);
if (str == "remove.gif") {
pic1.src = "../images/delete.gif";
//pic1.alt="我是B图片";
}
else if (str == "delete.gif") {
pic1.src = "../images/icons/remove.gif";
//pic1.alt="我是A图片";
}
}
function imgFresh2ChangePic() {
var pic1 = document.getElementById("imgFresh2");
var start = pic1.src.lastIndexOf("/");
var str = pic1.src.substring(start + 1);
if (str == "btnFresh.gif") {
pic1.src = "../images/icons/progress.gif";
//pic1.alt="我是B图片";
}
else if (str == "progress.gif") {
pic1.src = "../images/icons/btnFresh.gif";
//pic1.alt="我是A图片";
}
}
function imgEdit2ChangePic() {
var pic1 = document.getElementById("imgEdit2");
var start = pic1.src.lastIndexOf("/");
var str = pic1.src.substring(start + 1);
if (str == "audit.gif") {
pic1.src = "../images/order_delete.gif";
//pic1.alt="我是B图片";
}
else if (str == "order_delete.gif") {
pic1.src = "../images/audit.gif";
//pic1.alt="我是A图片";
}
}
function ShowDetailAdd2() {
if ($("hdSOURCEID").value.trim()=="" && $("hdSOURCE").value.trim()=="")
{
alert('请先选中市场来源大类!');
return;
}
var URLs = "../ParameterSet/CodeSourceDetailInfo.aspx?handle=add&SOURCEID=" + $("hdSOURCEID").value + "&SOURCENAME=" + $("hdSOURCE").value;
ret = window.open(URLs, "_blank", "height=150px, width=600px,center:yes,help:no,toolbar=no,menubar=no,scrollbars=no,resizable=0,location=no,status=no,Top= " + (screen.height / 2 - 100) + ",Left= " + (screen.width / 2 - 250));
}
function ShowDetailDel2() {
var checked2 = mygrid_log2.getCheckedRows(0); //所有选中的grid的id编号
if (checked2 != null && checked2 != "") {
if (confirm('确定删除吗?')) {
$("hid_id2").value = checked2; //mygrid_log2.getSelectedRowId();
document.getElementById("btDel2").click();
ShowDetailFresh2();
}
}
else {
alert('请先选中要删除的数据!');
return;
}
}
function ShowDetailUpdate2() {
var selectedId = mygrid_log2.getSelectedRowId();
if (selectedId == null || selectedId == "") {
alert("请先选择要操作的数据!");
}
else {
var selectedId = mygrid_log2.getSelectedRowId();
var URLs = "../ParameterSet/CodeSourceDetailInfo.aspx?SOURCEID=" + $("hdSOURCEID").value + "&SOURCENAME=" + $("hdSOURCE").value + "&handle=edit&id=" + selectedId;
ret = window.open(URLs, "_blank", "height=150px, width=600px,center:yes,help:no,toolbar=no,menubar=no,scrollbars=no,resizable=0,location=no,status=no,Top= " + (screen.height / 2 - 100) + ",Left= " + (screen.width / 2 - 250));
}
}