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.

1312 lines
46 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.

var mygrid_log;
var pager;
var jsonPage;
var jsonPageObj;
var pageTotal;
var pageShowCount = 15;
var curPage = 1;
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); }
function $(id){
return document.getElementById(id);
}
function initLog()
{
//getUserSetting
//getUserGridSetting();
mygrid_log = new dhtmlXGridObject('mygrid_container_log');
mygrid_log.setImagePath("../images/");
mygrid_log.setSkin("xp");
//
var arrayHeader = new Array();
var arrayColWidth = new Array();
if(jsonPageObj != null)
{
for(var i = 0;i<jsonPageObj.columns.length;i++){
arrayHeader.push(jsonPageObj.columns[i].TITLE.trim());
arrayColWidth.push(jsonPageObj.columns[i].width);
}
var strHeader = arrayHeader.toString();
var strWidth = arrayColWidth.toString();
pageShowCount = jsonPageObj.show;
mygrid_log.setHeader(strHeader);
mygrid_log.setInitWidths(strWidth);
}
else
{
mygrid_log.setHeader("<input type=\"checkbox\" id=\"ck_all\" onclick=\"checkall()\" />,url,文件名,路径,LINKGID,AFFIXSIZE,TABLENAME");
mygrid_log.setInitWidths("30,570,0,0,0,0,0");
}
mygrid_log.setColAlign("center,left,left,left,left,left,left");
mygrid_log.setColSorting("na,str,str,str,str,str,str");
mygrid_log.setColTypes("ch,link,ro,ro,ro,ro,ro");
mygrid_log.init();
//2012-9-19 刘文鹏
mygrid_log.load("../SeaiFee/WmsRateGridSource.aspx?handle=opseaifujian&show_page=15&cur_page=1&tb=op_seai&linkgid="+$("hdGid").value,"json");
//
setTimeout(function(){
// initPage();
},300);
}
function getUserGridSetting(){
var urlVal = "OpSailingDateInfoGridSource.aspx?handle=setting&val="+newGuid()+"&tb=op_seai&linkgid="+$("dvOrderNumVal_3").value;
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
jsonPage = loadVal;
if(IsNum(jsonPage)){
jsonPageObj = null;
}else{
jsonPageObj = eval('(' + loadVal + ')');
}
}
function PagerView(id){
var self = this;
this.id = id;
this.container = null;
this.index = 1; // 当前页码, 从1开始
this.size = pageShowCount; // 每页显示记录数
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=\"PagerView\">\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=\"cusShowCount\" style=\"width:70px;\" onchange=\"changeShowCount('cusShowCount')\">"+getPageOption()+"</select>";
str += "</div><!-- /.pagerView -->\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 initPage(){
// pager = new PagerView('pager');
var urlVal = "../SeaiFee/WmsRateGridSource.aspx?handle=page&val="+newGuid()+"&tb=op_seai&linkgid="+$("dvOrderNumVal_3").value;
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
pageTotal = loadVal;
pager.itemCount = pageTotal;
pager.size = pageShowCount;
pager.index = 1;
pager.onclick = function(index){
document.getElementById('info').innerHTML = '现在翻到第' + index + '页';
//getUserGridSetting();
mygrid_log = new dhtmlXGridObject('mygrid_container_log');
mygrid_log.setImagePath("../images/");
mygrid_log.setSkin("xp");
var arrayHeader = new Array();
var arrayColWidth = new Array();
if(jsonPageObj != null){
for(var i = 0;i<jsonPageObj.columns.length;i++){
arrayHeader.push(jsonPageObj.columns[i].TITLE.trim());
arrayColWidth.push(jsonPageObj.columns[i].width);
}
var strHeader = arrayHeader.toString();
var strWidth = arrayColWidth.toString();
pageShowCount = jsonPageObj.show;
mygrid_log.setHeader(strHeader);
mygrid_log.setInitWidths(strWidth);
}
else
{
mygrid_log.setHeader("<input type=\"checkbox\" id=\"ck_all\" onclick=\"checkall()\" />,url,文件名,路径,LINKGID,AFFIXSIZE,TABLENAME");
mygrid_log.setInitWidths("30,100,0,0,0,0,0");
}
mygrid_log.setColAlign("center,left,left,left,left,left,left");
mygrid_log.setColSorting("na,str,str,str,str,str,str");
mygrid_log.setColTypes("ch,link,ro,ro,ro,ro,ro");
mygrid_log.init();
// mygrid_log.enableDragAndDrop(true);
// mygrid_log.enableDragOrder(true);
// mygrid_log.enableColumnMove(true);
setTimeout(function(){
mygrid_log.load("../SeaiFee/WmsRateGridSource.aspx?handle=opseaifujian&show_page=15&cur_page=1&tb=op_seai&linkgid="+$("dvOrderNumVal_3").value,"json");
},300);
initMenu();
};
pager.render();
}
//获取GUID
function newGuid()
{
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 change()
{
var colCount = mygrid_log.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 = mygrid_log.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_log.getColumnLabel(i)+"\",";//column TITLE
tempJson += "\"col4\":\""+i.toString()+"\",";//index
tempJson += "\"col5\":\""+mygrid_log.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() ;
}
function el(id){
return document.getElementById(id);
}
function initMenu(){
el("mygrid_container_log").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;
}
// = e.parentNode.getElementsByTagName("td")[1].innerHTML;
// e.parentNode.id = "tr_"+id;
var sname = document.location.pathname.substring(7,location.pathname.length).toString();
// var s = "<a href=\"javascript:showInfo({id},'{sname}');\">编辑标题</a>";
// s += "<a href=\"javascript:refresh('{sname}');\">重新排序</a>";
// //s += "<a href='javascript:editInfo({id});'>修改用户信息</a>";
// //s += "<a href='javascript:deleteInfo({id});'>删除该条记录</a>";
// s = s.replace(/{id}/g, id);
// s = s.replace(/{sname}/g, sname);
// var s = "<input type=\"text\" id=\"txt_label\" style=\"width:90px;\" value=\""+id+"\" /><a style=\"width:30px;\" href=\"javascript:void(0);\" onclick=\"saveLabel('txt_label','"+id+"')\" >保存</a>";
// var s = "<div style=\"float:left;width:100%;padding-left:120px;\"><div class=\"enterButton\" onclick=\"saveColumnHeader()\">保存</div><div class=\"enterButton\" onclick=\"cancelColumnHeader()\">取消</div></div>";
var s = "<div class=\"dvMenu\" >修改标题</div><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 refresh(sname){
var req = getReq();
req.open("GET", sname+"?refresh=1&id=", true);
/*req.onreadystatechange = function(){
if(req.readyState==4)
{
el("bod").innerHTML = req.responseText;
}
};*/
req.send(null);
}
function showInfo(id,sname){
hideMenu();
shideBody();
el("tit").innerHTML = "查看用户的详细信息";
el("bod").innerHTML = "<img src='wait.gif' alt='loading...' />";
el("bot").innerHTML = "<input type='button' value='关闭' onclick='cancelShide()' />";
var req = getReq();
req.open("GET", sname+"?getinfo=1&id="+id, true);
req.onreadystatechange = function(){
if(req.readyState==4){
el("bod").innerHTML = req.responseText;
}
};
req.send(null);
}
//function editInfo(id){
// hideMenu();
// shideBody();
//
// el("tit").innerHTML = "编辑用户信息";
// el("bod").innerHTML = "<img src='wait.gif' alt='loading...' />";
// el("bot").innerHTML = "<input type='button' value='确定' onclick='doEdit("+id+")' /> <input type='button' value='取消' onclick='cancelShide()' />";
// var tds = el("tr_"+id).getElementsByTagName("td");
// var boy = tds[2].innerHTML == "男";
// var s = "<table>";
// s += "<tr><td>姓名</td><td><input type='text' value='"+ tds[1].innerHTML +"' /></td></tr>";
// s += "<tr><td>性别</td><td><input type='radio' name='rad_sex'"+ (boy?" checked":"") +" />男 <input type='radio' name='rad_sex'"+ (!boy?" checked":"") +" />女</td></tr>";
// s += "<tr><td>年龄</td><td><input type='text' value='"+ tds[3].innerHTML +"' /></td></tr>";
// s += "</table>";
// el("bod").innerHTML = s;
//}
//function deleteInfo(id){
// hideMenu();
// if(!confirm("确定要删除该记录吗?"))return;
//
// removeRow(el("tr_"+id));
//
// var req = getReq();
// req.open("GET", "default.aspx?delete=1&id="+id, true);
// req.onreadystatechange = function(){};
// req.send(null);
//}
//function doEdit(id){
// var puts = el("bod").getElementsByTagName("input");
// if(isNaN(puts[3].value)){
// puts[3].select();return;
// }
// var tds = el("tr_"+id).getElementsByTagName("td");
// tds[1].innerHTML = puts[0].value;
// tds[2].innerHTML = puts[1].checked?"男":"女";
// tds[3].innerHTML = puts[3].value;
//
// var data = "name="+ escape(tds[1].innerHTML);
// data += "&sex="+ escape(tds[2].innerHTML);
// data += "&age="+ escape(tds[3].innerHTML);
//
// var req = getReq();
// req.open("POST", "default.aspx?edit=1&id="+id, true);
// req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
// req.onreadystatechange = function(){};
// req.send(data);
//
// cancelShide();
//}
var shield;
function shideBody()
{
shield = document.createElement("DIV");
shield.id = "shield";
shield.style.position = "absolute";
shield.style.left = "0px";
shield.style.top = "0px";
shield.style.width = "100%";
shield.style.height = document.documentElement.scrollHeight+"px";
shield.style.background = "#333333";
shield.style.textAlign = "center";
shield.style.zIndex = "10";
shield.style.filter = "alpha(opacity=0)";
shield.style.opacity = 0;
document.body.appendChild(shield);
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(shield,c);
}
var ad = setInterval("doAlpha()",1);
el("divh").style.display = "";
el("divh").style.marginTop = -75+document.documentElement.scrollTop + "px";
}
function cancelShide()
{
if(el("divh"))
{
el("divh").style.display = "none";
}
if(shield)
{
document.body.removeChild(shield);
shield = null;
}
}
function getReq()
{
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 removeRow(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 getPageOption(){
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(pageShowCount == 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 changeShowCount(id){
var selectObj = $(id);
var selVal = selectObj.options[selectObj.selectedIndex].value;
pageShowCount = selVal;
openNewDiv();
}
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();
}
newDiv.appendChild(saveButton);
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 unSaveGrid(){
mygrid_log = new dhtmlXGridObject('mygrid_container_log');
mygrid_log.setImagePath("../images/");
mygrid_log.setSkin("xp");
mygrid_log.setHeader("<input type=\"checkbox\" id=\"ck_all\" onclick=\"checkall()\" />,url,文件名,路径,LINKGID,AFFIXSIZE,TABLENAME");
mygrid_log.setInitWidths("30,100,0,0,0,0,0");
mygrid_log.setColAlign("center,left,left,left,left,left,left");
mygrid_log.setColSorting("na,str,str,str,str,str,str");
mygrid_log.setColTypes("ch,link,ro,ro,ro,ro,ro");
mygrid_log.init();
setTimeout(function(){
mygrid_log.load("../SeaiFee/WmsRateGridSource.aspx?handle=opseaifujian&show_page=15&cur_page=1&tb=op_seai&linkgid="+$("dvOrderNumVal_3").value,"json");
},300);
mygrid_log.initGrid();
mygrid_log.bind();
// initPage();
initMenu();
}
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) - 570) / 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].TITLE+"</option>";
}
}
var editObj = "<div style=\"float:left\"><select id=\"sel_LogColumns\" multiple=\"multiple\" style=\"width:200px;height:300px;\">"
+ "<option value=\"AFFIXNAME\">附件名称</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 sourceObj;
var targetObj;
/*
function $(id){
return document.getElementById(id);
}
*/
function add(){
sourceObj = $("sel_LogColumns");
targetObj = $("sel_VisiableColumns");
for(var i=0;i<sourceObj.options.length;i++){
if(sourceObj.options[i].selected){
if(!isExistVal(targetObj,sourceObj.options[i].value)){
var optionObj = document.createElement("option");
optionObj.text = sourceObj.options[i].text;
optionObj.value = sourceObj.options[i].value;
targetObj.add(optionObj);
}
}
}
}
function remove(){
sourceObj = $("sel_VisiableColumns");
for(var i=0;i<sourceObj.options.length;i++){
if(sourceObj.options[i].selected){
sourceObj.remove(i);
i = -1;
}
}
}
function up(){
sourceObj = $("sel_VisiableColumns");
var cacheArg = new Array();
for(var i=0;i<sourceObj.options.length;i++){
if(sourceObj.options[i].selected){
var optionObj = sourceObj.options[i];
if(i > 1){
sourceObj.remove(i);
sourceObj.add(optionObj,i-1);
}else{
sourceObj.remove(i);
sourceObj.add(optionObj,0);
}
}
}
}
function down(){
sourceObj = $("sel_VisiableColumns");
var cacheArg = new Array();
for(var i=0;i<sourceObj.options.length;i++){
if(sourceObj.options[i].selected){
var optionObj = sourceObj.options[i];
if(i < sourceObj.options.length){
sourceObj.remove(i);
sourceObj.add(optionObj,i+1);
i = i+1;
}else{
sourceObj.remove(i);
sourceObj.add(optionObj,sourceObj.options.length);
}
}
}
}
function isExistVal(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 getColumnWidth(gridObj,txtVal){
var colWidth = 50;
var colCount = gridObj.getColumnsNum();
for(var i=0;i<colCount;i++){
var rId = mygrid_log.getRowId(i);
var colLab = mygrid_log.getColumnLabel(i);
if(colLab.trim() == txtVal){
colWidth = mygrid_log.getColWidth(i);
}
}
return colWidth;
}
function getColumnIndex(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 saveColumnHeader(){
var sel_VisibleObj = $("sel_VisiableColumns");
sourceObj = $("sel_LogColumns");
if(sel_VisibleObj.options.length > 0){
document.body.removeChild(docEle("dvColumnSet"));
document.body.removeChild(docEle("mask"));
}else{
document.body.removeChild(docEle("dvColumnSet"));
document.body.removeChild(docEle("mask"));
return
}
var jsonLogObj = "";
jsonLogObj = "{\"$type\":\"DSWeb.Models.JsonColumnGroupEntity, DSWeb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\",\"ShowCount\":"+pageShowCount+",\"JsonColumnEntities\":[";
var tempGroupJson = "";
for(var i=0;i<sourceObj.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\":\""+sourceObj.options[i].value+"\",";//column name
tempJson += "\"col3\":\""+sourceObj.options[i].text+"\",";//column TITLE
tempJson += "\"col4\":\""+getColumnIndex(sel_VisibleObj,sourceObj.options[i].value).toString()+"\",";//index
tempJson += "\"col5\":\""+getColumnWidth(mygrid_log,sourceObj.options[i].text)+"\",";//width
tempJson += "\"col6\":"+(isExistVal(sel_VisibleObj,sourceObj.options[i].value)?1:0).toString();
tempJson = "{"+tempJson+"}";
if(i == sourceObj.options.length - 1){
tempGroupJson += tempJson;
}else{
tempGroupJson += tempJson+",";
}
}
jsonLogObj += tempGroupJson;
jsonLogObj += "]}";
$("hid_header").value = jsonLogObj;
jsonFeeObj = null;
//alert(jsonFeeObj);
var myForm = document.getElementById("form1");
myForm.submit() ;
}
function cancelColumnHeader(){
document.body.removeChild(docEle("dvColumnSet"));
document.body.removeChild(docEle("mask"));
}
var selIndex = -1;
function pushRename(){
var selObj = $("sel_VisiableColumns");
var iSelectCount = 0;
selIndex = 0;
for(var i=0;i<selObj.options.length;i++){
if(selObj.options[i].selected){
iSelectCount++;
selIndex = i;
}
}
if(iSelectCount > 1){
alert("请单选要重命名的项");
}else if(iSelectCount < 1){
alert("未选中要重命名的项");
}else{
$("txt_rename").value = selObj.options[selIndex].text;
}
}
function saveRename()
{
var selObj = $("sel_VisiableColumns");
var txtRenameVal = $("txt_rename").value;
if(txtRenameVal.trim() != ""){
if(selIndex >= 0){
var urlVal = "OpSailingDateInfoGridSource.aspx?handle=rename&old_header="+escape(selObj.options[selIndex].text.trim())+"&new_header="+escape(txtRenameVal.trim())+"&val="+newGuid()+"&tb=op_seai&linkgid="+$("dvOrderNumVal_3").value;
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
var saveState = loadVal;
if(saveState == 1)
{
selObj.options[selIndex].text = txtRenameVal.trim();
}
else
{
alert("重命名失败");
}
}
}
initLog();
}
function time_custom(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()
{
var checkStatus = $("ck_all").checked;
if(checkStatus == 1)
{
var iCount = mygrid_log.getRowsNum();
for(var i=0;i < iCount;i++)
{
mygrid_log.cellByIndex(i,0).setValue(1);
}
}
else
{
var iCount = mygrid_log.getRowsNum();
for(var i=0;i < iCount;i++)
{
mygrid_log.cellByIndex(i,0).setValue(0);
}
}
}
//--------------------------------------------------------------------------------------------------------------------------------------------------
function QueryString()
{
var name,value,i;//构造参数对象并初始化
var str=location.href;//获得浏览器地址栏URL串
var num=str.indexOf("?")
str=str.substr(num+1);//截取“?”后面的参数串
var arrtmp=str.split("&");//将各参数分离形成参数数组
for(i=0;i < arrtmp.length;i++)
{
num=arrtmp[i].indexOf("=");
if(num>0)
{
name=arrtmp[i].substring(0,num);//取得参数名称
value=arrtmp[i].substr(num+1);//取得参数值
this[name]=value;//定义对象属性并初始化
}
}
}
function ShowDetailDel()
{
var asid=mygrid_log.getCheckedRows(0);//所有选中的grid的id编号
if(asid==null || asid=="")
{
alert("请先选择要操作的数据!");
}
else
{
if(confirm('确定删除吗?'))
{
var dg=new dialog();
dg.html="程序正在提交,请稍等!";
dg.width=200;
dg.height=100;
dg.title="标题";
dg.show();
$("hid_id").value = mygrid_log.getCheckedRows(0);//所有选中的grid的id编号
var urlVal = "OpSailingDateInfoGridSource.aspx?handle=delete&val="+newGuid()+"&linkgid="+$("dvOrderNumVal_3").value+"&gids="+$("hid_id").value;
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
if(loadVal.trim()!="")
{
//alert(loadVal);
}
FuJianOnload();
dg.close();
}
}
}
function newGuid(){
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 imgDelChangePic()
{
var pic1=document.getElementById("imgDel");
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 FuJianOnload()
{
initLog();
initMenu();
}
//--蒙板--
function dialog() {
this.width = 450;
this.height = 360;
this.title_height = 20;
this.html = '';
this.title = '';
var self = this;
var bgObj, msgObj, titleObj;
this.close = function () {
document.body.removeChild(document.getElementById("bgDiv"));
document.getElementById("msgDiv").removeChild(document.getElementById("msgTitle"));
document.body.removeChild(document.getElementById("msgDiv"));
}
this.show = function () {
var msgw, msgh, bordercolor;
msgw = self.width;
msgh = self.height;
bordercolor = "#336699";
titlecolor = "#99CCFF";
var sWidth, sHeight;
sWidth = document.body.offsetWidth;
sHeight = screen.height;
bgObj = document.createElement("div");
bgObj.setAttribute('id', 'bgDiv');
bgObj.style.position = "absolute";
bgObj.style.top = "0";
bgObj.style.background = "#777";
bgObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
bgObj.style.opacity = "0.6";
bgObj.style.left = "0";
bgObj.style.width = sWidth + "px";
bgObj.style.height = sHeight + "px";
bgObj.style.zIndex = "10000";
document.body.appendChild(bgObj);
msgObj = document.createElement("div")
msgObj.setAttribute("id", "msgDiv");
msgObj.setAttribute("align", "center");
msgObj.style.background = "white";
msgObj.style.border = "1px solid " + bordercolor;
msgObj.style.position = "absolute";
msgObj.style.left = "50%";
msgObj.style.top = "30%";
msgObj.style.font = "12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
msgObj.style.marginLeft = "-225px";
msgObj.style.marginTop = -75 + document.documentElement.scrollTop + "px";
msgObj.style.width = msgw + "px";
msgObj.style.height = msgh + "px";
msgObj.style.textAlign = "center";
msgObj.style.lineHeight = "25px";
msgObj.style.zIndex = "10001";
titleObj = document.createElement("h4");
titleObj.setAttribute("id", "msgTitle");
titleObj.setAttribute("align", "center");
titleObj.style.margin = "0";
titleObj.style.padding = "3px";
titleObj.style.background = bordercolor;
titleObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
titleObj.style.opacity = "0.75";
titleObj.style.border = "1px solid " + bordercolor;
titleObj.style.height = self.title_height + "px";
titleObj.style.font = "12px Verdana, Geneva, Arial, Helvetica, sans-serif";
titleObj.style.color = "white";
titleObj.style.cursor = "pointer";
titleObj.innerHTML = self.title;
//titleObj.onclick=function(){self.close();}
document.body.appendChild(msgObj);
document.getElementById("msgDiv").appendChild(titleObj);
var txt = document.createElement("div");
txt.style.margin = "1em 0"
txt.setAttribute("id", "msgTxt");
txt.innerHTML = self.html;
document.getElementById("msgDiv").appendChild(txt);
}
}
function msgBox() {
var dg = new dialog();
dg.html = "程序正在提交,请稍等!";
//dg.html+="<input type=button onclick='new dialog().close();' value='确定'>";
dg.width = 200;
dg.height = 100;
dg.title = "标题";
dg.show();
}
//--按钮条-->
function divdadd()
{
if($("hdISISSUE").value=="1")
{
document.getElementById('divadd').style.display = "none";
//document.getElementById('divsave').style.display = "none";
document.getElementById('divrefresh').style.display = "none";
document.getElementById('divdel').style.display = "none";
document.getElementById('divrollback').style.display = "none";
}
else
{
document.getElementById('divadd').style.display = "";
//document.getElementById('divsave').style.display = "";
document.getElementById('divrefresh').style.display = "";
document.getElementById('divdel').style.display = "none";
document.getElementById('divrollback').style.display = "none";
}
}
function divdisplay()
{
var dsdf =$("hdISISSUE").value;
if($("hdISISSUE").value=="1")
{
document.getElementById('divadd').style.display = "none";
//document.getElementById('divsave').style.display = "none";
document.getElementById('divrefresh').style.display = "none";
document.getElementById('divdel').style.display = "none";
document.getElementById('divrollback').style.display = "none";
}
else if($("hdISISSUE").value=="3")
{
document.getElementById('divadd').style.display = "none";
//document.getElementById('divsave').style.display = "none";
document.getElementById('divrefresh').style.display = "none";
document.getElementById('divdel').style.display = "none";
document.getElementById('divrollback').style.display = "none";
}
else if($("hdISISSUE").value=="1")
{
document.getElementById('divadd').style.display = "none";
//document.getElementById('divsave').style.display = "none";
document.getElementById('divrefresh').style.display = "none";
document.getElementById('divdel').style.display = "none";
document.getElementById('divrollback').style.display = "none";
}
else
{
document.getElementById('divadd').style.display = "";
//document.getElementById('divsave').style.display = "";
document.getElementById('divrefresh').style.display = "";
document.getElementById('divdel').style.display = "";
document.getElementById('divrollback').style.display = "";
}
}
function ShowDetailRejected()
{
var URLs = "SeaeOrderInfoRejected.aspx?ORDNO="+$("dvOrderNumVal_3").value;
ret = window.open(URLs,"_blank", "height=220, width=350, toolbar=no, menubar=no,scrollbars=yes, resizable=1,location=no, status=no,Top= " +(screen.height/2-100) + ",Left= "+(screen.width/2-200));
}
//附件上传按钮事件
function setFuJianEnter()
{
$("hdEnter").value="0";
msgBox();
postEnter();
}
//刘文鹏 2012-9-19
//function saveFuJianChange()//将附件信息打包为json格式存入变量recvContainer_3
//{
// var jsonFuJianObj = null;
// for(var i=0;i<mygrid_recv_2.getGridObj().getRowsNum();i++){
// var rowId=mygrid_recv_2.getGridObj().getRowId(i);
//
// var name = mygrid_recv_2.getGridObj().cellByIndex(i,2).getValue();
// var link = mygrid_recv_2.getGridObj().cellByIndex(i,3).getValue();
//
// if(jsonFuJianObj == null){
// var cacheBuffer = "";
// cacheBuffer += "{";
// cacheBuffer += "\"name\":\""+name+"\",";
// cacheBuffer += "\"link\":\""+link+"\"";
// cacheBuffer += "}";
// var result = "";
// result += "{\"rates\":[";
// result += cacheBuffer;
// result += "]}";
// jsonFuJianObj = eval('(' + result + ')');
// }else{
// var newRateRow = jsonFuJianObj.rates;
// newRateRow = {name:name,link:link};
//
// jsonFuJianObj.rates.push(newRateRow);
// }
// }
//$("recvContainer_3").value = JSON.stringify(jsonFuJianObj);
// return 1;
//}
//post提交表单数据
function postEnter(){
var myForm = document.getElementById("form1");
myForm.submit();
}
//回车键控制
document.onkeypress=function()
{
if(event.keyCode==13)
{
if(event.srcElement.tagName== 'TEXTAREA')
{
return true;
}
//window.event.keyCode=9;
return false;
}
}
function newGuid(){
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 IsNum(val){
var re = /^[-\+]?\d+(\.\d+)?$/;
if (!re.test(val)){
return false;
}else{
return true;
}
}
//是否为数字2
function IsNum2(val){
var re = /^[0-9]*[1-9][0-9]*$/;
if (!re.test(val)){
return false;
}else{
return true;
}
}
//
function imgFreshChangePic()
{
var pic1=document.getElementById("imgFresh");
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 reloadParent(strBSNO, strHandle)
{
//alert("strBSNO="+strBSNO);
var parentObj = window.parent.location;
var oldUrl = parentObj.href;
var idIndex = oldUrl.indexOf("&id");//alert(oldUrl);
//
var newUrl = "";
if(strHandle=="addfull")
{
var handleIndex = oldUrl.indexOf("handle=");//alert(handleIndex);
newUrl = oldUrl.substring(0,handleIndex);
window.parent.opener.location.href = window.parent.opener.location.href;
parentObj.href = newUrl+"handle=edit&id="+strBSNO;
}
else if (strHandle == "edit")
{
//newUrl = oldUrl.substring(0,idIndex+4);//alert(oldUrl.substring(0,idIndex));
window.parent.opener.location.href = window.parent.opener.location.href;
//parentObj.href = newUrl+strBSNO;
}
else if(strHandle == "add")
{
var handleIndex = oldUrl.indexOf("handle=");//alert(handleIndex);
newUrl = oldUrl.substring(0,handleIndex);
window.parent.opener.location.href = window.parent.opener.location.href;
parentObj.href = newUrl+"handle=edit&id="+strBSNO;
}
//
//alert("操作成功!");
}
function add_mygrid_logRow() { //添加附件
var newId = newGuid();
var fujian = $("FileUpload1").value;
var url = "../SeaiFee/WmsRateGridSource.aspx?handle=deleterate";
var loader = dhtmlxAjax.getSync(url);
var deleteState = parseInt(loader.xmlDoc.responseText);
if (deleteState == 1) {
iDelCount++;
}
//获取插入新纪录位置
var rowCount = mygrid_log.getGridObj().getRowsNum();
var preindex = 0;
var FEEGRADE = 0;
if (rowCount > 0) {
preindex = rowCount - 1;
FEEGRADE = parseInt(mygrid_log.getGridObj().cellByIndex(preindex, 1).getValue());
FEEGRADE = FEEGRADE + 1;
mygrid_log.getGridObj().addRow(newId, [0, FEEGRADE, 0, 0, "吨天", "", "", "", BSNO], rowCount);
}
else {
mygrid_log.getGridObj().addRow(newId, [0, 1, 0, 0, "吨天", "", "", "", BSNO], rowCount);
}
}
//mygrid_log.setHeader("<input type=\"checkbox\" id=\"ck_all\" onclick=\"checkall()\" />,REMAR,url,文件名,路径,LINKGID,AFFIXSIZE,TABLENAME");