jc-xuanzefangan.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. var self,
  2. pCodes,//总患者code
  3. doctorCode,
  4. type = 1,//血糖类型
  5. $xtUl = $('#xt-ul'),
  6. $xyUl = $('#xy-ul'),
  7. $scroll = $('#iScroll');
  8. /* 从慢病档案页面跳转过来新增的参数 start */
  9. var selectedTab,
  10. xtCode, //从前一个页面带过来的方案的code
  11. xyCode,
  12. comeFrom;
  13. /* 从慢病档案页面跳转过来新增的参数 end */
  14. mui.plusReady(function(){
  15. self = plus.webview.currentWebview();
  16. pCodes = self.pCodes;
  17. //添加type判断
  18. selectedTab = self.selectedTab || 1;
  19. xtCode = self.xtCode;
  20. xyCode = self.xyCode;
  21. comeFrom = self.comeFrom;
  22. doctorCode = JSON.parse(plus.storage.getItem("docInfo")).code;
  23. mui('.mui-scroll-wrapper').scroll({
  24. deceleration:0.0005
  25. })
  26. if(selectedTab == 2){
  27. $('#jc-Type li').removeClass("active");
  28. $('#jc-Type li:eq(1)').addClass("active");
  29. type=2
  30. $xyUl.show();
  31. $xtUl.hide();
  32. $('#xt-addBtn').hide()
  33. $('#xy-addBtn').show()
  34. }
  35. queryXTData()
  36. queryXYData()
  37. bindEvents()
  38. })
  39. function queryXTData(){
  40. plus.nativeUI.showWaiting();
  41. sendPost("doctor/scheme/get/bloodsugger/list",{doctorcode:doctorCode}, function(){
  42. plus.nativeUI.closeWaiting();
  43. mui.toast("请求失败");
  44. }, function(res){
  45. plus.nativeUI.closeWaiting();
  46. if(res.status == 200){
  47. //周日放后
  48. $.map(res.data,function(item,index){
  49. var list = item.list
  50. delete item.list
  51. var sunday =list[0]
  52. var arr = list.slice(1)
  53. arr.push(sunday)
  54. item['list']=arr
  55. })
  56. var html = template('xt_tmp',{data:$.map(res.data,function(o,i){
  57. o.jsonStr = JSON.stringify(o);
  58. o.canUpdate = true;
  59. o.isSelected = false;
  60. if(comeFrom == 'jumindangan'){
  61. o.canUpdate = false; //从居民慢病档案页面跳转过来的时候,不可以编辑
  62. }
  63. if(xtCode){
  64. if(xtCode == o.code){
  65. o.isSelected = true;
  66. }
  67. }
  68. return o
  69. })
  70. })
  71. $('#xt-ul').html(html)
  72. }
  73. },'get')
  74. }
  75. function queryXYData(){
  76. plus.nativeUI.showWaiting();
  77. sendPost("doctor/scheme/get/bloodpressure/list",{doctorcode:doctorCode}, function(){
  78. plus.nativeUI.closeWaiting();
  79. mui.toast("请求失败");
  80. }, function(res){
  81. plus.nativeUI.closeWaiting();
  82. if(res.status == 200){
  83. //周日放后
  84. $.map(res.data,function(item,index){
  85. var list = item.list
  86. delete item.list
  87. var sunday =list[0]
  88. var arr = list.slice(1)
  89. arr.push(sunday)
  90. item['list']=arr
  91. })
  92. var html = template('xy_tmp',{data:$.map(res.data,function(o,i){
  93. o.jsonStr = JSON.stringify(o);
  94. o.canUpdate = true;
  95. o.isSelected = false;
  96. if(comeFrom == 'jumindangan'){
  97. o.canUpdate = false; //从居民慢病档案页面跳转过来的时候,不可以编辑
  98. }
  99. if(xyCode){
  100. o.canUpdate = false;
  101. if(xyCode == o.code){
  102. o.isSelected = true;
  103. }
  104. }
  105. return o
  106. })
  107. })
  108. $('#xy-ul').html(html)
  109. }
  110. },'get')
  111. }
  112. function bindEvents(){
  113. //点击跳转
  114. $('#xt-addBtn').on('tap',function(){
  115. mui.openWindow({
  116. id: "jc-addxuetang",
  117. url: "jc-addxuetang.html",
  118. waiting:{autoShow:false},
  119. extras: {
  120. }
  121. })
  122. })
  123. //修改
  124. $scroll.on('tap','.j-revise',function(){
  125. var $that = $(this)
  126. if(type == 1){
  127. mui.openWindow({
  128. id: "jc-addxuetang",
  129. url: "jc-addxuetang.html",
  130. waiting:{autoShow:false},
  131. extras: {
  132. jsonStr:$that.parent().attr('data-json')
  133. }
  134. })
  135. }else{
  136. mui.openWindow({
  137. id: "jc-addxueya",
  138. url: "jc-addxueya.html",
  139. waiting:{autoShow:false},
  140. extras: {
  141. jsonStr:$that.parent().attr('data-json')
  142. }
  143. })
  144. }
  145. })
  146. $('#xy-addBtn').on('tap',function(){
  147. mui.openWindow({
  148. id: "jc-addxueya",
  149. url: "jc-addxueya.html",
  150. waiting:{autoShow:false},
  151. extras: {
  152. }
  153. })
  154. })
  155. //展开
  156. $scroll.on('tap','.fa-up',function(){
  157. var $this = $(this)
  158. if($this.hasClass('active')){
  159. $this.removeClass('active')
  160. $this.siblings('.fa-down').hide()
  161. }else{
  162. $this.addClass('active')
  163. $this.siblings('.fa-down').show()
  164. }
  165. })
  166. //选择
  167. $scroll.on('tap','.j-select',function(){
  168. var $this = $(this)
  169. var params={
  170. doctorcode:doctorCode,
  171. schemecode:$this.parent().attr('data-code'),
  172. type:type,
  173. patientcodes:pCodes.join(',')
  174. }
  175. plus.nativeUI.showWaiting()
  176. sendPost("doctor/scheme/post/save/patient/scheme",params, function(){
  177. plus.nativeUI.closeWaiting();
  178. mui.toast("请求失败");
  179. }, function(res){
  180. plus.nativeUI.closeWaiting();
  181. if(res.status == 200){
  182. mui.toast('设置成功')
  183. closePage()
  184. refreshHz()
  185. setTimeout(function(){
  186. mui.back();
  187. },500)
  188. }else{
  189. mui.toast('设置失败')
  190. }
  191. })
  192. })
  193. //切换类型
  194. $('#jc-Type').on('tap','li',function(){
  195. var $this = $(this)
  196. if(!$this.hasClass('active')){
  197. $this.addClass('active').siblings().removeClass('active');
  198. if($this.attr('data-type') == 1){
  199. type=2
  200. $xyUl.show();
  201. $xtUl.hide();
  202. $('#xt-addBtn').hide()
  203. $('#xy-addBtn').show()
  204. }else{
  205. type=1
  206. $xyUl.hide();
  207. $xtUl.show();
  208. $('#xy-addBtn').hide()
  209. $('#xt-addBtn').show()
  210. }
  211. }
  212. })
  213. }
  214. //刷新事件
  215. window.addEventListener("refreshData", function(){
  216. queryXTData()
  217. queryXYData()
  218. })
  219. //页面刷新
  220. function refreshHz(){
  221. var page = plus.webview.getWebviewById("manbingguanli");
  222. if(page){
  223. mui.fire(page, "refreshManBing")
  224. }
  225. //刷新居民档案页面的内容
  226. var wv = plus.webview.currentWebview().opener();
  227. if(wv){
  228. console.log("fire");
  229. mui.fire(wv, "reloadJiance");
  230. }
  231. //刷新页面,如果从重点跟踪页面过来,则需要将选择居民的页面也一起关闭
  232. var preOpener = wv.opener();
  233. if(preOpener.id == "zhongdiangenzong"){
  234. wv.close();
  235. //不需要刷新页面
  236. // mui.fire(preOpener);
  237. }
  238. }
  239. //关闭页面
  240. function closePage(){
  241. var last = plus.webview.getWebviewById("jc-xuanzejumin");
  242. if(last){
  243. last.close()
  244. }
  245. }