fvDetail.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. // 基本信息(包括userAgent)
  2. var baseInfo = null,
  3. // 基础环境信息(包括当前webview、encry相关)
  4. baseEnv = null,
  5. docInfo = null,
  6. fv_id = null,
  7. followupClass = null, //记录随访类型 高血压或糖尿病
  8. noFillItem = 0,
  9. patientCode = null, //记录患者code
  10. otherPeople = '',
  11. fv_status = null, //记录随访状态
  12. prescriptionStatus,
  13. prescriptionCode ="";//续方
  14. var reference = ""; //记录前一个页面的id
  15. var $proList = $("#project_list");
  16. // 获取登录相关信息
  17. var getBaseInfo = function() {
  18. docInfo = JSON.parse(plus.storage.getItem("docInfo"));
  19. prescriptionCode = baseEnv.webview.prescriptionCode;
  20. fv_id = baseEnv.webview.followup_id;
  21. fv_status = baseEnv.webview.status;
  22. reference = baseEnv.webview.reference;
  23. otherPeople = baseEnv.webview.otherPeople;
  24. //获取续方状态
  25. if(prescriptionCode){
  26. sendGet('doctor/prescriptionInfo/getContinuedPrescriptionAsDoctor',{code: prescriptionCode,type:1}, null, function(res){
  27. if(res.status == 200) {
  28. prescriptionStatus = res.data.prescription.status;
  29. isShowBtn()
  30. }else{
  31. mui.toast('获取续方状态失败')
  32. isShowBtn()
  33. }
  34. })
  35. }else{
  36. isShowBtn()
  37. }
  38. // 登录的相关信息
  39. var userAgent = JSON.parse(plus.storage.getItem("userAgent"));
  40. return {
  41. userAgent: userAgent
  42. }
  43. },
  44. // 获取基础环境信息
  45. getBaseEnvPromise = function () {
  46. var env = {
  47. webview: plus.webview.currentWebview()
  48. };
  49. mui.back = function(){
  50. backAction();
  51. }
  52. // 因为有异步请求,需要等待数据返回之后进行处理,所以返回Promise
  53. return Promise.resolve().then(function(res) {
  54. return env;
  55. });
  56. },
  57. isShowBtn = function(){
  58. //非操作人员
  59. if(otherPeople || (prescriptionStatus>=0 && prescriptionStatus < 40)){
  60. $('#completeSec').hide();
  61. }else{
  62. setTimeout(function(){
  63. $('#completeSec').show();
  64. },1000)
  65. }
  66. },
  67. initPage = function(){
  68. noFillItem = 0;
  69. if(fv_status == 1){
  70. $("#complete").text("保存修改");
  71. }
  72. //获取随访计划详情
  73. plus.nativeUI.showWaiting();
  74. var url = "doctor/followup/getFollowup";
  75. sendPost(url,{id: fv_id}, null, function(res){
  76. if(res.status == 200) {
  77. patientCode = res.data.patientCode;
  78. $(".docInfo").text(res.data.doctorName+" "+res.data.orgName);
  79. $(".patientName").text(res.data.patientName);
  80. if(res.data.followupNo){
  81. $(".planNo").text(res.data.followupNo);
  82. $(".planNo").closest("li").removeClass("c-hide");
  83. }
  84. $(".fvType").text(res.data.followupTypeName);
  85. $(".fvClass").text(res.data.followupClassName);
  86. $(".fvDate").text(res.data.followupDate);
  87. if(res.data.mobile && res.data.followupType == 3){ //电话随访方式才可以打电话
  88. $(".div-phone").show();
  89. $(".div-phone").attr("data-phone", res.data.mobile);
  90. }
  91. followupClass = res.data.followupClass;
  92. getFollowupProject();
  93. }else{
  94. plus.nativeUI.closeWaiting();
  95. mui.toast('数据加载失败')
  96. }
  97. }, "GET");
  98. },
  99. getFollowupProject = function(){
  100. //获取随访项目列表
  101. var url = "doctor/followup/getFollowupProject";
  102. sendPost(url,{id: fv_id}, null, function(res){
  103. if(res.status == 200) {
  104. var html = template("pro_list_temp", res);
  105. $proList.empty().append(html);
  106. for(i=0; i<res.data.length; i++){
  107. var item = res.data[i];
  108. if(item.status == 0){
  109. noFillItem += 1;
  110. }
  111. }
  112. }
  113. plus.nativeUI.closeWaiting();
  114. }, "GET");
  115. },
  116. backAction = function(){
  117. var self = plus.webview.currentWebview(),
  118. opener = self.opener(),
  119. pre_opener = opener.opener();
  120. var indexWv = plus.webview.getWebviewById('index');
  121. var server = plus.webview.getWebviewById("fuwujilu");
  122. var suifangList = plus.webview.getWebviewById('suifang_list');
  123. var xufangzixun = plus.webview.getWebviewById('xufangzixun');
  124. var chooseSuifang = plus.webview.getWebviewById('choose_suifang');
  125. var followWay = plus.webview.getWebviewById('follow_way');
  126. var suifangDetail = plus.webview.getWebviewById('suifang_detail');
  127. var startPlan = plus.webview.getWebviewById('start_plan');
  128. if(suifangList){
  129. mui.fire(suifangList, "refresh2");
  130. if(chooseSuifang){chooseSuifang.close('none')}
  131. if(followWay){followWay.close('none')}
  132. if(suifangDetail){suifangDetail.close('none')}
  133. if(startPlan){startPlan.close('none')}
  134. mui.later(function(){
  135. self.close('none')
  136. }, 300);
  137. }else if(xufangzixun){//续方咨询
  138. var fw = plus.webview.getWebviewById('xf_follow_way');
  139. if(fw){fw.close('none')}
  140. mui.later(function(){
  141. self.close('none');
  142. }, 300);
  143. }else if(server){//服务记录
  144. mui.fire(server, "refresh2");
  145. if(chooseSuifang){chooseSuifang.close('none')}
  146. if(followWay){followWay.close('none')}
  147. if(startPlan){startPlan.close('none')}
  148. if(suifangDetail){suifangDetail.close('none')}
  149. mui.later(function(){
  150. self.close('none');
  151. }, 300);
  152. openWebview("../../huanzhe/html/fuwujilu.html", {type: 'sf', patientCode: patientCode});
  153. }else if(pre_opener && pre_opener.id == "choose_suifang"){
  154. var pre_pre_opener = pre_opener.opener();
  155. if(pre_pre_opener.id == "suifang_detail"){
  156. //index->suifang_detail->choose_suifang->follow_way->fvDetail
  157. mui.fire(indexWv,'refresh');
  158. openWebview("index.html");
  159. mui.later(function(){
  160. pre_pre_opener.close('none');
  161. pre_opener.close('none');
  162. opener.close('none');
  163. self.close('none');
  164. },300);
  165. }else{
  166. //IM/juminxinxi->choose_suifang->follow_way->fvDetail
  167. var fuwujilu = plus.webview.getWebviewById("fuwujilu");
  168. if(fuwujilu){
  169. mui.fire(fuwujilu, "newPage", {type: 'sf', patientCode: patientCode});
  170. }
  171. openWebview("../../huanzhe/html/fuwujilu.html", {type: 'sf', patientCode: patientCode});
  172. mui.later(function(){
  173. pre_opener.close('none');
  174. opener.close('none');
  175. self.close('none');
  176. }, 1000);
  177. }
  178. }else{
  179. if(indexWv){
  180. mui.fire(indexWv,'refresh');
  181. openWebview("index.html");
  182. }
  183. mui.later(function(){
  184. var pre_pre_opener = pre_opener.opener();
  185. if(opener.id == "start_plan" || opener.id == "follow_way" || opener.id == "suifang_detail"){
  186. opener.close('none');
  187. }
  188. if(pre_opener && (pre_opener.id == "sousuojumin_one" || pre_opener.id == "xuanzejumin_one")){
  189. pre_opener.close('none');
  190. }
  191. if(pre_opener && pre_opener.id == "suifang_detail"){
  192. pre_opener.close('none');
  193. }
  194. if(pre_pre_opener && pre_pre_opener.id == "xuanzejumin_one"){
  195. pre_pre_opener.close('none');
  196. }
  197. self.close('none');
  198. }, 300);
  199. }
  200. }
  201. bindEvents = function(){
  202. $proList.on("tap","li", function(){
  203. if(!otherPeople || $(this).find('.c-list-key span').text()=='已登记'){
  204. var project_id = $(this).attr("data-id"),
  205. title = $(this).attr("data-label"),
  206. url = (project_id == "6")? "drugs.html":"questionaires.html";
  207. openWebview(url,{
  208. followup_id: fv_id,
  209. project_id: project_id,
  210. title: title,
  211. followupClass:followupClass,
  212. patientCode: patientCode,
  213. otherPeople:otherPeople
  214. });
  215. }
  216. });
  217. $("#complete").on('click',function(){
  218. var $ul = $('#project_list').find('li');
  219. if( !($ul.eq(1).attr('data-fill')*1 && $ul.eq(4).attr('data-fill')*1) ){
  220. mui.toast('请完善体征和评价')
  221. return false
  222. }
  223. if(noFillItem > 0){
  224. dialog({
  225. content: "当前还有<strong style='color:red;'>"+noFillItem+"</strong>项未提交,您确定要上传吗?",
  226. okValue:'继续上传',
  227. ok: function (){
  228. plus.nativeUI.showWaiting();
  229. var url = "doctor/followup/finishFollowup",
  230. params = {id: fv_id};
  231. sendPost(url, params, null, function(res){
  232. if(res.status == 200){
  233. mui.toast("完成本次随访");
  234. backAction();
  235. }
  236. plus.nativeUI.closeWaiting();
  237. },'POST');
  238. },
  239. cancelValue: '返回补充',
  240. cancel: function () {
  241. return;
  242. }
  243. }).showModal();
  244. }else{
  245. plus.nativeUI.showWaiting();
  246. var url = "doctor/followup/finishFollowup",
  247. params = {id: fv_id};
  248. sendPost(url, params, null, function(res){
  249. if(res.status == 200){
  250. mui.toast("完成本次随访");
  251. backAction();
  252. }
  253. plus.nativeUI.closeWaiting();
  254. },'POST');
  255. }
  256. });
  257. $(".div-phone").on('click', function(){
  258. var mobile = $(this).attr("data-phone");
  259. dialog({
  260. content: mobile,
  261. okValue:'立即拨号',
  262. ok: function (){
  263. window.location.href = "tel:"+mobile;
  264. },
  265. cancelValue: '不了,谢谢',
  266. cancel: function () {
  267. return;
  268. }
  269. }).showModal();
  270. });
  271. };
  272. // 页面业务处理流程开始
  273. new Promise(function(resolve, reject) {
  274. // TODO 临时放开
  275. //resolve(true);
  276. mui.plusReady(function() {
  277. // plus已经准备好,可以往下执行
  278. resolve(true);
  279. });
  280. }).then(function() {
  281. // 获取基础环境信息
  282. return getBaseEnvPromise().then(function(env) {
  283. baseEnv = env;
  284. }).then(function() {
  285. // 获取登录医生信息
  286. baseInfo = getBaseInfo();
  287. //初始化页面内容
  288. initPage();
  289. // 绑定页面事件
  290. bindEvents();
  291. })
  292. }).catch(function(e) {
  293. plus.nativeUI.closeWaiting();
  294. console && console.error(e);
  295. });
  296. window.addEventListener('refresh',function(){
  297. initPage();
  298. })