You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

940 lines
43 KiB
Plaintext

11 months ago

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>统计分析</title>
<link href="../Comm/Style/Table0.css" rel="stylesheet" type="text/css" />
<link href="../Scripts/easyUI/themes/default/easyui.css" rel="stylesheet" type="text/css" />
<link href="../Scripts/easyUI/themes/icon.css" rel="stylesheet" type="text/css" />
<script src="../Scripts/easyUI/jquery-1.8.0.min.js" type="text/javascript"></script>
<script src="../Scripts/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
<script src="../Comm/JS/Calendar/WdatePicker.js" type="text/javascript"></script>
<link href="../Comm/JS/Calendar/skin/WdatePicker.css" rel="stylesheet" type="text/css" />
<link href="../../DataUser/Style/ccbpm.css" rel="Stylesheet" />
<link href="../Scripts/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
<script src="../Scripts/EasyUIUtility.js" type="text/javascript"></script>
<!--引入图表-->
<script src="../Comm/FusionCharts/fusioncharts.js" type="text/javascript"></script>
<!--引入公共的JS-->
<script src="../Scripts/QueryString.js" type="text/javascript"></script>
<script src="../Scripts/config.js" type="text/javascript"></script>
<script src="../Comm/Gener.js" type="text/javascript"></script>
<script type="text/javascript">
//定义公共个变量.
var webUser = new WebUser();
var ensName = GetQueryString("EnsName");
var OrderBy = this.GetQueryString("OrderBy");
var OrderWay = this.GetQueryString("OrderWay");
var NumKey = this.GetQueryString("NumKey");
var fk_flow = GetQueryString("FK_Flow");
var groupType = GetQueryString("GroupType");
var rptNo = "ND" + parseInt(fk_flow) + "Rpt" + groupType;
var ur;
var searchAttrs;
//初始化页面
$(function () {
if (groupType == null)
groupType = GetQueryString("SearchType");
// $("#Msg").show();
//$("#Msg").css("line-height", $("body").height() / 1.5 + "px");
switch (groupType) {
case "My":
$("#mainDiv").panel({ title: '我发起的流程' });
break;
case "MyJoin":
$("#mainDiv").panel({ title: '我审批的流程' });
break;
case "MyDept":
$("#mainDiv").panel({ title: '部门发起的流程' });
break;
case "Adminer":
$("#mainDiv").panel({ title: '高级查询' });
break;
}
//初始化页面
InitPage();
//显示数据
// doPostBack();
// $("#Msg").html("");
});
//初始化数据.
function InitPage() {
//创建处理器.
var handler = new HttpHandler("BP.WF.HttpHandler.WF_RptDfine");
handler.AddPara("GroupType", groupType);
handler.AddPara("FK_Flow", GetQueryString("FK_Flow"));
//获得查询信息,包含了查询数据表.
var data = handler.DoMethodReturnString("FlowGroup_Init");
if (data.indexOf("err@") != -1) {
$.messager.alert("错误", data, "icon-error");
return;
}
data = ToJson(data);
//初始化按钮
InitToolBar(data);
//显示内容
DealGroupContent(data);
//分析项目
GroupAnalysis(data);
//分析结果显示
doPostBack(null, true);
}
function InitToolBar(data) {
//绑定外键枚举查询条件.
searchAttrs = data["FilterCtrls"];
var md = data.Sys_MapData[0];
//格式为: @WFSta=0@FK_Dept=02
//获取search的注册信息
var searchUR = new Entity("BP.Sys.UserRegedit");
searchUR.MyPK = webUser.No + rptNo + "_SearchAttrs";
searchUR.RetrieveFromDBSources();
var json = AtParaToJson(searchUR.Vals);
for (var i = 0; i < searchAttrs.length; i++) {
var attr = searchAttrs[i];
var str = "";
str += "<label for='CXDDL_" + attr.Field + "'>" + attr.Name + " : </label><select class='form-control' name='CXDDL_" + attr.Field + "' ID='DDL_" + attr.Field + "'>" + InitDDLOperation(data, attr, "all") + "</select>&nbsp;&nbsp;&nbsp;&nbsp;";
str = $(str);
$("#toolBar").prepend(str); //设置基础信息.
}
var html = "";
if (md.IsSearchKey == "1")
html += "<label for='TB_Key'>关键字:</label><input style='width:100px;' type=text id='TB_Key' name='TB_Key' value='" + searchUR.SearchKey + "' class='form-control' />&nbsp;&nbsp;&nbsp;&nbsp;";
if (md.DTSearchWay != "0") {
html += md.T_DateLabel;
if (md.DTSearchWay == "1") {
html += "<input type=text id='TB_DTFrom' name='TB_DTFrom' value='" + md.T_DTFrom + "' onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd'})\" style='width:120px;' class='form-control Wdate' />";
html += "到<input type=text id='TB_DTTo' name='TB_DTTo' value='" + md.T_DTTo + "' onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd'})\" style='width:120px;' class='form-control Wdate' />&nbsp;&nbsp;&nbsp;&nbsp;";
} else {
html += "<input type=text id='TB_DTFrom' name='TB_DTFrom' value='" + md.T_DTFrom + "' onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});\" style='width:135px;' class='form-control Wdate' />";
html += "到<input type=text id='TB_DTTo' name='TB_DTTo' value='" + md.T_DTTo + "' onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});\" style='width:135px;' class='form-control Wdate' />&nbsp;&nbsp;&nbsp;&nbsp;";
}
}
//当前用户页面信息.
var searchUr = new Entity("BP.Sys.UserRegedit");
searchUr.MyPK = webUser.No + "_" + ensName + "_SearchAttrs";
searchUr.RetrieveFromDBSources();
var json = AtParaToJson(searchUr.Vals);
$("#toolBar").prepend(html); //设置基础信息.
//为查询外键赋值.
for (var i = 0; i < searchAttrs.length; i++) {
var attr = searchAttrs[i];
var selectVal = json[attr.Field];
if (selectVal == undefined || selectVal == "")
selectVal = "all";
$("#DDL_" + attr.Field).val(selectVal);
}
}
//初始化下拉列表框的OPERATION
function InitDDLOperation(frmData, mapAttr, defVal) {
var operations = "";
var ens = frmData[mapAttr.Field];
if (ens == null) {
ens = [{ 'IntKey': 0, 'Lab': '否' }, { 'IntKey': 1, 'Lab': '是' }];
}
for (var i = 0; i < ens.length; i++) {
var en = ens[i];
var selected = "";
if (en.Selected && en.Selected.toString() == "true")
selected = "selected=selected";
if (en.No == undefined)
operations += "<option value='" + en.IntKey + "' " + selected + ">" + en.Lab + "</option>";
else
operations += "<option value='" + en.No + "' " + selected + ">" + en.Name + "</option>";
}
return operations;
}
function DealGroupContent(data) {
//创建处理器.
var groupAttrs = data["Group_MapAttr"];
if (groupAttrs.length == 0) {
alert("[" + document.title + "]没有外键或枚举,不能做分组查询.");
return;
}
for (var i = 0; i < groupAttrs.length; i++) {
var html = "";
var checked = "";
if (groupAttrs[i].Checked && groupAttrs[i].Checked.toString() == "true") {
checked = "checked=checked";
}
html += "<tr>";
html += "<td>";
html += "<label for='" + groupAttrs[i].Field + "'><input type='checkbox' id='" + groupAttrs[i].Field + "' name='groupContent' " + checked + " onclick='javascript:doPostBack(this,true)' value='" + groupAttrs[i].Field + "'/>" + groupAttrs[i].Name + "</label>";
html += "</td>";
html += "</tr>";
$("#CheckBoxList").append(html);
}
}
function GroupAnalysis(data) {
//创建处理器.
var analyAtts = data["Analysis_MapAttr"];
for (var i = 0; i < analyAtts.length; i++) {
var html = "";
var checked = "";
if (analyAtts[i].Checked && analyAtts[i].Checked.toString() == "true") {
checked = "checked=checked";
}
html += "<tr>";
html += "<td align='center'>";
html += "<label for='" + analyAtts[i].Field + "'><input type='checkbox' id='" + analyAtts[i].Field + "' name='groupAnaly' " + checked + " onclick='javascript:doPostBack(this,true)' value='" + analyAtts[i].Field + "'/>" + analyAtts[i].Name + "</label>";
html += "</td>";
html += "<td style='font-size:12px;text-align:right;padding:5px;'>";
html += "<select style='width:80%' class='form-control' name='DDL_" + analyAtts[i].Field + "' ID='DDL_" + analyAtts[i].Field + "' onchange='javascript:doPostBack(this,true)'>" + InitDDLOperation(data, analyAtts[i], null) + "</select>&nbsp;&nbsp;&nbsp;&nbsp;";
html += "</td>";
html += "</tr>";
$("#AnalyGroup").append(html);
}
}
function doPostBack(scorp, ispost) {
//给注册表信息重新赋值
var myPK = webUser.No + rptNo + "_GroupAttrs";
ur = new Entity("BP.Sys.UserRegedit", myPK);
if (ur && ur.IsPic == 1 && ispost == true) {
document.getElementById("CB_IsShowPict").checked = "checked";
}
var groupCount = $('input[name="groupContent"]:checked').length;
if (groupCount > 1) {
if (ispost == true) {
ur.IsPic = 0;
document.getElementById("CB_IsShowPict").checked = "";
}
$("#CB_IsShowPict").attr("disabled", "disabled");
}
else {
$("#CB_IsShowPict").attr("disabled", false);
}
var selectedGroupKey = "";
$('input[name="groupContent"]:checked').each(function () {
selectedGroupKey += '@' + $(this).val(); //将选中的值添加到数组chk_value中
});
var stateNumKey = "";
$('input[name="groupAnaly"]:checked').each(function () {
var key = $(this).val();
//获取下拉框的值
var defVal = $("#DDL_" + key).val();
stateNumKey += '@' + $(this).val() + '=' + defVal; //将选中的值添加到数组chk_value中
});
ur.Vals = "SelectedGroupKey=" + selectedGroupKey + "@StateNumKey" + stateNumKey + '@';
if (ispost == false) {
if ($("#CB_IsShowPict").is(":checked") == true) {
ur.IsPic = 1;
} else {
ur.IsPic = 0;
}
}
ur.SetPKVal(ur.MyPK);
ur.FK_Emp = webUser.No;
ur.CfgKy = ensName;
ur.Save();
Group_Search();
}
function Group_Search() {
//创建处理器.
var handler = new HttpHandler("BP.WF.HttpHandler.WF_RptDfine");
handler.AddUrlData(); //增加参数.
handler.AddFormData();
var groupList = "";
$('input[name="groupContent"]').each(function () {
groupList += '@' + $(this).val(); //将选中的值添加到数组chk_value中
});
handler.AddPara("GroupList", groupList);
var data = handler.DoMethodReturnString("FlowGropu_Done");
if (data.indexOf('err@') != -1) {
alert(data);
return;
}
if (data.indexOf('info@') != -1) {
data = data.replace("info@", "");
$("#Content").html("").append(data);
return;
}
var data = JSON.parse(data);
var groupSearch = data["GroupSearch"];
var AttrsOfNum = data["AttrsOfNum"];
var AttrsOfGroup = data["AttrsOfGroup"];
var ActiveAttr = data["ActiveAttr"];
var noShowSum = "";
//生成表格
if ($("#CB_IsShowPict").is(":checked") == false) {
GenerTable("Content", groupSearch, AttrsOfNum, AttrsOfGroup, ur, ActiveAttr, noShowSum);
//生成图表
} else {
GenerChart(groupSearch, AttrsOfGroup, AttrsOfNum, ur, ActiveAttr, noShowSum);
}
}
function GenerTable(divId, groupSearch, AttrsOfNum, AttrsOfGroup, ur, ActiveAttr, noShowSum) {
var flowNo = GetQueryString("FK_Flow");
var groupType = GetQueryString("GroupType");
var html = "<table id='mainTable' class='table table-bordered table-hover' style='text-align:center;'> ";
//生成表头
/**含有合计的时候**/
if (ur.Vals.indexOf("=AMOUNT") != -1) {
html += "<tr>";
html += "<td rowspan=2 class='GroupTitle'>ID</td>";
for (var i = 0; i < AttrsOfGroup.length; i++) {
html += "<td rowspan=2 class='GroupTitle'>" + AttrsOfGroup[i].Name + "</td>";
}
// 增加数据列
for (var i = 0; i < AttrsOfNum.length; i++) {
if (ur.Vals.indexOf.indexOf(AttrsOfNum[i].KeyOfEn + "=AMOUNT") != -1)
/* 如果本数据列 包含累计 */
html += "<td colspan=2 class='GroupTitle' >" + AttrsOfNum[i].Name + "</td>";
else
html += "<td rowspan=2 class='GroupTitle' >" + AttrsOfNum[i].Name + "</td>";
}
html += "</tr>";
html += "<tr>";
for (var i = 0; i < AttrsOfNum.length; i++) {
if (ur.Vals.indexOf(AttrsOfNum[i].KeyOfEn + "=AMOUNT") == -1)
continue;
html += "<td class='GroupTitle'>本月</td>"; //本月 this.ToE("OrderCondErr")
html += "<td class='GroupTitle'>累计</td>"; //累计
}
html += "</tr>";
} else {
html += "<tr>";
html += "<td class='GroupTitle' style='text-align:center' >序</td>";
html += "</td>";
// 分组条件
for (var i = 0; i < AttrsOfGroup.length; i++) {
if (OrderBy == AttrsOfGroup[i].KeyOfEn) {
switch (OrderWay) {
case "Down":
html += "<td class='GroupTitle' nowrap><a href='Group.htm?FK_Flow=" + flowNo + "&GroupType=" + groupType + "&OrderBy=" + AttrsOfGroup[i].KeyOfEn + "&OrderWay=Up' >" + AttrsOfGroup[i].Name + "<img src='../Img/ArrDown.gif' border=0/></a></td>";
break;
case "Up":
default:
html += "<td class='GroupTitle' nowrap><a href='Group.htm?FK_Flow=" + flowNo + "&GroupType=" + groupType + "&OrderBy=" + AttrsOfGroup[i].KeyOfEn + "&OrderWay=Down' >" + AttrsOfGroup[i].Name + "<img src='../Img/ArrUp.gif' border=0/></a></td>";
break;
}
}
else {
html += "<td class='GroupTitle' nowrap><a href='Group.htm?FK_Flow=" + flowNo + "&GroupType=" + groupType + "&OrderBy=" + AttrsOfGroup[i].KeyOfEn + "&OrderWay=Down' >" + AttrsOfGroup[i].Name + "</a></td>";
}
}
// 分组数据
for (var i = 0; i < AttrsOfNum.length; i++) {
var lab = "";
if (ur.Vals.indexOf(AttrsOfNum[i].KeyOfEn + "=SUM") != -1) {
lab = "(合计)" + AttrsOfNum[i].Name;
}
else {
lab = "(平均)" + AttrsOfNum[i].Name;
}
if (OrderBy == AttrsOfNum[i].KeyOfEn) {
switch (OrderWay) {
case "Down":
if (NumKey == AttrsOfNum[i].KeyOfEn)
html += "<td class='GroupTitle' nowrap>" + lab + "<a href='Group.htm?FK_Flow=" + flowNo + "&GroupType=" + groupType + "&NumKey=" + AttrsOfNum[i].KeyOfEn + "&OrderBy=" + AttrsOfNum[i].KeyOfEn + "&OrderWay=Up'><img src='../Img/ArrDown.gif' border=0/></a></td>";
else
html += "<td class='GroupTitle' nowrap><a href=\"Group.htm?FK_Flow=" + flowNo + "&GroupType=" + groupType + "&NumKey=" + AttrsOfNum[i].KeyOfEn + "\" >" + lab + "</a><a href='Group.htm?EnsName=" + ensName + "&NumKey=" + AttrsOfNum[i].KeyOfEn + "&OrderBy=" + AttrsOfNum[i].KeyOfEn + "&OrderWay=Up'><img src='../Img/ArrDown.gif' border=0/></a></td>";
break;
case "Up":
default:
if (NumKey == AttrsOfNum[i].KeyOfEn)
html += "<td class='GroupTitle' nowrap>" + lab + "<a href='Group.htm?FK_Flow=" + flowNo + "&GroupType=" + groupType + "&OrderBy=" + AttrsOfNum[i].KeyOfEn + "&NumKey=" + AttrsOfNum[i].KeyOfEn + "&OrderWay=Down'><img src='../Img/ArrUp.gif' border=0/></a></td>";
else
html += "<td class='GroupTitle' nowrap><a href=\"Group.htm?FK_Flow=" + flowNo + "&GroupType=" + groupType + "&NumKey=" + AttrsOfNum[i].KeyOfEn + "\" >" + lab + "</a><a href='Group.htm?EnsName=" + ensName + "&OrderBy=" + AttrsOfNum[i].KeyOfEn + "&NumKey=" + AttrsOfNum[i].KeyOfEn + "&OrderWay=Down'><img src='../Img/ArrUp.gif' border=0/></a></td>";
break;
}
}
else {
if (NumKey == AttrsOfNum[i].KeyOfEn)
html += "<td class='GroupTitle' nowrap>" + lab + "<a href='Group.htm?FK_Flow=" + flowNo + "&GroupType=" + groupType + "&NumKey=" + AttrsOfNum[i].KeyOfEn + "&OrderBy=" + AttrsOfNum[i].KeyOfEn + "' ><img src='../Img/ArrDownUp.gif' border=0/></a></td>";
else
html += "<td class='GroupTitle' nowrap><a href=\"Group.htm?FK_Flow=" + flowNo + "&GroupType=" + groupType + "&NumKey=" + AttrsOfNum[i].KeyOfEn + "\" >" + lab + "</a><a href='Group.htm?GroupType=" + groupType + "&FK_Flow=" + flowNo + "&NumKey=" + AttrsOfNum[i].KeyOfEn + "&OrderBy=" + AttrsOfNum[i].KeyOfEn + "' ><img src='../Img/ArrDownUp.gif' border=0/></a></td>";
}
}
html += "<td class='GroupTitle' nowrap></td>";
}
html += "</tr>"
//生成详情的url searchAttrs
var baseUrl = "ContrastDtl.htm?SearchType=" + groupType + "&FK_Flow=" + fk_flow;
var keys = "";
// 分组的信息中是否包含部门?
var IsHaveFK_Dept = false;
if (ur.Vals.indexOf("FK_Dept") != -1)
IsHaveFK_Dept = true;
for (var i = 0; i < searchAttrs.length; i++) {
var attr = searchAttrs[i];
if (attr.MyFieldType == 6)
continue;
if (IsHaveFK_Dept && attr.Field == "FK_Dept")
continue;
var val = $("#DDL_" + attr.Field).val();
if (val == "all")
continue;
if (keys.indexOf(attr.Field) == -1)
keys += "&" + attr.Field + "=" + val;
}
baseUrl = baseUrl + keys;
//生成数据行
for (var i = 0; i < groupSearch.length; i++) {
var url = "";
var dr = groupSearch[i];
$.each(AttrsOfGroup, function (k, o) {
if (url.indexOf(o.KeyOfEn) == -1)
url += "&" + o.KeyOfEn + "=" + dr[o.KeyOfEn];
});
if ((i + 1) % 2 == 0)
html += "<tr bgcolor='AliceBlue' >";
else
html += "<tr bgcolor='white' >";
html += "<td class='Idx' nowrap>" + dr.IDX + "</td>";
for (var j = 0; j < AttrsOfGroup.length; j++) {
html += "<td nowrap >" + dr[AttrsOfGroup[j].KeyOfEn + "T"] + "</td>";
}
for (var j = 0; j < AttrsOfNum.length; j++) {
var obj = dr[AttrsOfNum[j].KeyOfEn];
if (AttrsOfNum[j].MyDataType == 8) {
if (ur.Vals.indexOf(AttrsOfNum[j].KeyOfEn + "=AMOUNT") != -1) {
//需要转换为金额类型,小数位数不到两位的补全,功能待定
html += "<td class=' ' nowrap >" + obj + "</td>";
html += "<td class=' ' nowrap >" + dr[AttrsOfNum[j].KeyOfEn + "Amount"] + "</td>";
} else {
html += "<td class=' ' nowrap >" + obj + "</td>";
}
} else {
if (ur.Vals.indexOf(AttrsOfNum[j].KeyOfEn + "=AMOUNT") != -1) {
html += "<td class=' ' nowrap >" + obj + "</td>";
html += "<td class=' ' nowrap >" + dr[AttrsOfNum[j].KeyOfEn + "Amount"] + "</td>";
} else {
html += "<td class=' ' nowrap >" + obj + "</td>";
}
}
}
url = baseUrl + url;
html += "<td style=''><a href=\"javascript:WinOpen('" + url + "', 'wincommgroup',900,900);\" class='btn btn-default btn-sm easyui-linkbutton'>详细</a></td>";
html += "</tr>";
}
//汇总信息
html += "<tr class='TRSum'>";
html += "<td nowrap>汇总</td>";
for (var j = 0; j < AttrsOfGroup.length; j++) {
html += "<td nowrap ></td>";
}
var AttrsOfNum1 = AttrsOfNum;
var d = 0;
for (var i = 0; i < AttrsOfNum.length; i++) {
if (noShowSum.indexOf("@" + AttrsOfNum[i].KeyOfEn + "@") != -1) {
var isHave = false;
for (var j = 0; j < ActiveAttr.length; j++) {
if (ActiveAttr[j].AttrKey != AttrsOfNum[i].KeyOfEn)
continue;
isHave = true;
var exp = ActiveAttr[j].ExpApp;
if (exp == null || exp == "") {
html += "<td></td>";
break;
}
for (var k = 0; k < AttrsOfNum1.length; k++) {
if (exp.indexOf("@" + AttrsOfNum1[k].KeyOfEn + "@") != -1) {
d = 0;
$.each(groupSearch, function (i, o) {
d += parseFloat(o[AttrsOfNum1[k].KeyOfEn]);
});
exp = exp.replace("@" + AttrsOfNum1[k].KeyOfEn + "@", d);
}
}
var handler = new HttpHandler("BP.WF.HttpHandler.WF_Comm");
handler.AddPara("Exp", exp);
var data = handler.DoMethodReturnString("ParseExpToDecimal");
//待定
html += "<td class=' ' nowrap >" + data.toFixed(4) + "</td>";
}
if (isHave == false)
html += "<td></td>";
continue;
}
switch (AttrsOfNum[i].MyDataType) {
case 8:
if (ur.Vals.indexOf(AttrsOfNum[i].KeyOfEn + "=AMOUNT") != -1) {
d = 0;
$.each(groupSearch, function (k, o) {
d += parseFloat(o[AttrsOfNum[i].KeyOfEn]);
});
html += "<td class=' ' nowrap >" + d.toFixed(4) + "</td>";
d = 0;
$.each(groupSearch, function (k, o) {
d += parseFloat(o[AttrsOfNum[i].KeyOfEn + "Amount"]);
});
html += "<td class=' ' nowrap >" + d.toFixed(4) + "</td>";
}
else {
d = 0;
$.each(groupSearch, function (k, o) {
d += parseFloat(o[AttrsOfNum[i].KeyOfEn + "Amount"]);
});
if (ur.Vals.indexOf(AttrsOfNum[i].KeyOfEn + "=AVG") < 1)
html += "<td class=' ' nowrap >" + d.toFixed(4) + "</td>";
else {
if (groupSearch.length == 0)
html += "<td class=' ' nowrap >0</td>";
else
html += "<td class=' ' nowrap >" + (d / groupSearch.length).toFixed(4) + "</td>";
}
}
break;
default:
if (ur.Vals.indexOf(AttrsOfNum[i].KeyOfEn + "=AMOUNT") != -1) {
d = 0;
$.each(groupSearch, function (k, o) {
d += parseFloat(o[AttrsOfNum[i].KeyOfEn]);
});
html += "<td class=' ' nowrap >" + d + "</td>";
d = 0;
$.each(groupSearch, function (k, o) {
d += parseFloat(o[AttrsOfNum[i].KeyOfEn + "Amount"]);
});
html += "<td class=' ' nowrap >" + d + "</td>";
} else {
d = 0;
$.each(groupSearch, function (k, o) {
d += parseFloat(o[AttrsOfNum[i].KeyOfEn]);
});
if (ur.Vals.indexOf(AttrsOfNum[i].KeyOfEn + "=AVG") == -1)
html += "<td class=' ' nowrap >" + d + "</td>";
else {
if (groupSearch.length == 0)
html += "<td class=' ' nowrap >0</td>";
else
html += "<td class=' ' nowrap >" + (d / groupSearch.length).toFixed(4) + "</td>";
}
}
break;
}
}
html += "<td class='TDNum' nowrap ></td>";
html += "</tr>";
html += "</table>";
$("#" + divId).html("");
$("#" + divId).html(html);
}
function GenerChart(groupSearch, AttrsOfGroup, AttrsOfNum, ur, ActiveAttr, noShowSum) {
var html = "";
//增加分组
html += "<div class='easyui-tabs' data-options=\"fit:true\">";
html += "<div id='table_div' title='分组数据' data-options=\"iconCls:'icon-table'\" style='padding:5px'></div>";
//增加柱状图像
html += "<div id='column_chart_div' title='柱状图' data-options=\"iconCls:'icon-columnchart'\" style='padding:5px;text-align:center'></div>";
//增加饼图
html += "<div id='pie_chart_div' title='饼状图' data-options=\"iconCls:'icon-piechart'\" style='padding:5px;text-align:center'></div>";
//增加折线图
html += "<div id='line_chart_div' title='折线图' data-options=\"iconCls:'icon-linechart'\" style='padding:5px;text-align:center'></div>";
html += "</div>";
var width = $("#TB_W").val();
if (width == "" || width == 0)
width = 300;
var height = $("#TB_H").val();
if (height == "" || height == 0)
height = 300;
$("#Content").html("").append(html);
$.parser.parse("#Content");
//获取url项目的名称
var projectName = "";
if (plant != "CCFlow") {
var pathName = window.location.pathname.substring(1); //jflow-web/WF/Comm/Group.htm
projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
}
GenerTable("table_div", groupSearch, AttrsOfNum, AttrsOfGroup, ur, ActiveAttr, noShowSum);
GenerateColumnChart(groupSearch, AttrsOfGroup[0].KeyOfEn, AttrsOfNum, width, height, projectName);
GeneratePieChart(groupSearch, AttrsOfGroup[0].KeyOfEn, AttrsOfNum, width, height, projectName);
GenerateLineChart(groupSearch, AttrsOfGroup[0].KeyOfEn, AttrsOfNum, width, height, projectName);
}
//柱状图像
function GenerateColumnChart(groupSearch, KeyOfEn, AttrsOfNum, w, h, projectName) {
var categories = "[{\"category\": [";
for (var i = 0; i < groupSearch.length; i++) {
categories += "{ \"label\":\"" + groupSearch[i][KeyOfEn + "T"] + "\"},";
}
if (groupSearch.length > 0) {
categories = categories.substr(0, categories.length - 1);
}
categories += "]}]";
categories = JSON.parse(categories);
var dataSet = "[";
for (var i = 0; i < AttrsOfNum.length; i++) {
if (AttrsOfNum[i].Name == null || AttrsOfNum[i].Name == "")
continue;
dataSet += "{\"seriesname\":\"" + AttrsOfNum[i].Name + "\",\"data\":[";
for (var j = 0; j < groupSearch.length; j++) {
dataSet += "{\"value\":\"" + +groupSearch[j][AttrsOfNum[i].KeyOfEn] + "\"},";
}
if (groupSearch.length > 0) {
dataSet = dataSet.substr(0, dataSet.length - 1);
}
dataSet += "]},";
}
dataSet = dataSet.substr(0, dataSet.length - 1);
dataSet += "]";
dataSet = JSON.parse(dataSet);
var dataSource = {
"chart": {
"exportEnabled": '0',
"exportAtClient": '1',
"exportHandler": 'fcExporter1',
"exportFormats": 'PNG=生成PNG图片|JPG=生成JPG图片|PDF=生成PDF文件',
"decimalPrecision": '4',
"hoverCapBgColor": 'ffffff', "bgColor": 'B8D288,FFFFFF', "outCnvBaseFontSize": '12', "anchorBgColor": '008ED6', "caption": document.title,
"AlternateHGridColor": 'ff5904', "divLineColor": 'ff5904', "divLineAlpha": '20', "alternateHGridAlpha": '5',
"showNames": '1', "showValues": '1', "showAlternateHGridColor": '1',
"decimalPrecision": '0', "formatNumberScale": '0'
},
"categories": categories,
"dataset": dataSet
};
FusionCharts.ready(function () {
var myChart = new FusionCharts({
type: "mscolumn2d",
renderAt: "chart-container",
width: w,
height: h,
dataFormat: "json",
dataSource: dataSource
}).render("column_chart_div");
});
}
//饼图
function GeneratePieChart(groupSearch, KeyOfEn, AttrsOfNum, w, h, projectName) {
var firstKey = AttrsOfNum[0];
var categories = "[{\"category\": [";
for (var i = 0; i < groupSearch.length; i++) {
categories += "{ \"label\":\"" + groupSearch[i][KeyOfEn + "T"] + "\"},";
}
if (groupSearch.length > 0) {
categories = categories.substr(0, categories.length - 1);
}
categories += "]}]";
categories = JSON.parse(categories);
var dataSet = "[{\"data\":[";
for (var j = 0; j < groupSearch.length; j++) {
dataSet += "{\"label\":\"" + groupSearch[j][KeyOfEn + "T"] + "\",\"value\":\"" + +groupSearch[j][firstKey.KeyOfEn] + "\" },";
}
if (groupSearch.length > 0) {
dataSet = dataSet.substr(0, dataSet.length - 1);
}
dataSet += "]}]";
dataSet = JSON.parse(dataSet);
var dataSource = {
"chart": {
//"exportEnabled": '0',
//"exportAtClient": '1',
//"exportHandler": 'fcExporter1',
// "exportFormats": 'PNG=生成PNG图片|JPG=生成JPG图片|PDF=生成PDF文件',
"caption": document.title + "-" + firstKey.Name,
"showValues": "1",
"numberSuffix": "%",
"theme": "hulk-light",
"enableMultiSlicing": "1",
"outCnvBaseFontColor": 'FFFFFF',
"hoverCapBgColor": '2E4A89',
//"basefontcolor": 'ccdee',
"basefontsize": '14',
"bgColor": '2E4A89, 90B1DE', "palette": '2', "animation": '1',
"formatNumberScale": '0', "pieSliceDepth": '30', "startingAngle": '125'
},
"dataset": dataSet
};
FusionCharts.ready(function () {
var myChart = new FusionCharts({
type: "Pie3d",
renderAt: "chart-container",
width: w,
height: h,
dataFormat: "json",
dataSource: dataSource
}).render("pie_chart_div");
});
}
//折线图
function GenerateLineChart(groupSearch, KeyOfEn, AttrsOfNum, w, h, projectName) {
var categories = "[{\"category\": [";
for (var i = 0; i < groupSearch.length; i++) {
categories += "{ \"label\":\"" + groupSearch[i][KeyOfEn + "T"] + "\"},";
}
if (groupSearch.length > 0) {
categories = categories.substr(0, categories.length - 1);
}
categories += "]}]";
categories = JSON.parse(categories);
var dataSet = "[";
for (var i = 0; i < AttrsOfNum.length; i++) {
if (AttrsOfNum[i].Name == null || AttrsOfNum[i].Name == "")
continue;
dataSet += "{\"seriesname\":\"" + AttrsOfNum[i].Name + "\",\"data\":[";
for (var j = 0; j < groupSearch.length; j++) {
dataSet += "{\"value\":\"" + +groupSearch[j][AttrsOfNum[i].KeyOfEn] + "\"},";
}
if (groupSearch.length) {
dataSet = dataSet.substr(0, dataSet.length - 1);
}
dataSet += "]},";
}
dataSet = dataSet.substr(0, dataSet.length - 1);
dataSet += "]";
dataSet = JSON.parse(dataSet);
var dataSource = {
"chart": {
"exportEnabled": '0',
"exportAtClient": '1',
"exportHandler": 'fcExporter1',
"exportFormats": 'PNG=生成PNG图片|JPG=生成JPG图片|PDF=生成PDF文件',
"decimalPrecision": '4',
"hoverCapBgColor": 'ffffff', "bgColor": 'B8D288,FFFFFF', "outCnvBaseFontSize": '12', "anchorBgColor": '008ED6', "caption": document.title,
"AlternateHGridColor": 'ff5904', "divLineColor": 'ff5904', "divLineAlpha": '20', "alternateHGridAlpha": '5',
"showNames": '1', "showValues": '1', "showAlternateHGridColor": '1',
"decimalPrecision": '0', "formatNumberScale": '0'
},
"categories": categories,
"dataset": dataSet
};
FusionCharts.ready(function () {
var myChart = new FusionCharts({
type: "MSLine",
renderAt: "chart-container",
width: w,
height: h,
dataFormat: "json",
dataSource: dataSource
}).render("line_chart_div");
});
}
function Search() {
//保存查询条件.
var ensName = GetQueryString("EnsName");
var ur = new Entity("BP.Sys.UserRegedit");
ur.MyPK = webUser.No + rptNo + "_SearchAttrs";
ur.FK_Emp = webUser.No;
if ($("#TB_Key") != null && $("#TB_Key").val() != "")
ur.SearchKey = $("#TB_Key").val();
else
ur.SearchKey = "";
//设置查询时间.
if ($("#TB_DTFrom").length == 1)
ur.DTFrom = $("#TB_DTFrom").val();
if ($("#TB_DTTo").length == 1)
ur.DTTo = $("#TB_DTTo").val();
//获得外键的查询条件,存储里面去.
var str = "";
$("select[name^='CXDDL_']").each(function () {
var id = $(this).attr("id");
if ($(this).val() != "all")
str += "@" + id + "=" + $(this).val();
});
ur.CfgKey = rptNo + "_SearchAttrs";
ur.Vals = str;
ur.FK_MapData = ensName;
//ur.SetPara("RecCount", count);
ur.Save();
//查询
Group_Search();
}
function Exp() {
var handler = new HttpHandler("BP.WF.HttpHandler.WF_RptDfine");
handler.AddPara("EnsName", GetQueryString("EnsName"));
handler.AddUrlData(); //增加参数.
handler.AddFormData();
var groupList = "";
$('input[name="groupContent"]').each(function () {
groupList += '@' + $(this).val(); //将选中的值添加到数组chk_value中
});
handler.AddPara("GroupList", groupList);
//查询集合
var data = handler.DoMethodReturnString("FlowGroup_Exp");
var url = "";
if (data.indexOf('err@') == 0) {
alert(data);
}
data = basePath + data;
window.open(data);
return;
}
function WinOpen(url, winName) {
var newWindow = window.open(url, winName, 'height=800,width=1030,top=' + (window.screen.availHeight - 800) / 2 + ',left=' + (window.screen.availWidth - 1030) / 2 + ',scrollbars=yes,resizable=yes,toolbar=false,location=false,center=yes,center: yes;');
newWindow.focus();
return;
}
</script>
</head>
<body class="easyui-layout group-easyui">
<form id="cc" class="form-inline" role="form">
<div id="mainDiv" data-options="region:'center',title:'学生',noheader:false,collapsible:false,split:false" style="padding: 5px">
<div class="easyui-layout group-easyui-body" data-options="fit:true">
<div id="toolBar" data-options="region:'north',noheader:true,split:false" style="padding: 5px 10px 0px; height:60px; ">
<a href="#" class="cc-btn-tab" data-options="plain:true,iconCls:'icon-search'" onclick="Search()">查询</a>
<a href="#" class="cc-btn-tab" data-options="plain:true,iconCls:'icon-excel'" onclick="Exp()">导出全部</a>
</div>
<div data-options="region:'west',title:'分组条件',split:true,collapsible:false,split:false" style="width: 280px;">
<div class="easyui-panel" title="显示内容" style=" Contentpadding: 5px; margin-bottom: 5px">
<table id="CheckBoxList" style="border-style:None;width:100%;"></table>
</div>
<div class="easyui-panel" title="分析项目" style="padding: 5px; margin-bottom: 5px">
<table id="AnalyGroup" cellspacing='0' cellpadding='0' border='0' style='border-style:none;width:100%'></table>
</div>
<div class="easyui-panel" title="图表" style="padding: 5px; margin-bottom: 5px">
<table class="table" style="border:none;">
<tr>
<td>
高度:<input name="TB_H" type="text" value="460" id="TB_H" class="form-control" style="width: 60px; height: auto;
text-align: right" />
</td>
<td style="text-align: right">
宽度:<input name="TB_W" type="text" value="800" id="TB_W" class="form-control" style="width: 60px; height: auto;
text-align: right" />
</td>
</tr>
<tr>
<td colspan="2">
<span class="aspNetDisabled" title="注意仅当“显示内容”选择1项时图表功能才可用" style="float: left">
<label for="CB_IsShowPict">
<input id="CB_IsShowPict" type="checkbox" name="CB_IsShowPict" onclick="javascript:doPostBack(this,false)" />
显示图表
</label>
</span>
<span style="float: right">
<a id="lbtnApply" class="cc-btn-tab" data-options="iconCls:&#39;icon-ok&#39;,plain:true">应用</a>
</span>
</td>
</tr>
</table>
</div>
</div>
<div id="Content" data-options="region:'center'" style="padding: 5px;"></div>
</div>
</div>
</form>
</body>
</html>