/* * DevNet Core 1.1.15 * Author sjfe_cn * 2012-03-03 * http://www.sdevnet.com */ var DN = { FileIISURL: '' ,Language:{} //删除记录 ,ajaxDeleteRecords: function (tableName, ids, fn) { var ret = {}; ret.dnpostmethodname = 'deleterecords'; ret.ids = ids; ret.tablename = tableName; DN.ajaxPost({ form: true, showmsg: false, params: ret, success: fn || DN.onOperCompleted }); } //调用Web服务操作记录, ,ajaxOperateRecords: function (spName, ids, op, fn) { var ret = {}; ret.dnpostmethodname = 'operaterecords'; ret.ids = ids; ret.spname = spName; ret.op = op; DN.ajaxPost({ form: true, showmsg: false, params: ret, success: fn || DN.onOperCompleted }); } , ajaxAddLog: function (opstr, fn) { var ret = {}; ret.dnpostmethodname = 'savelog'; ret.logcontent = opstr; DN.ajaxPost({ form: false, showmsg: false, params: ret, success: function () { }, error: function () { return false; } }); } , ajaxError: function (XMLHttpRequest, textStatus, errorThrown, isCusShowError) { var txt = null; if (typeof (XMLHttpRequest.responseText) != 'undefined') { txt = XMLHttpRequest.responseText.replace(/<[^>].*?>/g, ""); } if (txt) { if (txt.toLowerCase().indexOf("/" + DN.TopWindow.managerdir + "/home/login.aspx") >= 0) { $.ShowMsg(DN.Language.LoginExpire, function () { DN.TopWindow.location.href = '/' + DN.TopWindow.managerdir + '/home/login.aspx'; }); return false; } if (txt.toLowerCase().indexOf("/develop/home/login.aspx") >= 0) { $.ShowMsg(DN.Language.LoginExpire, function () { DN.TopWindow.location.href = '/develop/home/login.aspx'; }); return false; } if (!isCusShowError) { $.ShowError(txt); return false; } } return true; } //ajaxpost页面数据opt.url opt.action opt.params ,ajaxPost: function (opt) { var url = opt ? (opt.url ? opt.url : window.location.href) : window.location.href; var act = opt ? (opt.action ? opt.action : 'DNPageAjaxPostBack') : 'DNPageAjaxPostBack'; if (url.indexOf('#') >= 0) url = url.substr(0, url.indexOf('#')); if (url.indexOf('?') >= 0) { url = url + '&Action=' + act; } else { url = url + '?Action=' + act; } var param = []; if (opt && opt.params) { if (opt.params.length) { $(opt.params).each(function () { param.push({ name: this.name, value: this.value }); }); } else if (typeof (opt.params) == "object") { for (var name in opt.params) { param.push({ name: name, value: opt.params[name] }); } } } if (!opt) { opt = { }; } var ret = ''; var ajaxOptions = { type: opt.type?opt.type:'post', url: url, data: param, uploadfile: opt.uploadfile, async: (opt.isAsync == false ? false : true), dataType: opt.dataType ? opt.dataType : 'json', success: function (data) { ret = data; if (opt && typeof (opt.success) == 'function') { opt.success(data); } else if (opt.isAsync == false) { ret = data; } else if (typeof (DN.postret) == 'function') { DN.postret(true, data); } }, error: function (XMLHttpRequest, textStatus, errorThrown) { var txt = null; if (typeof (XMLHttpRequest.responseText) != 'undefined') { txt = XMLHttpRequest.responseText.replace(/<[^>].*?>/g, ""); } var ret = true; if (typeof (opt && opt.error) == 'function') { ret = opt.error(txt); if (ret == false) return; } ret = DN.ajaxError(XMLHttpRequest, textStatus, errorThrown); if (ret == false) return; if (typeof (DN.postret) == 'function') { DN.postret(false, txt); } } }; if (opt && opt.showmsg == false) { //$.ajax(ajaxOptions); } else { $.ShowProcess(opt ? (opt.msg ? opt.msg : DN.Language.Submiting) : DN.Language.Submiting); } if (opt.uploadfile == true) opt.form = true; if (opt && opt.form) { if (!opt.validateForm) { opt.validateForm = false; } DN.setGridData(opt); var formid = window.document.forms[0].id; $("#" + formid).ajaxSubmit(ajaxOptions); } else { $.ajax(ajaxOptions); } return ret; } //批量操作Grid ,ajaxOperateGrid: function (gridobj, t, pkfield, op, spName,opts) { if (op == '') { $.ShowError(DN.Language.FlagError); return; } if (typeof (pkfield) == 'undefined') { $.ShowError(DN.Language.FirstSetPrimaryKey); return; } if (gridobj.endEdit() == false) { if (op == 'delete') { gridobj.endEdit(null,true); } else { return; } } var rows = gridobj.getCheckedRows(); var ids = ""; var rowids = []; $(rows).each(function () { //gridobj.endEdit(this); if (this[pkfield] == null || this[pkfield] == '') { rowids.push(this); } else { if (this[pkfield]) { if(ids!='') { ids += ','; } ids += this[pkfield]; } } }); if (ids == "" && rowids.length == 0) { $.ShowMsg(DN.Language.GridSelectOperateRow.replace('{0}', t)); return; } if (rowids.length > 0) { if (ids == "") { if (op != 'delete') { $.ShowError(DN.Language.GridNotFindRowPrimaryValue); return; } else { $.ShowConfirm(DN.Language.GridDeleteConfirm, function () { for (var j = 0; j < rowids.length; j++) { gridobj._deleteRow(rowids[j], true); } }); return; } } } if (ids == "") { $.ShowMsg(DN.Language.GridSelectOperateRow.replace('{0}',t)); return; } var changedRows = []; if (gridobj.options.enabledEdit == true) { gridobj.endEdit(); changedRows = gridobj._getModifiedData(); } if (changedRows.length > 0) { $.ShowConfirm(DN.Language.GridLostDataConfirm, function () { DN._operGrid(gridobj, t, op, spName, ids, pkfield, rows, opts); }); } else { DN._operGrid(gridobj, t, op, spName, ids, pkfield, rows, opts); } } ,_operGrid: function (gridobj, t, op, spName, ids, pkfield,rows,opts) { var msg = DN.Language.GridOperateConfirm.replace('{0}', t); if (op == 'export') { //导出 $.ShowConfirm(msg, function () { $.ShowProcess(DN.Language.Operating.replace('{0}', DN.Language.Export)); if (typeof (grid_operateRows) == 'function') { var ret = grid_operateRows(gridobj, t, ids, op); if (ret == false) return; } DN.exportData(gridobj, { ids: ids }); }); return; } else if (op == 'execflow') { //审核 if (!opts || !opts.actname) { $.ShowMsg('ActinName 不能为空'); return; } var remark = ''; var showdlg = true; if (typeof (grid_operateRows) == 'function') { var ret = grid_operateRows(gridobj, t, ids, op, opts); if (ret == false) return; if(ret) { remark = ret.chkremark; if (ret.showdlg == false) showdlg = false; } } if (showdlg == false) { DN.ajaxMethod({ method: 'LnkExecAction', params: { actionName: opts.actname, chkremark: remark, ids: ids }, msg: DN.Language.Operating.replace('{0}', t), success: function (data) { DN.refreshTabItemContent(window.parentTabID); if (!data) { data = actionText + DN.Language.OperateSuccess; } $.ShowMsg(data, function () { gridobj.search({ newpage: gridobj.options.newPage, rememberRow: true }); }); return false; } }); } else { $.ShowConfirm(msg, function() { DN.ajaxMethod({ method: 'LnkExecAction', params: { actionName: opts.actname, chkremark: remark, ids: ids }, msg: DN.Language.Operating.replace('{0}', t), success: function (data) { DN.refreshTabItemContent(window.parentTabID); if (!data) { data = actionText + DN.Language.OperateSuccess; } $.ShowMsg(data, function () { gridobj.search({ newpage: gridobj.options.newPage, rememberRow: true }); }); return false; } }); }); } return; } //存储过程优先,如果有 if (spName == undefined || spName == 'undefined') { if (typeof (grid_operateRows) == 'function') { $.ShowConfirm(msg, function () { $.ShowProcess(DN.Language.Operating.replace('{0}', t), false); var ret = grid_operateRows(gridobj, t, ids, op); if (ret == true) { if (gridobj.options.tableName) { if (op == 'delete') { //删除 DN.ajaxDeleteRecords(gridobj.options.tableName, ids , function (data) { if(!data) { var curpage = gridobj.options.newPage; if(curpage>1) { var count = 0; for (var rowid in gridobj.records) { if (gridobj.records[rowid][gridobj.options.statusName] != 'delete') { count = count + 1; } } if(rows.length==count) { gridobj.options.newPage = gridobj.options.newPage - 1; } } /*var formid = window.document.forms[0].id; var ds = $("#" + formid).attr('datasource'); if (ds) { DN.setFormState('modify', gridobj.id); }*/ } DN.onOperCompleted(data, gridobj, { ope: 'delete', txt: t + DN.Language.Success }); } ); return; } } $.ShowMsg(DN.Language.GridNotSetSpNameOrTableName); } }); } else { if (gridobj.options.tableName) { if (op == 'delete') { //删除 $.ShowConfirm(msg, function () { $.ShowProcess(DN.Language.Operating.replace('{0}', DN.Language.Delete)); DN.ajaxDeleteRecords(gridobj.options.tableName, ids , function (data) { if (!data) { var curpage = gridobj.options.newPage; if (curpage > 1) { var count = 0; for (var rowid in gridobj.records) { if (gridobj.records[rowid][gridobj.options.statusName] != 'delete') { count = count + 1; } } if (rows.length == count) { gridobj.options.newPage = gridobj.options.newPage - 1; } } /*var formid = window.document.forms[0].id; var ds = $("#" + formid).attr('datasource'); if (ds) { DN.setFormState('modify', gridobj.id); }*/ } DN.onOperCompleted(data, gridobj, { ope: 'delete', txt: t + DN.Language.Success }); } ); }); return; } } $.ShowMsg(DN.Language.GridNotSetSpNameOrTableName); } return; } $.ShowConfirm(msg, function () { $.ShowProcess(DN.Language.Operating.replace('{0}', t)); if (typeof (grid_operateRows) == 'function') { var ret = grid_operateRows(gridobj, t, ids, op); if (ret == false) return; } DN.ajaxOperateRecords(spName, ids, op, function(data) { DN.onOperCompleted(data, gridobj, { rememberRow: true, ope: op, txt: t + DN.Language.Success }); } ); }); } //grid保存 , ajaxSaveGrid: function (grdobj, options, saveOpt) { if (grdobj.endEdit() == false) return false; var changedData = grdobj.getChangedData(); if (changedData == '' || changedData.length == 0) { $.ShowMsg(DN.Language.GridNotUpdateData); return false; } var sub = grdobj.validateEditData(changedData); if (sub == false) { return false; } grdobj.setChangedData(changedData); if (typeof (grid_SaveChangedData) == 'function') { return grid_SaveChangedData(grdobj, changedData, saveOpt); } $.ShowProcess(DN.Language.Submiting); return true; } //操作单条 ,ajaxOperate: function (grdobj, spName, id, op, row, rowindex, title, actname) { if (!id) { if (op == 'delete') {//移除 //grdobj.remove(rowindex); grdobj._deleteRow(row, true); } else { $.ShowError(DN.Language.GridNotFindPrimaryValue); } return; } try { parseInt(op, 10); } catch (e) { op = ''; } if (op == '') { $.ShowError(DN.Language.FlagError); return; } var tit = getMsgByop(op); if (title && title != '') { tit = title; } var msg = DN.Language.OperatingRowConfirm.replace('{0}', tit); //存储过程优先,如果有 if (spName == undefined || spName == 'undefined') { if (typeof (grid_operateRow) == 'function') { $.ShowConfirm(msg, function () { $.ShowProcess(DN.Language.Operating.replace('{0}', tit)); var ret = grid_operateRow(grdobj, tit, id, op); if (ret == true) { if (grdobj.options.tableName) { if (op == 'delete') { DN.ajaxDeleteRecords(grdobj.options.tableName, id , function (data) { if (!data) { var curpage = grdobj.options.newPage; if (curpage > 1) { var count = 0; for (var rowid in grdobj.records) { if (grdobj.records[rowid][grdobj.options.statusName] != 'delete') { count = count + 1; } } if (rows.length == count) { grdobj.options.newPage = grdobj.options.newPage - 1; } } var formid = window.document.forms[0].id; var ds = $("#" + formid).attr('datasource'); if (ds) { DN.setFormState('modify', grdobj.id); } } DN.onOperCompleted(data, grdobj, { ope: op, txt: tit + DN.Language.Success }); } ); return; } } $.ShowMsg(DN.Language.GridNotSetSpNameOrTableName); } }); } else { if (grdobj.options.tableName) { if (op == 'delete') { $.ShowConfirm(msg, function () { $.ShowProcess(DN.Language.Operating.replace('{0}', tit)); DN.ajaxDeleteRecords(grdobj.options.tableName, id , function (data) { if (!data) { var curpage = grdobj.options.newPage; if (curpage > 1) { var count = 0; for (var rowid in grdobj.records) { if (grdobj.records[rowid][grdobj.options.statusName] != 'delete') { count = count + 1; } } if (rows.length == count) { grdobj.options.newPage = grdobj.options.newPage - 1; } } var formid = window.document.forms[0].id; var ds = $("#" + formid).attr('datasource'); if (ds) { DN.setFormState('modify', grdobj.id); } } DN.onOperCompleted(data, grdobj, { ope: op, txt: tit + DN.Language.Success }); } ); }); return; } } $.ShowMsg(DN.Language.GridNotSetSpNameOrTableName); } return; } $.ShowConfirm(msg, function () { $.ShowProcess(DN.Language.Operating.replace('{0}', tit)); if (typeof (grid_operateRow) == 'function') { var ret = grid_operateRow(grdobj, tit, id, op); if (ret == false) return; } DN.ajaxOperateRecords(spName, id, op , function (data) { DN.onOperCompleted(data, grdobj, { rememberRow: true, ope: op, txt: tit + DN.Language.Success }); } ); }); } //查询数据 ,ajaxSearch: function (gridobj, searchOpt) { var showmsg = true; if (typeof (searchOpt) != 'undefined' && searchOpt.showmsg == false) showmsg = false; if (showmsg == true) $.ShowProcess(DN.Language.Loading); var where = ''; if (typeof (getFilter) == 'function') { where = getFilter(gridobj.id); } if (searchOpt&& searchOpt.filter) { where += '|' + searchOpt.filter; } var np = null; if (typeof (searchOpt) == 'undefined') { searchOpt = false; np = 1; } if (searchOpt == true) { np = 1; } else { if (searchOpt) np = searchOpt.newpage; } if (!np) np = 1; gridobj.reloadData({ filter: where, newpage: np, rememberRow: searchOpt ? searchOpt.rememberRow : null, reloaddata: searchOpt?searchOpt.reloaddata:true, isThousand: searchOpt?searchOpt.isThousand:false }); //$.CloseMsg(); if (searchOpt == true || searchOpt.addlog == true) { DN.ajaxAddLog(DN.Language.Search); } return false; } //操作完成的回调方法 , onOperCompleted: function (data, ctl, opt) { DN.refreshTabItemContent(window.parentTabID); if (typeof (page_postret) == 'function') { var ret = true; var retmsg = ''; if (data && data.length > 0) { ret = false; retmsg = data; } var result = page_postret(ret, retmsg, ctl,opt); if (result == false) return false; } if (data && data.length > 0) { $.ShowMsg(data); return false; } else { var txt = DN.Language.OperateSuccess; if (opt && opt.txt) { txt = opt.txt; } $.ShowMsg(txt, function () { $.CloseMsg(); if (ctl) { ctl.search({ newpage: ctl.options ? ctl.options.newPage : 1, rememberRow: opt?opt.rememberRow:null,reloaddata:true }); } else { if (typeof (postbacksearch) == 'function') { postbacksearch(false); } } }); } return true; } ,getGridObj:function(gridid) { return $("#" + gridid).ligerGetGridManager(); } ,getTreeObj: function (treeid) { return $("#" + treeid).ligerGetTreeManager(); } //更新对话框编辑列 ,setGridColumnValue: function (gridid, rowid, columnindex, val) { var grdobj = $("#" + gridid).ligerGetGridManager(); if (typeof (grid_setGridColumnValue) == 'function') { var ret = grid_setGridColumnValue(grdobj, rowid, columnindex, val); if (ret == false) return; } var column = grdobj.columns[columnindex]; var curRow = grdobj.getRow(rowid); grdobj.endEdit(null, true); if (typeof (val) == 'string') val = DN.htmlEncode(val); grdobj.updateCell(column.columnname, val, curRow); grdobj._setNextCellEditing(grdobj, curRow, column); } //Grid弹出框选择后设置关联列 ,setGridRelationColumn: function (gridid, rowid, columnindex, rows) { var grdobj = null; try { grdobj = $("#" + gridid).ligerGetGridManager(); } catch (e) { grdobj = null; } if (typeof (grid_setGridRelationColumn) == 'function') { var ret = grid_setGridRelationColumn((grdobj != null ? grdobj : gridid), rowid, columnindex, rows); if (ret == false) return; } if (rows.length == 0) { $.ShowMsg(DN.Language.GridNotSelectRow); return; } if (!grdobj) return; if (grdobj.endEdit() == false) { grdobj.endEdit(null, true); } for (var j = 0; j < rows.length; j++) { if (columnindex >= 0 && rowid != 'r0') { var column = grdobj.columns[columnindex]; if (column.editor.excludeColumns) { var excol = column.editor.excludeColumns; var excols = excol.split('|'); var isfind = false; var exist = ''; for (var k = 0; k < grdobj.rows.length; k++) { if (grdobj.rows[k]['__status'] == 'delete') { continue; } exist = ''; isfind = false; for (var l = 0; l < excols.length; l++) { var excl = excols[l].split('='); var oldcol = excl[0]; var newcol = excl.length > 1 ? excl[1] : excl[0]; var oldval = grdobj.rows[k][oldcol]; var newval = rows[j][newcol]; if (oldval != newval) { isfind = true; break; } if (exist != '') exist = exist + ','; exist = exist + '['+newval+']'; } if(!isfind) { break; } } if (!isfind) { if (exist != '') { alert(DN.Language.GridDataExists.replace('{0}', exist)); } continue; } } if (j > 0) { var nr = grdobj.addEditRow(null, false); rowid = nr['__id']; } var curRow = grdobj.getRow(rowid); var rels = column.relationColumns; if (!rels) { rels = column.editor.relationColumns; } if (!rels) { rels = column.name + '#' + column.name; } else { if (rels.indexOf(column.name + '#') < 0 && rels.indexOf(column.name + '=') < 0) { if (rels.length > 0) rels = rels + '|'; rels = rels + column.name + '#' + column.name; } } column.relationColumns = rels; var relCols = column.relationColumns.split('|'); for (var i = 0; i < relCols.length; i++) { var relCol; if (relCols[i].indexOf('=') >= 0) { relCol = relCols[i].split('='); } else { relCol = relCols[i].split('#'); } if (relCol.length == 2) { if (typeof(rows[j][relCol[1]]) != 'undefined') { grdobj.updateCell(relCol[0], rows[j][relCol[1]], curRow); grdobj.trigger('afterEdit', { record: curRow, value: rows[j][relCol[1]], column: { name: relCol[0] }, rowindex: curRow['__index'] }); } } } /*if (j < rows.length - 1) { var newrow = grdobj.addEditRow(null,false); rowid = newrow['__id']; }*/ } else { //这里非grid列选择 var newrow = grdobj.addEditRow(null,false); grdobj.updateRow(newrow, rows[j]); } } var curRow = grdobj.getRow(rowid); var column = grdobj.columns[columnindex]; grdobj._setNextCellEditing(grdobj, curRow, column); }, //显示编辑对话框 showEditDlg: function (page, pkvalue, dlgopt, extopt) { if (typeof (pkvalue) == 'undefined') { $.ShowError(DN.Language.GridNotFindPrimaryValue); return; } var prefix = '?'; if (page.indexOf('?') >= 0) { prefix = '&'; } var pdg = null; try { if (frameElement) pdg = frameElement.dg; } catch (e) { } if (pdg) { if (typeof (pdg.__getType) != 'undefined') { pdg = null; } } if (typeof (dlgopt) == 'function') { dlgopt = dlgopt(extopt); } var title = DN.Language.PageEditTitle; if (dlgopt && dlgopt.title) { title = dlgopt.title; } var pkname = 'id'; if (extopt && extopt.pkfield) pkname = extopt.pkfield; var opt = $.extend({ id: 'lnkeditinfo_' + new Date().getTime(), // pkvalue, title: title, page: page + prefix + pkname + '=' + pkvalue ,//+'\'', btnbar: false }, dlgopt || {}); var zindex = 10100; if (pdg) { zindex = pdg.dg.style.zIndex; } else { if (window.DNZIndex) zindex = window.DNZIndex; } opt.zIndex = zindex + 2; var dlg; if (pdg) { if (!opt.parent) opt.parent = pdg; dlg = new pdg.curWin.$.dialog(opt); } else { dlg = new $.dialog(opt); } dlg.ShowDialog(); return dlg; }, //显示新增对话框 showAddDlg: function (page, dlgopt, extopt) { var paredg = null; try { if (frameElement) paredg = frameElement.dg; } catch (e) { } if (paredg) { if (typeof (paredg.__getType) != 'undefined') { paredg = null; } } var prefix = '?'; if (page.indexOf('?') >= 0) { prefix = '&'; } var pkname = 'id'; if (extopt && extopt.pkfield) pkname = extopt.pkfield; if (typeof (dlgopt) == 'function') { dlgopt = dlgopt(extopt); } var title = DN.Language.PageAddTitle; if (dlgopt && dlgopt.title) { title = dlgopt.title; } var isguid = $("#" + document.forms[0].id).attr("isguid"); var opt = $.extend({ id: 'lnkaddinfo' + new Date().getTime(), title: title, page: page + prefix + pkname + '=' + (isguid == '1' ? '00000000-0000-0000-0000-000000000000' : '0'), btnbar: false }, dlgopt || {}); var zindex = 10100; if (paredg) { zindex = paredg.dg.style.zIndex; } else { if (window.DNZIndex) zindex = window.DNZIndex; } opt.zIndex = zindex + 2; var cdlg; if (paredg) { if (!opt.parent) opt.parent = paredg; cdlg = new paredg.curWin.$.dialog(opt); } else { cdlg = new $.dialog(opt); } cdlg.ShowDialog(); return cdlg; }, SaveClose: true, saveRefresh:function(opt) { DN.SaveRefresh(opt); }, SaveRefresh:function(opt) { if(!opt) { opt = { }; } if(!opt.isrefresh) { opt.isrefresh = true; } DN.SaveData(opt); }, saveAdd:function(opt) { DN.SaveAdd(opt); }, SaveAdd:function(opt) { if(!opt) { opt = { }; } if (!opt.saveAdd) { opt.saveAdd = true; } DN.SaveData(opt); }, saveData:function(opt) { DN.SaveData(opt); }, refreshGridData:function() { $("div[libctl='libgrid']").each(function () { var grdobj = $("#" + $(this).attr("id")).ligerGetGridManager(); if (grdobj) { grdobj.refreshData({chkstate:true}); } }); }, SaveData: function (opt) { if (!opt) opt = {}; if (opt.saveClose == false) DN.SaveClose = false; DN.postback(opt.issubmit,opt.saveAdd,opt.addCopy,opt.isrefresh,opt); }, setGridData: function (opt) { var sub = true; $("div[libctl='libgrid']").each(function () { var grdobj = $("#" + $(this).attr("id")).ligerGetGridManager(); if (grdobj) { if (grdobj.endEdit() == false) { sub = false; } var changedata = grdobj.getChangedData(); if (opt && opt.validateForm == false) { } else { if(sub==false) { return false; } sub = grdobj.validateEditData(changedata); if (sub == false) { sub = '0'; return false; } } grdobj.setChangedData(changedata); } }); return sub; }, //回发 postback: function (issubmit,saveAdd,addCopy,isrefresh,opt) { //$.ShowProcess(DN.Language.ValidateData); var sub = DN.setGridData(opt); if(sub === '0') { return; } if (!sub) { $.CloseMsg(); return; } var f = window.document.forms[0]; $(f).find('[class*=DN_FCKFlag]').each(function() { var ids = $(this).attr("class").split('_'); var id = ids[2]; var oEditor = FCKeditorAPI.GetInstance(id); oEditor.UpdateLinkedField(); }); var ret = true; if (opt && opt.validateForm == false) { } else { ret = DN.validateForm(null, { validateGrid: false }); //手动触发验证 } if (typeof (page_formvalidated) == 'function') { var vret = page_formvalidated(ret); if (vret == false) { return; } } if (ret == true) { var subflow = false; var submsg = DN.Language.Save; if (issubmit && (issubmit == 1 || issubmit == true || issubmit == 'true')) { submsg = DN.Language.Submit; } if(opt&&opt.text) { submsg = opt.text; } if (typeof (page_postback) == 'function') { ret = page_postback(issubmit); if (ret == false) { //$.CloseMsg(); return; } } if (ret == true) ret = {}; if (!ret) { ret = {}; } if (!ret.showmsg) ret.showmsg = false; if (!ret.addlog) { ret.addlog = true; } if (issubmit && (issubmit == 1 || issubmit == true || issubmit == 'true')) { if (ret.params) { if (ret.params.length) { ret.params.push({ dnsubmitflow: 'true' }); } else if (typeof (ret.params) == "object") { ret.params.dnsubmitflow = 'true'; } } else { ret.params = {}; ret.params.dnsubmitflow = 'true'; } ret.method = 'LnkStartFlow'; subflow = true; } else { $.ShowProcess(DN.Language.Operating.replace('{0}', submsg)); } ret.operate = submsg; if(saveAdd==true) { DN.SaveClose = false; } if (DN.SaveClose != false) { var pagedgc = null; try { if (frameElement) pagedgc = frameElement.dg; } catch (e) { } if (pagedgc) { if (typeof (pagedgc.__getType) != 'undefined') { pagedgc = null; } } if(!pagedgc) { DN.SaveClose = false; } } if (DN.SaveClose == false) { ret.success = function (data) { DN.setFormState('unchanged', $(f).attr("id")); DN.refreshTabItemContent(window.parentTabID); DN.ajaxAddLog(submsg + "表单"); if (opt && typeof (opt.success) == 'function') { var optret = opt.success(data); if (optret == false) { return false; } } if (data && typeof (data) == 'object') { var retmsg = DN.Language.OperateSuccessRefresh.replace('{0}', submsg); var refresh = function () { try { var find = false; var needrefresh = false; var query = ''; //alert(key+'-'+json[key]); var url = window.location.href; var params = url.split('?'); var search = ''; if (params.length == 2) { search = params[1]; url = params[0]; } var searchparams = []; if (search != '') { searchparams = search.split('&'); } var saveaddcopy = false; var isguid = $("#" + document.forms[0].id).attr("isguid"); var pkv = (isguid == '1' ? '00000000-0000-0000-0000-000000000000' : '0'); for (var key in json) { $("input[pkfield='" + key + "']").each(function () { if (saveAdd == true && addCopy == true) { $(this).val(pkv); saveaddcopy = true; } else if ($(this).val() == '' || $(this).val() == '0' || $(this).val() == '00000000-0000-0000-0000-000000000000') { if (!saveAdd) { $(this).val(json[key]); } needrefresh = true; var spfind = false; for (var i = 0; i < searchparams.length; i++) { var sp = searchparams[i].split('='); if (sp.length == 2) { if (sp[0] == key || sp[0] == ('_' + key)) { spfind = true; if (!saveAdd) { searchparams[i] = key + '=' + json[key]; } else { searchparams[i] = key + '=' + pkv; } break; } } } if (spfind == false) { if (!saveAdd) { searchparams.push(key + '=' + json[key]); } else { searchparams.push(key + '=' + pkv); } } } else { if (saveAdd == true) { $(this).val(pkv); needrefresh = true; var spfind = false; for (var i = 0; i < searchparams.length; i++) { var sp = searchparams[i].split('='); if (sp.length == 2) { if (sp[0] == key || sp[0] == ('_' + key)) { spfind = true; searchparams[i] = key + '=' + pkv; break; } } } if (spfind == false) { searchparams.push(key + '=' + pkv); } } } find = true; }); } if (saveaddcopy == true) { return true; } if (needrefresh == true || isrefresh == true) { $.ShowProcess(retmsg); for (var i = 0; i < searchparams.length; i++) { if (query != '') { query = query + '&'; } query = query + searchparams[i]; } if (query != '') { url = url + '?' + query; } DN.ajaxAddLog(submsg + "表单"); window.location.href = url; return false; } DN.refreshGridData(); $.ShowMsg(submsg + DN.Language.Success, function () { $.CloseMsg(); if (find == true) { if (typeof (postbacksearch) == 'function') { postbacksearch(false); } } else { DN.postbacksearch(); } }); return true; } catch (e) { //$.ShowMsg(submsg + DN.Language.Success, function() { // $.CloseMsg(); // DN.postbacksearch(); //}); alert(e.description); return false; } }; var json = data; if (typeof (page_postret) == 'function') { var result = page_postret(true, json, null, { ope: 'save' }); if (result == false) return false; } if (saveAdd == true) { $.ShowConfirm(DN.Language.OperateSuccessAddConfirm.replace('{0}', submsg), function() { var ret1 = refresh(); if (ret1 == true) { if (typeof(page_saveadd) == 'function') { page_saveadd(true, json, { ope: 'saveadd' }); } } }, null, null, null, function() { if (typeof(page_saveadd) == 'function') { page_saveadd(true, json, { ope: 'cancel' }); } $.CloseMsg(); DN.postbacksearch(); } ); } else { refresh(); } } else { DN.refreshGridData(); if (typeof (page_postret) == 'function') { var result = page_postret(true, null, null, { ope: submsg }); if (result == false) return false; } $.ShowMsg(submsg + DN.Language.Success, function () { $.CloseMsg(); DN.postbacksearch(); }); } return false; }; } else { ret.success = function (data) { DN.refreshTabItemContent(window.parentTabID); if (typeof (page_postret) == 'function') { var result = page_postret(true, data, null, { ope: 'save' }); if (result == false) return; } $.ShowMsg(DN.Language.SubmitSucces, function () { DN.setFormState('unchanged'); $.CloseMsg(); DN.postbacksearch(); }); }; } if (subflow == true) { $.ShowConfirm(DN.Language.OperatingRowConfirm.replace('{0}', submsg), function () { DN.ajaxSubmitForm(ret); }); } else { DN.ajaxSubmitForm(ret); } } else { $.CloseMsg(); } }, refreshParentTab:function() { DN.refreshTabItemContent(window.parentTabID); }, refreshTabItemContent:function(tabitemid) { setTimeout(function () { if (tabitemid) { DN.TopWindow.refreshTabContent(tabitemid); } }, 10); }, //postret postret: function (ret, retmsg) { if (typeof (page_postret) == 'function') { var result = page_postret(ret, retmsg); if (result == false) return; } if (ret) { $.ShowMsg(DN.Language.SubmitSucces, function () { DN.setFormState('unchanged'); $.CloseMsg(); DN.postbacksearch(); }); } else { var showmsg = DN.Language.SubmitFailRetry; if (retmsg) { showmsg = showmsg + retmsg; } $.ShowError(showmsg); } }, postbacksearch: function () { var pagedgc = null; try { if (frameElement) pagedgc = frameElement.dg; } catch (e) { } if (pagedgc) { if (typeof (pagedgc.__getType) != 'undefined') { pagedgc = null; } } var ret = true; if (pagedgc) { if (pagedgc.opt.parent) { if (typeof(pagedgc.opt.parent.dgWin.postbacksearch) == 'function') ret = pagedgc.opt.parent.dgWin.postbacksearch(false); } else { if (typeof(pagedgc.curWin.postbacksearch) == 'function') ret = pagedgc.curWin.postbacksearch(false); } if (ret == true) { if (pagedgc.opt.ctl && typeof (pagedgc.opt.ctl.search) == 'function') { pagedgc.opt.ctl.search({ newpage: pagedgc.opt.ctl.options ? pagedgc.opt.ctl.options.newPage : 1, rememberRow: true, reloaddata: true }); } } pagedgc.close(); //关闭对话框,不调用oncancel事件,引发onclose事件 } else { if (typeof (postbacksearch) == 'function') { postbacksearch(false); } } }, go: function (url) { if (!url) return; if(DN.formState != 'unchanged') { var ret = confirm(DN.Language.DataChangedCloseConfirm); if (!ret) return; } window.location.href = url; }, closeDlg: function (isrefresh) { if (isrefresh) { DN.postbacksearch(); } else { var pagedgc; try { if (frameElement) pagedgc = frameElement.dg; } catch (e) { } if (pagedgc) { pagedgc.cancel(); } else { if (typeof (DN.TopWindow.closeTab) == 'function') { DN.TopWindow.closeTab(); } } } }, closeForm:function() { DN.closeDlg(); }, addTab: function (url, title, id) { var tabid = id; if (!tabid) tabid=DN.getPageName(url); /*if (DN.TopWindow.containsTabItem(tabid) == false) DN.TopWindow.ShowProcess();*/ DN.TopWindow.addTab(tabid, title, url, true); }, closeTab:function(tabid) { DN.TopWindow.closeTab(tabid); }, validateGrid: function (grdid) { var sub = true; function validategrid(gridid) { var ret = true; var grdobj = $("#" + gridid).ligerGetGridManager(); if (grdobj) { if (grdobj.endEdit() == false) { return false; } var changedata = grdobj.getChangedData(); ret = grdobj.validateEditData(changedata); if (ret == false) { return false; } } return ret; } if (!grdid) { $("div[libctl='libgrid']").each(function () { sub = validategrid($(this).attr("id")); if (sub == false) { return false; } }); return sub; } else { sub = validategrid(grdid); if (sub == false) { return false; } } return sub; }, //验证 validateForm: function (obj, opt) { var ret = true; if (window.IsDNValidate) { ret = DNValidate.validateForm(obj); } else { var form = document.forms[0]; if (form) { if (typeof ($(form).validationEngine) == 'function') { ret = $(form).validationEngine('validate'); } } } if (ret == true) { if (opt && opt.validateGrid == false) { } else { ret = DN.validateGrid(); } } return ret; }, //获取页面名称 getPageName: function (url) { var href = url; if (!href) href = window.location.href; var b = href.split("/"); var c = b.slice(b.length - 1, b.length).toString(String).split("."); var ret = c.slice(0, 1); var index = ret[0].indexOf('?'); if (index > 0) { return ret[0].substring(0, index); } return ret[0]; }, getDecimals: function (number) { number = (number || 0).toString(); return number.indexOf('.') > -1 ? number.split('.')[1].length : 0; }, pInt: function (s, mag) { return parseInt(s, mag || 10); }, getNumberFormat:function(number,decimals,decPoint,thousandsSep) { return DN.numberFormat(number, decimals, decPoint, thousandsSep); }, numberFormat: function (number, decimals, decPoint, thousandsSep) { if (String(number)=='') return number; var n = number, c = decimals === -1 ? DN.getDecimals(number) : (isNaN(decimals = Math.abs(decimals)) ? 2 : decimals), d = decPoint === undefined ? '.' : decPoint, t = thousandsSep === undefined ? '' : thousandsSep, s = n < 0 ? "-" : "", i = String(DN.pInt(n = Math.abs(+n || 0).toFixed(c))), j = i.length > 3 ? i.length % 3 : 0; return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : ""); }, //获取Where条件字符串 getWhere: function (filter, fieldname, sqlcompare, fieldvalue, tablename) { if (!filter) filter = ''; filter = filter + '|'; if (!tablename) tablename = 2; return filter + '' + tablename + ':' + fieldname + ' ' + sqlcompare + ' ' + fieldvalue; }, invokeMethod: function (methodName, methodParams, opt, fn) { var opts = { }; opts.method = methodName; opts.methodParams = methodParams; if (fn) { opts.success = function (data) { return fn(data); } } $.extend(opts, opt || { }); DN.ajaxMethod(opts); }, //使用text类型回发 ajaxMethod: function (opt) { if (!opt) { opt = {}; } if (typeof (opt.showmsg) == 'undefined') { opt.showmsg = true; } opt.dataType = opt.dataType ? opt.dataType : 'text'; if (opt.isAsync == false) { opt.showmsg = false; } if (typeof (opt.addlog) == 'undefined') opt.addlog = true; opt.operate = '[' + DN.Language.InvokeMethod + ': (' + opt.method + ') ]'; if (!opt.validateForm) { opt.validateForm = false; } DN.setGridData(opt); return DN.ajaxSubmitForm(opt); }, //ajax提交表单 ajaxSubmitForm: function (opt) { var url = opt ? (opt.url ? opt.url : window.location.href) : window.location.href; var act = opt ? (opt.action ? opt.action : 'DNPageAjaxPostBack') : 'DNPageAjaxPostBack'; if (url.indexOf('#') >= 0) url = url.substr(0, url.indexOf('#')); if (url.indexOf('?') >= 0) { url = url + '&Action=' + act; } else { url = url + '?Action=' + act; } var param = []; if (opt && opt.params) { if (opt.params.length) { $(opt.params).each(function () { param.push({ name: this.name, value: this.value }); }); } else if (typeof (opt.params) == "object") { for (var name in opt.params) { param.push({ name: name, value: opt.params[name] }); } } } if (opt.method) { param.push({ name: 'dnpostmethodname', value: opt.method }); } else { param.push({ name: 'dnpostmethodname', value: 'LnkSaveContainer' }); } if (typeof (opt.methodParams) != 'undefined') { param.push({ name: 'dnpostmethodparams', value: opt.methodParams }); } var ret = false; var ajaxOptions = { type: 'post', url: url, data: param, dataType: opt.dataType ? opt.dataType : 'json', uploadfile: opt.uploadfile, async: (opt.isAsync == false ? false : true), success: function (data) { if (opt && opt.showmsg == true) { $.CloseMsg(); } if (data && data.length > 0 && typeof(data)=='string') { if (data.indexOf("Error:") >= 0) { ajaxOptions.error({ responseText: data }); return; } } if (opt.isAsync == false) { ret = data; } if (opt && typeof (opt.success) == 'function') { var resu = opt.success(data); if (resu == false) { } else { if (opt.addlog == false) { } else { var opte = DN.Language.Save; if (opt.operate) opte = opt.operate; DN.ajaxAddLog(opte+"表单"); } } } /* else if (opt.isAsync == false) { ret = data; }*/ else if (typeof (DN.postret) == 'function') { DN.postret(true, data); if (opt.addlog == false) { } else { var opte = DN.Language.Save; if (opt.operate) opte = opt.operate; DN.ajaxAddLog(opte + "表单"); } } }, error: function (XMLHttpRequest, textStatus, errorThrown) { var txt = null; if (typeof (XMLHttpRequest.responseText) != 'undefined') { txt = XMLHttpRequest.responseText.replace(/<[^>].*?>/g, ""); } var rets; if (typeof (opt && opt.error) == 'function') { rets = opt.error(txt); if (rets == false) return false; } rets = DN.ajaxError(XMLHttpRequest, textStatus, errorThrown); if (rets == false) return false; if (typeof (DN.postret) == 'function') { DN.postret(false, txt); } } }; if (opt && opt.showmsg == false) { } else { $.ShowProcess(opt ? (opt.msg ? opt.msg : DN.Language.Submiting) : DN.Language.Submiting); } var formid = window.document.forms[0].id; if (formid) { $("#" + formid).ajaxSubmit(ajaxOptions); //return false; } else { $.ShowMsg(DN.Language.NotFindForm); return false; } return ret; }, showFlow: function (flowcode, keyid, flag) { if (!flag) flag = ''; var url = '/' + DN.TopWindow.managerdir + '/Common/FlowDetail.aspx'; url = url + '?flowcode=' + escape(flowcode) + '&keyid=' + escape(keyid) + '&flag=' + escape(flag); $.ShowDlg(url, { title: '审阅明细', width: 750, height: 450 }); }, execAction: function (node, action, actionText, opt) { if(!action) { $.ShowMsg('ActionName不能为空'); return; } var ret = true; if (opt && opt.validateForm == false) { } else { ret = DN.validateForm(); } if (typeof (page_formvalidated) == 'function') { var vret = page_formvalidated(ret); if (vret == false) { return; } } if (!ret) { return; } if (typeof (page_beforeOperate) == 'function') { if (!opt) opt = {}; opt.nodeName = node; opt.actionName = action; opt.ope = 'execflow'; opt.actionText = actionText; var vret = page_beforeOperate(actionText, action, opt); if (vret == false) { return; } } if (!opt) opt = {}; if (opt.showdlg == false) { $.ShowConfirm(DN.Language.OperatingRowConfirm.replace('{0}', actionText), function() { DN.execFlowAction(node, action, actionText, ''); }); } else { var url = '/' + DN.TopWindow.managerdir + '/Common/FlowRemark.aspx'; url = url + '?node=' + escape(node) + '&action=' + escape(action) + '&actiontext=' + escape(actionText); $.ShowDlg(url, { title: '审阅意见',width:400,height:280,btnbar:true }); } }, execFlowAction: function (node, action, actionText, remark,dlg) { DN.ajaxMethod({ method: 'LnkExecAction', dataType: 'json', params: { nodeName: node, actionName: action, chkremark: remark }, msg: DN.Language.Operating.replace('{0}', actionText), success: function (data) { DN.refreshTabItemContent(window.parentTabID); if (typeof (page_postret) == 'function') { var ret = true; var retmsg = ''; if (data && data.length > 0) { ret = false; retmsg = data; } if (data && typeof (data) == "object") { ret = true; retmsg = data; } if (retmsg == '') { retmsg = {}; var key = $("input[pkfield]").attr('pkfield'); retmsg[key] = $("input[pkfield]").val(); } var result = page_postret(ret, retmsg, null , { ope: 'execflow', actionText: actionText, actionName: action, nodeName: node }); if (result == false) return false; } $.ShowMsg(actionText + DN.Language.OperateSuccess, function () { if (DN.SaveClose == true) { $.CloseMsg(); DN.postbacksearch(); DN.closeDlg(); } else { DN.refreshPage(data); } }); return true; } }); }, setRefreshFlag:function(data,dlg) { dlg.opt.onclose = function() { DN.refreshPage(data); }; }, //4-3 add chart ajaxReloadChart: function (chartobj, opt) { var where = ''; if (typeof (getChartFilter) == 'function') { where = getChartFilter(chartobj.renderTo.id); } if (typeof (opt) == 'undefined') { opt = false; } var options = {}; if (opt == true || opt == false) { if (where && where != '' || where.length > 0) { options.params = $.extend({ where: where.filter }, where.params || {}); } } else { options.params = $.extend({ where: opt.filter }, opt.params || {}); } options.action = chartobj.renderTo.id + 'GetChartData'; options.dataType = 'text'; options.success = function (data) { var json; try { json = eval('(' + data + ')'); } catch (e) { var XMLHttpRequest = {}; XMLHttpRequest.responseText = data; var ret = DN.ajaxError(XMLHttpRequest, null, null, true); if (ret == true) { $.ShowError(DN.Language.DataFormatErrorRetry); } return; } DN.ClearDlgs(); chartobj.destroy(); chartobj = new Highcharts.Chart(json.data); var rpt = 'function rpt_' + chartobj.renderTo.id + 'Reload'; for (var i = 0; i < DN.Reportfn.length; i++) { var fn = DN.Reportfn[i]; fn = String(fn); if (fn.indexOf(rpt) >= 0) { DN.Reportfn[i](chartobj); } } if (opt.success) { opt.success(json, chartobj); } $.CloseMsg(); }; options.error = function (data) { $.ShowError(data); return false; }; options.msg = DN.Language.Loading; options.form = true; DN.ajaxPost(options); if (opt == true || opt.addlog == true) { DN.ajaxAddLog(DN.Language.Search); } }, Dlgs: [], ClearDlgs: function () { for (var i = 0; i < DN.Dlgs.length; i++) { if (DN.Dlgs[i].cancel) { DN.Dlgs[i].cancel(); } } DN.Dlgs = []; }, Reportfn: [], operateForm: function (spName, opstr,opt) { var ret1 = true; if (opt && opt.validateForm == false) { } else { ret1 = DN.validateForm(); //手动触发验证 } if (typeof (page_formvalidated) == 'function') { var vret = page_formvalidated(ret1); if (vret == false) { return; } } if(ret1==false) { return; } if (typeof (page_beforeOperate) == 'function') { var vret = page_beforeOperate(opstr, spName,opt); if (vret == false) { return; } } var pkv = $("input[pkfield]"); var pkval = pkv.val(); if(DN.isInsert(pkval)) { pkval = ''; } if(!opt) { opt = { }; } if (opt.showdlg == false) { DN._operateForm(spName, opstr, pkval, opt); } else { $.ShowConfirm(DN.Language.OperatingRowConfirm.replace('{0}', opstr), function() { DN._operateForm(spName, opstr, pkval, opt); }); } }, _operateForm: function (spName, opstr, pkval, opt) { $.ShowProcess(DN.Language.Operating.replace('{0}', opstr)); DN.ajaxOperateRecords(escape(spName), pkval, escape(opstr), function(data) { if (typeof(page_postret) == 'function') { var ret = true; var retmsg = ''; if (data && data.length > 0) { ret = false; retmsg = data; } if (data && typeof(data) == "object") { ret = true; retmsg = data; } if (retmsg == '') { retmsg = { }; var key = $("input[pkfield]").attr('pkfield'); retmsg[key] = $("input[pkfield]").val(); } var result = page_postret(ret, retmsg, null, { ope: opstr }); if (result == false) return false; } $.ShowMsg(opstr + DN.Language.OperateSuccess, function() { DN.refreshPage(data); }); return true; }); }, refreshPage: function (data, msg) { if(!msg) { msg = DN.Language.RefreshData; } $.ShowProcess(msg); if (data && typeof (data) == "object") { var url = window.location.href; var params = url.split('?'); var search = ''; if (params.length == 2) { search = params[1]; url = params[0]; } var searchparams = []; if (search != '') { searchparams = search.split('&'); } for (var key in data) { var spfind = false; for (var i = 0; i < searchparams.length; i++) { var sp = searchparams[i].split('='); if (sp.length == 2) { if (sp[0] == key || sp[0] == ('_' + key)) { spfind = true; searchparams[i] = key + '=' + data[key]; break; } } } if(!spfind) { searchparams.push(key + '=' + data[key]); } } var query = ''; for (var i = 0; i < searchparams.length; i++) { if (query != '') { query = query + '&'; } query = query + searchparams[i]; } if (query != '') { url = url + '?' + query; } window.location.href = url; } else { if (window.location.href.indexOf('?') >= 0) { window.location.href = window.location.href + '&rand=' + new Date().getTime(); } else { window.location.href = window.location.href + '?rand=' + new Date().getTime(); } } } //4-9 ButtonOperate , operateRows: function (ctlobj, op, opstr, opts) { var title = ''; if (opstr && opstr != '') { title = opstr; } else { title = getMsgByop(op); } if (op == 'add') { //新增 ctlobj.addNewRow(opts); } else if (op == 'edit') { // 编辑 ctlobj.editRow(opts,title); } else if (op == 'save') { //保存 if (ctlobj == null) { DN.postback(); } else { ctlobj.save(opts); } } else if (op == 'print') {//打印 DN.print(ctlobj,opts); } else if (op == 'printview') {//预览 DN.printView(ctlobj,opts); } else if(op=='printdesign') { DN.printDesign(ctlobj); } else if (op == 'export') {//导出 DN.exportData(ctlobj, opts); } else if (op == 'import') { //导入 } else if (op == 'search') { //导入 if(ctlobj) { ctlobj.search(); } } else if (op == 'submit') {//提交 if (ctlobj == null) { DN.postback(1); } else { ctlobj.save(opts); } } else { ctlobj.operateRows(title, op,opts); } }, printDesign: function (ctlobj) { if (!DNPrint) { $.ShowMsg(DN.Language.NotFindPrint); return; } if (!ctlobj) return; var pm = $("#" + ctlobj).attr("printmode"); //1page 2control if (pm == '2')//control { var printName = $("#cmb_DN_Print_Input").val(); if (printName != '无格式') { DNPrint.Design({reportfile:printName}); return; } } $.ShowMsg(DN.Language.NotFindPrintFile); //页面模式暂不能由客户设计 } , printView: function (ctlobj, opts) { var printName = $("#cmb_DN_Print_Input").val(); if (ctlobj) { var pm = $("#" + ctlobj).attr("printmode"); //1page 2control if (pm == '2' && printName != '无格式')//control { if (!DNPrint) { $.ShowMsg(DN.Language.NotFindPrint); return; } var ctl = opts && opts.ctl ? opts.ctl : null; DNPrint.PrintView({ reportfile: printName, ctl: ctl,opstr:DN.Language.PrintView }); return; } } //获取打印设计编码 $.ShowProcess(DN.Language.PreparePrintDoc); DN.ajaxMethod({ method: 'getprintinfo', showmsg: false, success: function (data) { //获取页面查询条件字符串 var pageurl = ''; if (!printName || printName == '' || printName == '无格式') { pageurl = window.location.pathname + data; } else { pageurl = printName + data; } $.ShowDlg('/' + DN.TopWindow.managerdir + '/common/printview.aspx?src=' + pageurl, { title: DN.Language.PrintView, btnbar: false, width: 900 }); setTimeout(function () { $.CloseProcess(); }, 300); return false; } }); }, print: function (ctlobj, opts) { var printName = $("#cmb_DN_Print_Input").val(); if (ctlobj) { var pm = $("#" + ctlobj).attr("printmode"); //1page 2control if (pm == '2' && printName != '无格式')//control { if (!DNPrint) { $.ShowMsg(DN.Language.NotFindPrint); return; } var ctl = opts && opts.ctl ? opts.ctl : null; DNPrint.Print({ reportfile: printName,ctl:ctl,opstr:DN.Language.Print }); return; } } if (!printName || printName == '' || printName == '无格式') { window.print(); } else { //获取打印设计编码 $.ShowProcess(DN.Language.PreparePrintDoc); DN.ajaxMethod({ method: 'getprintinfo', showmsg: false, success: function (data) {//获取页面查询条件字符串 printName = printName + data; $.PrintPage({ url: printName }); return false; } }); } }, printCmbSelected:function(newvalue,newtext,printctlid) { var pm = $("#" + printctlid).attr("printmode"); if (typeof (page_printCmbSelected) == 'functin') { var ret = page_printCmbSelected(newvalue, newtext, printctlid); if(ret==false) { return; } } if(pm=='2') { if(DNPrint) { DNPrint.reLoadPrintObj(); } } } ,exportData: function (gridobj, opt) { var g = gridobj; if (!opt) { opt = {}; } if (typeof (page_exportData) == 'function') { var rets = page_exportData(gridobj, opt); if (rets == false) { return; } } if (!opt.ids) { if (g.options.usePager) { $.ShowConfirm(DN.Language.ExportPageOrAllData, function () { opt.extParamValue = 'all'; DN._exportdata(g, opt); }, true, DN.Language.All, DN.Language.ThisPage, function () { opt.extParamValue = 'pageindex'; DN._exportdata(g, opt); }); return; } else { opt.extParamValue = 'all'; } } else { opt.extParamValue = opt.ids; } DN._exportdata(g, opt); }, _exportdata: function (gridobj, opt) { $.ShowProcess(DN.Language.Operating.replace('{0}',DN.Language.Export)); opt.retType = 'text'; opt.success = function (ret) { if (ret != null && ret != '') { DN.downFile(ret, gridobj.id); } }; var ret = gridobj.exportData(opt); }, downFile: function (fileurl,ctlid) { $.CloseMsg(); if (typeof (page_downfile) == 'function') { var ret = page_downfile(fileurl, ctlid); if (ret == false) { return; } } var downdlg = $.ShowDlg('/' + DN.TopWindow.managerdir + '/common/filehandle.aspx?filepath=' + escape(fileurl) + "&s=" + new Date().getTime(), { width: 300, height: 130, title: DN.Language.FileDown, loadingText: DN.Language.Operating.replace('{0}',DN.Language.Down), btnbar: false, maxbtn: false, resize: true}); setTimeout(function () { try { var el = $("#divmsg", downdlg.dgDoc); if (el.html() == null || el.html() == '') { downdlg.hide(); downdlg = null; } } catch (e) { //alert(e.description); if (downdlg) { downdlg.hide(); downdlg = null; } } }, 3000); }, uploadFile: function (opt) { DN._optSelectUpload = null; DN._optAfterUpload = null; if (typeof (page_setUploadOption) == 'function') { if(!opt) { opt = { }; } opt = page_setUploadOption(opt); if (opt && opt.ret == false) return; } var qs = ''; if (opt) { if (opt.uploadfolder) { qs = 'uploadfolder=' + opt.uploadfolder; } if (opt.allowext) { if (qs != '') { qs = qs + '&'; } qs = qs + 'allowext=' + opt.allowext;//*.rar;*.pdf;*.jpg } if (opt.onlyext) { if (qs != '') { qs = qs + '&'; } qs = qs + 'onlyext=' + opt.onlyext; } if (opt.onlyone == '1') { if (qs != '') { qs = qs + '&'; } qs = qs + 'onlyone=' + opt.onlyone; } if (opt.multi) { if (qs != '') { qs = qs + '&'; } qs = qs + 'multi=' + opt.multi; } if (opt.cover) { //覆盖原文件 if (qs != '') { qs = qs + '&'; } qs = qs + 'cover=' + opt.cover; } if (opt.filename) {//指定文件名 if (qs != '') { qs = qs + '&'; } qs = qs + 'filename=' + opt.filename; } if(opt.ctlid) { if(qs!='') { qs = qs + '&'; } qs = qs + 'ctlid=' + opt.ctlid; } if (typeof (opt.autoupload) != 'undefined') { if(qs!='') { qs = qs + '&'; } qs = qs + 'autoupload=' + opt.autoupload; } if (opt.slt == '1') { if(qs!='') { qs = qs + '&'; } qs = qs + 'slt=1'; } if (opt.slth) { if (qs != '') { qs = qs + '&'; } qs = qs + 'slth=' + opt.slth; } if (opt.sltw) { if (qs != '') { qs = qs + '&'; } qs = qs + 'sltw=' + opt.sltw; } if (opt.mode) { if(qs!='') { qs = qs + '&'; } qs = qs + 'mode=' + opt.mode; } if(opt.gridcolumn) { if (qs != '') { qs = qs + '&'; } qs = qs + 'gridcolumn=' + opt.gridcolumn; } if(opt.gridrowindex) { if (qs != '') { qs = qs + '&'; } qs = qs + 'gridrowindex=' + opt.gridrowindex; } if (typeof (opt.upmode)=='undefined') { opt.upmode = 'config'; } if (opt.upmode=='') { opt.upmode = 'local'; } if(qs!='') { qs = qs + '&'; } qs = qs + 'upmode=' + opt.upmode; if (typeof (opt.selectUpload) == 'function') { DN._optSelectUpload = opt.selectUpload; } if (typeof (opt.afterUpload) == 'function') { DN._optAfterUpload = opt.afterUpload; } } var url = '/' + DN.TopWindow.managerdir + '/common/Upload.aspx'; if (opt && opt.url) { url = opt.url; } if (qs != '') { url = url + '?' + qs; } if (typeof (page_beforeUpload) == 'function') { var ret = page_beforeUpload(url, opt); if (ret == false) return; } var updlg = $.ShowDlg(url, { title: DN.Language.FileUpLoad, width: 470, height: 330, maxbtn: false, btnbar: true }); }, getUploadParam: function (swfuploadify, name) { if (!swfuploadify) return ''; return swfuploadify.settings[name]; }, setUploadParam: function (swfuploadify, name, value) { if (!swfuploadify) return; var settings = swfuploadify.settings; switch (name) { case 'uploader': swfuploadify.setUploadURL(value); break; case 'formData': value = $.extend(settings.formData, value); if (typeof (swfuploadify.setPostParams) == 'function') { swfuploadify.setPostParams(settings.formData); } else { swfuploadify.settings[name] = value; } break; case 'method': if (value == 'get') { swfuploadify.setUseQueryString(true); } else { swfuploadify.setUseQueryString(false); } break; case 'fileObjName': swfuploadify.setFilePostName(value); break; case 'fileTypeExts': swfuploadify.setFileTypes(value, settings.fileTypeDesc); break; case 'fileTypeDesc': swfuploadify.setFileTypes(settings.fileTypeExts, value); break; case 'fileSizeLimit': swfuploadify.setFileSizeLimit(value); break; case 'uploadLimit': swfuploadify.setFileUploadLimit(value); break; case 'queueSizeLimit': swfuploadify.setFileQueueLimit(value); break; case 'multi': if (value) { swfuploadify.setButtonAction(-110); } else { swfuploadify.setButtonAction(-100); } break; } swfuploadify.settings[name] = value; }, uploadSelect: function (dg, fileObj, queueId, gridcolumnname, gridrowindex, ctlid, swfuploadify) { if (typeof (DN._optSelectUpload) == 'function') { var ret; try { ret = DN._optSelectUpload(dg, fileObj, queueId, gridcolumnname, gridrowindex, ctlid, swfuploadify); } catch(e) { alert(e.description); } DN._optSelectUpload = null; return ret; } if(typeof(page_selectUpload)=='function') { return page_selectUpload(dg, fileObj, queueId, gridcolumnname, gridrowindex,ctlid, swfuploadify); } } , uploadComplete: function (dg, files, ctlid, autoupload, orgfiles, gridcolumnname, gridrowindex, fileobjs) { if (files && files.length > 0) { if (ctlid) { var syncstate = '1'; try { syncstate = $("#" + ctlid).attr('syncstate'); } catch (e) { } if (syncstate != '0') { DN.setFormState('modify', ctlid); } } else { DN.setFormState('modify', ctlid); } } if (gridcolumnname && gridrowindex && gridcolumnname != '' && gridrowindex != '') { var grdobj = DN.getGridObj(ctlid); if (grdobj) { if (typeof (page_afterUpload) == 'function') { var ret = page_afterUpload(files, ctlid, autoupload, dg, orgfiles, gridcolumnname, gridrowindex, fileobjs); if(ret==false) { if (autoupload != true) { setTimeout(function () { try { dg.cancel(); } catch (e) { } }, 200); } return; } } grdobj.updateFileCell(files, gridcolumnname, gridrowindex); var grow = grdobj.getRow(gridrowindex); grdobj.trigger('afterEdit', { record: grow, value: files, column: { name: gridcolumnname }, rowindex: gridrowindex }); if (autoupload != true) { $.ShowMsg(DN.Language.FileUploadSuccess, function() { $.CloseMsg(); setTimeout(function() { dg.cancel(); }, 100); }); } return; } } var pageuploadmethod = null; if (typeof (DN._optAfterUpload) == 'function') { pageuploadmethod = DN._optAfterUpload; } else if (typeof (page_upload) == 'function') { pageuploadmethod = page_upload; } else if (typeof (page_ajaxuploadfile) == 'function') { pageuploadmethod = page_ajaxuploadfile; } else if (typeof (page_afterUpload) == 'function') { pageuploadmethod = page_afterUpload; } else if (typeof (page_afterUploadFile) == 'function') { pageuploadmethod = page_afterUploadFile; } if (pageuploadmethod) { var rets; try { rets = pageuploadmethod(files, ctlid, autoupload, dg, orgfiles, gridcolumnname, gridrowindex, fileobjs); } catch(e) { alert(e.description); } DN._optAfterUpload = null; if (rets == false) { if (autoupload != true) { setTimeout(function() { try { dg.cancel(); } catch(e) { } }, 200); } return; } } $.ShowMsg(DN.Language.FileUploadSuccess, function() { $.CloseMsg(); setTimeout(function() { dg.cancel(); }, 100); }); }, _pageupload: function (files, ctlid, autoupload, dg, orgfiles, gridcolumnname, gridrowindex, fileobjs) { if (typeof (page_ajaxuploadfile) == 'function') { var ret = page_ajaxuploadfile(files, ctlid, autoupload, dg, orgfiles, gridcolumnname, gridrowindex, fileobjs); if (ret == false) return false; } else if (typeof (page_afterUpload) == 'function') { var ret = page_afterUpload(files, ctlid, autoupload, dg, orgfiles, gridcolumnname, gridrowindex, fileobjs); if (ret == false) return false; } else if (typeof (page_afterUploadFile) == 'function') { var ret = page_afterUploadFile(files, ctlid, autoupload, dg, orgfiles, gridcolumnname, gridrowindex, fileobjs); if (ret == false) return false; } DN.setUploadFile(files, ctlid, orgfiles); if (typeof (page_afterajaxuploadfile) == 'function') { var ret = page_afterajaxuploadfile(files, ctlid, autoupload, dg, orgfiles, gridcolumnname, gridrowindex, fileobjs); if (ret == false) return false; } else if (typeof (page_uploadComplete) == 'function') { var ret = page_uploadComplete(files, ctlid, autoupload, dg, orgfiles, gridcolumnname, gridrowindex, fileobjs); if (ret == false) return false; } if (autoupload == true) return false; else return true; }, setUploadFile:function(files,ctlid,orgfiles) { if (files.length > 0) { var file = $("#" + ctlid + "_Input").val(); var j = file.split(',').length; if (file == '') j = 0; var showfile = $("#" + ctlid).attr("showfile"); var rptcol = $("#" + ctlid).attr("rptcol"); var downfile = $("#" + ctlid).attr("downfile"); rptcol = parseInt(rptcol); if (isNaN(rptcol)) rptcol = 0; var onlyone = $("#" + ctlid).attr("onlyone"); var fileiisurl = DN.FileIISURL; var upmode = $("#" + ctlid).attr("upmode"); if (upmode == '') { fileiisurl = ''; } if (onlyone == '1') { file = ''; j = 0; var relctlid = $("#" + ctlid).attr("relationctlid"); if (relctlid) { $("#" + relctlid).html(''); } $("div[upfilediv='" + ctlid + "']").remove(); } var isdis = $("#" + ctlid).attr("isdis"); for (var i = 0; i < files.length; i++) { if (file != '') { file += ','; } file += files[i]; var fs = files[i].split('/'); var html = '
'; html += ''; if (downfile == '1') { html += '' + fs[fs.length - 1] + ''; } else { html += '' + fs[fs.length - 1] + ''; } if (isdis == '1') { html += ''; html += ''; html += ''; } html += ''; html += '
'; if (isdis == '1') { $("#" + ctlid + "addfile").before(html); } else { $("#" + ctlid).append(html); } if (rptcol > 0) { if ((j+1) % rptcol == 0) { if (isdis == '1') { $("#" + ctlid + "addfile").before('
'); } else { $("#" + ctlid).append('
'); } } } DN._setUploadFileRelationCtl(ctlid, files[i], fs[fs.length - 1], j); j = j + 1; } $("#" + ctlid + "_Input").val(file); } }, _iniUploadFileRelationCtl:function(ctlid,files) { if (files && files.length > 0) { var fs = files.split(','); for (var i = 0; i < fs.length; i++) { if (fs[i] != '') { var fn = fs[i].split('/'); DN._setUploadFileRelationCtl(ctlid, fs[i], fn[fn.length - 1], (i)); } } } }, _setUploadFileRelationCtl:function(ctlid,filepath,filename,index) { var rel = $("#" + ctlid).attr("relationctlid"); if (rel) { var fileiisurl = DN.FileIISURL; var upmode = $("#" + ctlid).attr("upmode"); if(upmode=='') { fileiisurl = ''; } var relctl = $("#" + rel); if (relctl[0].tagName.toLowerCase() == 'img') { relctl.attr("src", fileiisurl + filepath); } else { var onlyone = $("#" + ctlid).attr("onlyone"); if (onlyone == '1') { relctl.html(''); } var isdlgpre = $("#" + ctlid).attr("isdlgpre"); var w = relctl.attr('imgwidth'); if (!w) { w = 90; } var h = relctl.attr('imgheight'); if (!h) { h = 100; } var filehtml = '
'; filehtml += '
'; var showfile = $("#" + ctlid).attr("showfile"); var isdis = $("#" + ctlid).attr("isdis"); if (showfile=='0' && isdis=='1') { filehtml += ''; filehtml += ''; filehtml += ''; } if (isdlgpre !='1') { filehtml += ''; } filehtml += ''; if (isdlgpre != '1') { filehtml += ''; } filehtml += '
'; if (showfile != '0') { filehtml += '
' + filename + '
'; } filehtml += '
'; if (isdlgpre == '1') { $("#" + ctlid + "file" + index + "_viewdiv_img").die().live('click', function() { $.ShowDlg(this.src, { title: DN.Language.PrintView + "-" + filename }); }); } relctl.append(filehtml); } } }, removeFileElement: function (id, filename, ctlid) { if (typeof (page_beforeajaxremovefile) == 'function') { var ret = page_beforeajaxremovefile(id, filename, ctlid); if (ret == false) return ; } $("#" + id).remove(); var v = $("#" + ctlid + "_Input").val(); var vs = v.split(','); v = ''; var fs = []; for (var k = 0;k < vs.length;k++) { if (vs[k] != filename) { if (v != '') v += ','; v += vs[k]; fs.push(vs[k]); } } $("#" + ctlid + "_Input").val(v); var rptcol = $("#" + ctlid).attr("rptcol"); rptcol = parseInt(rptcol); if (isNaN(rptcol)) rptcol = 0; if (rptcol > 0) { $("#" + ctlid + "_Input").val(''); $("div[upfilediv='" + ctlid + "']").remove(); var relctlid = $("#" + ctlid).attr("relationctlid"); if (relctlid) { $("#" + relctlid).html(''); } DN.setUploadFile(fs, ctlid); } else { var rel = $("#" + ctlid).attr("relationctlid"); if (rel) { var relctl = $("#" + rel); if (relctl[0].tagName.toLowerCase() == 'img') { var imgsrc = relctl.attr("src"); if (imgsrc.indexOf(filename) >= 0) { relctl.attr("src", ''); } } else { var viewdiv = $("#" + id + "_viewdiv"); if (viewdiv) { viewdiv.remove(); } } } } if (typeof (page_afterajaxremovefile) == 'function') { page_afterajaxremovefile(id, filename, ctlid); } }, addSelectEle: function (rows, ctlid, opt) { if (!rows || rows.length <= 0) { return; } if (!opt) { opt = { }; } if (!opt.textField || !opt.valueField) { return; } var isdis = $("#" + ctlid+'div').attr('isdis'); var rptcol = $("#" + ctlid + "div").attr('rptcol'); rptcol = parseInt(rptcol); if (isNaN(rptcol)) rptcol = 0; var ic = $("#" + ctlid + "div").attr('itemclick'); if (opt.isClear == true) { $('#' + ctlid+'div').html(''); $('#' + ctlid + '_Input').val(''); $('#' + ctlid + '_Input_Text').val(''); } var hval = $('#' + ctlid + '_Input').val(); var k = hval.split(',').length; if (hval == '') k = 0; if (opt.isClear == true) { k = 0; } if (k < 0) k = 0; var rem = $("#" + ctlid + "div").attr('remele'); for (var i = 0; i < rows.length; i++) { var valid = rows[i][opt.valueField]; if (valid) { valid = valid.toString(); } /*if ($('#' + ctlid + 'div').children('#' + ctlid + '_' + rows[i][opt.valueField]).length > 0) { continue; }*/ var find = false; $('#' + ctlid + 'div').children().each(function () { if ($(this).attr('id') == ctlid + '_' + valid) { find = true; return false; } }); if (find) { continue; } if (rem != '1' && typeof (page_beforeaddselectele) == 'function') { var ret = page_beforeaddselectele(ctlid, rows[i]); if (ret == false) { continue; } } var html = '
'; if (ic) { html += (""); } html += rows[i][opt.textField]; if (ic) { html += (""); } if (isdis == '1') { html += ''; } html+='
'; if (opt.html) { html = opt.html.replace(/rowvalue/g, rows[i][opt.valueField]); html = html.replace(/rowtext/g, rows[i][opt.textField]); html = html.replace(/rowremoveid/g, ctlid + '_' + rows[i][opt.valueField]); } var tag = $(html); if (isdis == '1') { var taga = tag.find("a"); taga.bind("click", function() { var p = $(this).attr('pid'); var pval = $(this).attr('pval'); DN.removeSelectEle(p, ctlid, pval,opt); }); } var val = $('#' + ctlid + '_Input').val(); $("#" + ctlid + 'div').append(tag); if (rptcol > 0) { if ((k+1) % rptcol == 0) { $("#" + ctlid + 'div').append('
'); } } if (val != '') { val += ','; } val += rows[i][opt.valueField]; $('#' + ctlid + '_Input').val(val); var txt = $('#' + ctlid + '_Input_Text').val(); if (txt != '') { txt += ','; } txt += rows[i][opt.textField]; $('#' + ctlid + '_Input_Text').val(txt); k = k + 1; if (rem != '1' && typeof (page_afteraddselectele) == 'function') { page_afteraddselectele(ctlid, rows[i]); } } if (window.DNValidate) DNValidate.hidePrompt($("#" + ctlid + "_Input")); } , removeSelectEle: function (id, ctlid,ctlval,opt) { if (typeof(page_beforeremoveselectele) == 'function') { var ret = page_beforeremoveselectele(id, ctlid,ctlval); if (ret == false) return; } var ele = document.getElementById(id); ele = $(ele); ele.remove(); var val = $('#' + ctlid + '_Input').val(); var txt = $('#' + ctlid + '_Input_Text').val(); var txts = txt.split(','); var vals = val.split(','); val = ''; txt = ''; var rows = []; for (var i = 0; i < vals.length; i++) { if (vals[i] != ctlval) { var r = { }; if (val != '') { val += ','; } val += vals[i]; r[opt.valueField] = vals[i]; if(txt!='') { txt += ','; } txt += txts[i]; r[opt.textField] = txts[i]; rows.push(r); } } $('#' + ctlid + '_Input').val(val); $('#' + ctlid + '_Input_Text').val(txt); var rptcol = $("#" + ctlid + "div").attr('rptcol'); rptcol = parseInt(rptcol); if (isNaN(rptcol)) rptcol = 0; if (rptcol > 0) { $('#' + ctlid + 'div').html(''); $('#' + ctlid + '_Input').val(''); $('#' + ctlid + '_Input_Text').val(''); $("#" + ctlid + "div").attr('remele', '1'); DN.addSelectEle(rows, ctlid, opt); $("#" + ctlid + "div").attr('remele', '0'); } if (typeof(page_afterremoveselectele) == 'function') { page_afterremoveselectele(id, ctlid,ctlval); } } , getTheme: function (cssid, defaultpath) { var uiroot = '/Theme/'; if (window.document.getElementById(cssid) == undefined) { var ret = DN.getThemeName(defaultpath, { uiThemeRoot: uiroot }); if (ret) { return uiThemeRoot + 'skins/' + ret; } return ''; } return ''; } ,curTheme:'' , getThemeName: function (defaultpath, pajson) { if (DN.curTheme != '') return DN.curTheme; var getPosition = function (b, c) { for (var a = 0; a < c.length; a++) { if (b == c[a]) { return a; } } }; var q = defaultpath; var linkskin = DN.TopWindow.document.getElementById("skin"); if (linkskin) { var skinattr = $(linkskin).attr("href"); if (skinattr != null && skinattr != "") { q = skinattr; } if(!pajson) { pajson = { }; } pajson.uiThemeRoot = $(linkskin).attr('themeRoot'); if (!pajson.uiThemeRoot) pajson.uiThemeRoot = '/Theme/'; } if (!q) return 'blue'; var i = q.split("/"); var f = getPosition("skins", i) + 1; var uiSkin = 'blue'; if (f) { uiSkin = i[f]; } return uiSkin; } , EmptyGuid: '00000000-0000-0000-0000-000000000000' ,Manager:{ managers: [], add: function (manager) { if (!manager.id) { return; } if (DN.Manager.managers[manager.id]) throw new Error('管理器id:[' + manager.id + ']已经存在'); DN.Manager.managers[manager.id] = manager; }, remove: function (arg) { if (typeof arg == "string" || typeof arg == "number") { delete DN.Manager.managers[arg]; } else if (typeof arg == "object" && arg instanceof $.ligerui.core.Component) { delete DN.Manager.managers[arg.id]; } }, get: function (arg) { if (typeof arg == "string" || typeof arg == "number") { return DN.Manager.managers[arg]; } else if (typeof arg == "object" && arg.length) { return DN.Manager.managers[arg.id]; } return null; } } , adjustGroupSize: function (fieldset) { var height = fieldset.css("height"); var ph = height; if (fieldset.attr("autoheight") == 'true') { ph = $(window).height(); var adh = 0; adh = parseInt(fieldset.attr("adjustheight")); if (isNaN(adh)) adh = 0; var offtop = fieldset.offset().top; ph = ph - offtop; ph = ph - 5 + adh; ph = ph + 'px'; } if (!ph) { ph = "auto"; } fieldset.css("height", ph);//.css('overflow', 'auto'); } , loadCalendarData: function (start, end, callback, ctlid) { var startd = DN.getDateFormat(start, 'yyyy-MM-dd HH:mm'); var endd = DN.getDateFormat(end, 'yyyy-MM-dd HH:mm'); var opt = { action: ctlid + 'GetCalendarData', params: { startdate: startd, enddate: endd }, msg: DN.Language.Loading, cache: false, success: function(data) { callback(data); $.CloseMsg(); return false; } }; DN.setGridData({ validateForm: false }); DN.ajaxSubmitForm(opt); },getEventKeyCode:function(event) { var evt = event || window.event; return evt ? (evt.keyCode || evt.which) : -1; } ,reloadPage:function(url) { if(!url) { url = window.location.href; } var fix = '?'; if (url.indexOf('?') >= 0) fix = '&'; url = url + fix + 'dnrand=' + new Date().getTime(); window.location.href = url; } //控件回车键后执行查询 ,controlSearch:function(obj,jscontrol,event) { var evt = event || window.event; var k = evt ? (evt.keyCode || evt.which) : -1; //回车键,复选框是click触发的,下拉框是onselected if (k == 13 || obj.type.toLowerCase() == 'checkbox' || (typeof (obj.__getType) == "function" && obj.__getType() == "ComboBox")|| ($(obj).attr('libctl')=='libdate') ) { if (jscontrol) { if (typeof(jscontrol) == 'function') { jscontrol(obj); } else if (typeof (jscontrol) == 'object' && typeof (jscontrol.search) == 'function') { if (typeof (obj.__getType) == "function" && obj.__getType() == "ComboBox") { if(!obj.allowTrigger) { if (typeof(obj.inited) != 'undefined') { if (obj.inited == false || obj.selectItem == true || obj.gridselectrow == true) return; } } obj._toggleSelectBox(true); } jscontrol.search(true); } } } } , setFocus: function (obj) { setTimeout(function () { obj.focus(); }, 50); }, randomNum: function (min, max) { if (min && max) { return parseInt(Math.random() * (max - min + 1) + min, 10); } if(min) { return parseInt(Math.random() * min + 1, 10); } return 1; }, //日期相关 //获取日期格式 getDateFormat: function (date, format) { if (date == "NaN") return ''; var value = date; if (typeof(value) == "string") { if (value.indexOf("/Date(") >= 0) { //value = value.replace("/Date(", "").replace(")/", ""); //date = new Date(parseInt(value, 10)); value = value.replace(/^\//, "new ").replace(/\/$/, ""); eval("value = " + value); return (DN.getDateFormat(value, format)); } else { value = value.replace('.', '-').replace('.', '-'); value = value.replace(/-/g, '/'); date = new Date(value); return (DN.getDateFormat(date, format)); } } if (!format) format = 'yyyy-MM-dd'; var o = { "M+": date.getMonth() + 1, "d+": date.getDate(), "H+": date.getHours(), "m+": date.getMinutes(), "s+": date.getSeconds(), "q+": Math.floor((date.getMonth() + 3) / 3), "S": date.getMilliseconds() } if (/(y+)/.test(format)) { format = format.replace(RegExp.$1, (date.getFullYear() + "") .substr(4 - RegExp.$1.length)); } for (var k in o) { if (new RegExp("(" + k + ")").test(format)) { format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)); } } return format; } //一年中的第几周 ,getWeekOfYear:function(curdate,firstweek) { var totalDays = 0; if (!curdate) curdate = new Date(); var years = curdate.getYear(); if (years < 1900) years = 1900 var days = new Array(12); days[0] = 31; days[2] = 31; days[3] = 30; days[4] = 31; days[5] = 30; days[6] = 31; days[7] = 31; days[8] = 30; days[9] = 31; days[10] = 30; days[11] = 31; //判断是否为闰年,针对2月的天数进行计算 if (DN.isLeapYear(years)) { days[1] = 29; } else { days[1] = 28; } var mv = new Date(years, 0, 1).getDay();//星期几 0-6 if(firstweek) { firstweek = parseInt(firstweek); if (!isNaN(firstweek) && firstweek != 0) { if(mv==firstweek) { mv = 0; firstweek = 0; } if (firstweek > mv) { mv = (7 - (firstweek - mv)); } else if (firstweek < mv) { mv = (mv - firstweek); } if (mv < 0) mv = 0; } } if (curdate.getMonth() == 0) { totalDays = totalDays + curdate.getDate();//一月中的第几天 } else { var curMonth = curdate.getMonth(); for (var count = 1; count <= curMonth; count++) { totalDays = totalDays + days[count - 1]; } totalDays = totalDays + curdate.getDate(); } totalDays = totalDays + mv; //得到第几周 var week = Math.ceil(totalDays / 7); return week; } //闰年 ,isLeapYear:function(year) { if (!isNaN(parseInt(year))) { if ((year % 4 == 0 && year % 100 != 0) || (year % 100 == 0 && year % 400 == 0)) { return true; } else { return false; } } else { return false; } } //时间补位 0 , fillZero: function (s) { s = parseFloat(s.toString().replace(/(^[\s0]+)|(\s+$)/g, '')); s = isNaN(s) ? 0 : s; return (s < 10 ? '0' : '') + s.toString(); } //周日期范围 , getWeekDateRange: function (curd) { if (!curd) curd = new Date(); var y = curd.getFullYear(); var m = curd.getMonth(); var d = curd.getDate(); var wd = curd.getDay(); if (wd != 0) { curd.setDate(d - wd); y = curd.getFullYear(); m = curd.getMonth(); d = curd.getDate(); } var st = y + '-' + DN.fillZero(m + 1) + '-' + DN.fillZero(d); curd.setDate(d + 6); y = curd.getFullYear(); m = curd.getMonth(); d = curd.getDate(); var se = y + '-' + DN.fillZero(m + 1) + '-' + DN.fillZero(d); return st + ' ~ ' + se; } , getCurrentDate: function (addtime,curd) { if (!curd) curd = new Date(); return curd.getFullYear() + "-" + DN.fillZero(curd.getMonth() + 1) + "-" + DN.fillZero(curd.getDate()) + (addtime ? ' ' + DN.fillZero(curd.getHours()) + ':' + DN.fillZero(curd.getMinutes()) : ''); } , getCurrentMonth: function (curd) { if (!curd) curd = new Date(); return curd.getFullYear() + "-" + DN.fillZero(curd.getMonth() + 1); } , getCurrentYear: function (curd) { if (!curd) curd = new Date(); return curd.getFullYear(); } , compareDate: function (start, end, comparetime) { if (start == 'now') start = new Date(); if (end == 'now') end = new Date(); var s = new Date(Date.parse(start.toString().replace(/-/g, "/"))); var e = new Date(Date.parse(end.toString().replace(/-/g, "/"))); if (!comparetime) { s.setHours(0, 0, 0, 0); e.setHours(0, 0, 0, 0); } if (s.toString()== e.toString()) return 0; return s < e ? 1 : -1; } , getScrollOffset: function (obj) { obj = $(obj); if (obj.length == 0) return { top: 0, left: 0 }; var x = 0; var y = 0; var sl = 0; var st = 0; var tmp = $(obj)[0]; while (tmp = tmp.offsetParent) { var objst = tmp.scrollTop; if (objst > 0) { y = y + objst; } var objsl = tmp.scrollLeft; if (objsl > 0) { x = x + objsl; } if (tmp.tagName.toLowerCase() == 'body') { break; } } x = x + sl; y = y + st; return { top: y, left: x }; } , getOffSet: function (obj, isabsolute) { obj = $(obj); if (obj.length == 0) return { top: 0, left: 0 }; var x = 0; var y = 0; var sl = 0; var st = 0; if (isabsolute) { var tmp = $(obj)[0]; x = tmp.offsetLeft; y = tmp.offsetTop; while (tmp = tmp.offsetParent) { //获取相对于最近的父级(position:relative)的位置 x += tmp.offsetLeft; y += tmp.offsetTop; if (tmp.tagName.toLowerCase() != 'body') { var objst = tmp.scrollTop; if(objst>0) { y = y - objst; } var objsl = tmp.scrollLeft; if(objsl>0) { x = x - objsl; } objsl = tmp.clientLeft; if(objsl>0) { x = x + objsl; } objst = tmp.clientTop; if(objst>0) { y = y + objst; } } } //st = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop || 0; //sl = document.documentElement.scrollLeft || window.pageXOffset || document.body.scrollLeft || 0; } else { var oRect = obj.position();//获取相对于最近的父级(position:relative)的位置 x = oRect.left; y = oRect.top; } x = x + sl; y = y + st; return { top: y, left: x }; } , getScrollOffSet: function () { var scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop || 0; var sl = document.documentElement.scrollLeft ||window.pageXOffset || document.body.scrollLeft || 0; return { top: scrollTop, left: sl }; } , addWaterRemark: function (txtid, waterstr, css) { if (!waterstr) return; if (!css) css = 'waterremark'; var txt = $("#" + txtid); txt.focus(function() { txt.removeClass(css) if (txt.val() == waterstr) { txt.val(''); } }).blur(function() { if (txt.val() == '') { txt.addClass(css).val(waterstr); } else if (txt.val() != waterstr) { txt.removeClass(css); } }); txt.blur(); } , TopWindow: window ,top:window //选择对话框 , showSelectDlg: function (opt) { if(typeof(page_showSelectDlg)=='function') { var ret = page_showSelectDlg(opt); if (ret == false) return; } if (!opt) opt = {}; if (!opt.selectPageTitle) opt.selectPageTitle = DN.Language.PageSelectTitle; if (!opt.url) { opt.url = '/' + DN.TopWindow.managerdir + '/Common/ViewSelect.aspx'; } var cmbselpageurl = opt.url; { var fix = '?'; if (cmbselpageurl.indexOf('?') >= 0) fix = '&'; cmbselpageurl += fix+'vn=' + escape(opt.dataSource); /* if (opt.isMore == true || opt.isMore == 1) { cmbselpageurl += '&grd=' + opt.ctlid; } else { cmbselpageurl += '&cmb=' + opt.ctlid; }*/ //if (opt.isselect == 1 || opt.isselect == true) { cmbselpageurl += '&isselect=1'; //} cmbselpageurl += "&ctlid=" + opt.ctlid; if (opt.treeDataSource) { cmbselpageurl += '&treevn=' + escape(opt.treeDataSource); } if (opt.treeWhere) { cmbselpageurl += '&treewhere=' + escape(opt.treeWhere); } var whereCtl = opt.whereCtl; var wt = ''; if (whereCtl && whereCtl != "") { var wctl = whereCtl; var relCols = wctl.split('|'); for (var i = 0; i < relCols.length; i++) { var relCol = relCols[i].split('#'); if (relCol.length == 2) { var ctlid = relCol[1]; var ctlv = $("#" + ctlid).val(); if (typeof (ctlv) == 'undefined' || ctlv == null) ctlv = ''; wctl = wctl.replace('#' + ctlid, ctlv.toString().toUpperCase()); } } wt = wt + '|' + encodeURIComponent(wctl); } if (opt.where) { wt = wt + '|' + encodeURIComponent(opt.where); } if (wt != '') { cmbselpageurl += '&where=' + wt; } if (opt.textField) { cmbselpageurl += '&dm=' + escape(opt.textField); } if (opt.valueField) { cmbselpageurl += '&vm=' + escape(opt.valueField); } if (opt.treeCodeField) { cmbselpageurl += '&code=' + escape(opt.treeCodeField); } if (opt.treeParentIdField) { cmbselpageurl += '&parent=' + escape(opt.treeParentIdField); } if (opt.treeTextField) { cmbselpageurl += '&name=' + escape(opt.treeTextField); } if (opt.treeIdField) { cmbselpageurl += '&value=' + escape(opt.treeIdField); } if (opt.sortStr) { cmbselpageurl += '&sortstr=' + escape(opt.sortStr); } if (opt.defselfn) { cmbselpageurl += '&defselfn=' + escape(opt.defselfn); } if (opt.design) { cmbselpageurl += '&design=' + escape(opt.design); } if (opt.gridChild && opt.gridpk) { cmbselpageurl += '&gridchild=' + escape(opt.gridChild); cmbselpageurl += '&gridpk=' + escape(opt.gridpk); } if (opt.treeChild) { cmbselpageurl += '&treechild=' + escape(opt.treeChild); } if (opt.treepk) { cmbselpageurl += '&treepk=' + escape(opt.treepk); } //1 All,2 Child,3 Parent,4 ChildSelf,5 ParentSelf,6 ExcludeSelfChild,7 ExcludeChild if (opt.treeSelMode) { cmbselpageurl += '&treeselmode=' + (opt.treeSelMode); } if (opt.comp) { cmbselpageurl += '&comp=' + escape(opt.comp); } if (opt.treesp == '1') { cmbselpageurl += '&treesp=1'; } if (opt.gridsp == '1') { cmbselpageurl += '&grdsp=1'; } if (typeof (opt.treeSelModeVal) != 'undefined') { var smv = opt.treeSelModeVal; if (smv.indexOf('#') >= 0) { smv = $(smv).val(); } cmbselpageurl += '&treeselmodeval=' + escape(smv); } if (opt.searchValue) { cmbselpageurl += '&stxt=' + opt.searchValue; } if (opt.addquote=='1') { cmbselpageurl += '&addquote=1'; } if (opt.isMore) { cmbselpageurl = cmbselpageurl + '&more=' + (opt.isMore == true ? 1 : column.editor.isMore); } if (opt.treeexplev) { cmbselpageurl += '&treeexplev=' + opt.treeexplev; } } var dlg; var dgcombo = null; try { dgcombo = frameElement.dg; if (dgcombo) { if (typeof(dgcombo.__getType) != 'undefined') { dgcombo = null; } } } catch (e) { } var zindex = 10100; if (dgcombo) { zindex = dgcombo.dg.style.zIndex; } else { if (window.DNZIndex) zindex = window.DNZIndex; } if (dgcombo) { dlg = new dgcombo.curWin.$.dialog($.extend({ id: (opt.ctlid + '_' + new Date().getTime()), title: opt.selectPageTitle, page: cmbselpageurl, parent: dgcombo, zIndex: zindex + 2 }, opt.dlgopt || { })); } else { dlg = new $.dialog($.extend({ id: (opt.ctlid + '_' + new Date().getTime()), title: opt.selectPageTitle, page: cmbselpageurl, zIndex: zindex + 2 }, opt.dlgopt || { })); } dlg.ShowDialog(); return dlg; } ,showTip:function(ctlid,msg,opts) { var field = $("#" + ctlid); if(!opts) { opts = { }; } opts.validateTipWidth = opts.width; opts.distanceX = opts.left; opts.distanceY = opts.top; opts.allowClickHide = true; opts.onclick = opts.onclick; opts.absolute = typeof (opts.absolute) == 'undefined' ? true : opts.absolute; opts.addStyle = opts.addStyle ? opts.addStyle : false; DNValidate.showPrompt(field, msg, opts); } ,hideTip:function(ctlid) { DNValidate.hidePrompt($("#" + ctlid)); } , formState: 'unchanged' //modify , setFormState: function (state,ctlid) { var formid = window.document.forms[0].id; if ($("#" + formid).attr('checkformstate') == '0') return; if (ctlid) { var sf = $("#" + ctlid).attr('searchfield'); if(sf) { return; } } DN.formState = state; if (typeof (page_formStateChanged) == 'function') { if (!ctlid) ctlid = formid; page_formStateChanged(state, ctlid); } } ,setIframeZIndex:function(ifrm) { if (!ifrm) return; setTimeout(function() { var iframe = null; try { iframe = ifrm.contentWindow; } catch(e) { iframe = null; } if (iframe == null) { return; } try { if (frameElement) { var dg = frameElement.dg; if (dg) { iframe.DNZIndex = dg.dg.style.zIndex; ifrm.dg = dg; } } var dntabid = $(ifrm).attr('dntabid'); iframe.curTabID = dntabid; var dnparentid = $(ifrm).attr("dnparenttabid"); if(dnparentid && dnparentid != '0') { iframe.parentTabID = dnparentid; } } catch(e) { //alert(e.description); } }, 200); } , calIframeBodyHeight: function (obj) { if (!obj) return; var iframecon = $("#" + obj.id).contents(); if (iframecon.length == 0) return; if (iframecon[0].location.href == 'about:blank') return; var ib = iframecon.find("body"); if (ib) { ib.addClass('bodyoverflow'); var bh = ib.height(); setTimeout(function () { try { var parenth = $("#" + obj.id).parent().height(); var dh = iframecon.height(); if(parenth > 50 && dh > parenth) { dh = parenth; } var pt = parseInt(ib.css('paddingTop')); var ph = parseInt(ib.css('paddingBottom')); if (isNaN(pt)) pt = 0; if (isNaN(ph)) ph = 0; bh = bh + pt + ph; pt = parseInt(ib.css('marginTop')); ph = parseInt(ib.css('marginBottom')); if (isNaN(pt)) pt = 0; if (isNaN(ph)) ph = 0; bh = bh + pt + ph + 1; //if (dh > bh) { iframecon.find('body').height(dh - 1); //} ib.removeClass('bodyoverflow'); } catch(e){} }, 500); } } ,getFormData: function (tablename, opt) { var row = { }; if (!tablename) { tablename = ''; } if (!opt) { opt = {}; } if (!opt.conatiner) opt.conatiner = $('body'); tablename = tablename.toLowerCase(); $('[mapfield]', opt.conatiner).each(function () { var jobj = $(this); var mapf = jobj.attr('mapfield'); if (mapf && typeof(mapf) != 'undefined' && mapf != '') { var mapt = jobj.attr('maptable'); if (!mapt) { mapt = ''; } if (mapt == tablename) { var v = ''; var id = jobj.attr('id'); if (id == '') { id = mapt+'_'+mapf; jobj.attr('id', id); } v = DN.getCtlValue(id); row[mapf] = v; } } }); return row; } ,fillFormData:function(row,tablename,opt) { if (!row) return; if(!tablename) { tablename = ''; } if(!opt) { opt = { }; } if (!opt.conatiner) opt.conatiner = $('body'); tablename = tablename.toLowerCase(); $('[mapfield]', opt.conatiner).each(function () { var jobj = $(this); var mapf = jobj.attr('mapfield'); if (mapf && typeof(row[mapf]) != 'undefined') { var mapt = jobj.attr('maptable'); if (!mapt) { mapt = ''; } if (mapt == tablename) { var v = ''; if (mapf in row) v = row[mapf]; var id = jobj.attr('id'); if (id == '') { id = mapt + '_' + mapf; jobj.attr('id', id); } DN.setCtlValue(id, v); } } }); } , getCtlValue: function (id) { var jobj = $("#" + id); var libctl = jobj.attr('libctl'); if (typeof (libctl) == 'undefined') { libctl = $('[group=' + id + ']'); libctl = $(libctl).attr('libctl'); } var dis = jobj.attr('disabled') || jobj.attr('readonly'); var v = ''; switch (libctl) { case 'libtxt': v = jobj.val(); if (dis) { v = $('#' + id + '_Input').val(); } var htmldecode = jobj.attr('htmldecode'); if (htmldecode == '1') { v = DN.htmlEncode(v); } var txttype = jobj.attr('txttype'); if (txttype == 'decimal' || txttype == 'number') { var thousands = jobj.attr('thousands'); var decimals = jobj.attr('decimals'); if (!decimals) decimals = -1; if (thousands == '1') { v = DN.numberFormat(v, decimals, '.', ','); } else { v = DN.numberFormat(v, decimals, '.', ''); } } break; case "libhid": v = jobj.val(); break; case "libdate": v = jobj.val(); if (dis) { v = $('#' + id + '_Input').val(); } else { if (v && v != '') { var format = jobj.attr('format'); if (format == 'yyyy-MM-dd') { var orgval = jobj.attr('orgval'); if (orgval && orgval.length > 10) { var ov = orgval.substring(0, 10); if (v == ov) { v = orgval; } else { v = v + ' ' + DN.getDateFormat(new Date, "HH:mm:ss"); } } else { v = v + ' ' + DN.getDateFormat(new Date, "HH:mm:ss"); } } else if (format == 'yyyy-MM-dd HH:mm' || format == 'yyyy-MM-dd HH:mm:ss') { var orgval = jobj.attr('orgval'); if (orgval && orgval.length > 16) { var ov = orgval.substring(0, 16); if (v == ov) { v = orgval; } else { v = v + ':' + DN.getDateFormat(new Date, "ss"); } } else { v = v + ':' + DN.getDateFormat(new Date, "ss"); } } } } break; case 'libcheck': case 'libradio': if (jobj[0].tagName.toLowerCase() != 'input') { var val = jobj.find('input').attr('checked') == true || jobj.find('input').attr('checked') == 'checked'; v = val == true ? "1" : "0"; id = jobj.find('input').attr("id"); } else { v = (jobj.attr('checked') == true || jobj.attr('checked') == 'checked') ? "1" : "0"; } dis = $("#" + id).attr('disabled') || $("#" + id).attr('readonly'); if (dis) { v = $('#' + id + '_Input').val(); } break; case "libcmb": v = $('#' + id + '_Input').val(); break; case "libdropdown": v = jobj.find("option:selected").val(); if (dis) { v = $('#' + id + '_Input').val(); } break; case "libchecklist": var vals = ''; jobj.find('input:checkbox').each(function () { dis = $(this).attr('disabled') || $(this).attr('readonly'); if ($(this).attr('checked') == true || $(this).attr('checked') == 'checked') { if (vals != '') { vals += ','; } vals += $(this).attr('value'); } }); if (dis) { vals = $('#' + id + '_Input').val(); } break; case "libimg": v = jobj.attr('src'); break; case "liblabel": v = jobj.html(); var convert = jobj.attr('converttype'); if (convert == 'input') { v = $('#' + id + '_Input').val(); } var loadinput = jobj.attr('loadinput'); if (loadinput == '1') { v = $('#' + id + '_Input').val(); } var htmldecode = jobj.attr('htmldecode'); if (htmldecode == '1') { v = DN.htmlEncode(v); } break; case "libradiolist": var vals = ''; jobj.find('input:radio').each(function () { var inputval = $(this).attr('value'); dis = $(this).attr('disabled') || $(this).attr('readonly'); if ($(this).attr('checked') == true || $(this).attr('checked') == 'checked') { if (vals != '') { vals += ','; } vals += inputval; } }); if (dis) { vals = $('#' + id + '_Input').val(); } v = vals; break; case "libfck": break; case "libuedit": if (dis) { v = jobj.html(); } else { v = UE.getEditor(id).getContent(); } break; case "libupload": v = $('#' + id + '_Input').val(); break; case "libselect": var ctlid = id.substr(0, id.length - 3); v = $('#' + ctlid + '_Input').val(); break; } return v; } , setCtlValue: function (id, val, changestate) { var jobj = $("#" + id); var libctl = jobj.attr('libctl'); if (typeof (libctl) == 'undefined') { libctl = $('[group=' + id + ']'); libctl = $(libctl).attr('libctl'); } var dis = jobj.attr('disabled') || jobj.attr('readonly'); if(val==null||val==undefined) { val = ''; } var v = val; var converttype = ''; switch (libctl) { case 'libtxt': var htmldecode = jobj.attr('htmldecode'); if (htmldecode == '1') { v = DN.htmlDecode(v); } var txttype = jobj.attr('txttype'); if (txttype == 'decimal' || txttype == 'number') { var thousands = jobj.attr('thousands'); var decimals = jobj.attr('decimals'); if (!decimals) decimals = -1; if (thousands == '1') { v = DN.numberFormat(v, decimals, '.', ','); } else { v = DN.numberFormat(v, decimals, '.', ''); } } jobj.val(v); if (dis) { $('#' + id + '_Input').val(v); } break; case "libhid": jobj.val(v); break; case "libdate": var fmt = jobj.attr('format'); if (fmt) { v = DN.getDateFormat(v, fmt); } converttype = jobj.attr('converttype'); if (converttype == 'date') { jobj.html(v); $('#' + id + '_Input').val(v); } else { jobj.val(v); if (dis) { $('#' + id + '_Input').val(v); } } break; case 'libcheck': var chked = false; if (v == '1' || v == 1 || v.toString().toLowerCase() == 'true') { chked = true; } var inputid = jobj.attr('id'); var chkobj = $("#" + inputid).ligerGetCheckBoxManager(); if (chkobj) { chkobj._setValue(chked); } break; case 'libradio': var chked = false; if (v == '1' || v == 1 || v.toString().toLowerCase() == 'true') { chked = true; } var inputid = jobj.attr('id'); var chkobj = $("#" + inputid).ligerGetRadioManager(); if (chkobj) { chkobj.setValue(chked); } break; case "libcmb": $('#' + id + '_Input').val(v); jobj.val(''); var cmb = $("#" + id).ligerGetComboBoxManager(); if (cmb) { if (cmb.data) { cmb.setValue(v); if (cmb.options.tolabelid) { $("#" + cmb.options.tolabelid).html($("#" + id).val()); } } else { if (cmb.options.auxSelect) { cmb._changeValue(v, v); } else { cmb.getTextByValue(v, { success: function(data) { if (!data) data = ''; cmb._changeValue(v, data); if (cmb.options.tolabelid) { $("#" + cmb.options.tolabelid).html(data); } } }); } } if (cmb.options.linkCmbID) { cmb.reloadLinkCmb(cmb.options.linkCmbID, v); } } break; case "libdropdown": jobj.find("option[value='" + v + "']").attr("selected", true); if (dis) { $('#' + id + '_Input').val(v); } converttype = jobj.attr('converttype'); if (converttype == 'dropdown') { var t = jobj.find("option:selected").text(); $("#" + id + "_span").html(t); } break; case "libchecklist": var vs = v.split(','); var vals = ''; jobj.find('input').each(function () { //$(this).attr('checked', false); //var dis1 = $(this).attr('disabled') || $(this).attr('readonly'); var inputval = $(this).parent().attr('itemvalue'); for (var i = 0; i < vs.length; i++) { var inputid = jobj.attr('id'); var chkobj = $("#" + inputid).ligerGetCheckBoxManager(); if (inputval == vs[i]) { if (chkobj) { chkobj._setValue(true); } if (vals != '') { vals += ','; } vals += vs[i]; } else { if (chkobj) { chkobj._setValue(false); } } } }); //if (dis) { $('#' + id + '_Input').val(vals); //} break; case "libimg": jobj.attr('src', v); break; case "liblabel": var htmldecode = jobj.attr('htmldecode'); if (htmldecode == '1') { v = DN.htmlDecode(v); } jobj.html(v); var convert = jobj.attr('converttype'); if (convert == 'input') { $('#' + id + '_Input').val(v); } var loadinput = jobj.attr('loadinput'); if(loadinput=='1') { $('#' + id + '_Input').val(v); } break; case "libradiolist": var vss = v.split(','); var vals = ''; jobj.find('input').each(function () { //$(this).attr('checked', false); var inputval = $(this).attr('value'); //var dis1 = $(this).attr('disabled') || $(this).attr('readonly'); for (var i = 0; i < vss.length; i++) { var inputid = jobj.attr('id'); var chkobj = $("#" + inputid).ligerGetRadioManager(); if (inputval == vss[i]) { if (chkobj) { chkobj.setValue(true); } if (vals != '') { vals += ','; } vals += vss[i]; } else { if (chkobj) { chkobj.setValue(false); } } } }); //if (dis) { $('#' + id + '_Input').val(vals); //} break; case "libfck": break; case "libuedit": if (dis) { jobj.html(v); } else { UE.getEditor(id).setContent(v, false); } break; case "libupload": $('#' + id + '_Input').val(''); $("div[upfilediv='" + id + "']").remove(); var rel = $("#" + id).attr("relationctlid"); if (rel) { var relctl = $("#" + rel); relctl.html(''); } if (v && v != '') { var files = v.split(','); DN.setUploadFile(files, id, files); } break; case "libselect": var ctlid = id.substr(0, id.length - 3); var textField = jobj.attr('textField'); var valueField = jobj.attr('valueField'); $('#' + ctlid + 'div').html(''); $('#' + ctlid + '_Input').val(''); $('#' + ctlid + '_Input_Text').val(''); if (v && v != '') { var url = window.location.href; if (url.indexOf('#') >= 0) url = url.substr(0, url.indexOf('#')); var prefix = '?'; if (url.indexOf('?') >= 0) { prefix = '&'; } url = url + prefix + 'Action=' + escape(ctlid) + 'GetSelectPanelData'; url = url + '&getselectpaneltext=1&selectpanelval=' + v; $.ajax({ type: 'get', url: url, cache: false, //dataType: 'json', success: function (data) { if (!data) { data = v; } var rows = []; var vals = v.split(','); var txts = data.split(','); for (var i = 0; i < vals.length; i++) { var r = {}; r[valueField] = vals[i]; r[textField] = txts[i]; rows.push(r); } DN.addSelectEle(rows, ctlid, { isClear: true, valueField: valueField, textField: textField }); } , error: function (XMLHttpRequest, textStatus) { if (DN && typeof (DN.ajaxError) == 'function') { var ret = DN.ajaxError(XMLHttpRequest, textStatus); if (ret == false) return; } var txt = null; if (typeof (XMLHttpRequest.responseText) != 'undefined') { txt = XMLHttpRequest.responseText.replace(/<[^>].*?>/g, ""); } alert(txt); } }); } break; } if (changestate == true) { DN.setFormState('modify', id); } } , setEnabled: function (id, enabled, bordercolor, bgcolor) { var jobj = $("#" + id); var libctl = jobj.attr('libctl'); if(typeof(libctl)=='undefined') { libctl = $('[group=' + id + ']'); libctl = $(libctl).attr('libctl'); } $(jobj).removeAttr('disabled'); switch (libctl) { case 'libtxt': if (enabled) { if (!bordercolor) { bordercolor = '#CCCCCC'; } if(!bgcolor) { bgcolor = '#ffffff'; } jobj.removeAttr('readonly').css({ 'border-color': bordercolor, 'background': bgcolor }); } else { if (!bordercolor) { bordercolor = '#C2C2C2'; } if (!bgcolor) { bgcolor = '#f6f6f6'; } jobj.attr('readonly', true).css({ 'border-color': bordercolor, 'background': bgcolor }); } break; case "libhid": break; case "libdate": if (enabled) { if (!bordercolor) { bordercolor = '#CCCCCC'; } if (!bgcolor) { bgcolor = '#ffffff'; } jobj.removeAttr('readonly').css({ 'border-color': bordercolor, 'background-color': bgcolor }); } else { if (!bordercolor) { bordercolor = '#C2C2C2'; } if (!bgcolor) { bgcolor = '#f6f6f6'; } jobj.attr('readonly', true).css({ 'border-color': bordercolor, 'background-color': bgcolor }); } break; case 'libcheck': var inputid = jobj.attr('id'); if (enabled) { var chkobj = $("#" + inputid).ligerGetCheckBoxManager(); if (chkobj) { chkobj.setDisabled(false); } } else { var chkobj = $("#" + inputid).ligerGetCheckBoxManager(); if (chkobj) { chkobj.setDisabled(true); } } break; case 'libradio': var inputid = jobj.attr('id'); if (enabled) { var chkobj = $("#" + inputid).ligerGetRadioManager(); if (chkobj) { chkobj.setEnabled(); } } else { var chkobj = $("#" + inputid).ligerGetRadioManager(); if (chkobj) { chkobj.setDisabled(); } } break; case "libcmb": var cmb = $("#" + id).ligerGetComboBoxManager(); if (cmb) { if (enabled) { cmb.setEnabled(); } else { cmb.setDisabled(); } } break; case "libdropdown": var disid = id + '_divdrpdis'; var distid = id + '_divdrpdisinput'; var did = id + '_divdrp'; var txt = jobj.find("option:selected").text(); if (enabled) { $("#" + disid).hide(); $("#" + did).show(); } else { $("#" + distid).val(txt); $("#" + did).hide(); $("#" + disid).show(); } break; case "libchecklist": jobj.find('input:checkbox').each(function () { var inputid = $(this).attr('id'); if (enabled) { var chkobj = $("#" + inputid).ligerGetCheckBoxManager(); if (chkobj) { chkobj.setDisabled(false); } } else { var chkobj = $("#" + inputid).ligerGetCheckBoxManager(); if (chkobj) { chkobj.setDisabled(true); } } }); break; case "libimg": break; case "liblabel": break; case "libradiolist": jobj.find('input:radio').each(function () { var inputid = $(this).attr('id'); if (enabled) { var chkobj = $("#" + inputid).ligerGetRadioManager(); if (chkobj) { chkobj.setEnabled(); } } else { var chkobj = $("#" + inputid).ligerGetRadioManager(); if (chkobj) { chkobj.setDisabled(); } } }); break; case "libfck": break; case "libuedit": break; case "libupload": var upid = id + 'addfile'; var delid = id + '_del'; if (enabled) { $("#" + upid).show(); $("." + delid).show(); } else { $("#" + upid).hide(); $("." + delid).hide(); } break; case "libselect": var upid = id + 'addselect'; var delid = id + '_del'; if (enabled) { $("#" + upid).show(); $("." + delid).show(); } else { $("#" + upid).hide(); $("." + delid).hide(); } break; } } ,isInsert:function(fidval) { if (!fidval || fidval == undefined || fidval == '' || fidval == '0' || fidval == '00000000-0000-0000-0000-000000000000') { return true; } return false; } , htmlEncode: function (str) { if (!str) return ''; var s = ""; str = str.toString(); if (str.length == 0) return ""; s = str.replace(/&/g, "&"); s = s.replace(//g, ">"); s = s.replace(/ /g, " "); s = s.replace(/\'/g, "'"); s = s.replace(/\"/g, """); s = s.replace(/,/g, ","); s = s.replace(/\n/g, "
"); s = s.replace(/\r/g, ""); return s; } , htmlDecode: function (str) { if (!str) return ''; var s = ""; str = str.toString(); if (str.length == 0) return ""; s = str.replace(/&/g, "&"); s = s.replace(/</g, "<"); s = s.replace(/>/g, ">"); s = s.replace(/ /g, " "); s = s.replace(/ /g, " "); s = s.replace(/'/g, "\'"); s = s.replace(/"/g, "\""); s = s.replace(/,/g, ","); s = s.replace(/
/g, "\n"); return s; } ,checkSQLVal: function (str) { if (!str || str == '') return true; var re = /create|select|insert|update|delete|exec|drop|alter|truncate|count|’|"|=|;|>|<|%/i; if (re.test(str.toLowerCase())) { return false; } return true; } ,cancelBubble: function (event) { var ie = navigator.appName == "Microsoft Internet Explorer" ? true : false; var e = event ? event : window.event; if (ie) { window.event.cancelBubble = true; window.event.returnValue = false; } else { e.preventDefault(); e.stopPropagation(); } return false; } , renderButton: function (obj) { if (!obj) { obj = $('body'); } var tn = DN.getThemeName('', { }); if (tn != 'bootstrap') { $(".lib-btn", obj).die().live('mouseover', function() { $(".lib-btn-inner", $(this)).addClass("lib-btn-inner-over"); $(".lib-btn-l", $(this)).addClass("lib-btn-l-over"); $(".lib-btn-r", $(this)).addClass("lib-btn-r-over"); }).live('mouseout', function() { $(".lib-btn-inner", $(this)).removeClass("lib-btn-inner-over"); $(".lib-btn-l", $(this)).removeClass("lib-btn-l-over"); $(".lib-btn-r", $(this)).removeClass("lib-btn-r-over"); }); $(".lib-btn-gray", obj).die().live('mouseover', function() { $(".lib-btn-inner-gray", $(this)).addClass("lib-btn-inner-over-gray"); $(".lib-btn-l-gray", $(this)).addClass("lib-btn-l-over-gray"); $(".lib-btn-r-gray", $(this)).addClass("lib-btn-r-over-gray"); }).live('mouseout', function() { $(".lib-btn-inner-gray", $(this)).removeClass("lib-btn-inner-over-gray"); $(".lib-btn-l-gray", $(this)).removeClass("lib-btn-l-over-gray"); $(".lib-btn-r-gray", $(this)).removeClass("lib-btn-r-over-gray"); }); setTimeout(function() { $(".lib-btn", obj).each(function() { var txt = $(this).html(); var iconclass = $(this).attr("iconclass"); if (iconclass) { iconclass = '
'; } else { iconclass = ''; } var wd = $(this).css("width"); wd = parseInt(wd); if (isNaN(wd) || wd == 0 || wd < 70) wd = 70; var style = ''; if (iconclass) style = 'width:' + (wd - 18) + 'px;padding-left:10px;'; else style = 'width:' + (wd - 8) + 'px;'; var innerHtml = '
' + iconclass + '
' + txt + '
'; $(this).html(innerHtml); }); $(".lib-btn-gray", obj).each(function() { var txt = $(this).html(); var iconclass = $(this).attr("iconclass"); if (iconclass) { iconclass = '
'; } else { iconclass = ''; } var wd = $(this).css("width"); wd = parseInt(wd); if (isNaN(wd) || wd == 0 || wd < 70) wd = 70; var style = ''; if (iconclass) style = 'width:' + (wd - 18) + 'px;padding-left:10px;'; else style = 'width:' + (wd - 8) + 'px;'; var innerHtml = '
' + iconclass + '
' + txt + '
'; $(this).html(innerHtml); }); }, $.browser.msie ? 0 : 200); } else { $(".lib-btn", obj).each(function () { $(this).removeClass('lib-btn').addClass('btn btn-submit'); }); } } }; while (DN.TopWindow.parent && DN.TopWindow.parent != DN.TopWindow) { try { if (DN.TopWindow.parent.document.domain != document.domain) break; } catch (e) { break; } DN.TopWindow = DN.TopWindow.parent; DN.top = DN.TopWindow; } var NS = DN; var hz = DN;by.1688.com最新网址by.5688.com入口5g影视在线免费观看永久免费看mv网站入口日日春扦插777视频在线快猫回家永久访问链接链接