gongzuobaogao.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. $(function() {
  2. var teamCode = '',
  3. tType = 0;
  4. //接口
  5. var pi = {
  6. ztqk: 'statistics/getStatTitleInfo',//总体情况
  7. zxtj: 'statistics/getReyStatbyTeam',//咨询统计
  8. jmgzqs: 'statistics/getConcernbyTeam',//居民关注趋势
  9. gzbhqs: 'statistics/getConcerAndCancel',//关注变化趋势
  10. jgnfw: 'statistics/getServiceRankingList',//机构内排行
  11. pjmyd: 'statistics/getAvgLine'//医生平均分
  12. };
  13. function openWebview(href,hrefId,extras) {
  14. if(plus.os.name == "Android") {
  15. var wv = plus.webview.create( href, hrefId, {hardwareAccelerated:false}, extras);
  16. wv.show("slide-in-right",250);
  17. } else {
  18. mui.openWindow({
  19. url:href,
  20. id:hrefId,
  21. extras:extras
  22. })
  23. }
  24. }
  25. var gzbg = {
  26. // 下拉
  27. $demoComtop: $('.demo-comtop'),
  28. $linMask: $('.lin-mask'),
  29. $linSelGroup: $('.lin-sel-group'),
  30. $selTit: $('#selTit'),
  31. // echarts
  32. $qyqkChart: document.getElementById('qyqkChart'),
  33. $zxtjChart: document.getElementById('zxtjChart'),
  34. $jmgzChart: document.getElementById('jmgzChart'),
  35. $gzbhChart: document.getElementById('gzbhChart'),
  36. $jgChart: document.getElementById('jgChart'),
  37. $mydChart: document.getElementById('mydChart'),
  38. //总体情况
  39. $qyrs: $('#qyrs'),
  40. $fwrs: $('#fwrs'),
  41. $pjmyd: $('#pjmyd'),
  42. //咨询统计
  43. $whfs: $('#whfs'),
  44. $yhfs: $('#yhfs'),
  45. $jgnph: $('.jgnph'),
  46. $zbdj: $('.zbdj'),
  47. //事件
  48. es: ['tap'],
  49. weeksData: null,
  50. monthData: null,
  51. type: 0,
  52. startDate: '',
  53. endDate: '',
  54. self: null,
  55. weeks: ['','第一周','第二周','第三周','第四周','第五周'],
  56. dateArr: [],
  57. init: function () {
  58. var me = this;
  59. me.self = plus.webview.currentWebview();
  60. teamCode = me.self.teamCode;
  61. me.bindEvent();
  62. me.setDate();
  63. },
  64. setDate: function () {
  65. if (this.type === 0) {
  66. this.startDate = $d.init(1);
  67. this.endDate = $d.init(2);
  68. } else {
  69. this.startDate = $d.init(3);
  70. this.endDate = $d.init(4);
  71. }
  72. if (this.weeksData === null || this.monthData === null) {
  73. this.loadDate();
  74. } else {
  75. this.setDateInPage();
  76. }
  77. },
  78. getZTQKData: function () {//总体情况
  79. return getReqPromise( pi.ztqk, {
  80. startDate: this.startDate,
  81. endDate: this.endDate
  82. }, 'GET');
  83. },
  84. getZXTJData: function () {//咨询统计
  85. return getReqPromise( pi.zxtj, {
  86. startDate: this.startDate,
  87. endDate: this.endDate,
  88. isNow: 1
  89. }, 'GET');
  90. },
  91. getJMGZQSData: function () {//居民关注趋势
  92. return getReqPromise( pi.jmgzqs, {
  93. startDate: this.startDate,
  94. endDate: this.endDate,
  95. type: this.type
  96. }, 'GET');
  97. },
  98. getGZBHQSData: function () {//关注变化趋势
  99. return getReqPromise( pi.gzbhqs, {
  100. startDate: this.startDate,
  101. endDate: this.endDate,
  102. type: this.type
  103. }, 'GET');
  104. },
  105. getJGNFWData: function () {//机构内排行
  106. return getReqPromise( pi.jgnfw, {
  107. startDate: this.startDate,
  108. endDate: this.endDate
  109. }, 'GET');
  110. },
  111. getPJMYDData: function () {//医生平均分
  112. return getReqPromise( pi.pjmyd, {
  113. startDate: this.startDate,
  114. endDate: this.endDate,
  115. type: this.type
  116. }, 'GET');
  117. },
  118. loadDate: function () {
  119. var me = this;
  120. plus.nativeUI.showWaiting();
  121. Promise.all([ me.getZTQKData(), me.getZXTJData(),me.getJMGZQSData(),me.getGZBHQSData(),me.getJGNFWData(),me.getPJMYDData()]).then(function (ress) {
  122. if (me.type === 0) {
  123. me.weeksData = ress;
  124. }
  125. if (me.type === 1) {
  126. me.monthData = ress;
  127. }
  128. // console.error(JSON.stringify(ress))
  129. // console.error(JSON.stringify(ress[3]))
  130. me.setDateInPage();
  131. plus.nativeUI.closeWaiting();
  132. });
  133. },
  134. setDateInPage: function () {
  135. var me = this,
  136. data = me.type === 0 ? me.weeksData : me.type === 1 ? me.monthData : [],
  137. d = [],
  138. qyrs = 0,
  139. fwrs = 0,
  140. pjmyd = 0,
  141. whfs = 0,
  142. yhfs = 0;
  143. if (data[0].status == 200) {
  144. d= data[0].data;
  145. qyrs = d[7].concernCount;
  146. fwrs = d[1].consultCount + d[2].reservationCount + d[3].articleCount + d[4].guidanceCount + d[5].followupCount;
  147. pjmyd = d[6].avgScore;
  148. }
  149. if (data[1].status == 200) {
  150. whfs = data[1].data.onReyCount;
  151. yhfs = data[1].data.totalCount;
  152. }
  153. me.$qyrs.html(qyrs);//qyrs
  154. if(pjmyd==0){
  155. me.$pjmyd.html("暂无评分");
  156. }else{
  157. me.$pjmyd.html(pjmyd);
  158. }
  159. //咨询统计
  160. me.$whfs.html(whfs);
  161. me.$yhfs.html(yhfs);
  162. me.initChartsData();
  163. },
  164. initChartsData: function () {
  165. var me = this,
  166. data = me.type === 0 ? me.weeksData : me.type === 1 ? me.monthData : [],
  167. qy = {dt:[],da:[]},
  168. zxtj = [],
  169. jgnfw = [],
  170. jmgzqs = [],
  171. gzbhqs = {},
  172. pjmyd = {dt:[],da:[]},
  173. xqzq = {da1: [], da2: []},
  174. dArr = $d.init(5);
  175. me.dateArr = $d.init(6);
  176. if (data[1].status == 200) {
  177. zxtj = data[1].data;
  178. }
  179. if (data[0].status == 200) {
  180. var datas = data[0];
  181. var fwrc = parseInt(datas.data[3].articleCount)+parseInt(datas.data[4].guidanceCount)+parseInt(datas.data[1].consultCount)
  182. jgnfw = [datas.data[1].consultCount, datas.data[5].followupCount, datas.data[2].reservationCount, datas.data[4].guidanceCount, datas.data[3].articleCount];
  183. me.$fwrs.html(fwrc);//fwrs
  184. }
  185. if (data[4].status == 200) {
  186. var html = '';
  187. html += '<li>' + (data[4].data[0].consultRK ? ('第' + data[4].data[0].consultRK + '名') : '未上榜') + '</li>';
  188. html += '<li>' + (data[4].data[3].guidanceRK ? ('第' + data[4].data[3].guidanceRK + '名') : '未上榜') + '</li>';
  189. html += '<li>' + (data[4].data[4].articleRK ? ('第' + data[4].data[4].articleRK + '名') : '未上榜') + '</li>';
  190. me.$jgnph.html(html);
  191. }
  192. if (data[5].status == 200) {
  193. pjmyd = me.getDataXY(data[5].data, 2);
  194. if (me.type === 0) {
  195. // me.dateArr = $d.init(5);
  196. pjmyd = $h.contrastDate( dArr, pjmyd, 'dt', 'da');
  197. }
  198. if (me.type === 1) {
  199. var d1 = $h.getWeeksData( pjmyd, 'dt', 'da'),
  200. pjmyd = d1.da;
  201. me.dateArr = d1.dt;
  202. }
  203. }
  204. if(data[2].status == 200){
  205. jmgzqs = me.getDataXY(data[2].data, 3);
  206. if (me.type === 0) {
  207. // me.dateArr = $d.init(5);
  208. jmgzqs = $h.contrastDate(dArr, jmgzqs, 'dt', 'da');
  209. }
  210. if (me.type === 1) {
  211. var d1 = $h.getWeeksData( jmgzqs, 'dt', 'da'),
  212. jmgzqs = d1.da;
  213. me.dateArr = d1.dt;
  214. }
  215. }
  216. //处理关注变化趋势
  217. if(data[3].status == 200){
  218. gzbhqs = data[3].data;
  219. var concorn = gzbhqs[0].concorn//新增关注
  220. var cancel = gzbhqs[0].cancel;//取消关注
  221. concorn = me.getDataXY(concorn, 3);
  222. cancel = me.getDataXY(cancel, 4);
  223. if (me.type === 0) {
  224. concorn = $h.contrastDate(dArr, concorn, 'dt', 'da');
  225. cancel = $h.contrastDate(dArr, cancel, 'dt', 'da');
  226. }
  227. if (me.type === 1) {
  228. var d1 = $h.getWeeksData( concorn, 'dt', 'da');
  229. var d2 = $h.getWeeksData( cancel, 'dt', 'da');
  230. concorn = d1.da;
  231. cancel = d2.da;
  232. me.dateArr = d1.dt;
  233. }
  234. gzbhqs = {concorn:concorn,cancel:cancel}
  235. }
  236. me.loadCharts(qy, zxtj, jgnfw, pjmyd, jmgzqs, gzbhqs);
  237. },
  238. loadCharts: function(qy, zxtj, jgnfw, pjmyd, jmgzqs, gzbhqs) {
  239. var me = this,gzbhxAxisData=[],gzbhSeriesData1=[],gzbhSeriesData2=[];
  240. var count = zxtj.onReyCount + zxtj.totalCount;
  241. var zx = count == 0 ? (1/2)*100 : 0;
  242. jgnfw.splice(1,2);//删除随访和代预约的值
  243. //处理咨询统计
  244. var unreplay = zxtj.onReyCount, //未回复数
  245. total = zxtj.totalCount,
  246. replay = parseInt(total) - parseInt(unreplay); //已回复咨询数
  247. $("#totalCount").text(total);//总咨询数
  248. Promise.all([
  249. //咨询统计
  250. $ic.init({
  251. el: me.$zxtjChart,
  252. seriesData: [{
  253. name: '未回复咨询',
  254. value: unreplay// || zx
  255. }, {
  256. name: '已回复咨询',
  257. value: replay// || zx
  258. }],
  259. chartsType: 2,
  260. seriesName:"咨询数量"
  261. }),
  262. //机构内服务
  263. $ic.init({
  264. el: me.$jgChart,
  265. xAxisData: ['咨询', '指导', '教育'],//['咨询', '随访', '代预约', '指导', '教育']
  266. seriesData: jgnfw,
  267. chartsType: 3,
  268. color: '#fbba31',
  269. cb: me.eConsole
  270. }),
  271. //平均医生评分
  272. $ic.init({
  273. el: me.$mydChart,
  274. xAxisData: me.dateArr,
  275. seriesData: me.setSeries(1, pjmyd),
  276. chartsType: 1,
  277. }),
  278. //居民关注趋势
  279. $ic.init({
  280. el: me.$jmgzChart,
  281. xAxisData: me.dateArr,
  282. seriesData: me.setSeries(2, jmgzqs),
  283. chartsType: 1
  284. }),
  285. //关注变化趋势
  286. $ic.init({
  287. el: me.$gzbhChart,
  288. xAxisData: me.dateArr,
  289. legend: {
  290. data:['新增关注','取消关注']
  291. },
  292. seriesData: [{
  293. name:"新增关注",
  294. type: "line",
  295. symbol: "emptyCircle",
  296. data: gzbhqs.concorn
  297. },
  298. {
  299. name:"取消关注",
  300. type: "line",
  301. symbol: "emptyCircle",
  302. data: gzbhqs.cancel
  303. }],
  304. chartsType: 1
  305. }),
  306. ]);
  307. },
  308. getDataXY: function ( d, t) {
  309. var data = {dt:[],da:[]};
  310. if (this.type == 0) {
  311. for (var i = 0, len = d.length; i< len; i++) {
  312. data.dt.push(t == 1 ? d[i].applyDate : t == 2 ?d[i].dateNo:d[i].applyDate);
  313. data.da.push(t == 1 ? d[i].signCount : t == 2 ?d[i].avgCount:t == 4?d[i].cancelCount:d[i].concernCount);
  314. }
  315. return data;
  316. }
  317. if (this.type == 1) {
  318. for (var i = 0, len = d.length; i< len; i++) {
  319. data.dt.push(t == 1 ? d[i].weekOfMonth : t == 2 ?d[i].weekNo:d[i].weekOfMonth);
  320. data.da.push(t == 1 ? d[i].signCount : t == 2 ?d[i].avgCount:t == 4?d[i].cancelCount:d[i].concernCount);
  321. }
  322. return data;
  323. }
  324. },
  325. getXQDataXY: function ( d, t) {
  326. var data = {dt:[],da:[]};
  327. for (var i = 0, len = d.length; i< len; i++) {
  328. if (this.type === 0) {
  329. data.dt.push(d[i].dateNo);
  330. }
  331. if (this.type === 1) {
  332. data.dt.push(d[i].weekOfMonth);
  333. }
  334. data.da.push(t == 1 ? d[i].inCount : d[i].outCount);
  335. }
  336. return data;
  337. },
  338. setSeries: function ( type, seriesData) {
  339. return [{
  340. name: type == 1 ? '医生评分' :'居民关注' ,
  341. type: "line",
  342. symbol: "emptyCircle",
  343. data: seriesData
  344. }]
  345. },
  346. bindEvent: function () {
  347. var me = this;
  348. $h.setEvent([
  349. [ me.$demoComtop, me.es[0], function () {
  350. me.xlEventFun( this, me);
  351. }, 'h1'],
  352. [ me.$linMask, me.es[0], function () {
  353. $(this).hide();
  354. me.$linSelGroup.hide();
  355. }],
  356. [ me.$linSelGroup, me.es[0], function () {
  357. me.switchWeeksToMonth( this, me);
  358. }, 'li'],
  359. ]);
  360. },
  361. //周月切换
  362. switchWeeksToMonth: function ( that, me) {
  363. var type = $(that).attr('data-type');
  364. $(that).siblings().removeClass('checked');
  365. $(that).addClass('checked');
  366. me.$selTit.html($(that).find('label').html());
  367. me.$linMask.hide();
  368. me.$linSelGroup.hide();
  369. me.type = parseInt(type);
  370. tType = me.type;
  371. this.setDate();
  372. },
  373. //下拉
  374. xlEventFun: function ( thst, me) {
  375. var lCss = me.$linMask.css('display');
  376. if (lCss == 'none') {
  377. me.$linMask.show();
  378. me.$linSelGroup.show();
  379. } else {
  380. me.$linMask.hide();
  381. me.$linSelGroup.hide();
  382. }
  383. },
  384. eConsole: function (param) {
  385. // return;
  386. if(typeof param.seriesIndex != 'undefined') {
  387. switch(param.dataIndex) {
  388. case 0:
  389. openWebview('../html/tuanduizixunxiangqing.html', 'tuanduizixunxiangqing', {
  390. teamCode: teamCode,
  391. type: tType
  392. })
  393. break;
  394. case 1:
  395. openWebview('../html/tuanduisuifangxiangqing.html', 'tuanduisuifangxiangqing', {
  396. teamCode: teamCode,
  397. type: tType
  398. })
  399. break;
  400. case 2:
  401. openWebview('../html/tuanduidaiyuyuexiangqing.html', 'tuanduidaiyuyuexiangqing', {
  402. teamCode: teamCode,
  403. type: tType
  404. })
  405. break;
  406. case 3:
  407. openWebview('../html/tuanduizhidaoxiangqing.html', 'tuanduizhidaoxiangqing', {
  408. teamCode: teamCode,
  409. type: tType
  410. })
  411. break;
  412. case 4:
  413. openWebview('../html/tuanduijiaoyuxiangqing.html', 'tuanduijiaoyuxiangqing', {
  414. teamCode: teamCode,
  415. type: tType
  416. })
  417. break;
  418. default:
  419. break;
  420. }
  421. }
  422. }
  423. };
  424. mui.init();
  425. mui.plusReady(function(){
  426. gzbg.init();
  427. });
  428. });