zhongdiangenzong.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. mui.init();
  2. var teamCode,
  3. docInfo,
  4. xueyaLoaded = false; //标记血压信息是否已经加载过
  5. var sdate = new Date(),
  6. edate = new Date();
  7. sdate.setDate(edate.getDate() - 6);
  8. sdate = sdate.format("yyyy-MM-dd");
  9. edate = edate.format('yyyy-MM-dd');
  10. mui.plusReady(function(){
  11. var self = plus.webview.currentWebview();
  12. docInfo = JSON.parse(plus.storage.getItem("docInfo"));
  13. teamCode = self.teamCode || docInfo.adminTeamCode;
  14. getTeamInfo();
  15. getPageInfo();
  16. bindEvents();
  17. });
  18. function getTeamInfo(){
  19. //设置团队
  20. var teamInfo = JSON.parse(plus.storage.getItem("teamInfo"));
  21. $('.lin-sel-group').html(template('teams_tmpl', teamInfo));
  22. var index =0;
  23. if(teamCode){
  24. for(var i=0;i<teamInfo.data.length;i++){
  25. if(teamInfo.data[i].id == teamCode){
  26. index = i;
  27. }
  28. }
  29. }
  30. $('.lin-sel-group li').eq(index).addClass('checked');
  31. setCurTeamName()
  32. }
  33. function setCurTeamName(){
  34. teamCode = $('.lin-sel-group li.checked').attr('data-code');
  35. $('.demo-comtop h1').html(($('.lin-sel-group li.checked').attr('data-name'))+'重点跟踪<label class="lin-down-arrow"></label>');
  36. }
  37. function getPageInfo(){
  38. //获得顶部居民数量数据
  39. getPaitentNumber();
  40. //获得服务情况数据
  41. getServiceData();
  42. //获得近一周血糖,血压情况
  43. getXuetangData(0);
  44. //获得近一周控制目标达标人数
  45. getTargetInfo();
  46. //获得设备绑定情况
  47. getDeviceBindInfo();
  48. }
  49. //获得顶部数据
  50. function getPaitentNumber(){
  51. var url = "/doctor/scheme/getTrackPatientCountTitle",
  52. params = {
  53. teamCode: teamCode,
  54. startDate: sdate,
  55. endDate: edate
  56. };
  57. plus.nativeUI.showWaiting();
  58. sendGet(url, params, null, function(res){
  59. if(res.status == 200){
  60. $(".all-people .num").text(res.data.trackPatientCount);
  61. $(".new-people .num").text(res.data.trackPatientAddCount);
  62. }else{
  63. mui.toast(res.msg);
  64. }
  65. plus.nativeUI.closeWaiting();
  66. }, true);
  67. }
  68. //获得服务情况数据
  69. function getServiceData(){
  70. var url = "/doctor/scheme/getTrackPatientServerCount",
  71. params = {
  72. teamCode: teamCode,
  73. startDate: sdate,
  74. endDate: edate
  75. };
  76. var colors = ["#1fa8dc", "#7360a8", "#69b839", "#ed704a", "#f4c31e"],
  77. names = ['健康咨询', '慢病随访', '健康指导', '续方审核', '代预约'];
  78. plus.nativeUI.showWaiting();
  79. sendGet(url, params, null, function(res){
  80. if(res.status == 200){
  81. var arr = [],
  82. total = 0;
  83. var data = res.data,
  84. dataArr = [data.consultCount, data.followupCount, data.guidanceCount, data.reviewedCount, data.reservationCount];
  85. for(i=0; i<5; i++){
  86. var obj = {
  87. value: dataArr[i],
  88. color: colors[i],
  89. name: names[i],
  90. itemStyle:{
  91. normal:{
  92. color: colors[i]
  93. }
  94. }
  95. };
  96. total += dataArr[i];
  97. arr.push(obj);
  98. }
  99. $("#allServiceNum").text(total);
  100. drawPieChart(arr);
  101. var html = template('service_tmp', {list: arr});
  102. $("#serverType").empty().append(html);
  103. }else{
  104. mui.toast(res.msg);
  105. }
  106. plus.nativeUI.closeWaiting();
  107. }, true);
  108. }
  109. //获得近一周血糖、血压情况数据
  110. function getXuetangData(type){
  111. var url = "/doctor/scheme/getPatientHealthIndexByTeam",
  112. params = {
  113. startDate: sdate,
  114. endDate: edate,
  115. type: type, //0:血糖, 1: 血压
  116. teamCode: teamCode
  117. };
  118. sendGet(url, params, null, function(res){
  119. if(res.status == 200){
  120. var html = template('xt-tmp', res.data);
  121. if(type == 0){
  122. $(".xuetang-info .mui-loading").remove();
  123. $(".xuetang-info").empty().append(html);
  124. }else{
  125. xueyaLoaded = true;
  126. $(".xueya-info .mui-loading").remove();
  127. $(".xueya-info").empty().append(html);
  128. }
  129. }else{
  130. mui.toast(res.msg);
  131. }
  132. });
  133. }
  134. //获得近一周控制目标达标人数
  135. function getTargetInfo(){
  136. var url = '/doctor/scheme/getTrackPatientAimByteam',
  137. params = {
  138. teamCode: teamCode,
  139. startDate: sdate,
  140. endDate: edate
  141. };
  142. plus.nativeUI.showWaiting();
  143. sendGet(url, params, null, function(res){
  144. if(res.status == 200){
  145. $("#xt_num").text(res.data.dbSuggerCount);
  146. $("#xy_num").text(res.data.dbPresCount);
  147. }else{
  148. mui.toast(res.msg);
  149. }
  150. plus.nativeUI.closeWaiting();
  151. }, true);
  152. }
  153. //获得设备绑定情况
  154. function getDeviceBindInfo(){
  155. var url = '/doctor/scheme/getDeviceStateByTeam',
  156. params = {teamCode: teamCode};
  157. sendGet(url, params, null, function(res){
  158. if(res.status == 200){
  159. $("#xty_num").text(res.data.suggerDevCount);
  160. $("#xyj_num").text(res.data.presDevCount);
  161. }else{
  162. mui.toast(res.msg);
  163. }
  164. }, true);
  165. }
  166. function drawPieChart(data){
  167. var pieChart = echarts.init(document.getElementById('pieChart'));
  168. var option = {
  169. tooltip: {
  170. trigger: 'item',
  171. // formatter: "{a} <br/>{b}: {c} ({d}%)",
  172. formatter: function(params, ticket, callback) {
  173. console.log(params)
  174. if (isNaN(params.percent)) {
  175. return params.seriesName + '<br />' + params.name + ':' + params.value + ' (0%)';
  176. } else {
  177. return params.seriesName + '<br />' + params.name + ':' + params.value + ' (' + params.percent + '%)';
  178. }
  179. },
  180. position: ['50%', '50%']
  181. },
  182. series: [
  183. {
  184. name:'近一周服务情况',
  185. type:'pie',
  186. radius: ['75%', '98%'],
  187. startAngle: 270,
  188. // legendHoverLink: false,
  189. hoverAnimation: false,
  190. avoidLabelOverlap: false,
  191. labelLine: {
  192. normal: {
  193. show: false
  194. }
  195. },
  196. data: data
  197. }
  198. ]
  199. };
  200. pieChart.setOption(option);
  201. }
  202. /**
  203. * 显示团队选择
  204. */
  205. function showGroupSel(e, isShow){
  206. isShow = isShow || $('.lin-mask:hidden').length != 0;
  207. $('.lin-mask').toggle(isShow);
  208. $('.lin-sel-group').toggle(isShow);
  209. }
  210. function bindEvents(){
  211. $('.demo-comtop h1').on('tap', showGroupSel);
  212. $(".lin-sel-group").on('click', 'li', function(){
  213. showGroupSel(undefined, false);
  214. if(!$(this).hasClass('checked')){
  215. $(this).addClass('checked').siblings().removeClass('checked');
  216. setCurTeamName();
  217. }
  218. getPageInfo();
  219. })
  220. $(".icon-notice").on('click', function(){
  221. var $this = $(this),
  222. val = $this.data("val"),
  223. content = "";
  224. switch(val){
  225. case 'fw':
  226. content = '近七天签约团队为重点关注居民服务的次数';
  227. break;
  228. case 'xt':
  229. content = '近七天重点关注居民的血糖/血压体征数据统计';
  230. break;
  231. case 'mubiao':
  232. content = '近七天体征达标率>=70%的重点关注居民人数';
  233. break;
  234. case 'shebei':
  235. content = '重点关注居民已绑定设备的数量统计';
  236. break;
  237. }
  238. if(content){
  239. dialog({
  240. content: '<div><div class="c-f14 c-333 c-t-left">'+content+'</div></div>',
  241. quickClose: true
  242. }).showModal();
  243. }
  244. return false;
  245. });
  246. //血压血糖按钮切换
  247. $(".switch-box").on('click', "span", function(){
  248. var $this = $(this),
  249. val = $this.attr("data-val"),
  250. index = $this.index();
  251. if($this.hasClass("active")){
  252. return false;
  253. }
  254. $this.siblings().removeClass("active");
  255. $this.addClass("active");
  256. mui('.mui-slider').slider().gotoItem(parseInt(index));
  257. if(val == "xt"){
  258. $("#xtName").text("血糖");
  259. }else if(val == "xy"){
  260. if(!xueyaLoaded){
  261. getXuetangData(1);
  262. }
  263. $("#xtName").text("血压");
  264. }
  265. });
  266. //监听血压,血糖情况滚动切换
  267. document.querySelector('.mui-slider').addEventListener('slide', function(event) {
  268. if (event.detail.slideNumber === 0) {
  269. $(".switch-box span").eq(0).addClass("active");
  270. $(".switch-box span").eq(1).removeClass("active");
  271. $("#xtName").text("血糖");
  272. } else if (event.detail.slideNumber === 1) {
  273. if(!xueyaLoaded){
  274. getXuetangData(1);
  275. }
  276. $(".switch-box span").eq(0).removeClass("active");
  277. $(".switch-box span").eq(1).addClass("active");
  278. $("#xtName").text("血压");
  279. }
  280. });
  281. //查看血糖情况
  282. $("body").on('tap', ".cycle-div", function(){
  283. var $this = $(this),
  284. $parent = $this.closest(".ui-grid"),
  285. type = 0; //0:血糖,1:血压
  286. if($parent.hasClass("xuetang-info")){
  287. type = 0;
  288. }else{
  289. type = 1;
  290. }
  291. openWebview("../../jkjl/html/patients-record.html", {
  292. teamCode: teamCode,
  293. type: type
  294. })
  295. });
  296. //跳转居民列表页
  297. $(".people").on('click', function(){
  298. var $this = $(this),
  299. selectType = $this.hasClass("all-people") ? '0' : '1';
  300. openWebview("guanzhujumin.html",{
  301. selectType: selectType //0: 总居民, 1: 新增居民
  302. });
  303. });
  304. //监测方案设置、控制目标设置、发送文章等点击跳转去选择居民页面
  305. $(".setting-div").on('click', function(){
  306. var $this = $(this),
  307. $name = $this.find(".name"),
  308. name = $name.text(),
  309. val = $name.data("val");
  310. openWebview("choose-jumin-multiple.html", {
  311. teamCode: teamCode,
  312. title: name,
  313. type: val //plan: 检测方案, target:控制目标, article: 健康文章
  314. });
  315. })
  316. }