123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597 |
- /**
- * 柱状图
- * @param data
- */
- function getHighchartTjt2(data, id) {
- var nameId = "chartDiv";
- if (id != "" && id != undefined) {
- nameId = id;
- }
- var length = data.color.length;
- var colors = new Array([length]);
- var series = [];
- for (var i = 0; i < length; i++) {
- colors[i] = '#' + data.color[i];
- var type = data.type == '' || data.type == undefined ? '' : data.type[i];
- series[i] = {
- name : data.names[i],
- data : data.yValue[i],
- stack : type
- };
- }
-
- Highcharts.setOptions({
- lang: {
- resetZoom: '重置',
- printChart: '打印图表',
- downloadJPEG: '导出JPEG图片',
- downloadPDF: '导出PDF文件',
- downloadPNG: '导出PNG图片',
- downloadSVG: '导出SVG文件'
- },
- global: { useUTC: false } //不使用时区
- });
-
- var legend = true;
- if (data.from == 'twfb') {
- legend = false;
- }
- var allowDecimals = true; //Y轴是否显示小数
- var spacingLeft = 0; //左边款距离
- var spacingBottom = 0; //下部
- var backgroundColor = ""; //背景色
- var gridLineColor = "#C0C0C0"; //网格线颜色
- if (data.from == "hkclient") {
- legend = false;
- backgroundColor = 'transparent';
- allowDecimals = false;
- spacingLeft = 0;
- spacingBottom = -15;
- gridLineColor = "#142c4c";
- }
-
- var chart = new Highcharts.Chart(nameId,{
- chart: {
- type: 'column',
- spacingLeft : spacingLeft,
- spacingBottom : spacingBottom,
- backgroundColor : backgroundColor
- },
- colors: colors,
- title: {
- text: data.title
- },
- credits: false,
- legend: {
- enabled: legend
- },
- xAxis: {
- categories: data.xValue
- },
- yAxis: {
- allowDecimals: allowDecimals,
- gridLineColor : gridLineColor,
- min: 0,
- title: {
- text: data.ydw
- }
- },
- tooltip: {
- formatter: function() {
- var str = '<b>' + this.x + '</b><br/>' + this.series.name + ': ' + this.y + data.ydw + '<br/>' + '总计: ' + this.point.stackTotal + data.ydw;
- if (this.point.extra != undefined) {
- str += '<br/><b>' + this.point.extra + '</b>';
- }
- // 体重分布平均体重曲线特殊显示
- if (data.from != '' && data.from != undefined && this.series.name == '平均体重') {
- str = '<b>' + this.point.extra + '</b>';
- }
- // 有耳标的温度分布特殊显示
- if (data.from == 'twfb') {
- str = '<b>总计:' + this.point.stackTotal + data.ydw + '</b><br/>' + this.point.extra;
- }
- //体重增长分布
- if (data.from == "tzzzfb") {
- str = '<b>' + this.x + '</b><br/>' + '总计: ' + this.point.stackTotal + data.ydw + '<br/><b>' + this.point.extra + '</b>';
- }
- return str;
- }
- },
- plotOptions: {
- column: {
- stacking: 'normal'
- },
- series: {
- cursor: 'pointer',
- events: {
- click: function(e) {
- if (data.from == "tzzzfb") {
- getTzzzGtxxList(e.point.category);
- }
- if (data.from == "tzfb" && e.point.series.name != "平均体重") {
- var yweb = $("#yweb").val();
- if (yweb == 1 || yweb == "1") {
- getTzfbGtxxList(e.point.category);
- }
- }
- if (data.from == "twfb") {
- var res = e.point.url.split("&");
- getGtxxList($("#mcid").val(), $("#zsid").val(), $("#lqid").val(), "twfb", res[1].split("=")[1], res[2].split("=")[1], res[0].split("=")[1]);
- }
- if (data.from == "xscs_fwfb") {
- getFwfbGtxxList(e.point.category);
- }
- }
- }
- }
- },
- series: series
- });
- }
- /**
- * 线状图
- * @param data
- */
- function getHighchartTjt(data, id) {
- var nameId = "chartDiv";
- if (id != "" && id != undefined) {
- nameId = id;
- }
- var dateFormat = '%m-%d %H:%M:%S';
- var length = data.color.length;
- var colors = new Array([length]);
- var series = [];
- for (var i = 0; i < length; i++) {
- colors[i] = '#' + data.color[i];
- series[i] = {
- name : data.names[i],
- data : data.values[i]
- };
- }
-
- if (data.dateFormat != '' && data.dateFormat != undefined) {
- dateFormat = data.dateFormat;
- }
- Highcharts.setOptions({
-
- lang: {
- resetZoom: '重置',
- printChart: '打印图表',
- downloadJPEG: '导出JPEG图片',
- downloadPDF: '导出PDF文件',
- downloadPNG: '导出PNG图片',
- downloadSVG: '导出SVG文件'
- },
- global: { useUTC: false } //不使用时区
- });
-
- var legend = {
- enabled: true
- }; //是否显示窗格
- var allowDecimals = true; //Y轴是否显示小数
- var spacingLeft = 0; //左边款距离
- var backgroundColor = ""; //背景色
- var gridLineColor = "#C0C0C0"; //网格线颜色
- var title = {
- text: data.title
- };
- if (data.from == "hkclient" || data.from == "hkclient_tjfx" || data.from == "hkclientSy") {
- legend = {
- enabled: false
- };
- if (data.from == "hkclient_tjfx") {
- legend = {
- layout: 'vertical',
- align: 'left',
- verticalAlign: 'top',
- x: 150,
- y: 100,
- floating: true,
- borderWidth: 1,
- backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
- };
- }
- backgroundColor = 'transparent';
- if (data.from != "hkclientSy") {
- allowDecimals = false;
- }
- spacingLeft = 0;
- gridLineColor = "#142c4c";
- title = {
- text:data.title,
- style:{
- color: "#ffffff",
- fontSize: "40px"
- }
- };
- }
- var chart = new Highcharts.Chart(nameId,{
- chart: {
- zoomType: 'x',
- borderWidth: 0,
- backgroundColor: backgroundColor,
- spacingLeft : spacingLeft
- },
- colors: colors,
- title: title,
- xAxis: {
- type: 'datetime',
- minRange: 60 * 1000 * 60,
- dateTimeLabelFormats: {
- second: '%H:%M:%S',
- minute: '%H:%M',
- hour: '%H:%M',
- day: '%m-%d',
- month: '%m-%d',
- week: '%m-%d',
- year: '$Y'
- }
- },
- yAxis: {
- title: {
- //text: '<strong>' + data.ydw + '</strong>'
- text: ''
- },
- allowDecimals: allowDecimals,
- gridLineColor: gridLineColor
- },
- legend: legend,
- credits: {
- enabled: false
- },
- plotOptions: {
- line: {
- turboThreshold: 0,
- marker: {
- radius: 2
- },
- lineWidth: 2,
- states: {
- hover: {
- enabled: false,
- lineWidth: 3
- }
- },
- },
- series: {
- cursor: 'pointer',
- events: {
- click: function(e) {
- // if (data.from == "qttzzz") {
- // tzzzfb(e.point.x);
- // }
- if (data.from == "hkbj_gzxx") {
- showGzxxList(e.point.x);
- }
- }
- }
- }
- },
- tooltip: {
- formatter: function () {
- var sj = Highcharts.dateFormat(dateFormat, this.x);
- if (sj.indexOf("-") > -1) {
- sj = "日期:" + sj;
- } else {
- sj = "时间:" + sj;
- }
- var str = sj + '<br/>' + '<strong>' + this.series.name + ':' + this.y + data.ydw + '</strong>';
- if (this.point.extra != undefined) {
- str += '<br/><strong>' + this.point.extra + '</strong>';
- }
- if (data.from == "hkclient") {
- str = '时间:' + Highcharts.dateFormat(dateFormat, this.x) + '<br/>' + '<strong>' + this.series.name + ':' + this.y + data.ydw + '</strong>';
- }
- return str;
- },
- crosshairs: [ {
- width: 2,
- color: '#FF5B00',
- dashStyle: 'shortdot'
- }, {
- width: 2,
- color: '#FF5B00',
- dashStyle: 'shortdot'
- }]
- },
- series: series
- });
- }
- /**
- *
- * @param mcid 牧场ID
- * @param zsid 猪舍ID
- * @param lqid 栏期ID
- * @param gjz 关键字
- * @param min 最小值
- * @param max 最大值
- * @param time 时间毫秒
- */
- function getGtxxList(mcid, zsid, lqid, gjz, min, max, time, ebh) {
- if (ebh == undefined || ebh == "" || ebh == "undefined") {
- ebh = "000000000000000";
- }
- Dialogs.load('setGtxxList.htm', {"mcid" : mcid, "zsid" : zsid, "lqid" : lqid, "gjz" : gjz, "min" : min, "max" : max, "time" : time, "ebh" : ebh}, {
- // 对话框基本配置选项
- draggable: true, // 是否拖动
- autosize: true, // 是否自适应大小
- resizable: true, // 是否可以改变大小
- maximizable: true, // 是否显示最大化最小化
- autopos: 'fixed', // 窗口是否(自动剧中,fixed)页面 默认’fixed’
- title: "个体信息列表", // 窗口标题
- lightbox: false, // 窗口应用时是否禁用其他操作
- width: 550, // 窗口宽度
- height: 430, // 窗口高度
- autocenter: true // 对话框窗体自动居中
- });
- }
- /**
- * 加载个体信息列表
- * @param id
- * @param param
- * @param fgf
- */
- function loadGtxxList(id, param, fgf) {
- jQuery("#" + id).flexigrid({
- url : 'getGtszList.htm',
- dataType : 'json',
- method : 'post',
- params : [{
- name : 'param',
- value : param
- }, {
- name : 'fgf',
- value : fgf
- }],
- title : '<b>个体生长浏览</b>',
- usepager : true,
- useRp : true,
- rp : 10,
- singleSelect : true,
- hidehead : false,
- showInputPage : true,
- showSelectRp : false,
- showTableToggleBtn : false,
- width : '790',
- height : '335',
- nowrap : true,
- resizable : false,
- cache : false,// 清除缓存
- colModel : [{
- display : '行号',
- name : 'hh',
- width : 25,
- sortable : false,
- align : 'center',
- process : function(col, record, d) {
- jQuery(col).html(d + 1);
- }
- }, {
- display : '动物耳标',
- name : 'dweb',
- width : 95,
- sortable : true,
- align : 'center',
- process : function(col, record, d) {
- jQuery(col).html("<font color = " + record.ysbz + ">" + record.dweb + "</font>");
- }
-
- }, {
- display : '当前体重(Kg)',
- name : 'dqtz',
- width : 65,
- sortable : false,
- align : 'center'
- }, {
- display : '体重增长(g)',
- name : 'tzzz',
- width : 65,
- sortable : false,
- align : 'center'
- }, {
- display : '注册体重(Kg)',
- name : 'rltz',
- width : 70,
- sortable : false,
- align : 'center'
- }, {
- display : '当前温度(℃)',
- name : 'dqwd',
- width : 70,
- sortable : false,
- align : 'center'
- }, {
- display : '入栏日期',
- name : 'rlsj',
- width : 65,
- sortable : false,
- align : 'center'
- }, {
- display : '全程温度',
- name : '',
- width : 55,
- sortable : false,
- align : 'center',
- process : function(col, record, d) {
- jQuery(col).addClass('s');
- jQuery(col).html(record.qcwd);
- }
- }, {
- display : '体重变化',
- name : '',
- width : 55,
- sortable : false,
- align : 'center',
- process : function(col, record, d) {
- jQuery(col).addClass('s');
- jQuery(col).html(record.tzbh);
- }
- }, {
- display : '体重增长',
- name : '',
- width : 55,
- sortable : false,
- align : 'center',
- process : function(col, record, d) {
- jQuery(col).addClass('s');
- jQuery(col).html(record.zztjt);
- }
- }, {
- display : '颜色标识',
- name : '',
- width : 45,
- sortable : false,
- align : 'center',
- process : function(col, record, d) {
- var html = selectYsbz(record.lqid, record.dweb, record.ysbz);
- jQuery(col).html(html);
- }
- }, {
- display : '是否异常',
- name : '',
- width : 45,
- sortable : false,
- align : 'center',
- process : function(col, record, d) {
- var html = selectSfyc(record.lqid, record.dweb, record.sfyc);
- jQuery(col).html(html);
- }
- }]
- });
- }
- /**
- * 个体信息颜色标识下拉框
- */
- function selectYsbz(lqid, dweb, ysbz) {
- var html = "<select id='ysbz" + dweb + "' onchange='getYsbzChange(" + lqid + "," + dweb + ", this.value)'>";
- if (ysbz == "" || ysbz == "0" || ysbz == undefined) {
- html += "<option value='' selected='selected'>无</option>";
- } else {
- html += "<option value=''>无</option>";
- }
- if (ysbz == "blue") {
- html += "<option value='blue' selected='selected'>蓝</option>";
- } else {
- html += "<option value='blue'>蓝</option>";
- }
- if (ysbz == "green") {
- html += "<option value='green' selected='selected'>绿</option>";
- } else {
- html += "<option value='green'>绿</option>";
- }
-
- if (ysbz == "red") {
- html += "<option value='red' selected='selected'>红</option>";
- } else {
- html += "<option value='red'>红</option>";
- }
- html += "</select>";
- return html;
- }
- /**
- * 颜色标识变更
- */
- function getYsbzChange(lqid, dweb, ysbz) {
- if (lqid != "" && dweb != "") {
- jQuery.ajax({
- url: "setYsbz.htm",
- dataType: "json",
- type: "post",
- async: false,
- data : {"lqid" : lqid, "dweb" : dweb, "ysbz" : ysbz},
- success: function(data){
- if (data.returnCode == 0) {
- $("#ysbz" + dweb).val("0");
- alert("颜色标识变更失败");
- }
- }
- });
- }
- }
- /**
- * 个体信息
- * @param dweb
- */
- function showGtxx(dweb, param, fgf, tjt) {
- param += fgf + '{name : tjt,value : ' + tjt + '}';
- param += fgf + '{name : dweb,value : ' + dweb + '}';
- var params = [{
- name : 'param',
- value : param
- }, {
- name : 'fgf',
- value : fgf
- }];
- huimv.loadPage("gtszDiv", "getGtxxtjt.htm", params);
- $("#gtszDiv").show();
- $("#gtszTable").hide();
- }
- /**
- * 是否异常下拉框
- */
- function selectSfyc(lqid, dweb, sfyc) {
- var html = "<select id='sfyc" + dweb + "' onchange='getSfycChange(" + lqid + "," + dweb + ", this.value)'>";
- if (sfyc == "0") {
- html += "<option value='0' selected='selected'>正常</option>";
- } else {
- html += "<option value='0'>正常</option>";
- }
- if (sfyc == "1") {
- html += "<option value='1' selected='selected'>异常</option>";
- } else {
- html += "<option value='1'>异常</option>";
- }
- html += "</select>";
- return html;
- }
- /**
- * 是否异常变更
- */
- function getSfycChange(lqid, dweb, sfyc) {
- var oldSfyc = 1 - sfyc;
- var sfycmc = sfyc == '0' ? "正常" : "异常";
-
- if (lqid != "" && dweb != "") {
- Dialogs.alert("确定变更为" + sfycmc + "?", {
- title : '提示信息',
- width : 250,
- height : 80,
- top : 150,
- button : {
- ok : ['确定',function(){
- this.close();
-
- jQuery.ajax({
- url: "setSfyc.htm",
- dataType: "json",
- type: "post",
- async: false,
- data : {"lqid" : lqid, "dweb" : dweb, "sfyc" : sfyc},
- success: function(data){
- if (data.returnCode > 0) {
- alert("操作成功");
- } else {
- $("#sfyc" + dweb).val(oldSfyc);
- alert("操作失败");
- }
- }
- });
- }],
- cancel : ['取消',function(){
- this.close();
- $("#sfyc" + dweb).val(oldSfyc);
- }]
- }
- });
- }
- }
|