gongzuobaogao.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  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. if (me.type === 0) {
  138. me.weeksData = ress;
  139. }
  140. if (me.type === 1) {
  141. me.monthData = ress;
  142. }
  143. me.setDateInPage();
  144. });
  145. },
  146. setDateInPage: function () {
  147. var me = this,
  148. data = me.type === 0 ? me.weeksData : me.type === 1 ? me.monthData : [],
  149. d = [],
  150. qyrs = 0,
  151. fwrs = 0,
  152. pjmyd = 0,
  153. whfs = 0,
  154. yhfs = 0;
  155. if (data[0].status == 200) {
  156. d= data[0].data;
  157. qyrs = d[0].signTotal;
  158. fwrs = d[1].consultCount + d[2].reservationCount + d[3].articleCount + d[4].guidanceCount + d[5].followupCount;
  159. pjmyd = d[6].avgScore;
  160. }
  161. if (data[2].status == 200) {
  162. whfs = data[2].data.onReyCount;
  163. yhfs = data[2].data.totalCount;
  164. }
  165. me.$qyrs.html(qyrs);
  166. me.$fwrs.html(fwrs);
  167. if(pjmyd==0){
  168. me.$pjmyd.html('暂无评分');
  169. }else{
  170. me.$pjmyd.html(pjmyd);
  171. }
  172. //咨询统计
  173. me.$whfs.html(whfs);
  174. me.$yhfs.html(yhfs);
  175. me.initChartsData();
  176. },
  177. initChartsData: function () {
  178. var me = this,
  179. data = me.type === 0 ? me.weeksData : me.type === 1 ? me.monthData : [],
  180. qy = {dt:[],da:[]},
  181. zxtj = [],
  182. jgnfw = [],
  183. ccftj = [],
  184. pjmyd = {dt:[],da:[]},
  185. xqzq = {da1: [], da2: []},
  186. dArr = $d.init(5);
  187. me.dateArr = $d.init(6);
  188. if (data[1].status == 200) {
  189. qy = me.getDataXY( data[1].data, 1);
  190. if (me.type === 0) {
  191. qy = $h.contrastDate( dArr, qy, 'dt', 'da');
  192. }
  193. if (me.type === 1) {
  194. var d1 = $h.getWeeksData( qy, 'dt', 'da'),
  195. qy = d1.da;
  196. me.dateArr = d1.dt;
  197. }
  198. }
  199. if (data[2].status == 200) {
  200. zxtj = data[2].data;
  201. }
  202. if (data[0].status == 200) {
  203. 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];
  204. }
  205. if (data[3].status == 200) {
  206. var html = '';
  207. html += '<li>' + (data[3].data[0].consultRK ? ('第' + data[3].data[0].consultRK + '名') : '') + '</li>';
  208. html += '<li>' + (data[3].data[1].followupRK ? ('第' + data[3].data[1].followupRK + '名') : '') + '</li>';
  209. html += '<li>' + (data[3].data[2].reservationRK ? ('第' + data[3].data[2].reservationRK + '名') : '') + '</li>';
  210. html += '<li>' + (data[3].data[3].guidanceRK ? ('第' + data[3].data[3].guidanceRK + '名') : '') + '</li>';
  211. html += '<li>' + (data[3].data[4].articleRK ? ('第' + data[3].data[4].articleRK + '名') : '') + '</li>';
  212. me.$jgnph.html(html);
  213. }
  214. if (data[4].status == 200) {
  215. pjmyd = me.getDataXY( data[4].data, 2);
  216. if (me.type === 0) {
  217. // me.dateArr = $d.init(5);
  218. pjmyd = $h.contrastDate( dArr, pjmyd, 'dt', 'da');
  219. }
  220. if (me.type === 1) {
  221. var d1 = $h.getWeeksData( pjmyd, 'dt', 'da'),
  222. pjmyd = d1.da;
  223. me.dateArr = d1.dt;
  224. }
  225. }
  226. if (data[5].status == 200) {
  227. xqzq.dt1 = me.getXQDataXY( data[5].data.inLine, 1);
  228. xqzq.dt2 = me.getXQDataXY( data[5].data.outLine, 2);
  229. if (me.type === 0) {
  230. // me.dateArr = $d.init(5);
  231. xqzq.dt1 = $h.contrastDate( dArr, xqzq.dt1, 'dt', 'da');
  232. xqzq.dt2 = $h.contrastDate( dArr, xqzq.dt2, 'dt', 'da');
  233. }
  234. if (me.type === 1) {
  235. var d1 = $h.getWeeksData( xqzq.dt1, 'dt', 'da'),
  236. d2 = $h.getWeeksData( xqzq.dt2, 'dt', 'da');
  237. xqzq.dt1 = d1.da;
  238. xqzq.dt2 = d2.da;
  239. me.dateArr = d1.dt;
  240. }
  241. }
  242. if(data[6].status == 200){
  243. var ccfdata = data[6].data;
  244. ccftj.push(ccfdata.total);
  245. ccftj.push(ccfdata.finishCount);
  246. ccftj.push(ccfdata.processingCount);
  247. ccftj.push(ccfdata.patientCancelCount);
  248. ccftj.push(ccfdata.noReviewedCount);
  249. ccftj.push(ccfdata.payOuttimeCount);
  250. }
  251. me.loadCharts( qy, zxtj, jgnfw, ccftj, pjmyd, [ me.setXQSeries( 1, xqzq.dt1), me.setXQSeries( 2, xqzq.dt2)]);
  252. },
  253. initQYQKCharts: function ( t, xd, yd) {
  254. // console.log(t)
  255. // console.log(xd)
  256. // console.log(yd)
  257. $ic.init({
  258. el: this.$qyqkChart,
  259. xAxisData: xd,
  260. seriesData: this.setSeries(t, yd),
  261. chartsType: 1
  262. });
  263. },
  264. loadCharts: function ( qy, zxtj, jgnfw, ccftj, pjmyd, xqzq) {
  265. var me = this;
  266. var count = zxtj.onReyCount + zxtj.totalCount;
  267. var zx = count == 0 ? (1/2)*100 : 0;
  268. Promise.all([
  269. // 签约情况
  270. me.initQYQKCharts( 1, me.dateArr, qy),
  271. // 资讯统计
  272. $ic.init({
  273. el: me.$zxtjChart,
  274. seriesData: [{
  275. name: '未回复咨询',
  276. value: zxtj.onReyCount || zx
  277. }, {
  278. name: '已回复咨询',
  279. value: zxtj.totalCount || zx
  280. }],
  281. chartsType: 2
  282. }),
  283. // 机构内服务
  284. $ic.init({
  285. el: me.$jgChart,
  286. xAxisData: ['咨询', '随访', '代预约', '指导', '教育'],
  287. seriesData: jgnfw,
  288. chartsType: 3,
  289. color: '#fbba31',
  290. cb: me.eConsole
  291. }),
  292. // 长处方统计
  293. $ic.init({
  294. el: me.$ccfChart,
  295. xAxisData: ['总量', '已完成', '进行中', '居民\n取消', '审核\n未通过', '其他\n原因\n取消'],
  296. seriesData: ccftj,
  297. chartsType: 3,
  298. color: '#17B3EC',
  299. grid: {
  300. x: 35,
  301. y: 30,
  302. x2: 20,
  303. y2: 60
  304. },
  305. cb: function(){}
  306. }),
  307. // 平均医生评分
  308. $ic.init({
  309. el: me.$mydChart,
  310. xAxisData: me.dateArr,
  311. seriesData: me.setSeries(2, pjmyd),
  312. chartsType: 1
  313. }),
  314. // 续签转签
  315. $ic.init({
  316. el: me.$xqzqChart,
  317. xAxisData: me.dateArr,
  318. seriesData: xqzq,
  319. chartsType: 1,
  320. legend: {
  321. x: 'right',
  322. data: ["签入人数", "签出人数"]
  323. }
  324. })
  325. ]);
  326. },
  327. getDataXY: function ( d, t) {
  328. var data = {dt:[],da:[]};
  329. if (this.type == 0) {
  330. for (var i = 0, len = d.length; i< len; i++) {
  331. data.dt.push(t == 1 ? d[i].applyDate : d[i].dateNo);
  332. data.da.push(t == 1 ? d[i].signCount : d[i].avgCount);
  333. }
  334. return data;
  335. }
  336. if (this.type == 1) {
  337. for (var i = 0, len = d.length; i< len; i++) {
  338. data.dt.push(t == 1 ? d[i].weekOfMonth : d[i].weekNo);
  339. data.da.push(t == 1 ? d[i].signCount : d[i].avgCount);
  340. }
  341. return data;
  342. }
  343. },
  344. getXQDataXY: function ( d, t) {
  345. var data = {dt:[],da:[]};
  346. for (var i = 0, len = d.length; i< len; i++) {
  347. if (this.type === 0) {
  348. data.dt.push(d[i].dateNo);
  349. }
  350. if (this.type === 1) {
  351. data.dt.push(d[i].weekOfMonth);
  352. }
  353. data.da.push(t == 1 ? d[i].inCount : d[i].outCount);
  354. }
  355. return data;
  356. },
  357. setXQSeries: function ( type, seriesData) {
  358. return {
  359. name: type == 1 ? '签入人数' : type == 2 ? '签出人数' : '',
  360. type: "line",
  361. symbol: "emptyCircle",
  362. data: seriesData
  363. }
  364. },
  365. setSeries: function ( type, seriesData) {
  366. return [{
  367. name: type == 1 ? '签约数' : type == 2 ? '医生评分' : type == 3 ? '续签数' : '',
  368. type: "line",
  369. symbol: "emptyCircle",
  370. data: seriesData
  371. }]
  372. },
  373. bindEvent: function () {
  374. var me = this;
  375. // 续约/签约切换
  376. $h.setEvent([
  377. [ me.$qiehuan, me.es[0], function () {
  378. me.xyQyEventFun( this, me);
  379. }],
  380. [ me.$demoComtop, me.es[0], function () {
  381. me.xlEventFun( this, me);
  382. }, 'h1'],
  383. [ me.$linMask, me.es[0], function () {
  384. $(this).hide();
  385. me.$linSelGroup.hide();
  386. }],
  387. [ me.$linSelGroup, me.es[0], function () {
  388. me.switchWeeksToMonth( this, me);
  389. }, 'li'],
  390. [ $(me.$xqzqChart), me.es[0], function () {
  391. openWebview('../html/tuanduizhuanqianxiangqing.html', 'tuanduizhuanqianxiangqing', {
  392. teamCode: teamCode
  393. })
  394. }],
  395. [ me.$zbdj, me.es[0], function () {
  396. var o = { seriesIndex:1, dataIndex:0};
  397. o.dataIndex = $(this).index();
  398. me.eConsole(o);
  399. console.log($(this).index());
  400. }, 'li']
  401. ]);
  402. },
  403. //周月切换
  404. switchWeeksToMonth: function ( that, me) {
  405. var type = $(that).attr('data-type');
  406. $(that).siblings().removeClass('checked');
  407. $(that).addClass('checked');
  408. me.$selTit.html($(that).find('label').html());
  409. me.$linMask.hide();
  410. me.$linSelGroup.hide();
  411. me.type = parseInt(type);
  412. tType = me.type;
  413. this.setDate();
  414. },
  415. //下拉
  416. xlEventFun: function ( thst, me) {
  417. var lCss = me.$linMask.css('display');
  418. if (lCss == 'none') {
  419. me.$linMask.show();
  420. me.$linSelGroup.show();
  421. } else {
  422. me.$linMask.hide();
  423. me.$linSelGroup.hide();
  424. }
  425. },
  426. getSwitchData: function ( t1, t2, t3, that, me) {
  427. var qy = {dt:[],da:[]};
  428. Promise.all([me.getQYQKData(t1)]).then(function (res) {
  429. if (res[0].status == 200) {
  430. qy = me.getDataXY( res[0].data, 1),
  431. dArr = $d.init(5);
  432. me.dateArr = $d.init(6);
  433. if (me.type === 0) {
  434. // me.dateArr = $d.init(5);
  435. qy = $h.contrastDate( dArr, qy, 'dt', 'da');
  436. }
  437. if (me.type === 1) {
  438. var d1 = $h.getWeeksData( qy, 'dt', 'da'),
  439. qy = d1.da;
  440. me.dateArr = d1.dt;
  441. }
  442. me.initQYQKCharts( t2, me.dateArr, qy);
  443. }
  444. });
  445. $(that).attr('data-type', t3);
  446. },
  447. // 续约/签约切换时间函数
  448. xyQyEventFun: function ( that, me) {
  449. var type = $(that).attr('data-type');
  450. if(type == '1') {
  451. me.$qyLab.html('续约情况');
  452. me.$qyQh.html('切换签约情况');
  453. me.getSwitchData( 1, 3, '2', that, me);
  454. }
  455. if(type == '2') {
  456. me.$qyLab.html('签约情况');
  457. me.$qyQh.html('切换续约情况');
  458. me.getSwitchData( 0, 1, '1', that, me);
  459. }
  460. },
  461. eConsole: function (param) {
  462. // return;
  463. if(typeof param.seriesIndex != 'undefined') {
  464. switch(param.dataIndex) {
  465. case 0:
  466. openWebview('../html/tuanduizixunxiangqing.html', 'tuanduizixunxiangqing', {
  467. teamCode: teamCode,
  468. type: tType
  469. })
  470. break;
  471. case 1:
  472. openWebview('../html/tuanduisuifangxiangqing.html', 'tuanduisuifangxiangqing', {
  473. teamCode: teamCode,
  474. type: tType
  475. })
  476. break;
  477. case 2:
  478. openWebview('../html/tuanduidaiyuyuexiangqing.html', 'tuanduidaiyuyuexiangqing', {
  479. teamCode: teamCode,
  480. type: tType
  481. })
  482. break;
  483. case 3:
  484. openWebview('../html/tuanduizhidaoxiangqing.html', 'tuanduizhidaoxiangqing', {
  485. teamCode: teamCode,
  486. type: tType
  487. })
  488. break;
  489. case 4:
  490. openWebview('../html/tuanduijiaoyuxiangqing.html', 'tuanduijiaoyuxiangqing', {
  491. teamCode: teamCode,
  492. type: tType
  493. })
  494. break;
  495. default:
  496. break;
  497. }
  498. }
  499. }
  500. };
  501. mui.init();
  502. mui.plusReady(function(){
  503. gzbg.init();
  504. });
  505. });