tjt.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. /**
  2. * 柱状图
  3. * @param data
  4. */
  5. function getHighchartTjt2(data, id) {
  6. var nameId = "chartDiv";
  7. if (id != "" && id != undefined) {
  8. nameId = id;
  9. }
  10. var length = data.color.length;
  11. var colors = new Array([length]);
  12. var series = [];
  13. for (var i = 0; i < length; i++) {
  14. colors[i] = '#' + data.color[i];
  15. var type = data.type == '' || data.type == undefined ? '' : data.type[i];
  16. series[i] = {
  17. name : data.names[i],
  18. data : data.yValue[i],
  19. stack : type
  20. };
  21. }
  22. Highcharts.setOptions({
  23. lang: {
  24. resetZoom: '重置',
  25. printChart: '打印图表',
  26. downloadJPEG: '导出JPEG图片',
  27. downloadPDF: '导出PDF文件',
  28. downloadPNG: '导出PNG图片',
  29. downloadSVG: '导出SVG文件'
  30. },
  31. global: { useUTC: false } //不使用时区
  32. });
  33. var legend = true;
  34. if (data.from == 'twfb') {
  35. legend = false;
  36. }
  37. var allowDecimals = true; //Y轴是否显示小数
  38. var spacingLeft = 0; //左边款距离
  39. var spacingBottom = 0; //下部
  40. var backgroundColor = ""; //背景色
  41. var gridLineColor = "#C0C0C0"; //网格线颜色
  42. if (data.from == "hkclient") {
  43. legend = false;
  44. backgroundColor = 'transparent';
  45. allowDecimals = false;
  46. spacingLeft = 0;
  47. spacingBottom = -15;
  48. gridLineColor = "#142c4c";
  49. }
  50. var chart = new Highcharts.Chart(nameId,{
  51. chart: {
  52. type: 'column',
  53. spacingLeft : spacingLeft,
  54. spacingBottom : spacingBottom,
  55. backgroundColor : backgroundColor
  56. },
  57. colors: colors,
  58. title: {
  59. text: data.title
  60. },
  61. credits: false,
  62. legend: {
  63. enabled: legend
  64. },
  65. xAxis: {
  66. categories: data.xValue
  67. },
  68. yAxis: {
  69. allowDecimals: allowDecimals,
  70. gridLineColor : gridLineColor,
  71. min: 0,
  72. title: {
  73. text: data.ydw
  74. }
  75. },
  76. tooltip: {
  77. formatter: function() {
  78. var str = '<b>' + this.x + '</b><br/>' + this.series.name + ': ' + this.y + data.ydw + '<br/>' + '总计: ' + this.point.stackTotal + data.ydw;
  79. if (this.point.extra != undefined) {
  80. str += '<br/><b>' + this.point.extra + '</b>';
  81. }
  82. // 体重分布平均体重曲线特殊显示
  83. if (data.from != '' && data.from != undefined && this.series.name == '平均体重') {
  84. str = '<b>' + this.point.extra + '</b>';
  85. }
  86. // 有耳标的温度分布特殊显示
  87. if (data.from == 'twfb') {
  88. str = '<b>总计:' + this.point.stackTotal + data.ydw + '</b><br/>' + this.point.extra;
  89. }
  90. //体重增长分布
  91. if (data.from == "tzzzfb") {
  92. str = '<b>' + this.x + '</b><br/>' + '总计: ' + this.point.stackTotal + data.ydw + '<br/><b>' + this.point.extra + '</b>';
  93. }
  94. return str;
  95. }
  96. },
  97. plotOptions: {
  98. column: {
  99. stacking: 'normal'
  100. },
  101. series: {
  102. cursor: 'pointer',
  103. events: {
  104. click: function(e) {
  105. if (data.from == "tzzzfb") {
  106. getTzzzGtxxList(e.point.category);
  107. }
  108. if (data.from == "tzfb" && e.point.series.name != "平均体重") {
  109. var yweb = $("#yweb").val();
  110. if (yweb == 1 || yweb == "1") {
  111. getTzfbGtxxList(e.point.category);
  112. }
  113. }
  114. if (data.from == "twfb") {
  115. var res = e.point.url.split("&");
  116. getGtxxList($("#mcid").val(), $("#zsid").val(), $("#lqid").val(), "twfb", res[1].split("=")[1], res[2].split("=")[1], res[0].split("=")[1]);
  117. }
  118. if (data.from == "xscs_fwfb") {
  119. getFwfbGtxxList(e.point.category);
  120. }
  121. }
  122. }
  123. }
  124. },
  125. series: series
  126. });
  127. }
  128. /**
  129. * 线状图
  130. * @param data
  131. */
  132. function getHighchartTjt(data, id) {
  133. var nameId = "chartDiv";
  134. if (id != "" && id != undefined) {
  135. nameId = id;
  136. }
  137. var dateFormat = '%m-%d %H:%M:%S';
  138. var length = data.color.length;
  139. var colors = new Array([length]);
  140. var series = [];
  141. for (var i = 0; i < length; i++) {
  142. colors[i] = '#' + data.color[i];
  143. series[i] = {
  144. name : data.names[i],
  145. data : data.values[i]
  146. };
  147. }
  148. if (data.dateFormat != '' && data.dateFormat != undefined) {
  149. dateFormat = data.dateFormat;
  150. }
  151. Highcharts.setOptions({
  152. lang: {
  153. resetZoom: '重置',
  154. printChart: '打印图表',
  155. downloadJPEG: '导出JPEG图片',
  156. downloadPDF: '导出PDF文件',
  157. downloadPNG: '导出PNG图片',
  158. downloadSVG: '导出SVG文件'
  159. },
  160. global: { useUTC: false } //不使用时区
  161. });
  162. var legend = {
  163. enabled: true
  164. }; //是否显示窗格
  165. var allowDecimals = true; //Y轴是否显示小数
  166. var spacingLeft = 0; //左边款距离
  167. var backgroundColor = ""; //背景色
  168. var gridLineColor = "#C0C0C0"; //网格线颜色
  169. var title = {
  170. text: data.title
  171. };
  172. if (data.from == "hkclient" || data.from == "hkclient_tjfx" || data.from == "hkclientSy") {
  173. legend = {
  174. enabled: false
  175. };
  176. if (data.from == "hkclient_tjfx") {
  177. legend = {
  178. layout: 'vertical',
  179. align: 'left',
  180. verticalAlign: 'top',
  181. x: 150,
  182. y: 100,
  183. floating: true,
  184. borderWidth: 1,
  185. backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
  186. };
  187. }
  188. backgroundColor = 'transparent';
  189. if (data.from != "hkclientSy") {
  190. allowDecimals = false;
  191. }
  192. spacingLeft = 0;
  193. gridLineColor = "#142c4c";
  194. title = {
  195. text:data.title,
  196. style:{
  197. color: "#ffffff",
  198. fontSize: "40px"
  199. }
  200. };
  201. }
  202. var chart = new Highcharts.Chart(nameId,{
  203. chart: {
  204. zoomType: 'x',
  205. borderWidth: 0,
  206. backgroundColor: backgroundColor,
  207. spacingLeft : spacingLeft
  208. },
  209. colors: colors,
  210. title: title,
  211. xAxis: {
  212. type: 'datetime',
  213. minRange: 60 * 1000 * 60,
  214. dateTimeLabelFormats: {
  215. second: '%H:%M:%S',
  216. minute: '%H:%M',
  217. hour: '%H:%M',
  218. day: '%m-%d',
  219. month: '%m-%d',
  220. week: '%m-%d',
  221. year: '$Y'
  222. }
  223. },
  224. yAxis: {
  225. title: {
  226. //text: '<strong>' + data.ydw + '</strong>'
  227. text: ''
  228. },
  229. allowDecimals: allowDecimals,
  230. gridLineColor: gridLineColor
  231. },
  232. legend: legend,
  233. credits: {
  234. enabled: false
  235. },
  236. plotOptions: {
  237. line: {
  238. turboThreshold: 0,
  239. marker: {
  240. radius: 2
  241. },
  242. lineWidth: 2,
  243. states: {
  244. hover: {
  245. enabled: false,
  246. lineWidth: 3
  247. }
  248. },
  249. },
  250. series: {
  251. cursor: 'pointer',
  252. events: {
  253. click: function(e) {
  254. // if (data.from == "qttzzz") {
  255. // tzzzfb(e.point.x);
  256. // }
  257. if (data.from == "hkbj_gzxx") {
  258. showGzxxList(e.point.x);
  259. }
  260. }
  261. }
  262. }
  263. },
  264. tooltip: {
  265. formatter: function () {
  266. var sj = Highcharts.dateFormat(dateFormat, this.x);
  267. if (sj.indexOf("-") > -1) {
  268. sj = "日期:" + sj;
  269. } else {
  270. sj = "时间:" + sj;
  271. }
  272. var str = sj + '<br/>' + '<strong>' + this.series.name + ':' + this.y + data.ydw + '</strong>';
  273. if (this.point.extra != undefined) {
  274. str += '<br/><strong>' + this.point.extra + '</strong>';
  275. }
  276. if (data.from == "hkclient") {
  277. str = '时间:' + Highcharts.dateFormat(dateFormat, this.x) + '<br/>' + '<strong>' + this.series.name + ':' + this.y + data.ydw + '</strong>';
  278. }
  279. return str;
  280. },
  281. crosshairs: [ {
  282. width: 2,
  283. color: '#FF5B00',
  284. dashStyle: 'shortdot'
  285. }, {
  286. width: 2,
  287. color: '#FF5B00',
  288. dashStyle: 'shortdot'
  289. }]
  290. },
  291. series: series
  292. });
  293. }
  294. /**
  295. *
  296. * @param mcid 牧场ID
  297. * @param zsid 猪舍ID
  298. * @param lqid 栏期ID
  299. * @param gjz 关键字
  300. * @param min 最小值
  301. * @param max 最大值
  302. * @param time 时间毫秒
  303. */
  304. function getGtxxList(mcid, zsid, lqid, gjz, min, max, time, ebh) {
  305. if (ebh == undefined || ebh == "" || ebh == "undefined") {
  306. ebh = "000000000000000";
  307. }
  308. Dialogs.load('setGtxxList.htm', {"mcid" : mcid, "zsid" : zsid, "lqid" : lqid, "gjz" : gjz, "min" : min, "max" : max, "time" : time, "ebh" : ebh}, {
  309. // 对话框基本配置选项
  310. draggable: true, // 是否拖动
  311. autosize: true, // 是否自适应大小
  312. resizable: true, // 是否可以改变大小
  313. maximizable: true, // 是否显示最大化最小化
  314. autopos: 'fixed', // 窗口是否(自动剧中,fixed)页面 默认’fixed’
  315. title: "个体信息列表", // 窗口标题
  316. lightbox: false, // 窗口应用时是否禁用其他操作
  317. width: 550, // 窗口宽度
  318. height: 430, // 窗口高度
  319. autocenter: true // 对话框窗体自动居中
  320. });
  321. }
  322. /**
  323. * 加载个体信息列表
  324. * @param id
  325. * @param param
  326. * @param fgf
  327. */
  328. function loadGtxxList(id, param, fgf) {
  329. jQuery("#" + id).flexigrid({
  330. url : 'getGtszList.htm',
  331. dataType : 'json',
  332. method : 'post',
  333. params : [{
  334. name : 'param',
  335. value : param
  336. }, {
  337. name : 'fgf',
  338. value : fgf
  339. }],
  340. title : '<b>个体生长浏览</b>',
  341. usepager : true,
  342. useRp : true,
  343. rp : 10,
  344. singleSelect : true,
  345. hidehead : false,
  346. showInputPage : true,
  347. showSelectRp : false,
  348. showTableToggleBtn : false,
  349. width : '790',
  350. height : '335',
  351. nowrap : true,
  352. resizable : false,
  353. cache : false,// 清除缓存
  354. colModel : [{
  355. display : '行号',
  356. name : 'hh',
  357. width : 25,
  358. sortable : false,
  359. align : 'center',
  360. process : function(col, record, d) {
  361. jQuery(col).html(d + 1);
  362. }
  363. }, {
  364. display : '动物耳标',
  365. name : 'dweb',
  366. width : 95,
  367. sortable : true,
  368. align : 'center',
  369. process : function(col, record, d) {
  370. jQuery(col).html("<font color = " + record.ysbz + ">" + record.dweb + "</font>");
  371. }
  372. }, {
  373. display : '当前体重(Kg)',
  374. name : 'dqtz',
  375. width : 65,
  376. sortable : false,
  377. align : 'center'
  378. }, {
  379. display : '体重增长(g)',
  380. name : 'tzzz',
  381. width : 65,
  382. sortable : false,
  383. align : 'center'
  384. }, {
  385. display : '注册体重(Kg)',
  386. name : 'rltz',
  387. width : 70,
  388. sortable : false,
  389. align : 'center'
  390. }, {
  391. display : '当前温度(℃)',
  392. name : 'dqwd',
  393. width : 70,
  394. sortable : false,
  395. align : 'center'
  396. }, {
  397. display : '入栏日期',
  398. name : 'rlsj',
  399. width : 65,
  400. sortable : false,
  401. align : 'center'
  402. }, {
  403. display : '全程温度',
  404. name : '',
  405. width : 55,
  406. sortable : false,
  407. align : 'center',
  408. process : function(col, record, d) {
  409. jQuery(col).addClass('s');
  410. jQuery(col).html(record.qcwd);
  411. }
  412. }, {
  413. display : '体重变化',
  414. name : '',
  415. width : 55,
  416. sortable : false,
  417. align : 'center',
  418. process : function(col, record, d) {
  419. jQuery(col).addClass('s');
  420. jQuery(col).html(record.tzbh);
  421. }
  422. }, {
  423. display : '体重增长',
  424. name : '',
  425. width : 55,
  426. sortable : false,
  427. align : 'center',
  428. process : function(col, record, d) {
  429. jQuery(col).addClass('s');
  430. jQuery(col).html(record.zztjt);
  431. }
  432. }, {
  433. display : '颜色标识',
  434. name : '',
  435. width : 45,
  436. sortable : false,
  437. align : 'center',
  438. process : function(col, record, d) {
  439. var html = selectYsbz(record.lqid, record.dweb, record.ysbz);
  440. jQuery(col).html(html);
  441. }
  442. }, {
  443. display : '是否异常',
  444. name : '',
  445. width : 45,
  446. sortable : false,
  447. align : 'center',
  448. process : function(col, record, d) {
  449. var html = selectSfyc(record.lqid, record.dweb, record.sfyc);
  450. jQuery(col).html(html);
  451. }
  452. }]
  453. });
  454. }
  455. /**
  456. * 个体信息颜色标识下拉框
  457. */
  458. function selectYsbz(lqid, dweb, ysbz) {
  459. var html = "<select id='ysbz" + dweb + "' onchange='getYsbzChange(" + lqid + "," + dweb + ", this.value)'>";
  460. if (ysbz == "" || ysbz == "0" || ysbz == undefined) {
  461. html += "<option value='' selected='selected'>无</option>";
  462. } else {
  463. html += "<option value=''>无</option>";
  464. }
  465. if (ysbz == "blue") {
  466. html += "<option value='blue' selected='selected'>蓝</option>";
  467. } else {
  468. html += "<option value='blue'>蓝</option>";
  469. }
  470. if (ysbz == "green") {
  471. html += "<option value='green' selected='selected'>绿</option>";
  472. } else {
  473. html += "<option value='green'>绿</option>";
  474. }
  475. if (ysbz == "red") {
  476. html += "<option value='red' selected='selected'>红</option>";
  477. } else {
  478. html += "<option value='red'>红</option>";
  479. }
  480. html += "</select>";
  481. return html;
  482. }
  483. /**
  484. * 颜色标识变更
  485. */
  486. function getYsbzChange(lqid, dweb, ysbz) {
  487. if (lqid != "" && dweb != "") {
  488. jQuery.ajax({
  489. url: "setYsbz.htm",
  490. dataType: "json",
  491. type: "post",
  492. async: false,
  493. data : {"lqid" : lqid, "dweb" : dweb, "ysbz" : ysbz},
  494. success: function(data){
  495. if (data.returnCode == 0) {
  496. $("#ysbz" + dweb).val("0");
  497. alert("颜色标识变更失败");
  498. }
  499. }
  500. });
  501. }
  502. }
  503. /**
  504. * 个体信息
  505. * @param dweb
  506. */
  507. function showGtxx(dweb, param, fgf, tjt) {
  508. param += fgf + '{name : tjt,value : ' + tjt + '}';
  509. param += fgf + '{name : dweb,value : ' + dweb + '}';
  510. var params = [{
  511. name : 'param',
  512. value : param
  513. }, {
  514. name : 'fgf',
  515. value : fgf
  516. }];
  517. huimv.loadPage("gtszDiv", "getGtxxtjt.htm", params);
  518. $("#gtszDiv").show();
  519. $("#gtszTable").hide();
  520. }
  521. /**
  522. * 是否异常下拉框
  523. */
  524. function selectSfyc(lqid, dweb, sfyc) {
  525. var html = "<select id='sfyc" + dweb + "' onchange='getSfycChange(" + lqid + "," + dweb + ", this.value)'>";
  526. if (sfyc == "0") {
  527. html += "<option value='0' selected='selected'>正常</option>";
  528. } else {
  529. html += "<option value='0'>正常</option>";
  530. }
  531. if (sfyc == "1") {
  532. html += "<option value='1' selected='selected'>异常</option>";
  533. } else {
  534. html += "<option value='1'>异常</option>";
  535. }
  536. html += "</select>";
  537. return html;
  538. }
  539. /**
  540. * 是否异常变更
  541. */
  542. function getSfycChange(lqid, dweb, sfyc) {
  543. var oldSfyc = 1 - sfyc;
  544. var sfycmc = sfyc == '0' ? "正常" : "异常";
  545. if (lqid != "" && dweb != "") {
  546. Dialogs.alert("确定变更为" + sfycmc + "?", {
  547. title : '提示信息',
  548. width : 250,
  549. height : 80,
  550. top : 150,
  551. button : {
  552. ok : ['确定',function(){
  553. this.close();
  554. jQuery.ajax({
  555. url: "setSfyc.htm",
  556. dataType: "json",
  557. type: "post",
  558. async: false,
  559. data : {"lqid" : lqid, "dweb" : dweb, "sfyc" : sfyc},
  560. success: function(data){
  561. if (data.returnCode > 0) {
  562. alert("操作成功");
  563. } else {
  564. $("#sfyc" + dweb).val(oldSfyc);
  565. alert("操作失败");
  566. }
  567. }
  568. });
  569. }],
  570. cancel : ['取消',function(){
  571. this.close();
  572. $("#sfyc" + dweb).val(oldSfyc);
  573. }]
  574. }
  575. });
  576. }
  577. }