xuanzejibing.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>选择居民疾病类型</title>
  6. <meta name="author" content="yihu.com" />
  7. <meta name="format-detection" content="telephone=no" />
  8. <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0" />
  9. <meta name="apple-mobile-web-app-capable" content="yes" />
  10. <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  11. <link rel="stylesheet" href="../../../common/cross/css/cross.css" type="text/css" />
  12. <link rel="stylesheet" href="../../../common/cross/css/cross.ui.css" type="text/css" />
  13. <link rel="stylesheet" href="../../../css/mui.min.css">
  14. <link rel="stylesheet" href="../css/xuanzejibing.css">
  15. <script type="text/javascript" src="../../../js/jquery/2.1.3/jquery.js"></script>
  16. </head>
  17. <body>
  18. <div class="main">
  19. <div class="h45">
  20. <div class="demo-comtop">
  21. <a class="mui-action-back"></a>
  22. <h1 style="font-size: 100%; margin: .67em 0;">选择居民疾病类型</h1>
  23. <div class="header-link" style="display: none;">
  24. <a onclick="submit()" class="c-ccc link">完成</a>
  25. </div>
  26. </div>
  27. </div>
  28. <div class="doc-mycarder" id="list" style="background: #fff;">
  29. </div>
  30. </div>
  31. <script type="text/html" id="disease_temp">
  32. {{each list as v i}}
  33. <div class="mui-input-row mui-checkbox mui-left item {{v.code | setDisabled}}">
  34. <label>{{v.name}}</label>
  35. <input class="chk-box" data-name="{{v.name}}" value="{{v.code}}" {{v.code | setChecked}} type="checkbox">
  36. </div>
  37. {{/each}}
  38. <div class="mui-input-row mui-checkbox mui-left item item-other">
  39. <label>无以上疾病</label>
  40. <input class="chk-box chk-other" value="-1" type="checkbox">
  41. </div>
  42. </script>
  43. <script src="../../../js/mui.min.js" type="text/javascript" charset="utf-8"></script>
  44. <script src="../../../js/common_http.js" type="text/javascript" charset="utf-8"></script>
  45. <script src="../../js/common.js" type="text/javascript" charset="utf-8"></script>
  46. <script src="../../../js/template.js" type="text/javascript" charset="utf-8"></script>
  47. <script src="../../js/common.js" type="text/javascript" charset="utf-8"></script>
  48. <script src="../../js/templateHelp.js" type="text/javascript" charset="utf-8"></script>
  49. <script type="text/javascript">
  50. var postUrl = "doctor/patient_group/patient";
  51. var self, patiCode, isModify,
  52. diseases,
  53. hasSanshi;
  54. mui.plusReady(function() {
  55. self = plus.webview.currentWebview();
  56. diseases = self.diseases;
  57. patiCode = self.patiCode;
  58. if(patiCode)
  59. $('.header-link').show();
  60. mui.init({
  61. beforeback: function() {
  62. if(patiCode){
  63. if(isModify){
  64. mui.confirm("您已作了修改,需要保存吗?", "提示", ["不保存", "保存"], function(e) {
  65. if(e.index == 0) {
  66. plus.webview.currentWebview().close();
  67. } else {
  68. submit();
  69. }
  70. })
  71. return false;
  72. }
  73. } else {
  74. fireOpener();
  75. }
  76. }
  77. });
  78. template.helper("setChecked", function(j) {
  79. if(!diseases)
  80. return " ";
  81. for(var k in diseases){
  82. if(diseases[k].disease == j){
  83. var disabled;
  84. if(diseases[k].signType== '1'){
  85. hasSanshi = true;
  86. disabled = "disabled";
  87. }
  88. return ' data-old=1 checked=checked data-signType='+ diseases[k].signType
  89. + ' ' + disabled;
  90. }
  91. }
  92. return "data-signType=2";
  93. });
  94. template.helper("setDisabled", function(j) {
  95. if(!diseases)
  96. return " ";
  97. for(var k in diseases){
  98. if(diseases[k].disease == j && diseases[k].signType== '1')
  99. return ' item-disabled ';
  100. }
  101. return " ";
  102. });
  103. getDiseases();
  104. });
  105. /**
  106. * 获取疾病选择
  107. */
  108. function getDiseases(){
  109. sendPost("/common/data/diseases", {}, null, function(res){
  110. $('#list').html(template("disease_temp", res));
  111. if(hasSanshi){
  112. $('.chk-other').attr('disabled', true).parent().addClass('item-disabled');
  113. // $('.chk-box[value='+ hasSanshi +']').attr('disabled', true).parent().addClass('item-disabled');
  114. }
  115. initAction();
  116. })
  117. }
  118. /**
  119. * 初始化事件
  120. */
  121. function initAction(){
  122. $('.chk-box').on('change', function(){
  123. if($(this).hasClass('chk-other'))
  124. $('.chk-box[value!=-1]').attr('checked', false);
  125. else
  126. $('.chk-box[value=-1]').attr('checked', false);
  127. check();
  128. })
  129. $('.chk-box').on('tap', function(){
  130. return false;
  131. })
  132. $('.item').on('tap', function(){
  133. if($(this).hasClass('item-disabled'))
  134. return false;
  135. $(this).find('input:first').click();
  136. })
  137. }
  138. /**
  139. * 判断是否修改
  140. */
  141. function check(){
  142. var old = $('.chk-box[data-old="1"]');
  143. if($('.chk-box:checked[data-old="1"]').length != old.length
  144. || $('.chk-box:checked').length > old.length){
  145. $('.link').removeClass('c-ccc');
  146. isModify = true;
  147. }
  148. else {
  149. isModify = false;
  150. $('.link').addClass('c-ccc');
  151. }
  152. }
  153. /**
  154. * 获取选中的数据
  155. */
  156. function getChecked(){
  157. var codes = [];
  158. var diseases = [];
  159. var names = [];
  160. $.each($('.chk-box:checked'), function(i, v) {
  161. if($(v).val() == -1)
  162. return;
  163. codes.push($(v).val());
  164. diseases.push({disease: $(v).val(), diseaseName: $(v).attr('data-name'), signType: $(v).attr('data-signType')});
  165. names.push($(v).attr('data-name'));
  166. });
  167. if(names.length == 0)
  168. names.push('无');
  169. return {codes: codes, diseases: diseases, names: names.join("、")};
  170. }
  171. /**
  172. * 更新父页面信息
  173. * @param {Object} chks
  174. */
  175. function fireOpener(chks){
  176. chks = chks || getChecked();
  177. mui.fire(self.opener(), "setDiseaseTypes", chks);
  178. }
  179. /**
  180. * 提交
  181. */
  182. function submit(){
  183. if(isModify){
  184. var chks = getChecked();
  185. sendPost("/doctor/patient/disease_update",
  186. {patient: patiCode, disease: chks.codes.join(',')},
  187. null,
  188. function(res){
  189. if(res.status == 200){
  190. fireOpener(chks);
  191. var huanzheWv = plus.webview.getWebviewById("huanzhe.html");
  192. if(huanzheWv)
  193. mui.fire(huanzheWv, "refresh");
  194. mui.toast('修改成功!');
  195. plus.webview.currentWebview().close();
  196. } else{
  197. mui.toast(res.msg);
  198. }
  199. }
  200. )
  201. }
  202. }
  203. </script>
  204. </body>
  205. </html>