home_page.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. var name = '';
  2. var ZTQS_TIME = 'W'; //整体趋势: W周;M月
  3. var HZLY_TIME = 'W'; //患者来源: W周;M月
  4. var SEL_TYPE = 1; //指标类型1~6
  5. var SEL_TYPE_HZLY = 3; //3累计绑定就诊卡数; 4累计线上门诊人数;
  6. $(function () {
  7. $('#btn-blue-1 .circlebg-blue').click(function(){
  8. $('#btn-blue-1 .circlebg-blue').removeClass('t-sortby');
  9. $(this).addClass('t-sortby');
  10. })
  11. $('#btn-blue-2 .circlebg-blue').click(function(){
  12. $('#btn-blue-2 .circlebg-blue').removeClass('t-sortby');
  13. $(this).addClass('t-sortby');
  14. })
  15. $('#datepickerA1').blur(function(){
  16. var start = $('#datepickerA1').val();
  17. var end = $('#datepickerA2').val();
  18. if (start>end){
  19. Commonjs.alert("开始时间应小于结束时间");
  20. }
  21. });
  22. $('#datepickerA2').blur(function(){
  23. var start = $('#datepickerA1').val();
  24. var end = $('#datepickerA2').val();
  25. if (start>end){
  26. Commonjs.alert("开始时间应小于结束时间");
  27. }
  28. });
  29. $('#datepickerB1').blur(function(){
  30. var start = $('#datepickerB1').val();
  31. var end = $('#datepickerB2').val();
  32. if (start>end){
  33. Commonjs.alert("开始时间应小于结束时间");
  34. }
  35. });
  36. $('#datepickerB2').blur(function(){
  37. var start = $('#datepickerB1').val();
  38. var end = $('#datepickerB2').val();
  39. if (start>end){
  40. Commonjs.alert("开始时间应小于结束时间");
  41. }
  42. });
  43. $('#btn-week-1').click(function(){
  44. ZTQS_TIME = 'W';
  45. //$('#btn-month-1').removeClass('t-sortby');
  46. //$('#btn-week-1').addClass('t-sortby');
  47. $('#datepickerA1').datetimepicker({value:Commonjs.getDate(-7)});
  48. $('#datepickerA2').datetimepicker({value:Commonjs.getDate(-1)});
  49. loadGrid(1);
  50. setSelType(SEL_TYPE);
  51. });
  52. $('#btn-month-1').click(function(){
  53. ZTQS_TIME = 'M';
  54. //$('#btn-week-1').removeClass('t-sortby');
  55. //$('#btn-month-1').addClass('t-sortby');
  56. $('#datepickerA1').datetimepicker({value:Commonjs.getDate(-30)});
  57. $('#datepickerA2').datetimepicker({value:Commonjs.getDate(-1)});
  58. loadGrid(1);
  59. setSelType(SEL_TYPE);
  60. });
  61. $('#btn-week-2').click(function(){
  62. HZLY_TIME = 'W';
  63. $('#datepickerB1').datetimepicker({value:Commonjs.getDate(-7)});
  64. $('#datepickerB2').datetimepicker({value:Commonjs.getDate(-1)});
  65. setSelTypeHzly(SEL_TYPE_HZLY);
  66. });
  67. $('#btn-month-2').click(function(){
  68. HZLY_TIME = 'M';
  69. $('#datepickerB1').datetimepicker({value:Commonjs.getDate(-30)});
  70. $('#datepickerB2').datetimepicker({value:Commonjs.getDate(-1)});
  71. setSelTypeHzly(SEL_TYPE_HZLY);
  72. });
  73. //点击日期文本框
  74. $('#datepickerA1,#datepickerA2').datetimepicker({onSelectDate:function(dp,input){
  75. var start = $('#datepickerA1').val();
  76. var end = $('#datepickerA2').val();
  77. if (start>end){
  78. Commonjs.alert("开始时间应小于结束时间");
  79. }else {
  80. loadGrid(1);
  81. setSelType(SEL_TYPE);
  82. }
  83. }});
  84. $('#datepickerB1,#datepickerB2').datetimepicker({onSelectDate:function(dp,input){
  85. var start = $('#datepickerB1').val();
  86. var end = $('#datepickerB2').val();
  87. if (start>end){
  88. Commonjs.alert("开始时间应小于结束时间");
  89. }else {
  90. setSelTypeHzly(SEL_TYPE_HZLY);
  91. }
  92. }});
  93. getDCsummary('Y');
  94. //spline(setSplineDivName(0));
  95. //showBar(setBarDivName(0));
  96. setTimeout(function(){
  97. loadGrid(1);
  98. setSelType(SEL_TYPE);
  99. setSelTypeHzly(SEL_TYPE_HZLY);
  100. },500);
  101. });
  102. /**
  103. * 加载表格数据
  104. *
  105. * @param {Object} index
  106. * @return {TypeName}
  107. */
  108. var loadGrid =function (index){
  109. $('#pagenumber').val(index);
  110. var pageIndex = index-1;
  111. var pageSize = 8;
  112. var param = {};
  113. var Service = {};
  114. Service.begindate = $('#datepickerA1').val();
  115. Service.enddate = $('#datepickerA2').val();
  116. var page = {};
  117. page.PIndex = pageIndex;
  118. page.PSize = pageSize;
  119. var code = 7008;
  120. var params = Commonjs.getParams(code,Service,page);//获取参数
  121. param.Api = "getDCGrid";
  122. param.Params = Commonjs.jsonToString(params);
  123. var d = Commonjs.ajax('./datacollection_callDataCollectionApi.do',param,false);
  124. $("#alltableid tr:gt(0)").remove();
  125. if(d.RespCode != 10000){
  126. Page(0,pageSize,'pager');
  127. return;
  128. }
  129. if(d.Page.PCount!=undefined){
  130. if(d.Page.PCount!=0){
  131. $("#totalcount").val(d.Page.PCount);
  132. }else{
  133. if(d.Page.PIndex==0)
  134. $("#totalcount").val(0);
  135. }
  136. }else{
  137. $("#totalcount").val(0);
  138. }
  139. Page($("#totalcount").val(),d.Page.PSize,'pager');
  140. var log = d.Data;
  141. if(!Commonjs.isEmpty(log)) {
  142. var tep = [];
  143. if(log.length==undefined&&!Commonjs.isEmpty(log.OperTime)){
  144. tep.push(log);
  145. log = tep;
  146. }
  147. for(var i=0;i<log.length;i++){
  148. $('#alltableid').append("<tr><td>"+log[i].OperTime+"</td><td>"+log[i].Type1+"</td><td>"+log[i].Type2+"</td><td>"+log[i].Type3+"</td><td>"+log[i].Type4+"</td><td>"+log[i].Type5+"</td><td><font color=red>¥</font>"+log[i].Type6/100.00+"</td></tr>");
  149. }
  150. }else {
  151. $('#alltableid').append("<tr align=center><td colspan=7><font color=red>未找到相关数据!</font></td></tr>");
  152. }
  153. };
  154. /**
  155. * 整体趋势中的选中
  156. * @param {Object} t
  157. */
  158. var setSelType = function(t) {
  159. SEL_TYPE = t;
  160. setDCline(t);
  161. }
  162. /**
  163. * 患者来源中的选中
  164. * @param {Object} t
  165. */
  166. var setSelTypeHzly = function(t) {
  167. SEL_TYPE_HZLY = t;
  168. setDCbar(t);
  169. }
  170. /**
  171. * 点折图数据
  172. * @param {Object} type
  173. * @return {TypeName}
  174. */
  175. var setDCline = function(type) {
  176. var param = {};
  177. var Service = {};
  178. Service.begindate = $('#datepickerA1').val();
  179. Service.enddate = $('#datepickerA2').val();
  180. Service.datatype = type;
  181. var code = 7009;
  182. var params = Commonjs.getParams(code,Service);//获取参数
  183. param.Api = "getDCLine";
  184. param.Params = Commonjs.jsonToString(params);
  185. var d = Commonjs.ajax('./datacollection_callDataCollectionApi.do',param,false);
  186. if(d.RespCode != 10000){
  187. return;
  188. }
  189. var log = d.Data;
  190. if(!Commonjs.isEmpty(log)) {
  191. var tep = [];
  192. if(log.length==undefined){
  193. tep.push(log);
  194. log = tep;
  195. }
  196. var div = setSplineDivName(type-1);
  197. spline(div, log[0].Categories, log[0].All, log[0].Wx,log[0].Bd, log[0].Zfb);
  198. }
  199. }
  200. /**
  201. * 条形图数据
  202. * @param {Object} type
  203. * @return {TypeName}
  204. */
  205. var setDCbar = function(type) {
  206. var param = {};
  207. var Service = {};
  208. Service.begindate = $('#datepickerB1').val();
  209. Service.enddate = $('#datepickerB2').val();
  210. Service.datatype = type;
  211. var code = 7010;
  212. var params = Commonjs.getParams(code,Service);//获取参数
  213. param.Api = "getDCbar";
  214. param.Params = Commonjs.jsonToString(params);
  215. var d = Commonjs.ajax('./datacollection_callDataCollectionApi.do',param,false);
  216. if(d.RespCode != 10000){
  217. return;
  218. }
  219. var log = d.Data;
  220. if(!Commonjs.isEmpty(log)) {
  221. var tep = [];
  222. if(log.length==undefined&&!Commonjs.isEmpty(log.Categories)){
  223. tep.push(log);
  224. log = tep;
  225. }
  226. var div = setBarDivName(type-3);
  227. showBar(div, log[0].Wx, log[0].Zfb, log[0].Bd);
  228. }
  229. }
  230. /**
  231. * 获取概要统计值
  232. * @param {Object} flag
  233. * @return {TypeName}
  234. */
  235. var getDCsummary = function(flag) {
  236. var param = {};
  237. var Service = {};
  238. Service.searchflag = flag;
  239. var code = 7007;
  240. var params = Commonjs.getParams(code,Service);//获取参数
  241. param.Api = "getDCSummary";
  242. param.Params = Commonjs.jsonToString(params);
  243. var d = Commonjs.ajax('./datacollection_callDataCollectionApi.do',param,false);
  244. $('#type1').html('0');
  245. $('#type2').html('0');
  246. $('#type3').html('0');
  247. $('#type4').html('0');
  248. $('#type5').html('0');
  249. $('#type6').html('<font color=red>¥</font>0.00');
  250. if(d.RespCode == 10000&&d.Data!=undefined){
  251. var res = d.Data;
  252. var tep = [];
  253. if(res.length==undefined&&!Commonjs.isEmpty(res.DataType)){
  254. tep.push(res);
  255. res = tep;
  256. }
  257. if(!Commonjs.isEmpty(res)&&!Commonjs.isEmpty(res.length)) {
  258. for(var i=0;i<res.length;i++) {
  259. if(res[i].DataType!=6) {
  260. $('#type'+res[i].DataType).html(res[i].DataValue);
  261. }else {
  262. $('#type'+res[i].DataType).html('<font color=red>¥</font>'+res[i].DataValue/100);
  263. }
  264. }
  265. }
  266. }
  267. }
  268. /**
  269. * 点折图
  270. *
  271. * @param {Object} id
  272. * @param {Object} categoriesP
  273. * @param {Object} data 格式: eval('[2,3,4]')
  274. */
  275. var spline = function(id, categoriesP, alldata, wx,bd, zfb){
  276. $('#'+id).empty();
  277. $('#'+id).highcharts({
  278. title: {
  279. text: '', x: -10
  280. },
  281. subtitle: {
  282. text: '',x: -10
  283. },
  284. xAxis: {
  285. categories: eval(categoriesP)//['01-01', '02-01', '03-01']
  286. },
  287. yAxis: {
  288. title: {
  289. text: ''
  290. },
  291. plotLines: [{value: 10,width: 1,color: '#808080'}]
  292. },
  293. tooltip: {
  294. valueSuffix: ''
  295. },
  296. legend: {
  297. layout: 'vertical',
  298. align: 'right',
  299. verticalAlign: 'middle',
  300. borderWidth: 0
  301. },credits: {
  302. enabled: false
  303. },exporting:{
  304. enabled:false
  305. },series: [{
  306. name: '所有',
  307. data: eval(alldata),//[7.0, 6.9, 9.5],
  308. color : '#2DC0E8'
  309. }, {
  310. name: '微信',
  311. data: eval(wx),//[ 11.3, 17.0, 22.0],
  312. color : '#4FB947'
  313. }, {
  314. name: '支付宝',
  315. data: eval(zfb),//[3.5, 8.4, 13.5],
  316. color : '#FF7523'
  317. }, {
  318. name: '百度直达号',
  319. data: eval(bd),//[3.9, 4.2, 5.7],
  320. color : '#4095F0'
  321. }]
  322. });
  323. }
  324. //条形图
  325. function showBar(id, wx,zfb,bd){
  326. var serialname = SEL_TYPE_HZLY==3?'累计绑定就诊卡数':'累计线上门诊人数';
  327. $('#'+id).highcharts({
  328. chart: {
  329. type: 'bar'
  330. },
  331. title: {
  332. text: ''
  333. },
  334. xAxis: {
  335. categories: ['微信','支付宝','百度直达号']
  336. },
  337. exporting:{
  338. enabled:false
  339. },
  340. yAxis: {
  341. min: 0,
  342. title: {
  343. text: '',
  344. align: 'high'
  345. }
  346. },
  347. tooltip: {
  348. valueSuffix: ''
  349. },
  350. legend: {
  351. backgroundColor: '#FFFFFF',
  352. reversed: true
  353. },
  354. plotOptions: {
  355. bar: {
  356. dataLabels: {
  357. enabled: false
  358. }
  359. }
  360. },
  361. credits: {
  362. enabled: false
  363. },
  364. series: [{
  365. name: serialname,
  366. data: [{
  367. y:parseInt(wx), //107
  368. color: '#4FB947'
  369. },{
  370. y:parseInt(zfb), //20
  371. color: '#FF7523'
  372. },{
  373. y:parseInt(bd), //150
  374. color: '#4095F0'
  375. }]
  376. }]
  377. });
  378. }
  379. function setBarDivName(index){
  380. switch(index){
  381. case 0:return 'allBindCardDiv';
  382. case 1:return 'allClinicNumDiv';
  383. default:return '';
  384. }
  385. }
  386. function setSplineDivName(index){
  387. switch(index){
  388. case 0:return 'newConcernDiv';
  389. case 1:return 'activeUserDiv';
  390. case 2:return 'bindCardDiv';
  391. case 3:return 'clinicNumDiv';
  392. case 4:return 'strikeTimeDiv';
  393. case 5:return 'strikeAmountDiv';
  394. default:return '';
  395. }
  396. }
  397. //tab
  398. function setTab(tabEleBoxId,tabConBoxId) {
  399. var _this=this;
  400. _this.tabEles=$('#'+tabEleBoxId).find('li'),
  401. _this.tabCons=$('#'+tabConBoxId).find('.trend-tab-con');
  402. if(!_this.tabEles.filter('.current').length){
  403. _this.tabEles.eq(0).addClass('current');
  404. _this.tabCons.eq(0).show();
  405. }
  406. _this.tabEles.click(function(){
  407. if(!$(this).hasClass('current')) {
  408. _this.tabEles.removeClass('current');
  409. $(this).addClass('current');
  410. _this.tabCons.hide();
  411. _this.tabCons.eq($(this).index()).fadeIn();
  412. if(tabEleBoxId == 'trendTab1')
  413. spline(setSplineDivName($(this).index()));
  414. else
  415. showBar(setBarDivName($(this).index()));
  416. }
  417. });
  418. }
  419. /**
  420. * 分页
  421. * @param {Object} totalcounts
  422. * @param {Object} pagecount
  423. * @param {Object} pager
  424. */
  425. var Page = function(totalcounts, pagecount,pager) {
  426. $("#"+pager).pager( {
  427. totalcounts : totalcounts,
  428. pagesize : 8,
  429. pagenumber : $("#pagenumber").val(),
  430. pagecount : parseInt(totalcounts/pagecount)+(totalcounts%pagecount >0?1:0),
  431. buttonClickCallback : function(al) {
  432. $("#pagenumber").val(al);
  433. loadGrid(al);
  434. }
  435. });
  436. };