| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641 | @{    Layout = null;}<!DOCTYPE html><html><head>    <meta name="viewport" content="width=device-width" />	<title>ChartsCount</title>	<link href="~/easyui/themes/default/easyui.css" rel="stylesheet" />	<link rel="stylesheet" type="text/css" href="~/easyui/themes/icon.css" />	<link href="~/Content/css/bootstrap.min.css" rel="stylesheet" />	<link href="~/Content/js/plugins/layer/skin/layer.css" rel="stylesheet" />	<script src="~/Content/js/jquery.min.js"></script>	<script src="~/Content/js/bootstrap.min.js"></script>	<script src="~/easyui/jquery.easyui.min.js"></script>	<script src="~/easyui/jquery.easyui.mobile.js"></script>	<script src="~/easyui/locale/easyui-lang-zh_CN.js"></script>	<script src="~/Content/js/plugins/layer/laydate/laydate.js"></script>	<script src="~/Content/js/plugins/layer/layer.min.js"></script>	<script src="~/Content/plugins/highcharts/highcharts.js"></script>	<script src="~/js/Utils.js"></script>	<link href="~/Content/css/Style/Markets.css" rel="stylesheet" />	<script src="~/Content/js/js/MarketJs.js"></script>	</head><body><section class="hidden">	<input type="hidden" id="hid_ReportType" value="@ViewBag.ReportType" />	<input type="hidden" id="hid_ReportTitle" value="@ViewBag.ReportTitle" />	<input id="hid_IsMarketSysAccount" name="hid_IsMarketSysAccount" type="hidden" value="@ViewBag.IsMarketSysAccount" />	<input id="hid_IsSystem" name="hid_IsSystem" type="hidden" value="@ViewBag.IsSystem" />	<input id="hid_MarketID" name="hid_MarketID" type="hidden" value="@ViewBag.MarketID" />	<input id="hid_ChartType" name="hid_ChartType" type="hidden" value="COLUMN" />	<input id="hid_NumberFormat" name="hid_NumberFormat" type="hidden" value="0" />	</section><section id="Search_Panel">	<div id="" class="easyui-panel" title="检测数据查询"	     style="width: 100%; height: 135px; padding: 8px;"	     data-options="closable:false,collapsible:true">		<table class="panel-table">			<tr>				<td class="td-label"><label for="SearchRegionID">辖区工商</label></td>				<td class="td-input">					<select class="easyui-combobox" type="text" id="SearchRegionID" name="SearchRegionID" style="height: 25px; width: 150px" data-options="onSelect:function(){GetMarketSelStr()}">						<option value="">全部</option>						@Html.Raw(ViewBag.SelRegionInfo)					</select>				</td>				<td class="td-label"><label for="SearchMarketID">隶属市场</label></td>				<td class="td-input">					<select class="easyui-combobox" style="height: 25px; width: 150px" id="SearchMarketID" name="SearchMarketID" data-options="">						@Html.Raw(ViewBag.SelMarketInfo)					</select>				</td>				<td class="td-label"><label for="SearchCorpKind">企业类型</label></td>				<td class="td-input">					<select class="easyui-combobox" style="height: 25px; width: 150px" id="SearchCorpKind" name="SearchCorpKind">						<option value="">全部</option>						@Html.Raw(ViewBag.SelCorpKindInfo)					</select>				</td>				<td class="td-label"><label for="SearchCorpName">被检企业</label></td>				<td class="td-input">					<input class="easyui-textbox" style="height: 25px; width: 150px" id="SearchCorpName" name="SearchCorpName">				</td>			</tr>			<tr>				<td class="td-label"><label for="SearchLittleKindName">品种类别</label></td>				<td class="td-input">					<select class="easyui-combobox" style="height: 25px; width: 150px" id="SearchLittleKindName" name="SearchLittleKindName" data-options="onSelect:function(){GetLittleKindSelStr()}">						<option value="">全部</option>						@Html.Raw(ViewBag.SelLittleKindInfo)					</select>				</td>				<td class="td-label"><label for="SearchSampleName">样品名称</label></td>				<td class="td-input">					<input class="easyui-combotree" style="height: 25px; width: 150px" id="SearchSampleName" name="SearchSampleName" data-options="" />					@*<select class="easyui-combobox" style="height: 25px; width: 150px" id="SearchSampleName" name="SearchSampleName" data-options="">						<option value="">全部</option>						@Html.Raw(ViewBag.SelSampleNameInfo)					</select>*@				</td>				<td class="td-label"><label for="SearchCheckProjectTypeID">检测项目</label></td>				<td class="td-input">					<select class="easyui-combobox" style="height: 25px; width: 150px" id="SearchCheckProjectTypeID" name="SearchCheckProjectTypeID">						<option value="">全部</option>						@Html.Raw(ViewBag.SelCheckProjectTypeInfo)					</select>				</td>				<td class="td-label"><label for="SearchProduceUnit">生产单位</label></td>				<td class="td-input">					<input class="easyui-textbox" style="height: 25px; width: 150px" id="SearchProduceUnit" name="SearchProduceUnit">				</td>			</tr>			<tr>				<td class="td-label"><label for="SearchStartTime">开始时间</label></td>				<td class="td-input"><input class="easyui-textbox" type="text" id="SearchStartTime" name="SearchStartTime" style="height: 25px; width: 150px" data-options="" placeholder="输入查询检测时间的开始日期"/></td>				<td class="td-label"><label for="SearchEndTime">截止时间</label></td>				<td class="td-input"><input class="easyui-textbox" type="text" id="SearchEndTime" name="SearchEndTime" style="height: 25px; width: 150px" data-options="" placeholder="输入查询检测时间的截止日期"/></td>			    <td class="td-label"><label for="SearchTopQty">查询数量</label></td>			    <td class="td-input">			        <select class="easyui-combobox" style="height: 25px; width: 150px" id="SearchTopQty" name="SearchTopQty">			            <option value="20">最前 20 条</option>                        <option value="30">最前 30 条</option>                        <option value="50">最前 50 条</option>                        <option value="-20">最后 20 条</option>                        <option value="-30">最后 30 条</option>                        <option value="-50">最后 50 条</option>			            <option value="">全部</option>			        </select>			    </td>							    <td class="td-input" colspan="2">			        <label style="margin: 0 10px">			            <input type="radio" name="ChartType" value="COLUMN" style="margin: 5px 3px 0 0;width: 30px" onclick="ChartType()" checked="checked" /> 柱图			        </label>			        <label style="margin: 0 10px">			            <input type="radio" name="ChartType" value="PIE" style="margin: 5px 3px 0 0;width: 30px" onclick="ChartType()"/> 饼图			        </label>			        <a href="#" class="easyui-linkbutton" iconCls="icon-search" style="width: 150px;height: 25px" onclick="LoadChart();">查询</a>			    </td>			</tr>		</table>	</div></section><section style="margin:20px auto 0;text-align:center">	<div id="container" style="width:90vw; height: 75vh; margin: 0 auto;">			</div></section><script>		//根据辖区获取市场下拉框的option	function GetMarketSelStr() {		$.ajax({			url: "/GetResult/GetMarketSelStrResult",			type: "post",			async:false,			dataType: "json",			//data: { RegionID: $("input.combobox-value[name='SearchRegionID']").val() },			data: { RegionID: $("#SearchRegionID").combobox("getValue") },			success: function (data) {				//console.log(msg);				if (CheckAajxData(data) === false) return;				var rows = data.rows;				var first = "{\"MarketID\":\"\",\"Names\":\"全部\"}";				var last = "{\"MarketID\":\"Other\",\"Names\":\"其他\"}";				var firstJson = JSON.parse(first);				var lastJson = JSON.parse(last);				rows.unshift(firstJson);				rows.push(lastJson);				//console.log(rows);				$('#SearchMarketID').combobox("clear").combobox({					data: rows,					valueField: 'MarketID',					textField: 'Names',					onLoadSuccess: function () {						var val = $(this).combobox('getData');						// ReSharper disable once MissingHasOwnPropertyInForeach						for (var item in val[0]) {							if (item === 'MarketID') {								$(this).combobox('select', val[0][item]);							}						}					}				});			}		});	}	//根据小类获取品种名下拉框的option	function GetLittleKindSelStr() {		$.ajax({			url: "/GetResult/GetLittleKindSelStrResult",			type: "post",			async:false,			dataType: "json",			data: { LittleKindName: $("#SearchLittleKindName").combotree("getValue") },			success: function (data) {				//console.log(msg);				if (CheckAajxData(data) === false) return;				if (data.length > 0) {					$("#SearchSampleName").combotree({						data: data					});				} else {					$("#SampleName").combotree({						data: []					});				}				//var rows = data.rows;				////var first = "{\"SpecialsID\":\"";				////for (var i = 0; i < rows.length; i++) {				////	first += (first === "{\"SpecialsID\":\"" ? "" : "@@|@@") + rows[i].SpecialsID;				////}				////first += "\",\"Name\":\"全部\"}";				//var first = "{\"Name\":\"\",\"Name\":\"全部\"}";				//var firstJson = JSON.parse(first);				//rows.unshift(firstJson);				//$('#SearchSampleName').combobox("clear").combobox({				//	data: rows,				//	valueField: 'Name',				//	textField: 'Name',				//	onLoadSuccess: function () {				//		var val = $(this).combobox('getData');				//		// ReSharper disable once MissingHasOwnPropertyInForeach				//		for (var item in val[0]) {				//			if (item === 'Name') {				//				$(this).combobox('select', val[0][item]);				//			}				//		}				//	}				//});			}		});	}	//根据检测方法获取检测项目下拉框的option	function GetCheckProjectSelStr() {		$.ajax({			url: "/GetResult/GetCheckProjectSelStrResult",			type: "post",			async:false,			dataType: "json",			data: { CheckMethod: $("#SearchCheckMethod").combobox("getValue") },			success: function (data) {				//console.log(msg);				if (CheckAajxData(data) === false) return;				var rows = data.rows;				var first = "{\"CheckProjectTypeID\":\"\",\"Name\":\"全部\"}";				var firstJson = JSON.parse(first);				rows.unshift(firstJson);				$('#SearchCheckProjectTypeID').combobox("clear").combobox({					data: rows,					valueField: 'CheckProjectTypeID',					textField: 'Name',					onLoadSuccess: function () {						var val = $(this).combobox('getData');						// ReSharper disable once MissingHasOwnPropertyInForeach						for (var item in val[0]) {							if (item === 'CheckProjectTypeID') {								$(this).combobox('select', val[0][item]);							}						}					}				});			}		});	}	var chart;	function LoadChart() {		var chartType = $("#hid_ChartType").val();		if (chartType === 'PIE') {			chart = new Highcharts.Chart({				chart: {					renderTo: 'container',					plotBorderColor:"rgba(255, 255, 255, 0)",					events: {						load: ChartQry					},					margin: [50, 200, 100, 80]   //marginTop, marginRight, marginBottom and marginLeft				},				title: {					text: $("#hid_ReportTitle").val(),					style:{color: '#3C3C3C',						fontSize: '22px',						fontWeight:500,						letterSpacing:"1px",						marginTop:"10px"					}				},				plotOptions: {					pie: {						allowPointSelect: true,						cursor: 'pointer',						dataLabels: {							enabled: true,							formatter: function() {								return this.point.name + ' (' + Highcharts.numberFormat(this.percentage, 2) + '%)';							},							color: 'black',							connectorColor: '#000000'						},						showInLegend: true					}				},				legend: {					align: 'right',					verticalAlign: 'middle',					layout: 'vertical',					shadow: false,					labelFormatter: function() {						return this.name + '(' + this.y + ')';					}/*,                        style: {                            left: 'auto',                            bottom: 'auto',                            right: '40px'                            //top: '10px'                        }*/				},				tooltip: {					formatter: function() {						return '<b>' + this.point.name + '</b>: ' + Highcharts.numberFormat(this.percentage, 1) + '% (' + Highcharts.numberFormat(this.y, 0, ',') + ' 个)';					}				},				credits: {					enabled: false				},				series: [{					type: 'pie',					data: [ ]				}]			});		}		else if (chartType === 'COLUMN') {			chart = new Highcharts.Chart({				chart: {					renderTo: 'container',					defaultSeriesType: 'column',					plotBorderColor:"rgba(255, 255, 255, 0)",					events: {						load: ChartQry					},					margin: [50, 50, 100, 80]				},				title: {					text: $("#hid_ReportTitle").val(),					style:{color: '#3C3C3C',						fontSize: '22px',						fontWeight:500,						letterSpacing:"1px",						marginTop:"10px"					}				},				xAxis: {					categories: [],					labels: {						rotation: 0,                                						align: 'center',						style: {							color: '#000000'							//font: 'normal 13px Verdana, sans-serif'						}					}				},				yAxis: {					min: 0,					title: {						text: ''					}				},				legend: {					// 只有一个series,就不要显示了					enabled: false				},				tooltip: {					// 鼠标移到柱上时显示内容					formatter: function() {						return '<b>' + this.x + '</b><br/>' + Highcharts.numberFormat(this.y, $("#hid_NumberFormat").val());					}				},				plotOptions: {  					// 只有一个series,用不同的颜色显示各柱子					series: {						colorByPoint: true					}				},				credits: {					enabled: false				},				series: [{					name: 'series0',					data: [],					dataLabels: {						enabled: true,						rotation: 0,  // 旋转显示						color: 'black',						align: 'center',						//x: 3,						//y: 15,						formatter: function() {							// 直接在柱上显示数值							return Highcharts.numberFormat(this.y,$("#hid_NumberFormat").val());						}					}				}]			});		}		else if (chartType === 'COMBO_DUALAXES') {			chart = new Highcharts.Chart({				chart: {					renderTo: 'container',					plotBorderColor:"rgba(255, 255, 255, 0)",					events: {						load: ChartQry					}/*,						    zoomType: 'xy'*/				},				title: {					text: $("#hid_ReportTitle").val(),					style:{color: '#3C3C3C',						fontSize: '22px',						fontWeight:500,						letterSpacing:"1px",						marginTop:"10px"					}				},				xAxis: [{					categories: [],					labels: {						rotation: 0,                                						align: 'center'					}				}],				yAxis: [{ // Primary yAxis					title: {						text: null,						margin: -70					},					// min设置为0可以使得合格率曲线看上去波动大一点					//min:0,					labels: {						align: 'right',						x:10,						y:-2,						formatter: function() {							return Highcharts.numberFormat(this.value*100, 2) +'%';						},						//x: 0,							    						style: {							color: '#89A54E'						}					},					opposite: false						    				}, { // Secondary yAxis					title: {						text: null,						margin: -20					},					gridLineWidth: 0,   // 避免在点击legend后导致各grid线不对齐(HighCharts的bug)					labels: { 						align: 'left',						x:-10,						y:-2					},					opposite: true     // 坐标是否在正常位置的相反方向(水平轴正常在左边,垂直轴正常在下方)						    				}],				tooltip: {					formatter: function() {						if (this.series.name === '总检测数') {							return ''+ this.x +': '+ this.y + '个';						}						else if (this.series.name === '合格率') {							return ''+ this.x +': '+ Highcharts.numberFormat(this.y*100, 2) + '%';						}						return ''+ this.x +': '+ this.y + '个';					}				},				legend: {					verticalAlign: 'bottom',					layout: 'horizontal',											backgroundColor: '#FFFFFF'				},				credits: {					enabled: false				},				series: [					{						name: '总检测数',						color: '#4572A7',						type: 'column',						dataLabels: {							enabled: true,							rotation: 0,  // 旋转显示							color: 'black',							align: 'center',							formatter: function() {								return Highcharts.numberFormat(this.y, 0);							}						},						yAxis: 1,       // 0表示对应chart.yAxis[0],1表示对应chart.yAxis[1]						data: []    	// HighChart.js在2.2以上的版本可以为空,后面ChartQry会以setData方式覆盖					}, {						name: '合格率',						color: '#89A54E',						        						type: 'spline',						data: []					}				]			});		}	}	function ChartQry() {	    var regionId = $("#SearchRegionID").combobox("getValue"),	        marketId = $("#SearchMarketID").combobox("getValue"),	        corpKind = $("#SearchCorpKind").combobox("getValue"),	        corpName = $("#SearchCorpName").textbox("getValue"),	        littleKindName = $("#SearchLittleKindName").combobox("getValue"),	        sampleName = $("#SearchSampleName").combotree("getValue"),	        checkProjectTypeId = $("#SearchCheckProjectTypeID").combobox("getValue"),	        produceUnit = $("#SearchProduceUnit").textbox("getValue"),            topQty = $("#SearchTopQty").combobox("getValue"),	        order = "Desc",            startTime = $('#SearchStartTime').val(),			endTime = $('#SearchEndTime').val(),			chartType = $("#hid_ChartType").val(),            reportType = $("#hid_ReportType").val();	        if (topQty.indexOf("-") > -1) {	            order = "";	            topQty = topQty.replace("-", "");            }	    console.log(topQty, order);	    $.ajax({	        url: '@Url.Action("DataChartsQryResult", "GetResult")', // 查询接口	        type: 'post',	        dataType: 'json', // 查询接口返回的数据类型	        timeout: 1000000, // 单位=毫秒。为了测试写成1000秒,正式环境下可改为20秒	        data: {	            RegionID: regionId,	            MarketID: marketId,	            StartTime: startTime,	            EndTime: endTime,	            CorpKind: corpKind,	            CorpName: corpName,	            LittleKindName: littleKindName,	            SampleName: sampleName,	            CheckProjectTypeID: checkProjectTypeId,	            ProduceUnit: produceUnit,	            ChartType: chartType,	            ReportType: reportType,                TopQty: topQty,	            Order: order	        }, 			success: function(data) {				// 查询接口无数据返回				if (CheckAajxData(data) === false) return;				var count = eval(data.__totalcount);				if (count === "" || count === null || count === "undefined" || count <= 0)					return;                        				if (chartType === 'PIE') {					chart.series[0].setData(data.__data,false);					chart.redraw();				}				else if (chartType === 'COLUMN') {					chart.xAxis[0].setCategories(data.__categories);					chart.series[0].setData(data.__series[0],false);					chart.redraw();				}				else if (chartType === 'COMBO_DUALAXES') {					chart.xAxis[0].setCategories(data.__categories);					if (data.__series.length === 2) {						chart.series[0].setData(data.__series[1],false);						chart.series[1].setData(data.__series[0],false);						chart.redraw();					}				}			},			// 捕获出错信息(服务器应答超时、返回数据不是json格式等,用于调试)			error: function(xmlHttpRequest, textStatus) {				layer.alert(textStatus, {icon:2, title: '提示信息' });			},			cache: false		});	};	function ChartType()	{		var val=$('input[name="ChartType"]:checked').val();  		if (val === "COLUMN") {			$("#hid_ChartType").val("COLUMN");			$("#hid_NumberFormat").val("0");		} else if (val === "PIE"){			$("#hid_ChartType").val("PIE");			$("#hid_NumberFormat").val("2");		}		LoadChart();	}	var start = {		elem: "#StartTime",		format: "YYYY-MM-DD",		min: "2010-01-01",		event: "focus",		choose: function(datas) {			end.min = datas; //开始日选好后,重置结束日的最小日期			end.start = datas; //将结束日的初始值设定为开始日			$('#SearchStartTime').val(datas);		}	};	var end = {		elem: "#EndTime",		format: "YYYY-MM-DD",		min: "2010-01-01",		event: "focus",		choose: function(datas) {			start.max = datas; //结束日选好后,重置开始日的最大日期			$('#SearchEndTime').val(datas);		}	};	$(function () {		$("#SearchStartTime").next("span").find("input").attr("id", "StartTime");		$("#SearchEndTime").next("span").find("input").attr("id", "EndTime");		$("#SearchStartTime").textbox("setValue", laydate.now(-30, 'YYYY-MM-DD'));		$("#SearchEndTime").textbox("setValue", laydate.now(0, 'YYYY-MM-DD'));		if ($("#hid_IsMarketSysAccount").val() === "0") {			$("#SearchRegionID").combobox("setValue", @ViewBag.RegionID).combobox("disable");			$("#SearchMarketID").combobox("setValue", $("#hid_MarketID").val()).combobox("disable");		} 		GetMarketSelStr();		GetLittleKindSelStr();		//GetCheckProjectSelStr();		//加载图表数据		LoadChart();		//加载日历控件		laydate(start);		laydate(end);	});</script></body></html>
 |