|
|
|
|
|
<!DOCTYPE html>
|
|
|
<html>
|
|
|
<head>
|
|
|
<meta charset="utf-8" />
|
|
|
<title>综合分析</title>
|
|
|
<meta name="renderer" content="webkit" />
|
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
|
|
|
<script src="/WF/Scripts/jquery-1.11.0.min.js" type="text/javascript"></script>
|
|
|
<!--layui-->
|
|
|
<script src="/WF/Scripts/layui/layui/lay/modules/layer.js"></script>
|
|
|
<link href="/WF/Scripts/layui/layui/css/modules/layer/default/layer.css" rel="stylesheet" />
|
|
|
<link href="/WF/Scripts/layui/layui/css/layui.css" rel="stylesheet" />
|
|
|
<script src="/WF/Scripts/layui/layui/layui.js" type="text/javascript"></script>
|
|
|
<link href="/WF/Scripts/layui/style/admin.css" rel="stylesheet" />
|
|
|
<!--通用的JS-->
|
|
|
<script src="/WF/Scripts/config.js" type="text/javascript"></script>
|
|
|
<script src="/WF/Scripts/QueryString.js" type="text/javascript"></script>
|
|
|
<script src="/WF/Scripts/QueryString.js" type="text/javascript"></script>
|
|
|
<script src="/WF/Scripts/echartsjs/echarts.min.js" type="text/javascript"></script>
|
|
|
<script src="/WF/Comm/Gener.js" type="text/javascript"></script>
|
|
|
<style type="text/css">
|
|
|
.layui-table-view {
|
|
|
margin-right: 10px;
|
|
|
}
|
|
|
|
|
|
.layui-elem-field legend {
|
|
|
font-size: 18px;
|
|
|
font-weight: bold;
|
|
|
}
|
|
|
|
|
|
.layui-input, .layui-select, .layui-textarea {
|
|
|
height: 28px !important;
|
|
|
}
|
|
|
|
|
|
.layui-form-label {
|
|
|
padding: 3px 8px !important;
|
|
|
}
|
|
|
|
|
|
.layui-btn {
|
|
|
height: 28px !important;
|
|
|
line-height: 28px !important;
|
|
|
}
|
|
|
|
|
|
::-webkit-scrollbar {
|
|
|
width: 5px;
|
|
|
}
|
|
|
|
|
|
::-webkit-scrollbar-track {
|
|
|
background: rgb(239, 239, 239);
|
|
|
border-radius: 2px;
|
|
|
}
|
|
|
|
|
|
::-webkit-scrollbar-thumb {
|
|
|
background: #bfbfbf;
|
|
|
border-radius: 10px;
|
|
|
}
|
|
|
|
|
|
.layui-tab-content {
|
|
|
overflow-y: scroll;
|
|
|
}
|
|
|
|
|
|
.layui-table-patch > .layui-table-cell {
|
|
|
width: 10px !important;
|
|
|
}
|
|
|
</style>
|
|
|
<script type="text/javascript">
|
|
|
var searchFields = new Array(); //DDL的查询条件
|
|
|
var fields = []; //字符型字段查询的集合
|
|
|
//定义公共个变量.
|
|
|
var webUser = new WebUser();
|
|
|
|
|
|
var param = {
|
|
|
GroupType: GetQueryString("GroupType"),
|
|
|
FrmID: GetQueryString("FrmID"),
|
|
|
WorkModel: GetQueryString("WorkModel"),
|
|
|
OrderBy: GetQueryString("OrderBy"),
|
|
|
OrderWay: GetQueryString("OrderWay"),
|
|
|
NumKey: GetQueryString("NumKey")
|
|
|
};
|
|
|
|
|
|
//当前用户页面信息.
|
|
|
var ur = new Entity("BP.Sys.UserRegedit");
|
|
|
ur.MyPK = webUser.No + param.FrmID + "_Group";
|
|
|
|
|
|
ur.RetrieveFromDBSources();
|
|
|
ur.OrderBy = param.OrderBy;
|
|
|
ur.OrderWay = param.OrderWay;
|
|
|
ur.NumKey = param.NumKey;
|
|
|
ur.Save();
|
|
|
var count = ur.GetPara("RecCount");
|
|
|
var mapBase;
|
|
|
var searchAttrs;
|
|
|
/**
|
|
|
*
|
|
|
* 初始化页面
|
|
|
*/
|
|
|
$(function () {
|
|
|
|
|
|
InitToolbar(); //初始化按钮
|
|
|
//显示内容
|
|
|
DealGroupContent();
|
|
|
//分析项目
|
|
|
GroupAnalysis();
|
|
|
//分析结果显示
|
|
|
ShowData();
|
|
|
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* 初始化工具栏操作
|
|
|
*
|
|
|
*/
|
|
|
function InitToolbar() {
|
|
|
|
|
|
|
|
|
//创建处理器.
|
|
|
var handler = new HttpHandler("BP.Cloud.HttpHandler.App_OneFrm_FrmSearch");
|
|
|
handler.AddUrlData(); //增加参数.
|
|
|
|
|
|
//获取查询条件
|
|
|
var data = handler.DoMethodReturnString("FrmSearch_InitToolBar");
|
|
|
if (data.indexOf("err@") != -1) {
|
|
|
layer.alert(data);
|
|
|
console.log(data);
|
|
|
return;
|
|
|
}
|
|
|
data = JSON.parse(data);
|
|
|
//绑定外键枚举查询条件.
|
|
|
searchAttrs = data["Attrs"];
|
|
|
|
|
|
//格式为: @WFSta=0@FK_Dept=02
|
|
|
mapBase = data.Sys_MapData[0];
|
|
|
|
|
|
//用户查询注册信息
|
|
|
ur = new Entity("BP.Sys.UserRegedit");
|
|
|
ur.MyPK = webUser.No + param.FrmID + "_SearchAttrs";
|
|
|
ur.RetrieveFromDBSources();
|
|
|
|
|
|
|
|
|
var _html = "<form class='layui-form'>";
|
|
|
|
|
|
//指定的文本字段查询
|
|
|
var rptStringSearchKeys = mapBase.RptStringSearchKeys;
|
|
|
if (rptStringSearchKeys == null || rptStringSearchKeys == undefined || rptStringSearchKeys == "") {
|
|
|
if (mapBase.RptIsSearchKey == "1") {
|
|
|
_html += '<div class="layui-inline">';
|
|
|
_html += '<label class="layui-form-label">关键字:</label>';
|
|
|
_html += '<div class="layui-input-inline" style="width:120px">';
|
|
|
_html += '<input type="text" id="TB_Key" name="TB_Key" value="' + ur.SearchKey + '" autocomplete="off" class="layui-input" />';
|
|
|
_html += '</div>';
|
|
|
_html += '</div>';
|
|
|
}
|
|
|
} else {
|
|
|
//按照指定的string字段查询.
|
|
|
var strs = rptStringSearchKeys.split("*");
|
|
|
var fieldV = ""
|
|
|
$.each(strs, function (i, str) {
|
|
|
if (str != "") {
|
|
|
var item = str.split(",");
|
|
|
fieldV = ur.GetPara(item[0]);
|
|
|
if (fieldV == null || fieldV == undefined)
|
|
|
fieldV = "";
|
|
|
if (item.length == 2) {
|
|
|
|
|
|
fields.push(item[0]);
|
|
|
_html += '<div class="layui-inline">';
|
|
|
_html += '<label class="layui-form-label">' + item[1] + ':</label>';
|
|
|
_html += '<div class="layui-input-inline">';
|
|
|
_html += '<input type="text" id="TB_' + item[0] + '" name="TB_' + item[0] + '" value="' + fieldV + '" autocomplete="off" class="layui-input" />';
|
|
|
_html += '</div>';
|
|
|
_html += '</div>';
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
|
|
|
if (mapBase.RptDTSearchWay && mapBase.RptDTSearchWay != "0") {
|
|
|
_html += '<div class="layui-inline">';
|
|
|
_html += '<label class="layui-form-label">' + mapBase.DTSearchLabel + ':</label>';
|
|
|
var onfocus = "onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd'})\"";
|
|
|
if (mapBase.DTSearchWay != "1")
|
|
|
onfocus = " onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})\"";
|
|
|
|
|
|
_html += '<div class="layui-input-inline" style="width:145px">';
|
|
|
_html += '<input type="text" id="TB_DTFrom" name="TB_DTFrom" value="' + ur.DTFrom + '"' + onfocus + ' class="layui-input" />';
|
|
|
_html += '</div>';
|
|
|
_html += '</div>';
|
|
|
_html += '<div class="layui-inline" ">';
|
|
|
_html += '<label class="layui-form-label" style="width:30px">到:</label>';
|
|
|
_html += '<div class="layui-input-inline" style="width:145px">';
|
|
|
_html += '<input type="text" id="TB_DTTo" name="TB_DTTo" value="' + ur.DTTo + '"' + onfocus + ' class="layui-input" />';
|
|
|
_html += '</div>';
|
|
|
_html += '</div>';
|
|
|
}
|
|
|
//外键、枚举、外部数据源
|
|
|
var json = AtParaToJson(ur.Vals);
|
|
|
for (var i = 0; i < searchAttrs.length; i++) {
|
|
|
|
|
|
var attr = searchAttrs[i];
|
|
|
var selectVal = json[attr.Field];
|
|
|
if (selectVal == undefined || selectVal == "")
|
|
|
selectVal = "all";
|
|
|
|
|
|
_html += '<div class="layui-inline ">';
|
|
|
_html += '<label class="layui-form-label">' + attr.Name + ':</label>';
|
|
|
_html += '<div class="layui-input-inline" style="width:145px">';
|
|
|
_html += '<select name="DDL_' + attr.Field + '" ID="DDL_' + attr.Field + '" lay-filter="' + attr.Field + 'M">' + InitDDLOperation(data, attr, "all", selectVal) + '</select>';
|
|
|
|
|
|
_html += '</div>';
|
|
|
_html += '</div>';
|
|
|
|
|
|
searchFields.push({ type: "select", id: attr.Field });
|
|
|
}
|
|
|
|
|
|
|
|
|
//增加操作按钮
|
|
|
_html += '<div class="layui-inline">';
|
|
|
_html += '<div class="layui-input-inline">';
|
|
|
_html += '<input type="button" class="layui-btn" id="searchBtn" onclick="Search()" style="margin-left: 15px" value="分析"/>';
|
|
|
_html += '<input type="button" class="layui-btn layui-btn-primary" id="searchBtn" onclick="ToSearch()" style="margin-left: 15px" value="查询"/>';
|
|
|
_html += '</div>';
|
|
|
$("#toolBar").html(_html);
|
|
|
|
|
|
//绑定外键枚举查询条件.
|
|
|
var attrs = data["Attrs"];
|
|
|
|
|
|
//为查询外键赋值.
|
|
|
for (var i = 0; i < attrs.length; i++) {
|
|
|
var attr = attrs[i];
|
|
|
var selectVal = json[attr.Field];
|
|
|
|
|
|
if (selectVal == undefined || selectVal == "")
|
|
|
selectVal = "all";
|
|
|
|
|
|
$("#DDL_" + attr.Field).val(selectVal);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//到查询页面.
|
|
|
function ToSearch() {
|
|
|
var url = "Search.htm?EnsName=" + GetQueryString("EnsName");
|
|
|
SetHref(url);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* 分组条件
|
|
|
*/
|
|
|
function DealGroupContent() {
|
|
|
//创建处理器.
|
|
|
var handler = new HttpHandler("BP.Cloud.HttpHandler.App_OneFrm_FrmSearch");
|
|
|
handler.AddUrlData(); //增加参数.
|
|
|
var data = handler.DoMethodReturnString("Group_ContentAttrs");
|
|
|
if (data.indexOf('err@') != -1) {
|
|
|
layer.alert(data);
|
|
|
console.log(data);
|
|
|
return;
|
|
|
}
|
|
|
data = JSON.parse(data);
|
|
|
var groupAttrs = data;
|
|
|
if (groupAttrs.length == 0) {
|
|
|
alert("[" + document.title + "]没有外键或枚举,不能做分组查询.");
|
|
|
return;
|
|
|
}
|
|
|
var _html = "";
|
|
|
for (var i = 0; i < groupAttrs.length; i++) {
|
|
|
|
|
|
var checked = "";
|
|
|
if (groupAttrs[i].Checked && groupAttrs[i].Checked.toString() == "true") {
|
|
|
checked = "checked=checked";
|
|
|
}
|
|
|
_html += '<div class="layui-form-item">';
|
|
|
|
|
|
_html += '<div class="layui-input-block" style="margin-left:20px">';
|
|
|
_html += "<input type='checkbox' id='" + groupAttrs[i].Field + "' name='groupContent' " + checked + " onclick='javascript:ShowData(this,\"\")' value='" + groupAttrs[i].Field + "' lay-skin='primary' lay-filter='switch' title='" + groupAttrs[i].Name + "'/>";
|
|
|
_html += '</div>';
|
|
|
_html += '</div>';
|
|
|
}
|
|
|
$("#CheckBoxList").html(_html);
|
|
|
|
|
|
}
|
|
|
/**
|
|
|
* 分析项目
|
|
|
*/
|
|
|
function GroupAnalysis() {
|
|
|
//创建处理器.
|
|
|
var handler = new HttpHandler("BP.Cloud.HttpHandler.App_OneFrm_FrmSearch");
|
|
|
handler.AddUrlData(); //增加参数.
|
|
|
var data = handler.DoMethodReturnString("Group_Analysis");
|
|
|
if (data.indexOf('err@') != -1) {
|
|
|
layer.alert(data);
|
|
|
console.log(data);
|
|
|
return;
|
|
|
}
|
|
|
var data = JSON.parse(data);
|
|
|
var analyAtts = data["Attrs"];
|
|
|
|
|
|
var _html = "";
|
|
|
for (var i = 0; i < analyAtts.length; i++) {
|
|
|
|
|
|
var checked = "";
|
|
|
if (analyAtts[i].Checked && analyAtts[i].Checked.toString() == "true") {
|
|
|
checked = "checked=checked";
|
|
|
}
|
|
|
_html += '<div class="layui-form-item">';
|
|
|
_html += '<div class="layui-inline">';
|
|
|
_html += '<div class="layui-input-block" style="margin-left:20px">';
|
|
|
_html += "<input type='checkbox' id='" + analyAtts[i].Field + "' name='groupAnaly' " + checked + " onclick='javascript:ShowData(this,\"\")' value='" + analyAtts[i].Field + "' lay-skin='primary' lay-filter='switch' title='" + analyAtts[i].Name + "'/>";
|
|
|
_html += '</div>';
|
|
|
_html += '</div>';
|
|
|
_html += '<div class="layui-inline" style="width:100px;margin-top:5px">';
|
|
|
_html += "<select style='width:80%' class='form-control' name='DDL_Aly_" + analyAtts[i].Field + "' ID='DDL_Aly_" + analyAtts[i].Field + "' onchange='javascript:ShowData(this,\"\")'>" + InitDDLOperation(data, analyAtts[i], null) + "</select> ";
|
|
|
_html += '</div>';
|
|
|
_html += '</div>';
|
|
|
_html += '</div>';
|
|
|
}
|
|
|
$("#AnalyGroup").html(_html);
|
|
|
}
|
|
|
/**
|
|
|
* 显示数据
|
|
|
*
|
|
|
*/
|
|
|
function ShowData() {
|
|
|
var groupCount = $('input[name="groupContent"]:checked');
|
|
|
if (groupCount.length == 0) {
|
|
|
var _html = "";
|
|
|
_html += '<div class="layadmin-tips">'
|
|
|
_html += '<i class="layui-icon layui-icon-help" face=""></i>';
|
|
|
|
|
|
_html += '<div class="layui-text" style="font-size: 30px;color:red;color: red;display: inline-block;height: 300px;text-align: left;vertical-align: middle;border-top:0px">必须选择一项分组条件</div>'
|
|
|
|
|
|
_html += '</div>'
|
|
|
$("#Content").html(_html);
|
|
|
return false;
|
|
|
}
|
|
|
var groupAnaly = $('input[name="groupAnaly"]:checked');
|
|
|
if (groupAnaly.length == 0) {
|
|
|
var _html = "";
|
|
|
_html += '<div class="layadmin-tips">'
|
|
|
_html += '<i class="layui-icon layui-icon-help" face=""></i>';
|
|
|
|
|
|
_html += '<div class="layui-text" style="font-size: 30px;color:red;color: red;display: inline-block;height: 300px;text-align: left;vertical-align: middle;border-top:0px">必须选择一项分析项</div>'
|
|
|
|
|
|
_html += '</div>'
|
|
|
$("#Content").html(_html);
|
|
|
|
|
|
return false;
|
|
|
}
|
|
|
if (groupCount.length > 1) {
|
|
|
$("#CB_IsShowPict").attr("disabled", "disabled");
|
|
|
|
|
|
$("#CB_IsShowPict").prop("checked", false);
|
|
|
$($("#CB_IsShowPict").next()[0]).removeClass("layui-form-checked");
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
$("#CB_IsShowPict").attr("disabled", false);
|
|
|
$($("#CB_IsShowPict").next()[0]).removeClass("layui-checkbox-disbaled").removeClass("layui-disabled");
|
|
|
$("#CB_IsShowPict").prop("checked", true);
|
|
|
$($("#CB_IsShowPict").next()[0]).addClass("layui-form-checked");
|
|
|
}
|
|
|
|
|
|
|
|
|
//给注册表信息重新赋值
|
|
|
ur = new Entity("BP.Sys.UserRegedit");
|
|
|
ur.MyPK = webUser.No + param.FrmID + "_Group";
|
|
|
var selectedGroupKey = "";
|
|
|
groupCount.each(function () {
|
|
|
selectedGroupKey += ',' + $(this).val() + ","; //将选中的值添加到数组chk_value中
|
|
|
});
|
|
|
var stateNumKey = "";
|
|
|
|
|
|
groupAnaly.each(function () {
|
|
|
var key = $(this).val();
|
|
|
//获取下拉框的值
|
|
|
var defVal = $("#DDL_Aly_" + key).val();
|
|
|
|
|
|
stateNumKey += ',' + $(this).val() + '=' + defVal + ","; //将选中的值添加到数组chk_value中
|
|
|
});
|
|
|
|
|
|
ur.Vals = "@SelectedGroupKey=" + selectedGroupKey + "@StateNumKey=" + stateNumKey;
|
|
|
|
|
|
if ($("#CB_IsShowPict").is(":checked") == true)
|
|
|
ur.IsPic = 1;
|
|
|
else
|
|
|
ur.IsPic = 0;
|
|
|
|
|
|
ur.SetPKVal(ur.MyPK);
|
|
|
ur.FK_Emp = webUser.No;
|
|
|
ur.CfgKy = param.FrmID + "_Group";
|
|
|
ur.Save();
|
|
|
|
|
|
var searchUr = new Entity("BP.Sys.UserRegedit");
|
|
|
searchUr.MyPK = webUser.No + param.FrmID + "_SearchAttrs";
|
|
|
searchUr.RetrieveFromDBSources();
|
|
|
|
|
|
|
|
|
//增加时间条件的查询
|
|
|
if ($("#TB_DTFrom").length > 0) {
|
|
|
searchUr.DTFrom = $("#TB_DTFrom").val();
|
|
|
searchUr.DTTo = $("#TB_DTTo").val();
|
|
|
}
|
|
|
//增加下拉框的查询条件
|
|
|
var vals = "";
|
|
|
$.each(searchFields, function () {
|
|
|
var id = this.id.replace("DDL_", "");
|
|
|
vals += "@" + id + "=" + $("#" + this.id).val();
|
|
|
});
|
|
|
searchUr.Vals = vals;
|
|
|
searchUr.Update();
|
|
|
|
|
|
Group_Search();
|
|
|
}
|
|
|
function Group_Search() {
|
|
|
|
|
|
//重新获取注册信息
|
|
|
ur = new Entity("BP.Sys.UserRegedit");
|
|
|
ur.MyPK = webUser.No + param.FrmID + "_Group";
|
|
|
|
|
|
ur.RetrieveFromDBSources();
|
|
|
|
|
|
//创建处理器.
|
|
|
var handler = new HttpHandler("BP.Cloud.HttpHandler.App_OneFrm_FrmSearch");
|
|
|
handler.AddUrlData(); //增加参数.
|
|
|
//handler.AddFormData();
|
|
|
var groupList = "";
|
|
|
$('input[name="groupContent"]').each(function () {
|
|
|
groupList += '@' + $(this).val(); //将选中的值添加到数组chk_value中
|
|
|
});
|
|
|
handler.AddPara("GroupList", groupList);
|
|
|
|
|
|
var data = handler.DoMethodReturnString("Group_Search");
|
|
|
if (data.indexOf('err@') != -1) {
|
|
|
layer.alert(data);
|
|
|
console.log(data);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (data.indexOf('info@') != -1) {
|
|
|
data = data.replace("info@", "");
|
|
|
$("#Content").html("").append(data);
|
|
|
return;
|
|
|
}
|
|
|
$("#Content").html("");
|
|
|
var data = JSON.parse(data);
|
|
|
|
|
|
var mainData = data["MainData"];
|
|
|
var mapAttrs = data["Sys_MapAttr"];
|
|
|
var attrsOfNum = data["AttrsOfNum"];
|
|
|
//生成表格
|
|
|
if (ur.IsPic == 0) {
|
|
|
GenerTable("Content", mainData, mapAttrs, attrsOfNum);
|
|
|
//生成图表
|
|
|
} else {
|
|
|
GenerChart(mainData, mapAttrs, attrsOfNum);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
function GenerTable(divID, mainData, mapAttrs) {
|
|
|
$("#" + divID).append($("<table class='layui-hide' id='groupTable' lay-filter='groubTable'></table>"));
|
|
|
//表格显示的列
|
|
|
var columns = new Array();;
|
|
|
columns.push({
|
|
|
title: '序',
|
|
|
field: '',
|
|
|
align: 'center',
|
|
|
width: 50,
|
|
|
type: 'numbers',
|
|
|
totalRowText: '汇总'
|
|
|
});
|
|
|
$.each(mapAttrs, function (i, attr) {
|
|
|
var field = attr.KeyOfEn;
|
|
|
var title = attr.Name;
|
|
|
var width = attr.Width;
|
|
|
|
|
|
if (field == "Title") {
|
|
|
width = 230;
|
|
|
}
|
|
|
var isTotalRow = false;
|
|
|
if (field == "Group_Number")
|
|
|
isTotalRow = true;
|
|
|
if (ur.Vals.indexOf(field + "=") != -1)
|
|
|
isTotalRow = true;
|
|
|
|
|
|
if (attr.UIContralType == 1) {
|
|
|
if (width == null || width == "" || width == undefined)
|
|
|
width = 180;
|
|
|
|
|
|
columns.push({
|
|
|
field: field, //字段名
|
|
|
title: title, //标题名称
|
|
|
minWidth: width, //宽度
|
|
|
sort: true,
|
|
|
totalRow: isTotalRow,
|
|
|
templet: function (data) {
|
|
|
var val = data[this.field + "Text"];
|
|
|
if (val == null && val == undefined)
|
|
|
val = data[this.field + "T"];
|
|
|
if (val == null && val == undefined)
|
|
|
val = data[this.field];
|
|
|
return val;
|
|
|
}
|
|
|
});
|
|
|
return true;
|
|
|
}
|
|
|
if (attr.UIContralType == 2) {
|
|
|
if (width == null || width == "" || width == undefined) {
|
|
|
width = 60;
|
|
|
}
|
|
|
|
|
|
columns.push({
|
|
|
field: field,
|
|
|
title: title,
|
|
|
minWidth: width,
|
|
|
sort: true,
|
|
|
totalRow: isTotalRow,
|
|
|
templet: function (data) {
|
|
|
if (data[this.field] == "0") return "否";
|
|
|
if (data[this.field] == "1") return "是";
|
|
|
}
|
|
|
});
|
|
|
return true;
|
|
|
}
|
|
|
if (width == null || width == "" || width == undefined)
|
|
|
width = 100;
|
|
|
if (field == "FlowStartRDT")
|
|
|
width = 160;
|
|
|
columns.push({
|
|
|
field: field,
|
|
|
title: title,
|
|
|
minWidth: width,
|
|
|
sort: true,
|
|
|
totalRow: isTotalRow,
|
|
|
});
|
|
|
});
|
|
|
columns.push({
|
|
|
field: "oper",
|
|
|
title: "操作",
|
|
|
minWidth: 80,
|
|
|
templet: function (data) {
|
|
|
var url = "FrmSearchDtl.htm?FrmID=" + param.FrmID + "&SearchType=" + param.GroupType+"&WorkModel="+param.WorkModel + "&TitleName=" + mapBase.Name;
|
|
|
var str = ur.Vals.substr(0, ur.Vals.indexOf("@StateNumKey"));
|
|
|
$.each(mapAttrs, function (k, o) {
|
|
|
if (url.indexOf(o.KeyOfEn) == -1 && str.indexOf(","+o.KeyOfEn+",")!=-1)
|
|
|
url += "&" + o.KeyOfEn + "=" + data[o.KeyOfEn];
|
|
|
});
|
|
|
|
|
|
return "<a href=\"javascript:WinOpen('" + url + "', 'wincommgroup',900,900);\" class='btn btn-default btn - sm easyui- linkbutton'>详细</a>"
|
|
|
}
|
|
|
});
|
|
|
|
|
|
layui.use(['table', 'form'], function () {
|
|
|
var table = layui.table;
|
|
|
var height = $(document).height() - $("#toolBar").height() - 100;
|
|
|
if ($(".layui-tab-title").length != 0)
|
|
|
height = 470;
|
|
|
table.render({
|
|
|
elem: '#groupTable'
|
|
|
, data: mainData
|
|
|
//, cellMinWidth: 80
|
|
|
, toolbar: 'true' //开启头部工具栏,并为其绑定左侧模板
|
|
|
, defaultToolbar: ['exports']
|
|
|
, title: '数据分析'
|
|
|
, cols: [columns]
|
|
|
, limit: Number.MAX_VALUE
|
|
|
, height: height
|
|
|
, totalRow: true
|
|
|
, done: function (res, curr, count) {
|
|
|
var tds = $(".layui-table-total tr td");
|
|
|
$.each(tds, function (i, item) {
|
|
|
|
|
|
var key = $(item).attr("data-field");
|
|
|
if (ur.Vals.indexOf(key + "=AVG") != -1) {
|
|
|
var children = $($(item).find("div")[0]);
|
|
|
|
|
|
//获取子节点的值
|
|
|
var value = children.html();
|
|
|
children.html((value / count).toFixed(2));
|
|
|
}
|
|
|
|
|
|
});
|
|
|
}
|
|
|
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 图标展示
|
|
|
* @param mainData
|
|
|
* @param mapAttrs
|
|
|
* @param AttrsOfNum
|
|
|
* @param ur
|
|
|
* @param ActiveAttr
|
|
|
* @param noShowSum
|
|
|
*/
|
|
|
function GenerChart(mainData, mapAttrs, attrsOfNum) {
|
|
|
//groupSearch = thisGroupSearch;
|
|
|
//AttrsOfNum = thisAttrsOfNum;
|
|
|
//AttrsOfGroup = thisAttrsOfGroup;
|
|
|
var width = $("#TB_W").val();
|
|
|
if (width == "" || width == 0)
|
|
|
width = 300;
|
|
|
var height = $("#TB_H").val();
|
|
|
if (height == "" || height == 0)
|
|
|
height = 300;
|
|
|
|
|
|
var _html = "";
|
|
|
_html += '<div class="layui-tab layui-tab-card" style="height:550px" >';
|
|
|
_html += '<ul class="layui-tab-title" id="tabEchart">';
|
|
|
_html += '<li class="layui-this">分组数据</li>';
|
|
|
_html += '<li >柱状图</li>';
|
|
|
_html += '<li>折线图</li>';
|
|
|
_html += '<li>饼状图</li>';
|
|
|
_html += '</ul>';
|
|
|
|
|
|
_html += '<div class="layui-tab-content" style="">';
|
|
|
|
|
|
_html += '<div class="layui-tab-item layui-show" id="table_div"></div>';
|
|
|
_html += '<div class="layui-tab-item layui-form layui-border-box layui-table-view" id="bar_chart_div" style="width:' + width + 'px:height:' + height + 'px" ></div>';
|
|
|
_html += '<div class="layui-tab-item " id="line_chart_div">4</div>';
|
|
|
|
|
|
_html += '<div class="layui-tab-item" id="pie_chart_div">3</div>';
|
|
|
|
|
|
_html += '</div>';
|
|
|
_html += '</div>';
|
|
|
|
|
|
|
|
|
|
|
|
$("#Content").html(_html);
|
|
|
|
|
|
var xAxis = [];
|
|
|
for (var i = 0; i < mainData.length; i++) {
|
|
|
var str = mainData[i][mapAttrs[0].KeyOfEn + "Text"];
|
|
|
if (str == null || str == undefined)
|
|
|
str = mainData[i][mapAttrs[0].KeyOfEn + "T"];
|
|
|
xAxis[i] = str;
|
|
|
}
|
|
|
//分析项目
|
|
|
var analyKey = ur.Vals.substring(ur.Vals.indexOf("@StateNumKey"));
|
|
|
|
|
|
|
|
|
//表格
|
|
|
GenerTable("table_div", mainData, mapAttrs, xAxis, width);
|
|
|
var width = $("#table_div").width();
|
|
|
//柱状图
|
|
|
GenerateBarChart(mainData, mapAttrs, attrsOfNum, xAxis, width);
|
|
|
|
|
|
//折线图
|
|
|
GenerateLineChart(mainData, mapAttrs, attrsOfNum, xAxis, width);
|
|
|
|
|
|
//饼状图
|
|
|
GeneratePieChart(mainData, mapAttrs, attrsOfNum, xAxis, mapAttrs[0].KeyOfEn, width);
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 柱状图
|
|
|
* @param groupSearch
|
|
|
* @param AttrsOfNum
|
|
|
* @param xAxis
|
|
|
*/
|
|
|
function GenerateBarChart(mainData, mapAttrs, attrsOfNum, xAxis, width) {
|
|
|
|
|
|
$("#bar_chart_div").css("width", width + "px").css("height", "300px");
|
|
|
var myChart = echarts.init(document.getElementById('bar_chart_div'));
|
|
|
var series = [];
|
|
|
for (var i = 0; i < attrsOfNum.length; i++) {
|
|
|
if (attrsOfNum[i].Name == null || attrsOfNum[i].Name == "")
|
|
|
continue;
|
|
|
var data = [];
|
|
|
for (var j = 0; j < mainData.length; j++) {
|
|
|
data[j] = mainData[j][attrsOfNum[i].KeyOfEn];
|
|
|
}
|
|
|
series.push({
|
|
|
name: attrsOfNum[i].Name,
|
|
|
data: data,
|
|
|
type: 'bar',
|
|
|
smooth: true,
|
|
|
|
|
|
});
|
|
|
}
|
|
|
// 指定图表的配置项和数据
|
|
|
var option = {
|
|
|
grid: {
|
|
|
top: '5%',
|
|
|
right: '1%',
|
|
|
left: '1%',
|
|
|
bottom: '10%',
|
|
|
containLabel: true
|
|
|
},
|
|
|
tooltip: {
|
|
|
trigger: 'axis'
|
|
|
},
|
|
|
xAxis: {
|
|
|
type: 'category',
|
|
|
data: xAxis
|
|
|
},
|
|
|
yAxis: {
|
|
|
type: 'value'
|
|
|
},
|
|
|
series: series
|
|
|
};
|
|
|
// 使用刚指定的配置项和数据显示图表。
|
|
|
myChart.setOption(option);
|
|
|
}
|
|
|
/**
|
|
|
* 折线图
|
|
|
* @param groupSearch
|
|
|
* @param AttrsOfNum
|
|
|
* @param xAxis
|
|
|
*/
|
|
|
function GenerateLineChart(mainData, mapAttrs, attrsOfNum, xAxis, width) {
|
|
|
$("#line_chart_div").css("width", width + "px").css("height", "300px");
|
|
|
var myChart = echarts.init(document.getElementById('line_chart_div'));
|
|
|
var series = [];
|
|
|
|
|
|
for (var i = 0; i < attrsOfNum.length; i++) {
|
|
|
if (attrsOfNum[i].Name == null || attrsOfNum[i].Name == "")
|
|
|
continue;
|
|
|
var data = [];
|
|
|
for (var j = 0; j < mainData.length; j++) {
|
|
|
data[j] = mainData[j][attrsOfNum[i].KeyOfEn];
|
|
|
}
|
|
|
series.push({
|
|
|
name: attrsOfNum[i].Name,
|
|
|
data: data,
|
|
|
type: 'line',
|
|
|
|
|
|
});
|
|
|
}
|
|
|
// 指定图表的配置项和数据
|
|
|
var option = {
|
|
|
grid: {
|
|
|
top: '5%',
|
|
|
right: '1%',
|
|
|
left: '1%',
|
|
|
bottom: '10%',
|
|
|
containLabel: true
|
|
|
},
|
|
|
tooltip: {
|
|
|
trigger: 'axis'
|
|
|
},
|
|
|
xAxis: {
|
|
|
type: 'category',
|
|
|
data: xAxis
|
|
|
},
|
|
|
yAxis: {
|
|
|
type: 'value'
|
|
|
},
|
|
|
series: series
|
|
|
};
|
|
|
// 使用刚指定的配置项和数据显示图表。
|
|
|
myChart.setOption(option);
|
|
|
}
|
|
|
|
|
|
function GeneratePieChart(mainData, mapAttrs, attrsOfNum, xAxis, KeyOfEn, width) {
|
|
|
$("#pie_chart_div").css("width", width + "px").css("height", "300px");
|
|
|
var myChart = echarts.init(document.getElementById('pie_chart_div'));
|
|
|
var series = [];
|
|
|
for (var i = 0; i < attrsOfNum.length; i++) {
|
|
|
if (attrsOfNum[i].Name == null || attrsOfNum[i].Name == "")
|
|
|
continue;
|
|
|
var data = [];
|
|
|
for (var j = 0; j < mainData.length; j++) {
|
|
|
var val = mainData[j][KeyOfEn + "Text"];
|
|
|
if (val == null || val == undefined)
|
|
|
val = mainData[j][KeyOfEn + "T"];
|
|
|
data.push({
|
|
|
"value": mainData[j][attrsOfNum[i].KeyOfEn],
|
|
|
"name": val
|
|
|
});
|
|
|
}
|
|
|
series.push({
|
|
|
name: attrsOfNum[i].Name,
|
|
|
data: data,
|
|
|
type: 'pie',
|
|
|
radius: '60%',
|
|
|
center: ['60%', '50%'],
|
|
|
itemStyle: {
|
|
|
// emphasis:英文意思是 强调;着重;(轮廓、图形等的)鲜明;突出,重读
|
|
|
// emphasis:设置鼠标放到哪一块扇形上面的时候,扇形样式、阴影
|
|
|
emphasis: {
|
|
|
shadowBlur: 10,
|
|
|
shadowOffsetX: 0,
|
|
|
shadowColor: 'rgba(30, 144, 255,0.5)'
|
|
|
}
|
|
|
},
|
|
|
|
|
|
});
|
|
|
}
|
|
|
|
|
|
var option = {
|
|
|
|
|
|
tooltip: {
|
|
|
trigger: 'item',
|
|
|
formatter: '{a} <br/>{b} : {c} ({d}%)'
|
|
|
},
|
|
|
legend: {
|
|
|
// orient 设置布局方式,默认水平布局,可选值:'horizontal'(水平) ¦ 'vertical'(垂直)
|
|
|
orient: 'vertical',
|
|
|
// x 设置水平安放位置,默认全图居中,可选值:'center' ¦ 'left' ¦ 'right' ¦ {number}(x坐标,单位px)
|
|
|
x: 'left',
|
|
|
// y 设置垂直安放位置,默认全图顶端,可选值:'top' ¦ 'bottom' ¦ 'center' ¦ {number}(y坐标,单位px)
|
|
|
y: 'center',
|
|
|
itemWidth: 24, // 设置图例图形的宽
|
|
|
itemHeight: 18, // 设置图例图形的高
|
|
|
textStyle: {
|
|
|
color: '#666' // 图例文字颜色
|
|
|
},
|
|
|
// itemGap设置各个item之间的间隔,单位px,默认为10,横向布局时为水平间隔,纵向布局时为纵向间隔
|
|
|
itemGap: 10,
|
|
|
//backgroundColor: '#f8f8f8', // 设置整个图例区域背景颜色
|
|
|
data: xAxis
|
|
|
},
|
|
|
series: series
|
|
|
};
|
|
|
|
|
|
// 使用刚指定的配置项和数据显示图表。
|
|
|
myChart.setOption(option);
|
|
|
}
|
|
|
|
|
|
function Search() {
|
|
|
var ur = new Entity("BP.Sys.UserRegedit");
|
|
|
ur.MyPK = webUser.No+ param.FrmID + "_SearchAttrs";
|
|
|
ur.FK_Emp = webUser.No;
|
|
|
|
|
|
if ($("#TB_Key") != null && $("#TB_Key").val() != "")
|
|
|
ur.SearchKey = $("#TB_Key").val();
|
|
|
else
|
|
|
ur.SearchKey = "";
|
|
|
|
|
|
for (var i = 0; i < fields.length; i++) {
|
|
|
var field = fields[i];
|
|
|
var strs = $("input[name=TB_" + field + "]");
|
|
|
if (strs.length == 1) {
|
|
|
ur.SetPara(field, $("#TB_" + field).val());
|
|
|
} else {
|
|
|
if ($("#TB_" + field + "_0").val() == "" && $("#TB_" + field + "_1").val() == "")
|
|
|
ur.SetPara(field, "");
|
|
|
else
|
|
|
ur.SetPara(field, $("#TB_" + field + "_0").val() + "," + $("#TB_" + field + "_1").val());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//设置查询时间.
|
|
|
if ($("#TB_DTFrom").length == 1)
|
|
|
ur.DTFrom = $("#TB_DTFrom").val();
|
|
|
|
|
|
if ($("#TB_DTTo").length == 1)
|
|
|
ur.DTTo = $("#TB_DTTo").val();
|
|
|
|
|
|
//增加下拉框的查询条件
|
|
|
var str = "";
|
|
|
$.each(searchFields, function () {
|
|
|
var val = $("#DDL_"+this.id).val();
|
|
|
str += "@" + this.id + "=" + val;
|
|
|
});
|
|
|
|
|
|
|
|
|
ur.FK_Emp = webUser.No;
|
|
|
ur.CfgKey = param.FrmID + "_SearchAttrs";
|
|
|
ur.Vals = str;
|
|
|
ur.FK_MapData = param.FrmID;
|
|
|
ur.SetPara("RecCount", count);
|
|
|
ur.Save();
|
|
|
//查询
|
|
|
Group_Search();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function WinOpen(url, winName) {
|
|
|
layer.open({
|
|
|
type: 2,
|
|
|
title: mapBase.Name + "数据分析详情",
|
|
|
shade: false,
|
|
|
maxmin: true,
|
|
|
area: ['80%', '90%'],
|
|
|
content: url
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
</script>
|
|
|
</head>
|
|
|
<body>
|
|
|
<div class="layui-body layui-tab-content site-demo site-demo-body" style="left:0px !important">
|
|
|
<form class="layui-form">
|
|
|
<div id="toolBar" class="layui-header layui-card" style="height:auto;padding:10px"></div>
|
|
|
<div class="layui-col-md2">
|
|
|
<div class="layui-card">
|
|
|
<div class="layui-card-header">分组条件</div>
|
|
|
<div id="CheckBoxList">
|
|
|
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="layui-card">
|
|
|
<div class="layui-card-header" style="border-top:1px solid #f6f6f6;">分析项目</div>
|
|
|
<div id="AnalyGroup">
|
|
|
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="layui-card">
|
|
|
<div class="layui-card-header">图表</div>
|
|
|
<div class="layui-form-item" style="margin-top:5px">
|
|
|
<div class="layui-inline">
|
|
|
<label class="layui-form-label" style="width:30px">高度</label>
|
|
|
<div class="layui-input-inline" style="width:60px">
|
|
|
<input type="text" name="TB_H" id="TB_H" lay-verify="required|number" autocomplete="off" class="layui-input" />
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="layui-inline">
|
|
|
<label class="layui-form-label" style="width:30px">宽度</label>
|
|
|
<div class="layui-input-inline" style="width:60px">
|
|
|
<input type="text" name="TB_W" id="TB_W" lay-verify="required|number" autocomplete="off" class="layui-input" />
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="layui-form-item" pane="">
|
|
|
|
|
|
<div class="layui-input-block" style="margin-left:20px">
|
|
|
<input type="checkbox" checked="" name="CB_IsShowPict" id="CB_IsShowPict" lay-skin='primary' title="显示图表" lay-filter="switch">
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="layui-col-md10">
|
|
|
<div class="layui-card" id="Content" style="margin-left:20px;height:550px">
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
</form>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<script>
|
|
|
layui.use(['layedit', 'table', 'element', 'laydate'], function () {
|
|
|
var table = layui.table;
|
|
|
var form = layui.form;
|
|
|
form.on('checkbox(switch)', function (data) {
|
|
|
ShowData();
|
|
|
});
|
|
|
if ($("#TB_DTFrom").length == 1) {
|
|
|
layui.laydate.render({
|
|
|
elem: '#TB_DTFrom'
|
|
|
, format: $("#TB_DTFrom").attr("data-info")
|
|
|
});
|
|
|
layui.laydate.render({
|
|
|
elem: '#TB_DTTo'
|
|
|
, format: $("#TB_DTTo").attr("data-info")
|
|
|
});
|
|
|
}
|
|
|
|
|
|
});
|
|
|
</script>
|
|
|
<script type="text/javascript">
|
|
|
/**
|
|
|
* 初始化下拉框
|
|
|
* @param frmData
|
|
|
* @param mapAttr
|
|
|
* @param defVal
|
|
|
*/
|
|
|
function InitDDLOperation(frmData, mapAttr, defVal) {
|
|
|
|
|
|
var operations = "";
|
|
|
if (defVal == "all")
|
|
|
operations += "<option value='all' >全部</option>";
|
|
|
|
|
|
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;
|
|
|
}
|
|
|
</script>
|
|
|
</body>
|
|
|
</html> |