function reActive(){ //激活tabpanel var cls = 'active'; $('.nav-tabs>li>a').click(function(){ if(!$(this).hasClass(cls)) { var nav = $(this).parent().parent(), bd = nav.next(), old = nav.children('.' + cls).index(), index = $(this).parent().index(); $('.tab-pane:eq(' + old + ')', bd).removeClass(cls); $('.tab-pane:eq(' + index + ')', bd).addClass(cls); var width = $('#topToolbar').width()-$('.nav-tabs>li:eq('+index+')').attr("oldwidth")-2; var lis = $('.nav-tabs>li'); for(var j=0; jli:eq('+index+')')[0].id){ lis[j].style.width = width/(lis.length-1)+'px'; } } $('.nav-tabs>li:eq('+index+')')[0].style.width = $('.nav-tabs>li:eq('+index+')').attr("oldwidth")+'px'; nav.children('.' + cls).removeClass(cls); $(this).parent().addClass(cls); } }); } function getUrlParam(name){ var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) return decodeURI(r[2]); return null; } function parseDate(date){ var y = date.getFullYear(), m = date.getMonth() + 1, d = date.getDate(), h = date.getHours(), i = date.getMinutes(); var now = new Date(), _y = now.getFullYear(), _m = now.getMonth() + 1, _d = now.getDate(); if(_y != y) { return y + '-' + m + '-' + d + ' ' + h + ':' + i; } else { if(_m != m) { return m + '月' + d + '号' + h + '点' + i + '分'; } else { if(_d != d) { return d + '号' + h + '点' + i + '分'; } else { return (h < 12 ? '上午' : '下午' ) + h + '点' + i + '分'; } } } } function setLoading (isLoading) { $('.loading-container').css('display', isLoading ? 'block' : 'none'); } function ValidateNumber(e, pnumber) { if (!/^\d+[.]?\d*$/.test(pnumber)) { $(e).val(/^\d+[.]?\d*/.exec($(e).val())); } return false; } function changeEscapeCharacter(da){ var e = da; if(isNaN(e)){//不是数字 e = e.replace(/\'/g, "'") .replace(/\"/g, """) .replace(/\>/g, ">") .replace(/\ 0 ){ $.each(ignores,function(key,value){ delete a[value]; }); } var b = new Object(); b._noc = 1; b.caller = caller; b.processInstanceId = instance ; b.formStore = '{'+keyName+':'+keyValue+'}'; b.param = $.toJSON(a); return b; }, errorTextFormat:function(a,b){//錯誤捕獲 if(a.responseJSON.exceptionInfo== 'ERR_NETWORK_SESSIONOUT') { return '保存信息失败,请先登录!'; } else { return '错误:'+ a.responseJSON.exceptionInfo; } }, afterSubmit : function(response, postdata) { $.showtip("修改明细成功!", 2000); setLoading(true); $.ajax({ url:basePath + 'common/loadNewGridStore.action', type: 'POST', data: {caller:caller,condition:mad_code +"='"+keyValue+"'",_noc: 1}, success: function(result){ setLoading(false); $('#'+gridId)[0].addJSONData(result.data); }, error:function(){ setLoading(false); } }); return true; } }); } var requiredFields = null,instance = null; function saveForm(keyName,keyValue,caller){ //requiredFields array格式 var d = {}; $("#mainForm select[readonly]").removeProp("disabled"); var t = $('#mainForm').serializeArray(); $("#mainForm select[readonly]").prop("disabled", true); $.each(t, function() { if($('#'+this.name).attr("logic") || $('#'+this.name).attr("logic") != 'ignore'){ //判断logic的属性是否为ignore 忽略 d[this.name] = this.value; } }); var bool = true; if (requiredFields != null) {//判断必填项是否填写 $.each(requiredFields, function(key, field){ if (d[field] == null || d[field] == "") { bool = false; $('#tips').text('保存之前请先填写必填的信息!'); $('#'+field).focus(); return; } }); } //获取改变了的值 $.each(d,function(key,field){//只将修改的值提交到后台 if(d[key] == bill[key]) delete d[key]; }); if($.isEmptyObject(d)){ $.showtip("还未添加或修改数据!", 2000); return; } if (bool) {//获取编辑的字段值 d[keyName] = keyValue; var b = new Object(); b._noc = 1; b.caller = caller; b.processInstanceId = instance; b.formStore = $.toJSON(d); setLoading(true); $.ajax({ url:basePath+"common/processUpdate.action", type: 'POST', data: b, success: function(result){ setLoading(false); $.showtip("修改成功!", 2000); var url = window.location.href; window.location.href = url.substr(0, url.indexOf('?') + 1) + 'nodeId=' + getUrlParam('nodeId'); }, error:function(){ setLoading(false); } }); } } function loadNewGridStore (gridId,condition){ setLoading(true); $.ajax({ url:basePath + 'common/loadNewGridStore.action', type: 'POST', data: {caller:pageCaller,condition:condition,_noc: 1}, success: function(result){ setLoading(false); $('#'+gridId).trigger("reloadGrid"); $('#'+gridId)[0].addJSONData(result.data); }, error:function(){ setLoading(false); } }); } function orient() { var orientation = (window.innerWidth > window.innerHeight) ?'portrait':'landscape'; document.body.parentNode.setAttribute('class',orientation); if (window.orientation == 90 || window.orientation == -90) { //ipad、iphone竖屏;Andriod横屏 $("body").attr("class", "landscape"); orientation = 'landscape'; return false; }else if (window.orientation == 0 || window.orientation == 180) { //ipad、iphone横屏;Andriod竖屏 $("body").attr("class", "portrait"); orientation = 'portrait'; return false; } } function autoTextarea (elem, extra, maxHeight) { extra = extra || 0; var isFirefox = !!document.getBoxObjectFor || 'mozInnerScreenX' in window, isOpera = !!window.opera && !!window.opera.toString().indexOf('Opera'), addEvent = function (type, callback) { elem.addEventListener ? elem.addEventListener(type, callback, false) : elem.attachEvent('on' + type, callback); }, getStyle = elem.currentStyle ? function (name) { var val = elem.currentStyle[name]; if (name === 'height' && val.search(/px/i) !== 1) { var rect = elem.getBoundingClientRect(); return rect.bottom - rect.top - parseFloat(getStyle('paddingTop')) - parseFloat(getStyle('paddingBottom')) + 'px'; }; return val; } : function (name) { return getComputedStyle(elem, null)[name]; }, minHeight = parseFloat(getStyle('height')); elem.style.resize = 'none'; var change = function () { var scrollTop, height, padding = 0, style = elem.style; if (elem._length === elem.value.length) return; elem._length = elem.value.length; if (!isFirefox && !isOpera) { padding = parseInt(getStyle('paddingTop')) + parseInt(getStyle('paddingBottom')); }; scrollTop = document.body.scrollTop || document.documentElement.scrollTop; elem.style.height = minHeight + 'px'; if (elem.scrollHeight > minHeight) { if (maxHeight && elem.scrollHeight > maxHeight) { height = maxHeight - padding; style.overflowY = 'auto'; } else { height = elem.scrollHeight - padding; style.overflowY = 'hidden'; }; style.height = height + extra + 'px'; scrollTop += parseInt(style.height) - elem.currHeight; document.body.scrollTop = scrollTop; document.documentElement.scrollTop = scrollTop; elem.currHeight = parseInt(style.height); }; }; addEvent('propertychange', change); addEvent('input', change); addEvent('focus', change); change(); }; $(document).ready(function() { $.event.special.boxready = { /** * 初始化事件处理器 - this指向元素 * @param 附加的数据 * @param 事件类型命名空间 * @param 回调函数 */ setup: function(data, namespaces, eventHandle) { var elem = this; $.event.add(elem, 'click', function (event) { if ($.data(elem, '@loaded') !== true) { $.event.trigger('boxready', null, elem); $.data(elem, '@loaded', true); } }); }, /** * 卸载事件处理器 - this指向元素 * @param 事件类型命名空间 */ teardown: function(namespaces) { var elem = this; $.event.remove(elem, 'click'); $.removeData(elem, '@loaded'); } }; var readyTime = new Date(); //激活tabpanel reActive(); // modal dialog var dialog = { show: function(title, content, timeout, callback){ var back = $('.modal-backdrop'), modal = $('.modal'), tt = $('.modal-title', modal), tb = $('.modal-body', modal); back.css('display', 'block'); modal.css('display', 'block'); tt.text(title); if(timeout && timeout > 0) { content = '
' + timeout + ' 秒后,' + content + '
'; } tb.html(content); if(timeout) { var pre = 1000; if(timeout <=0 ) {// auto close pre = 1500; if(!callback) callback = dialog.hide; } var timer = function(t) { setTimeout(function(){ if(t > -1) { $('#timeout').text(t--); timer(t); } else { callback && callback.call(); } }, pre); }; timer(timeout); } }, hide: function() { var back = $('.modal-backdrop'), modal = $('.modal'); back.css('display', 'none'); modal.css('display', 'none'); } }; $("#clearbutton").click(function(){ dialog.hide(); }); var parseBillDetail = function(content,i,detail,field,keyValue,keyName){//field 可编辑的字段,keyValue关联主表字段值 var caller = detail[i].mad_caller; var mad_code = detail[i].mad_code; var detno_code = detail[i].mad_detnocode; var condition ,ok = i; if(caller == "PayPleaseDet"){ condition = mad_code +"=(select ppd_id from (select ppd_id,row_number() over (order by ppd_detno) rn from paypleasedetail where ppd_ppid="+keyValue+") where rn < 2)" }else if(caller == "PayPleaseDet!YF"){ condition = mad_code +"=(select ppd_id from (select ppd_id,row_number() over (order by ppd_detno) rn from paypleasedetail where ppd_ppid="+keyValue+") where rn < 2)" }else{ condition = mad_code +"='"+keyValue+"'"; } setLoading(true); //获取表的列名,列值 $.ajax({ url:basePath + 'common/singleGridPanel.action', type: 'POST', data: {caller:caller,condition:condition,_noc: 1}, success: function(result){ var i = ok; setLoading(false); var colModel = []; if(field.length != 0){ //增加一列编辑列 colModel.push({"label":'编辑',"name":'act',"index":'act',"sorttype":false,"width":75,"editable":false,"frozen":true,"align":'center'}); } dbfinds = result.dbfinds; var limits = result.limits,limitarray=new Array(); if(limits && limits.length>0){ for(var i=0;i