//组织相关的变量 var ORG_VARIABLE = { UUID_TO_CHILD_NAME:{ 'top_corp_uuid':'corp_name', 'corp_uuid':'county_name', 'county_uuid':'dept_name', 'dept_uuid':'sale_line_name', 'sale_line_uuid':'sale_line_name' }, CODE_TO_UUID:{ '01':'top_corp_uuid' ,'02':'corp_uuid' ,'03':'county_uuid' ,'07':'dept_uuid' ,'08':'sale_line_uuid' }, UUID_TO_CODE:{ 'top_corp_uuid':'01' ,'corp_uuid':'02' ,'county_uuid':'03' ,'dept_uuid':'07' ,'sale_line_uuid':'08' }, CODE_TO_CHILD_CODE:{ '01':'02' ,'02':'03' ,'03':'07' ,'07':'08' ,'08':'08' } }; $.extend($.fn.datagrid.methods, { autoMergeCells: function (jq, fields) { return jq.each(function () { var target = $(this); if (!fields) { fields = target.datagrid("getColumnFields",true); } var rows = target.datagrid("getRows"); var i = 0, j = 0, temp = {}; for (i; i < rows.length; i++) { var row = rows[i]; j = 0; for (j; j < fields.length; j++) { var field = fields[j]; var tf = temp[field]; if (!tf) { tf = temp[field] = {}; tf[row[field]] = [i]; } else { var tfv = tf[row[field]]; if (tfv) { tfv.push(i); } else { tfv = tf[row[field]] = [i]; } } } } $.each(temp, function (field, colunm) { $.each(colunm, function () { var group = this; if (group.length > 1) { var before, after, megerIndex = group[0]; for (var i = 0; i < group.length; i++) { before = group[i]; after = group[i + 1]; if (after && (after - before) == 1) { continue; } var rowspan = before - megerIndex + 1; if (rowspan > 1) { target.datagrid('mergeCells', { index: megerIndex, field: field, rowspan: rowspan }); } if (after && (after - before) != 1) { megerIndex = after; } } } }); }); }); } }); //yubstart report module function loading(){ $("
").appendTo('body'); var msg = $("
").html('正在装载,请稍候。。。').appendTo('body'); msg.css("marginLeft", -msg.outerWidth() / 2); } function loaded(){ $('body').children("div.datagrid-mask-msg").remove(); $('body').children("div.datagrid-mask").remove(); } function getReportData(_containerid){ return $('#'+_containerid).data('report_data'); } function orderReport(_containerid,_orderbyfield){ loading(); var jparam = $("#"+_containerid).data("report_data"); var _id = $("#"+_containerid).data("report_data").id; var jForm = $('#form_'+_id); var bigData = $.json2str($("#"+_containerid).data("report_data").queryParams); bigData = Base64.encode(bigData); jForm.find("input[name='data']").val(bigData);//赋值给iframe中表单的文本框中 jForm.find("input[name='orderbyfield']").val(Base64.encode(_orderbyfield)); //var jAttach = $('#attach_reort_export'); //jAttach.find("input[name='orderbyfield']").val(Base64.encode(_orderbyfield)); jForm.submit();//提交数据 } $.extend({ /** * [getFilterOrgField 根据历史查询还是根据当前查询] * @param {[type]} src_org_uuid [原始组织UUID] * @return {[type]} [无] */ getFilterOrgField:function(src_org_uuid){ var orgMapping = { "dept_uuid":"cust_dept_uuid", "sale_line_uuid":"cust_sale_line_uuid" }; if(orgMapping.hasOwnProperty && orgMapping.hasOwnProperty(src_org_uuid)){ return orgMapping[src_org_uuid]; } if((src_org_uuid in orgMapping)){ return orgMapping[src_org_uuid]; } return src_org_uuid; }, show_corp_level:function(jparam){ var org_field = jparam._org_field?jparam._org_field:''; var corp_level = jparam._corp_level?jparam._corp_level:''; var object_dim = {}; var dimList = []; var dimorder = ""; var dimcode = ""; if(org_field.length>0&&corp_level.length>0){ if (org_field == 'corp_uuid'){ if (corp_level == 'corp_name'){ dimList = [{ fieldname: '单位', fieldcode: 'corp_name', fieldtype: 'dim', sum: true, width:210, align:'left' }]; dimcode = 'corp_name'; dimorder = 'corp_order'; } else if (corp_level == 'county_name'){ dimList = [{ fieldname: '区县公司', fieldcode: 'county_name', fieldtype: 'dim', sum: true, width:210, align:'left' }]; dimcode = 'county_name'; dimorder = 'county_order'; } else if (corp_level == 'dept_name'){ dimList = [{ fieldname: '区县公司', fieldcode: 'county_name', fieldtype: 'dim', sum: true, width:210, align:'left' }, { fieldname: '市场部', fieldcode: 'dept_name', fieldtype: 'dim', sum: true, width:230, align:'left' }]; dimcode = 'county_name,dept_name'; dimorder = 'county_order,dept_order'; } else if (corp_level == 'sale_line_name'){ dimList = [{ fieldname: '区县公司', fieldcode: 'county_name', fieldtype: 'dim', sum: true, width:210, align:'left' }, { fieldname: '市场部', fieldcode: 'dept_name', fieldtype: 'dim', sum: true, width:230, align:'left' }, { fieldname: '营销线', fieldcode: 'sale_line_name', fieldtype: 'dim', sum: true, width:230, align:'left' }]; dimcode = 'county_name,dept_name,sale_line_name'; dimorder = 'county_order,dept_order,sale_line_order'; } } else if (org_field == "county_uuid") { if (corp_level == 'corp_name') { dimList = [{ fieldname: '单位', fieldcode: 'corp_name', fieldtype: 'dim', sum: true, width: 210, align: 'left' }]; dimcode = 'corp_name'; dimorder = 'corp_order'; } else if (corp_level == 'county_name') { dimList = [{ fieldname: '区县公司', fieldcode: 'county_name', fieldtype: 'dim', sum: true, width: 210, align: 'left' }]; dimcode = 'county_name'; dimorder = 'county_order'; } else if (corp_level == 'dept_name') { dimList = [{ fieldname: '市场部', fieldcode: 'dept_name', fieldtype: 'dim', sum: true, width: 130, align: 'left' }]; dimcode = 'dept_name'; dimorder = 'dept_order'; } else if (corp_level == 'sale_line_name') { dimList = [{ fieldname: '市场部', fieldcode: 'dept_name', fieldtype: 'dim', sum: true, width: 130, align: 'left' }, { fieldname: '营销线', fieldcode: 'sale_line_name', fieldtype: 'dim', sum: true, width: 230, align: 'left' }]; dimcode = 'county_name,dept_name,sale_line_name'; dimorder = 'county_order,dept_order,sale_line_order'; } } else if (org_field == "dept_uuid") { if (corp_level == 'corp_name') { dimList = [{ fieldname: '单位', fieldcode: 'corp_name', fieldtype: 'dim', sum: true, width: 210, align: 'left' }]; dimcode = 'corp_name'; dimorder = 'corp_order'; } else if (corp_level == 'county_name') { dimList = [{ fieldname: '区县公司', fieldcode: 'county_name', fieldtype: 'dim', sum: true, width: 210, align: 'left' }]; dimcode = 'county_name'; dimorder = 'county_order'; } else if (corp_level == 'dept_name') { dimList = [{ fieldname: '市场部', fieldcode: 'dept_name', fieldtype: 'dim', sum: true, width: 130, align: 'left' }]; dimcode = 'dept_name'; dimorder = 'dept_order'; } else if (corp_level == 'sale_line_name') { dimList = [{ fieldname: '营销线', fieldcode: 'sale_line_name', fieldtype: 'dim', sum: true, width: 230, align: 'left' }]; dimcode = 'sale_line_name'; dimorder = 'sale_line_order'; } } else if (org_field == "sale_line_uuid"){ if (corp_level == 'corp_name') { dimList = [{ fieldname: '单位', fieldcode: 'corp_name', fieldtype: 'dim', sum: true, width: 210, align: 'left' }]; dimcode = 'corp_name'; dimorder = 'corp_order'; } else if (corp_level == 'county_name') { dimList = [{ fieldname: '区县公司', fieldcode: 'county_name', fieldtype: 'dim', sum: true, width: 210, align: 'left' }]; dimcode = 'county_name'; dimorder = 'county_order'; } else if (corp_level == 'dept_name') { dimList = [{ fieldname: '市场部', fieldcode: 'dept_name', fieldtype: 'dim', sum: true, width: 130, align: 'left' }]; dimcode = 'dept_name'; dimorder = 'dept_order'; } else if (corp_level == 'sale_line_name') { dimList = [{ fieldname: '营销线', fieldcode: 'sale_line_name', fieldtype: 'dim', sum: true, width: 230, align: 'left' }]; dimcode = 'sale_line_name'; dimorder = 'sale_line_order'; } } } object_dim["dimList"] = dimList; object_dim["dimcode"] = dimcode; object_dim["dimorder"] = dimorder; return object_dim; }, openDebug:function(_containerid){ if(_containerid == undefined){ _containerid = 'report_gird'; } var bigData = $.json2str($("#"+_containerid).data("report_data").queryParams); bigData = Base64.encode(bigData); $.postOpen('wdk?action=pf.report&method=forwardDebug2',{data:bigData}); }, postOpen:function(URL, PARAMS) { var temp_form = document.createElement("form"); temp_form.id = "debug_form"; temp_form.action = URL; temp_form.target = "_blank"; temp_form.method = "post"; temp_form.style.display = "none"; for (var x in PARAMS) { var opt = document.createElement("textarea"); opt.name = x; opt.value = PARAMS[x]; temp_form.appendChild(opt); } document.body.appendChild(temp_form); temp_form.submit(); }, /** * [generateContextmenu 创建右键菜单] * @param {[type]} jparams [菜单] * @return {[type]} [无] */ generateContextmenu:function(jparams){ var contextmenu = []; if(typeof _buttons != 'undefined'){ if(_buttons && jparams && jQuery.isArray(_buttons) && jQuery.isArray(jparams)){ for(var i=0;i0){ }else{ divobj = $('
').appendTo('body'); } var scriptobj = $('#script_frame'); if(scriptobj && scriptobj.length>0){ }else{ scriptobj = $('').appendTo('head'); } $('#'+_id).mouseover(function(){ var tablestr = []; tablestr.push(''); tablestr.push(''); for(var i=0;i<_data.length;i++){ tablestr.push(''); } tablestr.push('
指标名称指标说明
'+_data[i].title+''+_data[i].desc+'
'); $('.metric_desc').html(tablestr.join('')); var topv = $(this).offset().top+$(this).height()+10; var rightv = $(this).offset().right; divobj.css('display','block'); divobj.css('top',topv); divobj.css('right',rightv); }).mouseleave(function(){ divobj.css('display','none'); }); }, /** * [salerSelect 销售员选择] * @param {[type]} jparam [输入参数] * @return {[type]} [无] */ salerSelect:function(jparam){ var _id = jparam.id?jparam.id:$.getUUID(); var _initvalue = jparam.initvalue?jparam.initvalue:'';//'0101,0201' var _inittext = jparam.inittext?jparam.inittext:'';//'0101,0201' var _callBack = jparam.callback?jparam.callback:function(){}; var _ismulti = jparam.ismulselect==undefined?'':jparam.ismulselect; var _onBeforeOpen = jparam.onBeforeOpen?jparam.onBeforeOpen:function(param){return param}; //人员所属组织标识串 $.inputpop({ id:_id, height:450, width:750, required:false, editable:false, url:'products/imp/pub/mds/persontree.jsp', initvalue:_initvalue, //code inittext:_inittext, //name initid:'', //uuid transfer:'1', queryParams:{ manage_unit_uuid: $.getSessionUser().manageunituuid, //管理单元标识 person_uuid:$.getSessionUser().personuuid, //操作人员标识 persontype:'02', //人员类型 orgattr:'03', //组织属性 orguuids:'', //人员所属组织标识串 isctrlperm:'', //是否控制权限 ismulselect:_ismulti, //是否多选 asyn:'1' //是否异步加载 }, onBeforeOpen:_onBeforeOpen, missingMessage:'', tipPosition:'bottom', callback:_callBack }); }, org_fieldMap:{ '01':'top_corp_uuid' ,'02':'corp_uuid' ,'03':'county_uuid' ,'07':'dept_uuid' ,'08':'sale_line_uuid' }, /** * [orgSelect 组织选择] * @return {[type]} [description] */ orgSelect:function(jparam){ var _id = jparam.id?jparam.id:$.getUUID(); var _initvalue = jparam.initvalue?jparam.initvalue:''; var _inittext = jparam.inittext?jparam.inittext:''; var _initid = jparam.initid?jparam.initid:''; var _callBack = jparam.callback?jparam.callback:function(){}; var _ismulti = jparam.ismulselect==undefined?'1':jparam.ismulselect;//默认多选 var _onBeforeOpen = jparam.onBeforeOpen?jparam.onBeforeOpen:function(param){return param}; var _onLoadSuccess = jparam.onLoadSuccess?jparam.onLoadSuccess:function(data){}; var _orgLevel = jparam.orgLevel?jparam.orgLevel:'';//过滤组织级别,支持个 if(_initvalue){ _onLoadSuccess.call(jparam,undefined); renderOrgTree(); }else{ $.cuajax({ url: 'wdk?action=wdk.pub&method=call_service&ajaxparam=' + new Date().getTime(), method: "post", timeout: WDK_Timeout, data: { _SRVNAME: 'service.md.org', _SRVMETHOD: 'queryTopOrg', _DATA: $.json2str({ op_account_uuid: $.getSessionUser().account_id, manage_unit_uuid: $.getSessionUser().manageunituuid, isctrlperm: '1', //控制权限 org_attr: '03' //组织属性-销售组织,根据实际情况修改 }), _DATAFILTER: 1 //启用数据权限 }, success: function(result) { $.wait_close(); var jres = $.str2json(result); var root_org; if (jres.code == '1') { if (jres.resultset && jres.resultset.length > 0) { //操作成功 root_org = jres.resultset[0]; //取返回结果的第一条数据 root_org.org_field = $.org_fieldMap[root_org.org_level_scode]; _onLoadSuccess.call(jparam,root_org); } } //设置区域初始值 if (root_org) { _initvalue = root_org.org_code; _inittext = root_org.org_name; _initid = root_org.org_uuid; renderOrgTree(root_org); } }, error: function(result) { $.wait_close(); alert('网络错误!result=' + result); } }); } function renderOrgTree(root_org){ var orglevel = ''; if(root_org){ orglevel = root_org.org_level_scode; } $.inputpop({ id:_id, height:450, width:750, required:false, editable:false, url:'platform/report/ctrl/departtree.jsp', initvalue:_initvalue, //code inittext:_inittext, //name initid:_initid, //uuid transfer:'1', queryParams:{ manage_unit_uuid: $.getSessionUser().manageunituuid, //管理单元标识 person_uuid:$.getSessionUser().personuuid, //操作人员标识 org_uuid:'', //上级组织标识 orglevel:orglevel, //组织级别 orgattr:'03', //组织属性:必须指定为营销组织 isctrlperm:'', //是否控制权限 ismulselect:_ismulti, //是否多选 filterorglevel:_orgLevel, //过滤的组织级别 asyn:'0', //是否异步加载 cascadecheck:'1', //是否级联勾选 returnorglevel:'' //返回的组织级别 }, onBeforeOpen:_onBeforeOpen, missingMessage:'', tipPosition:'bottom', idField:'org_uuid', textField:'org_name', valueField:'org_code', callback:_callBack }); //数据暂存 if(root_org){ $("#"+_id).data("orgSelect", root_org); } } }, /** * [orgSelect_getValue 获取组织选择控件默认值] * @param {[type]} _id [description] * @return {[type]} [description] */ orgSelect_getDefaultValue:function(_id,callbackFun){ var data=undefined; if(_id){ data = $("#"+_id).data("orgSelect"); } if(data){ var jo = {}; jo.org_uuid = data.org_uuid; jo.org_name = data.org_name; jo.org_field = $.org_fieldMap[data.org_level_scode]; return jo; }else{ if(callbackFun){ $.cuajax({ url: 'wdk?action=wdk.pub&method=call_service&ajaxparam=' + new Date().getTime(), method: "post", timeout: WDK_Timeout, data: { _SRVNAME: 'service.md.org', _SRVMETHOD: 'queryTopOrg', _DATA: $.json2str({ op_account_uuid: $.getSessionUser().account_id, manage_unit_uuid: $.getSessionUser().manageunituuid, isctrlperm: '1', //控制权限 org_attr: '03' //组织属性-销售组织,根据实际情况修改 }), _DATAFILTER: 1 //启用数据权限 }, success: function(result) { var jres = $.str2json(result); var root_org; if (jres.code == '1') { if (jres.resultset && jres.resultset.length > 0) { //操作成功 root_org = jres.resultset[0]; //取返回结果的第一条数据 root_org.org_field = $.org_fieldMap[root_org.org_level_scode]; callbackFun(root_org); } } }, error: function(result) { $.wait_close(); alert('网络错误!result=' + result); } }); }else{ return undefined; } } }, /** * [productSelect 卷烟选择] * @param {[type]} jparam [输入参数] * @return {[type]} [无] */ productSelect:function(jparam){ var _id = jparam.id?jparam.id:$.getUUID(); var _initvalue = jparam.initvalue?jparam.initvalue:'';//'0101,0201' var _inittext = jparam.inittext?jparam.inittext:'';//'0101,0201' var _callBack = jparam.callback?jparam.callback:function(){}; var _ismulti = jparam.ismulselect==undefined?'':jparam.ismulselect; var _onBeforeOpen = jparam.onBeforeOpen?jparam.onBeforeOpen:function(param){return param}; var _top = $.getRoot(); var _attr_expr = { his_active:'1' ,other:{ factory:{ is_active:'-1' } ,brand:{ is_active:'-1' } } };//默认需要 if($.isPlainObject(jparam.attr_expr) && !$.isEmptyObject(jparam.attr_expr)){ _attr_expr = jparam.attr_expr; } var popupParam = { id:_id, required:false, editable:false, initvalue:_initvalue, //code inittext:_inittext, //name initid:_initvalue, //uuid transfer:'1', onBeforeOpen:_onBeforeOpen, missingMessage:'', tipPosition:'bottom', //idField:'org_uuid', //textField:'org_name', //valueField:'org_code', callback:_callBack }; if(_ismulti && _ismulti == '1'){ //多选,需要 popupParam.height = 550; popupParam.width = 900; popupParam.url = 'products/imp/pub/mds/cigarselect.jsp'; popupParam.queryParams = { manage_unit_uuid:$.getSessionUser().manageunituuid, //管理单元标识 person_uuid:$.getSessionUser().personuuid, //操作人员标识 account_id:$.getSessionUser().account_id, querymode:'1' //area_uuid:'', //顶级区域标识 //showlevel:'', //显示级别 //isctrlperm:'1', //是否控制权限 //ismulselect:'1', //是否多选 }; $.inputpop(popupParam); }else{ //单选的话,就初始化卷烟数据吧 popupParam.height = 450; popupParam.width = 750; popupParam.url = 'platform/report/ctrl/producttree.jsp'; popupParam.queryParams = { manage_unit_uuid: $.getSessionUser().manageunituuid, //管理单元标识 person_uuid:$.getSessionUser().personuuid, //操作人员标识 factory_uuid:'', //厂家标识 brand_uuid:'', //品牌标识 ismulselect:_ismulti, //是否多选 attr_expr:_attr_expr }; $.inputpop(popupParam); initProductData(); } function initProductData(){ if(_top.PRODUCT_CTRL_DATA_HIS && _top.PRODUCT_CTRL_DATA_HIS.length > 0){ }else{ $.cuajax({ url:'wdk?action=wdk.pub&method=call_service&ajaxparam='+new Date().getTime(), data:{ _SRVNAME:'service.md.product', _SRVMETHOD:'queryProductTreeAttr', _DATA:$.json2str({ op_acc:$.getSessionUser().account_id, manage_unit_uuid:$.getSessionUser().manageunituuid, factory_uuid:'', brand_uuid:'', attr_expr:_attr_expr }), _RSTYPE:'tree', _RSPARAM:$.json2str({ idFields:'node_type,id', parentFields:'parent_type,pid', asyn:'0', idField:'id', textField:'name', parentField:'pid', iconField:'', attrs:'node_type,code', asyn_urlField:'pid', asyn_dataField:'' //如果是异步,则从url中取出的参数替换_DATA参数的名 }), _RSFIELD:'resultset' }, success:function(data){ _top.PRODUCT_CTRL_DATA_HIS = $.str2json(data); } }); } } }, /** * [brandSelect 品牌选择] * @param {[type]} jparam [输入参数] * @return {[type]} [无] */ brandSelect:function(jparam){ var _id = jparam.id?jparam.id:$.getUUID(); var _initvalue = jparam.initvalue?jparam.initvalue:'';//'0101,0201' var _inittext = jparam.inittext?jparam.inittext:'';//'0101,0201' var _callBack = jparam.callback?jparam.callback:function(){}; var _ismulti = jparam.ismulselect==undefined?'':jparam.ismulselect; var _onBeforeOpen = jparam.onBeforeOpen?jparam.onBeforeOpen:function(param){return param}; $.inputpop({ id:_id, height:450, width:750, required:false, editable:false, url:'products/imp/pub/mds/brandtree.jsp', initvalue:_initvalue, //code inittext:_inittext, //name initid:_initvalue, //uuid transfer:'1', queryParams:{ manage_unit_uuid:$.getSessionUser().manageunituuid, //管理单元标识 person_uuid:$.getSessionUser().personuuid, //操作人员标识 factory_uuid:'', //厂家标识 ismulselect:_ismulti //是否多选 }, onBeforeOpen:_onBeforeOpen, missingMessage:'', tipPosition:'bottom', //idField:'org_uuid', //textField:'org_name', //valueField:'org_code', callback:_callBack }); }, /** * [factorySelect 厂家选择] * @param {[type]} jparam [输入参数] * @return {[type]} [无] */ factorySelect:function(jparam){ var _id = jparam.id?jparam.id:$.getUUID(); var _initvalue = jparam.initvalue?jparam.initvalue:'';//'0101,0201' var _inittext = jparam.inittext?jparam.inittext:'';//'0101,0201' var _callBack = jparam.callback?jparam.callback:function(){}; var _ismulti = jparam.ismulselect==undefined?'':jparam.ismulselect; var _onBeforeOpen = jparam.onBeforeOpen?jparam.onBeforeOpen:function(param){return param}; $.inputpop({ id:_id, height:450, width:750, required:false, editable:false, url:'products/imp/pub/mds/factorytree.jsp', initvalue:_initvalue, //code inittext:_inittext, //name initid:_initvalue, //uuid transfer:'1', queryParams:{ manage_unit_uuid:$.getSessionUser().manageunituuid, //管理单元标识 person_uuid:$.getSessionUser().personuuid, //操作人员标识 ismulselect:_ismulti //是否多选 }, onBeforeOpen:_onBeforeOpen, missingMessage:'', tipPosition:'bottom', //idField:'org_uuid', //textField:'org_name', //valueField:'org_code', callback:_callBack }); }, /** * [bizStorSelect 仓库选择] * @return {[type]} [description] */ bizStorSelect:function(jparam){ var _id = jparam.id?jparam.id:$.getUUID(); var _initvalue = jparam.initvalue?jparam.initvalue:'';//'0101,0201' var _inittext = jparam.inittext?jparam.inittext:'';//'0101,0201' var _callBack = jparam.callback?jparam.callback:function(){}; var _ismulti = jparam.ismulselect==undefined?'':jparam.ismulselect; var _onBeforeOpen = jparam.onBeforeOpen?jparam.onBeforeOpen:function(param){return param}; $.inputpop({ id:_id, height:450, width:750, required:false, editable:false, url:'products/imp/pub/mds/bizstorselect.jsp', initvalue:_initvalue,//'001000017,001000018', //code inittext:_inittext,//'001000017,001000018', //name initid:_initvalue,//'001000017,001000018', //uuid transfer:'1', queryParams:{ manage_unit_uuid:$.getSessionUser().manageunituuid, //管理单元标识 person_uuid:$.getSessionUser().personuuid, //操作人员标识 onlydvlstor:'', //只显示配送库 onlypurchstor:'', //只显示采购库 real_stor_uuid:'', //实物库标识 isctrlperm:'', //是否控制权限 ismulselect:_ismulti //是否多选 }, onBeforeOpen:_onBeforeOpen, missingMessage:'', tipPosition:'bottom', callback:_callBack }); }, saleTypeGroupMapping:{ "01":"普通批发", "02":"特殊销售", "03":"商商调拨" }, /** * [saleTypeSelect 销售类型选择] * @param {[type]} jparam [输入参数] * @return {[type]} [无] */ saleTypeSelect:function(jparam){ var _id = jparam.id?jparam.id:$.getUUID(); var _condition = jparam.condition?jparam.condition:" parent_scode IN ('01','02')"; var _initvalue = jparam.initvalue?jparam.initvalue:'';//'0101,0201' var _callBack = jparam.callback?jparam.callback:function(){}; var panel; $.combobox({ //订单类型sale_type id : _id, url : 'wdk?action=wdk.pub&method=call_service&ajaxparam='+ new Date().getTime(), queryParams : { _SRVNAME : 'service.wdk.pub', _SRVMETHOD : 'wql_query', _DATA : $.json2str({ modulecode : 'S_TC_ORDER_SALETYPE', jparam : { condition : _condition } }), _RSFIELD : 'result' }, initvalue:_initvalue, // 0101 - required : false, editable : false, multiple : true, disabled:false, height : 25, idField : 'sysdic_code', textField : 'sysdic_name', groupField:'parent_scode', groupFormatter: function(group){ panel = $(this).combo('panel'); return '
'+$.saleTypeGroupMapping[group] + '
'; }, onLoadSuccess:function(data){ if(panel){ panel.find(".combobox-item").css("padding-left","20px"); } }, onSelect:_callBack }); }, ready_count:0, /** * [onReadyListener 监听查询条件加载完毕] * @return {[type]} [无] */ onReadyListener:function(dimFunc,metricFunc,callback){ var dimension = dimFunc(); var metric = metricFunc();//$('input[name="metric"]'); if(metric && metric.length>0 && dimension && dimension.length>0){ this.ready_count = 0; callback(); }else{ this.ready_count ++ ; if(this.ready_count<20){ setTimeout(function(){$.onReadyListener(dimFunc,metricFunc,callback)},100); }else{ console.log('超时!'); } } }, combo_dimension:function(jparam){ $.combobox({ id:jparam.id //,url:'wdk?action=pf.report&method=grid_dimension&ajaxparam='+new Date().getTime() //,queryParams:{} ,data:jparam.data ,idField:'id' ,textField:'text' ,height:25 ,isinitselect:true ,initvalue:jparam.initvalue }); }, dimension_getValue:function(id){ //构建维护dimension var list = []; var data = $('#'+id).combobox('getData'); if(data && data.length>0){ var key = $.combobox_getValue({id:id}); //list.push({fieldname:'单位',fieldcode:'county_name'}); for(var i=0;i0){ $(_formid).find("#radio_"+_id).remove(); } var _container = $('
'); if(_url.length >0){ $.cuajax({ url:_url, //async:false, data:_queryParams, success:function(data){ _data=$.str2json(data); reader(_data); } }); }else{ reader(_data); } function reader(_data){ for(var i = 0 ;i<_data.length;i++){ var da = _data[i]; var _extra = da.extra?da.extra:{}; var _extra2 = $.json2str(_extra).replace(new RegExp('"','gm'),'\''); var inp = $(''); if(_disabled){ inp.attr('disabled',true); } inp.data('data',da); if(_defaultFirst && i== 0){ inp.attr('checked','checked'); } _container.append(inp); } _container.find('input[id*='+_id+'][value="'+_initvalue+'"]').attr('checked','checked'); _container.on('loadSuccess',function(){ _onLoadSuccess.call(this); }); obj.after(_container); obj.remove(); _container.find("input").on('ifChanged', function(event){ if($(this).is(":checked")){ _onChange.call(this,$(this).data("data")); } }); _container.find("input").iCheck({ labelHover : false, cursor : true, checkboxClass : 'icheckbox_minimal-blue icheckbox', radioClass : 'iradio_minimal-blue icheckbox', increaseArea : '20%' }); _container.trigger("loadSuccess"); } }, metricCheckbox:function(param){ //属性 var _id = param.id?param.id:''; var _formid=param.formid; if(!_formid){ _formid="body"; }else{ _formid="#"+_formid; } var _initvalue = param.initvalue?param.initvalue:''; var _url = param.url?param.url:''; var _queryParams = param.queryParams?param.queryParams:{}; var _disabled = param.disabled?param.disabled:false; var _data = param.data?param.data:[]; var _spacing = param.spacing?param.spacing:10; //事件 var _onSelect = param.onSelect?$.event_getHandler(param.onSelect):function(){}; var _onUnSelect = param.onUnSelect?$.event_getHandler(param.onUnSelect):function(){}; if($(_formid).find("#checkbox_"+_id).length>0){ $(_formid).find("#checkbox_"+_id).remove(); } var _container = $('
'); if(_url.length >0){ $.cuajax({ url:_url, data:_queryParams, success:function(data){ _data=$.str2json(data); reader(_data); } }); }else{ reader(_data); } function reader(_data){ for(var i = 0 ;i<_data.length;i++){ var da = _data[i]; if(i==_data.length-1){ _spacing=0; } var _extra = da.extra?da.extra:{}; var _extra2 = $.json2str(_extra).replace(new RegExp('"','gm'),'\''); var inp = $(''); if(_disabled){ inp.attr('disabled',true); } inp.data('data',da); _container.append(inp); } if(_initvalue.length >0){ var values = _initvalue.split(","); for(var i = 0;i-1){ newDate.push(_data[i]); } } used = newDate; }else{ used = [{ id: 'corp_name',//最大维护字段 text: '地区', org_level:'02' }, { id: 'county_name',//最大维护字段 text: '县级', org_level:'03' }]; } $.radio({ formid: _formid,//'search_form', id: _id,//'corp_level', defaultFirst:true, onChange:_onChange, spacing:-1, initvalue:_initvalue, data: used }); }, date_fomart:function(date){ return date.format('yyyy-MM-dd'); }, month_fomart:function(date){ return date.format('yyyy-MM'); }, getCurrentYearFirst:function(nowdate){ nowdate.setMonth(0); return nowdate; }, getLastMonthDate:function(nowdate){ var currentMonth = nowdate.getMonth(); nowdate.setMonth(nowdate.getMonth()-1); var thisMonth = nowdate.getMonth(); var cnt = 0; while (thisMonth == currentMonth){ nowdate.setDate(nowdate.getDate()-1); thisMonth = nowdate.getMonth(); cnt++; if(cnt>10){ break; } } return nowdate; }, getLastYearDate:function(nowdate){ nowdate.setFullYear(nowdate.getFullYear()-1); return nowdate; }, getCurrentMonthFirst:function(date){ date.setDate(1); return date; }, getCurrentMonthLast:function(date){ var currentMonth=date.getMonth(); var nextMonth=++currentMonth; var nextMonthFirstDay=new Date(date.getFullYear(),nextMonth,1); var oneDay=1000*60*60*24; return new Date(nextMonthFirstDay-oneDay); }, getLastMonthFirst:function(date){//获取上个月1号的日期 date.setDate(1); date.setMonth(date.getMonth()-1); return date; }, getYesterday:function(date){//昨天 date.setDate(date.getDate()-1); return date; }, /** * [export 导出xls、word、pdf等文件] * @param {[type]} _data [导出需要的报文体] * @param {[type]} file_type [文件类型,xls、pdf、doc] * @return {[type]} [无] */ rp_export:function(_data,file_type){ var _id = 'reort_export'; var _containerid = '';//报表ID if($.rp_export.caller){ var args = $.rp_export.caller.arguments; if(args.length>0){ _containerid = args[0]; } } //本次请求的链路ID var _traceid = $.getUUID(); _data = $.extend({ _SERVICE_NAME:'metric_system'//默认让指标系统处理数据 }, _data,{ _TRACEID:_traceid }); var su = $.getSessionUser(); if(su){ _data._BIZ_ACCOUNT_UUID = su.account_id; _data._BIZ_MANAGE_UUID = su.manageunituuid; } var _title = _data.title||$('title').text(); var bigData = $.json2str(_data); if(!file_type){ file_type = '';//防止文件类型为:undefined } var isload = false;//默认第一次未装载 if($('#'+_id).length == 0){ var rptframeDiv = $('
').appendTo('body'); $('').appendTo(rptframeDiv); var url = 'wdk?action=pf.report&method=grid_export_file&ajaxparam='+new Date().getTime(); var formstr = "
" + " " + " " + " " + " " + "
"; var jForm = $(formstr).css('display','none'); jForm.appendTo(rptframeDiv); //第一次加载iframe时 window.initReport = function(){ if(isload==false){ frameLoadSuccess(true); } isload = true; } }else{ frameLoadSuccess(false); } //导出文件时, function frameLoadSuccess(init){ var jForm = $('#attach_'+_id); if(jForm && jForm.length > 0){ jForm.find("input[name='type']").val(file_type); bigData = Base64.encode(bigData);//做提交 jForm.find("input[name='data']").val(bigData); _title = Base64.encode(_title); jForm.find("input[name='title']").val(_title); if(_containerid){ if($("#"+_containerid).data("report_data")){ var _fid = $("#"+_containerid).data("report_data").id; var rpForm = $('#form_'+_fid); if(rpForm.length > 0){ jForm.find("input[name='orderbyfield']").val(rpForm.find("input[name='orderbyfield']").val()); } } } jForm.submit();//提交数据 } } //1.5秒后关闭等待框 setTimeout(function(){loaded()},1500); }, /** * [reportyub 报表组件,分页和不分页采用不同的实现方案] * @param {[type]} jparam [请求需要的报文体] * @return {[type]} [无] */ report:function(jparam){ window.RPT_CONTAINER_FLAG = true;//报表容器的标识 var isload = false; var _id = jparam.id?jparam.id:$.getID(); var _pagination = (true==jparam.pagination)?jparam.pagination:false; //是否显示分页工具栏 var _containerid = jparam.containerid?jparam.containerid:_DEFAULT_containerid; //容器的ID var _queryParams = jparam.queryParams?jparam.queryParams:{}; //url请求附带参数 var _isinit = jparam.isinit==undefined?true:jparam.isinit; //是否初始化 var _pageSize = jparam.pageSize?jparam.pageSize:200; var _pageList = jparam.pageList?jparam.pageList:[200,500,1000]; var _pageNumber = jparam.pageNumber?jparam.pageNumber:1; var _view = jparam.view?jparam.view:'default';//采用哪个方式,默认方式是后台画table;front代表前端绘制table var _onLoadSuccess = jparam.onLoadSuccess?$.event_getHandler(jparam.onLoadSuccess):function(data){}; var _onClickRow = jparam.onClickRow?$.event_getHandler(jparam.onClickRow):function(rowIndex, rowData){}; if(_pagination == true && false){ //分页时,采用改良过的easyui-datagird(Report)组件 $.biGrid(jparam); }else{ // _pagination = true; //不分页时,采用自己封装的基于jsp-taglib的table方式 var _traceid = $.getUUID(); //本次请求的唯一标识 var _data = $.extend({ _SERVICE_NAME:'metric_system'//默认让指标系统处理数据 }, _queryParams,{ _TRACEID:_traceid }); var su = $.getSessionUser(); if(su){ _data._BIZ_ACCOUNT_UUID = su.account_id; _data._BIZ_MANAGE_UUID = su.manageunituuid; } //如果是初始化,那就不需要数据(数据服务为空) if(_isinit){ _data["_SERVICE_NAME"] = ''; } //暂时把用户的信息丢到容器上去,子页面渲染完毕后,再获取 jparam.queryParams = _data; if(_view == 'default'){ $("#"+_containerid).data("report_data", jparam); //分不页的情况下,采用自定义的改造过的table展现 if($('#'+_id).length == 0){ var url = 'wdk?action=pf.report&method=renderReportHtml&ajaxparam='+new Date().getTime(); var form ="
" + " " + " " + " " + " " + " " + " " + "
"; var htmlstr = ''; if(_pagination == true){ htmlstr = '
'; } //$('#'+_containerid).append(''); $('#'+_containerid).append(htmlstr); var jForm = $(form).css('display','none'); jForm.appendTo('#'+_containerid); //第一次加载iframe时 window.initReport = function(){ if(isload==false){ frameLoadSuccess(true); } isload = true; } }else{ //第二次以后加载iframe frameLoadSuccess(false); } }else{ //前端方式绘制 $.cuajax({ url:'wdk?action=pf.report&method=report_chart_data&ajaxparam='+new Date().getTime(), method:"post", timeout:WDK_Timeout, data:{ data:$.json2str(_data) }, success:function(result) { var jres = $.str2json(result); if($('#'+_id).length>0){ renderTable(jres); } _onLoadSuccess(jres); loaded(); }, error:function(result){ loaded(); } }); } function frameLoadSuccess(init){ if(_pagination == true){ //分页时构建分页组件 $('#report_pagination').pagination({ total:0,//TODO pageList:_pageList, pageSize:_pageSize, pageNumber:_pageNumber, onSelectPage:function(pageNumber, pageSize){ $(this).pagination('loading'); loading(); $(this).pagination('refresh',{ pageNumber:pageNumber, pageSize:pageSize }); var jForm = $('#form_'+_id); var bigData = $.json2str($("#"+_containerid).data("report_data").queryParams); bigData = Base64.encode(bigData); jForm.find("input[name='data']").val(bigData);//赋值给iframe中表单的文本框中 jForm.find("input[name='rows']").val(pageSize); jForm.find("input[name='page']").val(pageNumber); jForm.submit();//提交数据 $(this).pagination('loaded'); }, onRefresh:function(pageNumber, pageSize){ } }); } var bigData = Base64.encode($.json2str(_data)); var jForm = $('#form_'+_id); jForm.find("input[name='orderbyfield']").val('');//每次点击查询,都清空内部的排序字段 jForm.find("input[name='data']").val(bigData);//赋值给iframe中表单的文本框中 if(_pagination == true){ jForm.find("input[name='rows']").val(_pageSize); jForm.find("input[name='page']").val(_pageNumber); } jForm.submit();//提交数据 } } /** * [renderTable 渲染表格] * @param {[type]} data [业务和数据] * @return {[type]} [无] */ function renderTable(data){ var containerStr = []; containerStr.push(''); containerStr.push(''); var htmlStr = []; if(data){ if(data.header){ htmlStr.push(''); for(var i=0;i'+data.header[i].text+''); } htmlStr.push(''); } if(data.data){ var htmlContent = data.data.map(function (d) { var str = []; str = data.header.map(function(d2){ var name = d2['id']; var value = d[name]; if(value == undefined){ value = ''; } return ''; }); return ""+str.join('')+""; }); htmlStr.push(htmlContent.join('')); } } var allrow = htmlStr.join(''); containerStr.push(allrow); containerStr.push('
'+value+'
'); $('#'+_id).html(containerStr.join('')); $('#report_content').on("click", "tr:not(:first-child)", function() { var index = $(this).parent().find("tr").index($(this)); //行号 if(index>0){ var rowData = {}; rowData.header = data.header; var oneData = []; oneData.push(data.data[index-1]); rowData.data = oneData; if(_onClickRow){ _onClickRow(index-1,rowData); } } }); } }, //大数据展现用gird biGrid:function(jparam){ loaded(); var _id = jparam.id?jparam.id:$.getID(); var _containerid = jparam.containerid?jparam.containerid:_DEFAULT_containerid; //容器的ID var _title = jparam.title?jparam.title:''; var _iconCls = jparam.iconCls?jparam.iconCls:'icon-edit'; var _width = jparam.width?jparam.width:'auto'; //宽度 var _height = jparam.height?jparam.height:'auto'; var _nowrap = (false==jparam.nowrap)?jparam.nowrap:true; //是否不折行 var _striped = (false==jparam.striped)?jparam.striped:true; //奇偶行不同颜色 //高度 //标题前的图标,可不设置 //标题,可不设置 var _fitColumns= jparam.fitColumns?jparam.fitColumns:false; //是否启用列自适应宽度,默认启用 var _border = (true==jparam.border)?jparam.border:false; //是否显示边框 var _collapsible = (true==jparam.collapsible)?jparam.collapsible:false; //是否可折叠的 var _fit = (false==jparam.fit)?jparam.fit:true; //自动大小 var _url = jparam.url?jparam.url:'wdk?action=pf.report&method=grid_query&ajaxparam='+new Date().getTime(); //grid数据获取url var _queryParams = jparam.queryParams?jparam.queryParams:{}; //url请求附带参数 var _pagination = (true==jparam.pagination)?jparam.pagination:false; //是否显示分页工具栏 var _rownumbers = (false==jparam.rownumbers)?jparam.rownumbers:true; //是否显示行号 var _pageSize = jparam.pageSize?jparam.pageSize:10; //默认每页记录数 var _pageList = jparam.pageList?jparam.pageList:[10,20,30,40,50]; //每页记录数列表 var _toolbar = jparam.toolbar?jparam.toolbar:null; //关联的工具栏ID var _footer = jparam.footer?jparam.footer:[]; //页脚统计行设置 var _keyHandler = jparam.keyHandler?jparam.keyHandler:null; //整个grid的handler var _mergeField = ''; var _formatter = jparam.formatter?jparam.formatter:{}; var _sortField = ''; if('string'==typeof(_sortField)){ _sortField = _sortField.split(','); } //格式化函数 //各类事件 var _onLoadSuccess = jparam.onLoadSuccess?$.event_getHandler(jparam.onLoadSuccess):function(data){}; var _onLoadError = jparam.onLoadError?$.event_getHandler(jparam.onLoadError):function(){}; var _onBeforeLoad = jparam.onBeforeLoad?$.event_getHandler(jparam.onBeforeLoad):function(param){}; var _onClickRow = jparam.onClickRow?$.event_getHandler(jparam.onClickRow):function(rowIndex, rowData){}; var _onCheck = jparam.onCheck?$.event_getHandler(jparam.onCheck):function(rowIndex, rowData){}; var _onUncheck = jparam.onUncheck?$.event_getHandler(jparam.onUncheck):function(rowIndex, rowData){}; var _onDblClickRow = jparam.onDblClickRow?$.event_getHandler(jparam.onDblClickRow):function(rowIndex,rowData){return true;}; var _onClickCell = jparam.onClickCell?$.event_getHandler(jparam.onClickCell):function(rowIndex, rowData,field,value){}; var _onDblClickCell = jparam.onDblClickCell?$.event_getHandler(jparam.onDblClickCell):function(rowIndex, rowData,field,value){}; var _onSortColumn = jparam.onSortColumn?$.event_getHandler(jparam.onSortColumn):function(sort, order){}; var _onResizeColumn = jparam.onResizeColumn?$.event_getHandler(jparam.onResizeColumn):function(field, width){}; var _onSelect = jparam.onSelect?$.event_getHandler(jparam.onSelect):function(rowIndex, rowData){}; var _onUnselect = jparam.onUnselect?$.event_getHandler(jparam.onUnselect):function(rowIndex, rowData){}; var _onSelectAll = jparam.onSelectAll?$.event_getHandler(jparam.onSelectAll):function(rows){}; var _onUnselectAll = jparam.onUnselectAll?$.event_getHandler(jparam.onUnselectAll):function(rows){}; var _onCheckAll = jparam.onCheckAll?$.event_getHandler(jparam.onCheckAll):function(rows){}; var _onUncheckAll = jparam.onUncheckAll?$.event_getHandler(jparam.onUncheckAll):function(rows){}; var _onBeforeEdit = jparam.onBeforeEdit?$.event_getHandler(jparam.onBeforeEdit):function(rowIndex, rowData){}; var _onAfterEdit = jparam.onAfterEdit?$.event_getHandler(jparam.onAfterEdit):function(rowIndex, rowData, changes){}; var _onCancelEdit = jparam.onCancelEdit?$.event_getHandler(jparam.onCancelEdit):function(rowIndex, rowData){}; var _onHeaderContextMenu = jparam.onHeaderContextMenu?$.event_getHandler(jparam.onHeaderContextMenu):function(){}; var _onRowContextMenu = jparam.onRowContextMenu?$.event_getHandler(jparam.onRowContextMenu):function(){}; var _caption_multystartcol = 0; //复合表头起始列 var _caption_level = 0; //复核表头层级 var _traceid = $.getUUID(); //本次请求的唯一标识 var _mergeColumns = []; if(_queryParams._FIXEDCOLUMNS){ for(var i=0;i<_queryParams._FIXEDCOLUMNS.length-1;i++){ var columncode = _queryParams._FIXEDCOLUMNS[i].fieldcode; if(!_queryParams._TRANSPOSE || _queryParams._TRANSPOSE.indexOf(columncode)==-1){ _mergeColumns.push(columncode); } } } var _data = $.extend({ _SERVICE_NAME:'metric_system'//默认让指标系统处理数据 }, _queryParams,{ _TRACEID:_traceid }); var _isinit = jparam.isinit==undefined?true:jparam.isinit; //是否初始化 //如果是初始化,那就不需要数据(数据服务为空) if(_isinit){ _data["_SERVICE_NAME"] = ''; } $('#'+_id).datagrid('loading'); $.cuajax({ url:'wdk?action=pf.report&method=grid_dyna_head&ajaxparam='+new Date().getTime(), method:"post", timeout:WDK_Timeout, data:{ data:$.json2str(_data) }, success:function(result) { var jparam = eval('('+result+')'); if('-1'==jparam.code){ }else if('0'==jparam.code){ $.getRoot().$.messager.alert('信息提示',jparam.desc,'warning'); }else{ try{ _initGrid(jparam.fields); }catch(e){ // alert('报表定义加载错误:'+e.message); $.getRoot().$.messager.alert('信息提示','报表定义加载错误:'+e.message,'error'); } } }, error:function(result){ // alert('网络错误!result='+result); $.getRoot().$.messager.alert('信息提示','网络错误:'+result,'error'); } }); function _initGridHead(fields){ //计算总层高 //计算合并行的属性 var isok = false; for(var i=0;i0){ pfield.rowspan = 1; pfield.colspan = colspan; }else{ // alert(pfield.fieldname+"= _caption_level="+_caption_level+" level="+level); pfield.rowspan = _caption_level-level; pfield.colspan = 1; } }; /** * 生成默认的grid html */ function _GridHTMLDefault(fields){ //1、生成默认html var arr = []; _initGridHead(fields); var frozenCol = 0; //需要冻结的列数 if(fields){ for(var i=0;i1&&frozenCol>_caption_multystartcol-1){ frozenCol = _caption_multystartcol-1; } //生成带colspan和rowspan的html arr.push(''); arr.push(' '); for(var i=0;i<_caption_level;i++){ arr.push(' '); //if(_checkbox&&0==i){ // arr.push(' '); //} for(var j=0;j'+jfield.fieldname+''); arr.push(' '); } } } arr.push(' '); arr.push(' '); arr.push(' '); for(var i=0;i<_caption_level;i++){ arr.push(' '); for(var j=frozenCol;j'+jfield.fieldname+''); arr.push(' '); } } } arr.push(' '); arr.push(' '); arr.push('
'+jfield.fieldname+'
'+jfield.fieldname+'
'); return arr.join(''); } //初始化grid function _initGrid(jparams){ var gridHTML = _GridHTMLDefault(jparams); $("#"+_containerid).html(gridHTML); //加载grid数据 if(_footer.length>0){ _queryParams.footer = $.json2str(_footer); } _queryParams.mergefield = _mergeField; _queryParams=$.formatParam(_queryParams); var gridParam = { gridid:_id, containerid:_containerid, title:_title, iconCls:_iconCls, //图标 width: _width, height: _height, nowrap: _nowrap, striped:_striped, /*fitColumns:_fitColumns,*/ border:_border, checkOnSelect:false, selectOnCheck:false, collapsible:_collapsible, //是否可折叠的 fit:_fit, //自动大小 url:_url, initdata:{}, toolbar:'#'+_toolbar, queryParams:{ data:$.json2str(_data) }, remoteSort:false, canMerge:true, copyrows:[], //被复制的行 enableedit:false, keyHandler:_keyHandler, footer:_footer, showFooter:_footer.length>0?true:false, singleSelect:true, //是否单选,始终false,始终可以多选,通过ctrl来控制 pagination:_pagination, //分页控件 rownumbers:_rownumbers, //行号 /*view:groupview, groupField:'company,brand',// 分组字段,可以多级 sumFormatter:function(groupname,rows){ var obj = {};//groupFormatter $.extend(obj,rows[0]); //obj.brand = '小计'; return obj; },*/ onLoadSuccess:function(data){ //var dc = $.data($('#'+_id).get(0),"report").dc; //删除当前表单的鼠标悬浮事件 //dc.body1.add(dc.body2).unbind('mouseover'); if(_mergeColumns.length>0){ //$.grid_merge(_id,_mergeColumns.join(',')); $('#'+_gridid).datagrid("autoMergeCells", _mergeColumns); } _onLoadSuccess(data); } }; if(_pagination == true){ gridParam.pageSize = _pageSize; //分页每页记录数 gridParam.pageList = _pageList; } $('#'+_id).datagrid(gridParam); //设置分页控件 if(_pagination){ var p = $('#'+_id).datagrid('getPager'); $(p).pagination({ pageSize: _pageSize,//每页显示的记录条数,默认为10 pageList: _pageList,//可以设置每页记录条数的列表 beforePageText: '第',//页数文本框前显示的汉字 afterPageText: '页 共 {pages} 页', displayMsg: '当前显示 {from} - {to} 条记录 共 {total} 条记录' }); } } } /** * 冻结行:onLoadSuccess中加入以下代码: * $(this).datagrid('freezeRow',0).datagrid('freezeRow',1); */ /** * */ }); $.extend({ getDateByWeek:function(year,week,weekStart,days){ weekStart = (weekStart || $.fn.weekcalendar.defaults.firstDay) - 0; if (isNaN(weekStart) || weekStart > 6) { weekStart = 0; } days = days||0; var firstDay = new Date(year, 0, 1); //第一周的天数 var firstWeekDays = 7 - firstDay.getDay() + weekStart; if (firstWeekDays > 7) { firstWeekDays -= 7; } firstDay.setDate(firstDay.getDate()+days+firstWeekDays+(week-2)*7); return firstDay; }, getLastWeek:function(_week,weekStart){ if(_week){ var week = {}; var date_start = new Date(); date_start.setTime(_week.date_start.getTime()); var date_end = new Date(); date_end.setTime(_week.date_end.getTime()); date_start.setDate(date_start.getDate()-7);//7天前; week.year = date_start.getFullYear(); week.week = date_start.getWeekOfYear(weekStart); week.date_start = date_start; date_end.setDate(date_end.getDate()-7); week.date_end = date_end; var m1 = date_start.getMonth()+1; var m2 = date_end.getMonth()+1; if(m2 < m1){ week.month = m2; }else{ week.month = m1; } return week; }else{ return _week; } } }); $.extend(Date.prototype, { // 计算当前日期在本年度的周数 getWeekOfYear: function(weekStart) { // weekStart:每周开始于周几:周日:0,周一:1,周二:2 ...,默认为周日 weekStart = (weekStart || $.fn.weekcalendar.defaults.firstDay) - 0; if (isNaN(weekStart) || weekStart > 6) { weekStart = 0; } var year = this.getFullYear(); var firstDay = new Date(year, 0, 1); var firstWeekDays = 7 - firstDay.getDay() + weekStart; if (firstWeekDays > 7) { firstWeekDays -= 7; } var dayOfYear = (((new Date(year, this.getMonth(), this.getDate())) - firstDay) / (24 * 3600 * 1000)) + 1; return Math.ceil((dayOfYear - firstWeekDays) / 7) + 1; }, // 计算当前日期在本月份的周数 getWeekOfMonth: function(weekStart) { weekStart = (weekStart || $.fn.weekcalendar.defaults.firstDay) - 0; if (isNaN(weekStart) || weekStart > 6) weekStart = 0; var dayOfWeek = this.getDay(); var day = this.getDate(); return Math.ceil((day - dayOfWeek - 1) / 7) + ((dayOfWeek >= weekStart) ? 1 : 0); }, // 计算是某年的第几天 getWhichDay : function() { //一天的秒数 var day_MillSeconds = 24 * 3600 * 1000, firstDay = new Date(this.getFullYear(), 0, 1); //新年第一天 //新年第一天 var dayOfYear = (this - firstDay) / day_MillSeconds + 1; return Math.ceil(dayOfYear); } }); (function($){ function _449(_44a){ var opts=$.data(_44a,"calendar").options; var t=$(_44a); opts.fit?$.extend(opts,t._fit()):t._fit(false); var _44b=t.find(".calendar-header"); t._outerWidth(opts.width); t._outerHeight(opts.height); t.find(".calendar-body")._outerHeight(t.height()-_44b._outerHeight()); }; function init(_44c){ $(_44c).addClass("calendar").html("
"+"
"+"
"+"
"+"
"+"
"+"Aprial 2010"+"
"+"
"+"
"+"
"+"
"+""+""+""+"
"+"
"+"
"+"
"+"
"); $(_44c).find(".calendar-title span").hover(function(){ $(this).addClass("calendar-menu-hover"); },function(){ $(this).removeClass("calendar-menu-hover"); }).click(function(){ var menu=$(_44c).find(".calendar-menu"); if(menu.is(":visible")){ menu.hide(); }else{ _453(_44c); } }); $(".calendar-prevmonth,.calendar-nextmonth,.calendar-prevyear,.calendar-nextyear",_44c).hover(function(){ $(this).addClass("calendar-nav-hover"); },function(){ $(this).removeClass("calendar-nav-hover"); }); $(_44c).find(".calendar-nextmonth").click(function(){ _44d(_44c,1); }); $(_44c).find(".calendar-prevmonth").click(function(){ _44d(_44c,-1); }); $(_44c).find(".calendar-nextyear").click(function(){ _450(_44c,1); }); $(_44c).find(".calendar-prevyear").click(function(){ _450(_44c,-1); }); $(_44c).bind("_resize",function(){ var opts=$.data(_44c,"calendar").options; if(opts.fit==true){ _449(_44c); } return false; }); }; function _44d(_44e,_44f){ var opts=$.data(_44e,"calendar").options; opts.month+=_44f; if(opts.month>12){ opts.year++; opts.month=1; }else{ if(opts.month<1){ opts.year--; opts.month=12; } } show(_44e); var menu=$(_44e).find(".calendar-menu-month-inner"); menu.find("td.calendar-selected").removeClass("calendar-selected"); menu.find("td:eq("+(opts.month-1)+")").addClass("calendar-selected"); }; function _450(_451,_452){ var opts=$.data(_451,"calendar").options; opts.year+=_452; show(_451); var menu=$(_451).find(".calendar-menu-year"); menu.val(opts.year); }; function _453(_454){ var opts=$.data(_454,"calendar").options; $(_454).find(".calendar-menu").show(); if($(_454).find(".calendar-menu-month-inner").is(":empty")){ $(_454).find(".calendar-menu-month-inner").empty(); var t=$("
").appendTo($(_454).find(".calendar-menu-month-inner")); var idx=0; for(var i=0;i<3;i++){ var tr=$("").appendTo(t); for(var j=0;j<4;j++){ $("").html(opts.months[idx++]).attr("abbr",idx).appendTo(tr); } } $(_454).find(".calendar-menu-prev,.calendar-menu-next").hover(function(){ $(this).addClass("calendar-menu-hover"); },function(){ $(this).removeClass("calendar-menu-hover"); }); $(_454).find(".calendar-menu-next").click(function(){ var y=$(_454).find(".calendar-menu-year"); if(!isNaN(y.val())){ y.val(parseInt(y.val())+1); } }); $(_454).find(".calendar-menu-prev").click(function(){ var y=$(_454).find(".calendar-menu-year"); if(!isNaN(y.val())){ y.val(parseInt(y.val()-1)); } }); $(_454).find(".calendar-menu-year").keypress(function(e){ if(e.keyCode==13){ _455(); } }); $(_454).find(".calendar-menu-month").hover(function(){ $(this).addClass("calendar-menu-hover"); },function(){ $(this).removeClass("calendar-menu-hover"); }).click(function(){ var menu=$(_454).find(".calendar-menu"); menu.find(".calendar-selected").removeClass("calendar-selected"); $(this).addClass("calendar-selected"); _455(); }); } function _455(){ var menu=$(_454).find(".calendar-menu"); var year=menu.find(".calendar-menu-year").val(); var _456=menu.find(".calendar-selected").attr("abbr"); if(!isNaN(year)){ opts.year=parseInt(year); opts.month=parseInt(_456); show(_454); } menu.hide(); }; var body=$(_454).find(".calendar-body"); var sele=$(_454).find(".calendar-menu"); var _457=sele.find(".calendar-menu-year-inner"); var _458=sele.find(".calendar-menu-month-inner"); _457.find("input").val(opts.year).focus(); _458.find("td.calendar-selected").removeClass("calendar-selected"); _458.find("td:eq("+(opts.month-1)+")").addClass("calendar-selected"); sele._outerWidth(body._outerWidth()); sele._outerHeight(body._outerHeight()); _458._outerHeight(sele.height()-_457._outerHeight()); }; function _459(_45a,year,_45b){ var opts=$.data(_45a,"calendar").options; var _45c=[]; var _45d=new Date(year,_45b,0).getDate(); for(var i=1;i<=_45d;i++){ _45c.push([year,_45b,i]); } var _45e=[],week=[]; var _45f=-1; while(_45c.length>0){ var date=_45c.shift(); week.push(date); var day=new Date(date[0],date[1]-1,date[2]).getDay(); if(_45f==day){ day=0; }else{ if(day==(opts.firstDay==0?7:opts.firstDay)-1){ _45e.push(week); week=[]; } } _45f=day; } if(week.length){ _45e.push(week); } var _460=_45e[0]; if(_460.length<7){ while(_460.length<7){ var _461=_460[0]; var date=new Date(_461[0],_461[1]-1,_461[2]-1); _460.unshift([date.getFullYear(),date.getMonth()+1,date.getDate()]); } }else{ var _461=_460[0]; var week=[]; for(var i=1;i<=7;i++){ var date=new Date(_461[0],_461[1]-1,_461[2]-i); week.unshift([date.getFullYear(),date.getMonth()+1,date.getDate()]); } _45e.unshift(week); } var _462=_45e[_45e.length-1]; while(_462.length<7){ var _463=_462[_462.length-1]; var date=new Date(_463[0],_463[1]-1,_463[2]+1); _462.push([date.getFullYear(),date.getMonth()+1,date.getDate()]); } if(_45e.length<6){ var _463=_462[_462.length-1]; var week=[]; for(var i=1;i<=7;i++){ var date=new Date(_463[0],_463[1]-1,_463[2]+i); week.push([date.getFullYear(),date.getMonth()+1,date.getDate()]); } _45e.push(week); } return _45e; }; function show(target){ var opts = $.data(target, 'calendar').options; $(target).find('.calendar-title span').html(opts.months[opts.month-1] + ' ' + opts.year); var body = $(target).find('div.calendar-body'); body.find('>table').remove(); var t = $('
').prependTo(body); var tr = $('').appendTo(t.find('thead')); tr.append(''+opts.weeks[0]+''); var afterWeeks = []; for(var i=1;i'+afterWeeks[i]+''); } for(var i=0; i'+afterWeeks[i]+''); } var weeks = _459(target, opts.year, opts.month); for(var i=0; i').appendTo(t.find('tbody')); var weekDay = week[0]; if (!(opts.year == weekDay[0] && opts.month == weekDay[1])){ weekDay=week[6]; } var weekValue = new Date(weekDay[0], parseInt(weekDay[1])-1, weekDay[2]).getWeekOfYear(opts.firstDay); tr.append(''+weekValue+'') for(var j=0; j').attr('abbr',day[0]+','+day[1]+','+day[2]).html(day[2]).appendTo(tr); } } t.find('td[abbr^="'+opts.year+','+opts.month+'"]').removeClass('calendar-other-month'); var now = new Date(); var today = now.getFullYear()+','+(now.getMonth()+1)+','+now.getDate(); t.find('td[abbr="'+today+'"]').addClass('calendar-today'); if (opts.week){ t.find('.calendar-week-selected').removeClass('calendar-week-selected'); t.find('td[name="'+opts.week+'"]').parent().addClass('calendar-week-selected'); } // calulate the saturday and sunday index var saIndex = 6 - opts.firstDay; var suIndex = saIndex + 1; if (saIndex >= 7) saIndex -= 7; if (suIndex >= 7) suIndex -= 7; saIndex = saIndex+1; suIndex = suIndex+1; t.find('tr').find('td:eq('+saIndex+')').addClass('calendar-saturday'); t.find('tr').find('td:eq('+suIndex+')').addClass('calendar-sunday'); t.find('tbody tr').hover( function(){$(this).addClass('calendar-hover');}, function(){$(this).removeClass('calendar-hover');} ).click(function(){ t.find('.calendar-selected').removeClass('calendar-selected'); $(this).addClass('calendar-selected'); var parts = $(this).find('.calendar-week').text(); var part1 = $(this).find('.calendar-day:first').attr('abbr').split(','); var part2 = $(this).find('.calendar-day:last').attr('abbr').split(','); opts.current = new Date(part1[0], parseInt(part1[1])-1, part1[2]); opts.onSelect.call(target, {year:parseInt(opts.year),week:parseInt(parts)}); }); }; $.fn.weekcalendar=function(_46b,_46c){ if(typeof _46b=="string"){ return $.fn.weekcalendar.methods[_46b](this,_46c); } _46b=_46b||{}; return this.each(function(){ var _46d=$.data(this,"calendar"); if(_46d){ $.extend(_46d.options,_46b); }else{ _46d=$.data(this,"calendar",{options:$.extend({},$.fn.weekcalendar.defaults,$.fn.calendar.parseOptions(this),_46b)}); init(this); } if(_46d.options.border==false){ $(this).addClass("calendar-noborder"); } _449(this); show(this); $(this).find("div.calendar-menu").hide(); }); }; $.fn.weekcalendar.methods={options:function(jq){ return $.data(jq[0],"calendar").options; },resize:function(jq){ return jq.each(function(){ _449(this); }); },moveTo:function(jq,date){ return jq.each(function(){ $(this).weekcalendar({year:date.year,month:date.month,week:date.week}); }); }}; $.fn.weekcalendar.defaults = { width:200, height:180, fit:false, border:true, firstDay:0, weeks:['周','日','一','二','三','四','五','六'], months:['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'], year:new Date().getFullYear(), month:new Date().getMonth()+1, current:(function(){ var d = new Date(); return new Date(d.getFullYear(), d.getMonth()+1, d.getDate()); })(), onSelect: function(date){} }; })(jQuery); $.parser.plugins.push("weekcalendar");//注册组件 (function($){ /** * create date box */ function createBox(target){ var state = $.data(target, 'weekbox'); var opts = state.options; opts.editable = false; $(target).addClass('datebox-f').combo($.extend({}, opts, { onShowPanel:function(){ setCalendarSize(); opts.onShowPanel.call(target); } })); $(target).combo('textbox').parent().addClass('datebox'); /** * if the calendar isn't created, create it. */ if (!state.weekcalendar){ createCalendar(); } function createCalendar(){ var panel = $(target).combo('panel'); state.weekcalendar = $('
').appendTo(panel).wrap('
'); var _firstDay = $.fn.weekcalendar.defaults.firstDay; if(opts.firstDay != undefined){ _firstDay = opts.firstDay; } state.weekcalendar.weekcalendar({ fit:true, border:false, firstDay:_firstDay, onSelect:function(date){ setValue(target, date); $(target).combo('hidePanel'); opts.onSelect.call(target, date); } }); setValue(target, opts.value); var button = $('
').appendTo(panel); var current_btn = $('').html(opts.currentText).appendTo(button); var close_btn = $('').html(opts.closeText).appendTo(button); var clear_btn = $('').html('清除').appendTo(button); var state2 = $.data(state.weekcalendar[0], 'calendar'); current_btn.click(function(){ var now = new Date(); var value = { year:now.getFullYear() ,month:now.getMonth()+1 ,week:now.getWeekOfYear(state2.options.firstDay) }; state.weekcalendar.weekcalendar(value); setValue(target, value); $(target).combo('hidePanel'); opts.onSelect.call(target,value); }); close_btn.click(function(){ $(target).combo('hidePanel'); }); clear_btn.click(function(){ setValue(target, ''); $(target).combo('hidePanel'); }); } function setCalendarSize(){ if (opts.panelHeight != 'auto'){ var panel = $(target).combo('panel'); var ci = panel.children('div.datebox-calendar-inner'); var height = panel.height(); panel.children().not(ci).each(function(){ height -= $(this).outerHeight(); }); ci._outerHeight(height); } state.weekcalendar.weekcalendar('resize'); } } /** * called when user inputs some value in text box */ function doQuery(target, q){ setValue(target, q); } /** * called when user press enter key */ function doEnter(target){ var state = $.data(target, 'weekbox'); var opts = state.options; var c = state.calendar; var value = opts.formatter(c.weekcalendar('options').current); setValue(target, value); $(target).combo('hidePanel'); } function setValue(target, value){ var state = $.data(target, 'weekbox'); var opts = state.options; if(value){ var state2 = $.data(state.weekcalendar[0], 'calendar'); var date_start = $.getDateByWeek(value.year,value.week,state2.options.firstDay,0); var mon1 = date_start.getMonth()+1; var date_end = $.getDateByWeek(value.year,value.week,state2.options.firstDay,6); var mon2 = date_end.getMonth()+1; if(mon2.datagrid-body{background-color:#FFF;}.dategroup>span{padding:0px;} .rp-search{float: left;height: 100%;margin-right: 100px;} .rp-buttons{position: absolute;top:0;bottom:0;right:0;min-width: 100px;padding:10px;display:table;height:100%;} .rp-buttons>div{display: table-row;} .calendar-week{ color: #2F2FDE; border-right: 1px solid #eee; padding: 0px 1px; cursor: pointer; } .calendar-day{ border-radius: 0px; -moz-border-radius: 0px; -webkit-border-radius: 0px; } .calendar-week-selected { background-color: #e6e6e6; }');