gongzuobaogao.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. $(function() {
  2. var teamCode = '',
  3. tType = 0;
  4. //接口
  5. var pi = {
  6. ztqk: 'statistics/getStatTitleInfo',
  7. qyqk: 'statistics/getSignCountLineByType',
  8. zxtj: 'statistics/getReyStatbyTeam',
  9. jgnfw: 'statistics/getServiceRankingList',
  10. ccftj: 'statistics/getPrescriptionTotalCount',
  11. xqzq: 'statistics/getTeamRenewChangeLine',
  12. pjmyd: 'statistics/getAvgLine'
  13. };
  14. function openWebview(href,hrefId,extras) {
  15. if(plus.os.name == "Android") {
  16. var wv = plus.webview.create( href, hrefId, {hardwareAccelerated:false}, extras);
  17. wv.show("slide-in-right",250);
  18. } else {
  19. mui.openWindow({
  20. url:href,
  21. id:hrefId,
  22. extras:extras
  23. })
  24. }
  25. }
  26. var gzbg = {
  27. // 下拉
  28. $demoComtop: $('.demo-comtop'),
  29. $linMask: $('.lin-mask'),
  30. $linSelGroup: $('.lin-sel-group'),
  31. $selTit: $('#selTit'),
  32. // echarts
  33. $qyqkChart: document.getElementById('qyqkChart'),
  34. $zxtjChart: document.getElementById('zxtjChart'),
  35. $jgChart: document.getElementById('jgChart'),
  36. $ccfChart: document.getElementById('ccfChart'),
  37. $xqzqChart: document.getElementById('xqzqChart'),
  38. $mydChart: document.getElementById('mydChart'),
  39. // 续约/签约切换
  40. $qiehuan: $('#qiehuan'),
  41. $qyLab: $('.qy-lab'),
  42. $qyQh: $('.qy-qh'),
  43. $jgnph: $('.jgnph'),
  44. //总体情况
  45. $qyrs: $('#qyrs'),
  46. $fwrs: $('#fwrs'),
  47. $pjmyd: $('#pjmyd'),
  48. //咨询统计
  49. $whfs: $('#whfs'),
  50. $yhfs: $('#yhfs'),
  51. $jgnph: $('.jgnph'),
  52. $zbdj: $('.zbdj'),
  53. //事件
  54. es: ['tap'],
  55. weeksData: null,
  56. monthData: null,
  57. type: 0,
  58. startDate: '',
  59. endDate: '',
  60. self: null,
  61. weeks: ['','第一周','第二周','第三周','第四周','第五周'],
  62. dateArr: [],
  63. init: function () {
  64. var me = this;
  65. me.self = plus.webview.currentWebview();
  66. teamCode = me.self.teamCode;
  67. me.bindEvent();
  68. me.setDate();
  69. },
  70. setDate: function () {
  71. if (this.type === 0) {
  72. this.startDate = $d.init(1);
  73. this.endDate = $d.init(2);
  74. } else {
  75. this.startDate = $d.init(3);
  76. this.endDate = $d.init(4);
  77. }
  78. if (this.weeksData === null || this.monthData === null) {
  79. this.loadDate();
  80. } else {
  81. this.setDateInPage();
  82. }
  83. },
  84. getZTQKData: function () {
  85. return getReqPromise( pi.ztqk, {
  86. startDate: this.startDate,
  87. endDate: this.endDate
  88. }, 'GET');
  89. },
  90. getQYQKData: function (t) {
  91. return getReqPromise( pi.qyqk, {
  92. startDate: this.startDate,
  93. endDate: this.endDate,
  94. signType: t,
  95. type: this.type
  96. }, 'GET');
  97. },
  98. getZXTJData: function () {
  99. return getReqPromise( pi.zxtj, {
  100. startDate: this.startDate,
  101. endDate: this.endDate,
  102. isNow: 1
  103. }, 'GET');
  104. },
  105. getJGNFWData: function () {
  106. return getReqPromise( pi.jgnfw, {
  107. startDate: this.startDate,
  108. endDate: this.endDate
  109. }, 'GET');
  110. },
  111. getCCFTJData: function(){
  112. //获得长处方统计数据
  113. return getReqPromise( pi.ccftj, {
  114. startDate: this.startDate,
  115. endDate: this.endDate,
  116. adminTeamId: teamCode
  117. }, 'GET');
  118. },
  119. getXQZQData: function () {
  120. return getReqPromise( pi.xqzq, {
  121. teamCode: teamCode,
  122. startDate: this.startDate,
  123. endDate: this.endDate,
  124. type: this.type
  125. }, 'GET');
  126. },
  127. getPJMYDData: function () {
  128. return getReqPromise( pi.pjmyd, {
  129. startDate: this.startDate,
  130. endDate: this.endDate,
  131. type: this.type
  132. }, 'GET');
  133. },
  134. loadDate: function () {
  135. var me = this;
  136. Promise.all([ me.getZTQKData(), me.getQYQKData(0), me.getZXTJData(), me.getJGNFWData(), me.getPJMYDData(), me.getXQZQData(), me.getCCFTJData()]).then(function (ress) {
  137. // ress = [{"msg":"查询成功","data":[{"signTotal":100000},{"consultCount":100000},{"reservationCount":100000},{"articleCount":100000},{"guidanceCount":100000},{"followupCount":100000},{"avgScore":""}],"status":200},{"msg":"查询成功","data":[{"signCount":100,"applyDate":"2018-06-25"},{"signCount":10,"applyDate":"2018-06-26"},{"signCount":10,"applyDate":"2018-06-27"},{"signCount":0,"applyDate":"2018-06-28"},{"signCount":0,"applyDate":"2018-06-29"},{"signCount":0,"applyDate":"2018-06-30"},{"signCount":0,"applyDate":"2018-07-01"}],"status":200},{"msg":"查询成功","data":{"onReyCount":550,"totalCount":50},"status":200},{"msg":"查询成功","data":[{"consultRK":0},{"followupRK":0},{"reservationRK":0},{"guidanceRK":0},{"articleRK":0}],"status":200},{"msg":"查询成功","data":[],"status":200},{"msg":"查询成功","data":{"outLine":[],"inLine":[]},"status":200},{"msg":"查询成功","data":{"patientCancelCount":0,"total":0,"finishCount":0,"payOuttimeCount":0,"processingCount":0,"noReviewedCount":0},"status":200}]
  138. if (me.type === 0) {
  139. me.weeksData = ress;
  140. }
  141. if (me.type === 1) {
  142. me.monthData = ress;
  143. }
  144. console.error(JSON.stringify(ress))
  145. me.setDateInPage();
  146. });
  147. },
  148. setDateInPage: function () {
  149. var me = this,
  150. data = me.type === 0 ? me.weeksData : me.type === 1 ? me.monthData : [],
  151. d = [],
  152. qyrs = 0,
  153. fwrs = 0,
  154. pjmyd = 0,
  155. whfs = 0,
  156. yhfs = 0;
  157. if (data[0].status == 200) {
  158. d= data[0].data;
  159. qyrs = d[0].concernCount;
  160. fwrs = d[1].consultCount + d[2].reservationCount + d[3].articleCount + d[4].guidanceCount + d[5].followupCount;
  161. pjmyd = d[6].avgScore;
  162. }
  163. if (data[2].status == 200) {
  164. whfs = data[2].data.onReyCount;
  165. yhfs = data[2].data.totalCount;
  166. }
  167. me.$qyrs.html(qyrs);
  168. me.$fwrs.html(fwrs);
  169. if(pjmyd==0){
  170. me.$pjmyd.html('暂无评分');
  171. }else{
  172. me.$pjmyd.html(pjmyd);
  173. }
  174. //咨询统计
  175. me.$whfs.html(whfs);
  176. me.$yhfs.html(yhfs);
  177. me.initChartsData();
  178. },
  179. initChartsData: function () {
  180. var me = this,
  181. data = me.type === 0 ? me.weeksData : me.type === 1 ? me.monthData : [],
  182. qy = {dt:[],da:[]},
  183. zxtj = [],
  184. jgnfw = [],
  185. ccftj = [],
  186. pjmyd = {dt:[],da:[]},
  187. xqzq = {da1: [], da2: []},
  188. dArr = $d.init(5);
  189. me.dateArr = $d.init(6);
  190. if (data[1].status == 200) {
  191. qy = me.getDataXY( data[1].data, 1);
  192. if (me.type === 0) {
  193. qy = $h.contrastDate( dArr, qy, 'dt', 'da');
  194. }
  195. if (me.type === 1) {
  196. var d1 = $h.getWeeksData( qy, 'dt', 'da'),
  197. qy = d1.da;
  198. me.dateArr = d1.dt;
  199. }
  200. }
  201. if (data[2].status == 200) {
  202. zxtj = data[2].data;
  203. }
  204. if (data[0].status == 200) {
  205. jgnfw = [data[0].data[1].consultCount, data[0].data[5].followupCount, data[0].data[2].reservationCount, data[0].data[4].guidanceCount, data[0].data[3].articleCount];
  206. }
  207. if (data[3].status == 200) {
  208. var html = '';
  209. html += '<li>' + (data[3].data[0].consultRK ? ('第' + data[3].data[0].consultRK + '名') : '') + '</li>';
  210. html += '<li>' + (data[3].data[1].followupRK ? ('第' + data[3].data[1].followupRK + '名') : '') + '</li>';
  211. html += '<li>' + (data[3].data[2].reservationRK ? ('第' + data[3].data[2].reservationRK + '名') : '') + '</li>';
  212. html += '<li>' + (data[3].data[3].guidanceRK ? ('第' + data[3].data[3].guidanceRK + '名') : '') + '</li>';
  213. html += '<li>' + (data[3].data[4].articleRK ? ('第' + data[3].data[4].articleRK + '名') : '') + '</li>';
  214. me.$jgnph.html(html);
  215. }
  216. if (data[4].status == 200) {
  217. pjmyd = me.getDataXY( data[4].data, 2);
  218. if (me.type === 0) {
  219. // me.dateArr = $d.init(5);
  220. pjmyd = $h.contrastDate( dArr, pjmyd, 'dt', 'da');
  221. }
  222. if (me.type === 1) {
  223. var d1 = $h.getWeeksData( pjmyd, 'dt', 'da'),
  224. pjmyd = d1.da;
  225. me.dateArr = d1.dt;
  226. }
  227. }
  228. if (data[5].status == 200) {
  229. xqzq.dt1 = me.getXQDataXY( data[5].data.inLine, 1);
  230. xqzq.dt2 = me.getXQDataXY( data[5].data.outLine, 2);
  231. if (me.type === 0) {
  232. // me.dateArr = $d.init(5);
  233. xqzq.dt1 = $h.contrastDate( dArr, xqzq.dt1, 'dt', 'da');
  234. xqzq.dt2 = $h.contrastDate( dArr, xqzq.dt2, 'dt', 'da');
  235. }
  236. if (me.type === 1) {
  237. var d1 = $h.getWeeksData( xqzq.dt1, 'dt', 'da'),
  238. d2 = $h.getWeeksData( xqzq.dt2, 'dt', 'da');
  239. xqzq.dt1 = d1.da;
  240. xqzq.dt2 = d2.da;
  241. me.dateArr = d1.dt;
  242. }
  243. }
  244. if(data[6].status == 200){
  245. var ccfdata = data[6].data;
  246. ccftj.push(ccfdata.total);
  247. ccftj.push(ccfdata.finishCount);
  248. ccftj.push(ccfdata.processingCount);
  249. ccftj.push(ccfdata.patientCancelCount);
  250. ccftj.push(ccfdata.noReviewedCount);
  251. ccftj.push(ccfdata.payOuttimeCount);
  252. }
  253. me.loadCharts( qy, zxtj, jgnfw, ccftj, pjmyd, [ me.setXQSeries( 1, xqzq.dt1), me.setXQSeries( 2, xqzq.dt2)]);
  254. },
  255. initQYQKCharts: function ( t, xd, yd) {
  256. // console.log(t)
  257. // console.log(xd)
  258. // console.log(yd)
  259. $ic.init({
  260. el: this.$qyqkChart,
  261. xAxisData: xd,
  262. seriesData: this.setSeries(t, yd),
  263. chartsType: 1
  264. });
  265. },
  266. loadCharts: function ( qy, zxtj, jgnfw, ccftj, pjmyd, xqzq) {
  267. var me = this;
  268. var count = zxtj.onReyCount + zxtj.totalCount;
  269. var zx = count == 0 ? (1/2)*100 : 0;
  270. Promise.all([
  271. // 签约情况
  272. // me.initQYQKCharts( 1, me.dateArr, qy),
  273. // 资讯统计
  274. $ic.init({
  275. el: me.$zxtjChart,
  276. seriesData: [{
  277. name: '未回复咨询',
  278. value: zxtj.onReyCount || zx
  279. }, {
  280. name: '已回复咨询',
  281. value: zxtj.totalCount || zx
  282. }],
  283. chartsType: 2
  284. }),
  285. // 机构内服务
  286. $ic.init({
  287. el: me.$jgChart,
  288. xAxisData: ['咨询', '随访', '代预约', '指导', '教育'],
  289. seriesData: jgnfw,
  290. chartsType: 3,
  291. color: '#fbba31',
  292. cb: me.eConsole
  293. }),
  294. // 长处方统计
  295. // $ic.init({
  296. // el: me.$ccfChart,
  297. // xAxisData: ['总量', '已完成', '进行中', '居民\n取消', '审核\n未通过', '其他\n原因\n取消'],
  298. // seriesData: ccftj,
  299. // chartsType: 3,
  300. // color: '#17B3EC',
  301. // grid: {
  302. // x: 35,
  303. // y: 30,
  304. // x2: 20,
  305. // y2: 60
  306. // },
  307. // cb: function(){}
  308. // }),
  309. // 平均医生评分
  310. // $ic.init({
  311. // el: me.$mydChart,
  312. // xAxisData: me.dateArr,
  313. // seriesData: me.setSeries(2, pjmyd),
  314. // chartsType: 1
  315. // }),
  316. // 续签转签
  317. // $ic.init({
  318. // el: me.$xqzqChart,
  319. // xAxisData: me.dateArr,
  320. // seriesData: xqzq,
  321. // chartsType: 1,
  322. // legend: {
  323. // x: 'right',
  324. // data: ["签入人数", "签出人数"]
  325. // }
  326. // })
  327. ]);
  328. },
  329. getDataXY: function ( d, t) {
  330. var data = {dt:[],da:[]};
  331. if (this.type == 0) {
  332. for (var i = 0, len = d.length; i< len; i++) {
  333. data.dt.push(t == 1 ? d[i].applyDate : d[i].dateNo);
  334. data.da.push(t == 1 ? d[i].signCount : d[i].avgCount);
  335. }
  336. return data;
  337. }
  338. if (this.type == 1) {
  339. for (var i = 0, len = d.length; i< len; i++) {
  340. data.dt.push(t == 1 ? d[i].weekOfMonth : d[i].weekNo);
  341. data.da.push(t == 1 ? d[i].signCount : d[i].avgCount);
  342. }
  343. return data;
  344. }
  345. },
  346. getXQDataXY: function ( d, t) {
  347. var data = {dt:[],da:[]};
  348. for (var i = 0, len = d.length; i< len; i++) {
  349. if (this.type === 0) {
  350. data.dt.push(d[i].dateNo);
  351. }
  352. if (this.type === 1) {
  353. data.dt.push(d[i].weekOfMonth);
  354. }
  355. data.da.push(t == 1 ? d[i].inCount : d[i].outCount);
  356. }
  357. return data;
  358. },
  359. setXQSeries: function ( type, seriesData) {
  360. return {
  361. name: type == 1 ? '签入人数' : type == 2 ? '签出人数' : '',
  362. type: "line",
  363. symbol: "emptyCircle",
  364. data: seriesData
  365. }
  366. },
  367. setSeries: function ( type, seriesData) {
  368. return [{
  369. name: type == 1 ? '签约数' : type == 2 ? '医生评分' : type == 3 ? '续签数' : '',
  370. type: "line",
  371. symbol: "emptyCircle",
  372. data: seriesData
  373. }]
  374. },
  375. bindEvent: function () {
  376. var me = this;
  377. // 续约/签约切换
  378. $h.setEvent([
  379. [ me.$qiehuan, me.es[0], function () {
  380. me.xyQyEventFun( this, me);
  381. }],
  382. [ me.$demoComtop, me.es[0], function () {
  383. me.xlEventFun( this, me);
  384. }, 'h1'],
  385. [ me.$linMask, me.es[0], function () {
  386. $(this).hide();
  387. me.$linSelGroup.hide();
  388. }],
  389. [ me.$linSelGroup, me.es[0], function () {
  390. me.switchWeeksToMonth( this, me);
  391. }, 'li'],
  392. [ $(me.$xqzqChart), me.es[0], function () {
  393. openWebview('../html/tuanduizhuanqianxiangqing.html', 'tuanduizhuanqianxiangqing', {
  394. teamCode: teamCode
  395. })
  396. }],
  397. [ me.$zbdj, me.es[0], function () {
  398. var o = { seriesIndex:1, dataIndex:0};
  399. o.dataIndex = $(this).index();
  400. me.eConsole(o);
  401. console.log($(this).index());
  402. }, 'li']
  403. ]);
  404. },
  405. //周月切换
  406. switchWeeksToMonth: function ( that, me) {
  407. var type = $(that).attr('data-type');
  408. $(that).siblings().removeClass('checked');
  409. $(that).addClass('checked');
  410. me.$selTit.html($(that).find('label').html());
  411. me.$linMask.hide();
  412. me.$linSelGroup.hide();
  413. me.type = parseInt(type);
  414. tType = me.type;
  415. this.setDate();
  416. },
  417. //下拉
  418. xlEventFun: function ( thst, me) {
  419. var lCss = me.$linMask.css('display');
  420. if (lCss == 'none') {
  421. me.$linMask.show();
  422. me.$linSelGroup.show();
  423. } else {
  424. me.$linMask.hide();
  425. me.$linSelGroup.hide();
  426. }
  427. },
  428. getSwitchData: function ( t1, t2, t3, that, me) {
  429. var qy = {dt:[],da:[]};
  430. Promise.all([me.getQYQKData(t1)]).then(function (res) {
  431. if (res[0].status == 200) {
  432. qy = me.getDataXY( res[0].data, 1),
  433. dArr = $d.init(5);
  434. me.dateArr = $d.init(6);
  435. if (me.type === 0) {
  436. // me.dateArr = $d.init(5);
  437. qy = $h.contrastDate( dArr, qy, 'dt', 'da');
  438. }
  439. if (me.type === 1) {
  440. var d1 = $h.getWeeksData( qy, 'dt', 'da'),
  441. qy = d1.da;
  442. me.dateArr = d1.dt;
  443. }
  444. me.initQYQKCharts( t2, me.dateArr, qy);
  445. }
  446. });
  447. $(that).attr('data-type', t3);
  448. },
  449. // 续约/签约切换时间函数
  450. xyQyEventFun: function ( that, me) {
  451. var type = $(that).attr('data-type');
  452. if(type == '1') {
  453. me.$qyLab.html('续约情况');
  454. me.$qyQh.html('切换签约情况');
  455. me.getSwitchData( 1, 3, '2', that, me);
  456. }
  457. if(type == '2') {
  458. me.$qyLab.html('签约情况');
  459. me.$qyQh.html('切换续约情况');
  460. me.getSwitchData( 0, 1, '1', that, me);
  461. }
  462. },
  463. eConsole: function (param) {
  464. // return;
  465. if(typeof param.seriesIndex != 'undefined') {
  466. switch(param.dataIndex) {
  467. case 0:
  468. openWebview('../html/tuanduizixunxiangqing.html', 'tuanduizixunxiangqing', {
  469. teamCode: teamCode,
  470. type: tType
  471. })
  472. break;
  473. case 1:
  474. openWebview('../html/tuanduisuifangxiangqing.html', 'tuanduisuifangxiangqing', {
  475. teamCode: teamCode,
  476. type: tType
  477. })
  478. break;
  479. case 2:
  480. openWebview('../html/tuanduidaiyuyuexiangqing.html', 'tuanduidaiyuyuexiangqing', {
  481. teamCode: teamCode,
  482. type: tType
  483. })
  484. break;
  485. case 3:
  486. openWebview('../html/tuanduizhidaoxiangqing.html', 'tuanduizhidaoxiangqing', {
  487. teamCode: teamCode,
  488. type: tType
  489. })
  490. break;
  491. case 4:
  492. openWebview('../html/tuanduijiaoyuxiangqing.html', 'tuanduijiaoyuxiangqing', {
  493. teamCode: teamCode,
  494. type: tType
  495. })
  496. break;
  497. default:
  498. break;
  499. }
  500. }
  501. }
  502. };
  503. mui.init();
  504. mui.plusReady(function(){
  505. gzbg.init();
  506. });
  507. });