dingyibiaoqian.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. var obj,
  2. code,
  3. name,
  4. patientInfo = {},
  5. patientInfoArr = [],
  6. self,
  7. arrSumInfo = [];
  8. var newPickerf,newPickers,newPicket
  9. //创建变量
  10. var $specialty = $("#specialty"),
  11. $healthy = $('#healthy'),
  12. $custom = $('#custom'),
  13. $concealment = $('#concealment');
  14. $recovery = $('#recovery');
  15. $nongroup = $('#nongroup');
  16. //初始化mui
  17. mui.init();
  18. //mui文档就绪执行函数
  19. mui.plusReady(function() {
  20. //获取基础信息
  21. obj = init();
  22. //获取页面信息
  23. self = plus.webview.currentWebview();
  24. //初始化页面
  25. initPage();
  26. //获取没标签居民数目(数字)
  27. residentCount();
  28. //获取没标签居民数(具体的居民列表)
  29. residentList()
  30. //事件绑定执行函数
  31. bindEvent();
  32. })
  33. function init() {
  34. var userAgent = JSON.parse(plus.storage.getItem('userAgent'));
  35. var teamInfo = JSON.parse(plus.storage.getItem('teamInfo'));
  36. var doctorInfo = JSON.parse(plus.storage.getItem("docInfo"));
  37. return {
  38. userAgent: userAgent,
  39. teamInfo: teamInfo,
  40. doctorInfo: doctorInfo
  41. }
  42. }
  43. function initPage(){
  44. newPickerf = new mui.PopPicker({});
  45. newPickers = new mui.PopPicker({});
  46. newPickert= new mui.PopPicker({});
  47. getSelect(7)
  48. getSelect(8)
  49. getSelect(4)
  50. }
  51. function getSelect(type) {
  52. sendGet('/doctor/specialist/findLabelbyType', {
  53. type: type,
  54. teamCode: ""
  55. }, null, function(res) {
  56. if(res.status == 200) {
  57. var arr = []
  58. for(i in res.data) {
  59. res.data[i].text = res.data[i].labelName;
  60. }
  61. if (type==7) {
  62. newPickerf.setData(res.data)
  63. }if (type==8) {
  64. newPickers.setData(res.data)
  65. }if (type==4) {
  66. newPickert.setData(res.data)
  67. }
  68. } else {
  69. mui.toast(res.msg);
  70. }
  71. plus.nativeUI.closeWaiting();
  72. }, 'GET', '', true);
  73. }
  74. function residentCount() {
  75. sendGet('/doctor/specialist/findSpecialistPatientRelationCout', {
  76. doctor: obj.doctorInfo.code
  77. }, null, function(res) {
  78. if(res.status == 200) {
  79. $('#sum').html(res.data)
  80. } else {
  81. mui.toast(res.msg);
  82. }
  83. }, 'GET', '', true);
  84. }
  85. function residentList() {
  86. sendGet('/doctor/specialist/findNoLabelPatientRelation', {
  87. doctor: obj.doctorInfo.code
  88. }, null, function(res) {
  89. if(res.status == 200) {
  90. for(var i in res.data){
  91. res.data[i].photo = getImgUrl(res.data[i].photo)
  92. }
  93. $('.n-list').html(template('no_label_resident', {
  94. list: res.data
  95. }));
  96. } else {
  97. mui.toast(res.msg);
  98. }
  99. }, 'GET', '', true);
  100. }
  101. function bindEvent() {
  102. $specialty.on('tap', function(e) {
  103. e.stopPropagation();
  104. newPickerf.show(function(selectItems) {
  105. $concealment.html(selectItems[0].text);
  106. $concealment.attr('data-code', selectItems[0].labelCode)
  107. $concealment.attr('data-type', selectItems[0].labelType)
  108. })
  109. });
  110. $healthy.on('tap', function(e) {
  111. e.stopPropagation();
  112. newPickers.show(function(selectItems) {
  113. $recovery.html(selectItems[0].text)
  114. $recovery.attr('data-code', selectItems[0].labelCode)
  115. $recovery.attr('data-type', selectItems[0].labelType)
  116. })
  117. });
  118. $custom.on('tap', function() {
  119. newPickert.show(function(selectItems) {
  120. $nongroup.html(selectItems[0].text)
  121. $nongroup.attr('data-code', selectItems[0].labelCode)
  122. $nongroup.attr('data-type', selectItems[0].labelType)
  123. })
  124. });
  125. $("#times").on("tap", function(e) {
  126. e.stopPropagation();
  127. e.preventDefault();
  128. });
  129. //点击确定的时候设置居民标签
  130. var juage = true;
  131. $('#makeSure').on('tap', function(e) {
  132. if(juage==true){
  133. var disType = $concealment.html();
  134. var situaType = $recovery.html();
  135. var Grouping = $nongroup.html();
  136. var residentSum = $(".n-list input[name=jvmin]:checked");
  137. var j_list = $(".n-list input[name=jvmin]:checked").parent().parent();
  138. if(disType.length == 0 || disType == '请选择专病类型') {
  139. dialog({
  140. contentType: 'tipsbox',
  141. skin: 'bk-popup',
  142. content: '专病类型不能为空!',
  143. closeTime: 2000
  144. }).showModal();
  145. return false;
  146. } else if(situaType.length == 0 || situaType == '请选择健康情况') {
  147. dialog({
  148. contentType: 'tipsbox',
  149. skin: 'bk-popup',
  150. content: '健康情况不能为空!',
  151. closeTime: 2000
  152. }).showModal();
  153. return false;
  154. } else if(residentSum.length == 0) {
  155. dialog({
  156. contentType: 'tipsbox',
  157. skin: 'bk-popup',
  158. content: '请选择居民!',
  159. closeTime: 2000
  160. }).showModal();
  161. return false;
  162. }
  163. for(var k = 0; k < j_list.length; k++) {
  164. var middleVar = {};
  165. var code = j_list[k].getAttribute('data-code');
  166. var name = j_list[k].getAttribute('data-name');
  167. middleVar = {
  168. patient: code,
  169. pname: name
  170. }
  171. patientInfoArr.push(middleVar);
  172. }
  173. //获取疾病类型标签
  174. var dName = $concealment.html();
  175. var dCode = $concealment.attr('data-code');
  176. var dType = $concealment.attr('data-type');
  177. //获取健康状况标签
  178. var hName = $recovery.html();
  179. var hCode = $recovery.attr('data-code');
  180. var hType = $recovery.attr('data-type');
  181. //获取自定义分组标签
  182. var cName = $nongroup.html();
  183. var cCode = $nongroup.attr('data-code');
  184. var cType = $nongroup.attr('data-type');
  185. //设置居民标签接口的参数
  186. var contain = [];
  187. if(Grouping.length != 0 || Grouping != '未分组') {
  188. for(var h = 0; h < 3; h++) {
  189. if(h == 0) {
  190. var obj1 ={};
  191. for(var j = 0;j<patientInfoArr.length;j++){
  192. patientInfoArr[j].labelName = dName;
  193. patientInfoArr[j].label = dCode;
  194. patientInfoArr[j].labelType = dType;
  195. obj1 = $.extend({},patientInfoArr[j]);
  196. arrSumInfo.push(obj1);
  197. }
  198. }if(h==1){
  199. var obj2= {};
  200. for(var j = 0;j<patientInfoArr.length;j++){
  201. patientInfoArr[j].labelName = hName;
  202. patientInfoArr[j].label = hCode;
  203. patientInfoArr[j].labelType = hType;
  204. obj2 = $.extend({},patientInfoArr[j]);
  205. arrSumInfo.push(obj2);
  206. }
  207. }else if(h==2){
  208. var obj3= {};
  209. for(var j = 0;j<patientInfoArr.length;j++){
  210. patientInfoArr[j].labelName = cName;
  211. patientInfoArr[j].label = cCode;
  212. patientInfoArr[j].labelType = cType;
  213. obj3 = $.extend({},patientInfoArr[j]);
  214. arrSumInfo.push(obj3);
  215. }
  216. }
  217. }
  218. }else{
  219. for(var h = 0; h < 2; h++) {
  220. if(h == 0) {
  221. var obj1 ={};
  222. for(var j = 0;j<patientInfoArr.length;j++){
  223. patientInfoArr[j].labelName = dName;
  224. patientInfoArr[j].label = dCode;
  225. patientInfoArr[j].labelType = dType;
  226. obj1 = $.extend({},patientInfoArr[j]);
  227. arrSumInfo.push(obj1);
  228. }
  229. }if(h==1){
  230. var obj2= {};
  231. for(var j = 0;j<arr_sj.patientInfoArr;j++){
  232. patientInfoArr[j].labelName = hName;
  233. patientInfoArr[j].label = hCode;
  234. patientInfoArr[j].labelType = hType;
  235. obj2 = $.extend({},patientInfoArr[j]);
  236. arrSumInfo.push(obj2);
  237. }
  238. }
  239. }
  240. }
  241. // 设置居民标签
  242. var labelUrl = '/doctor/specialist/setPatientLabelInfo';
  243. // 设置参数
  244. var params = {
  245. json:JSON.stringify(arrSumInfo)
  246. }
  247. sendPost(labelUrl, params, null, function(res){
  248. if (res.status==200) {
  249. mui.confirm('您的居民标签定义好了,是否继续分配计管医师?(计管医师可帮助您制定康复计划)',
  250. "提示",["继续", "退出"],function(e){
  251. //选择继续的时候
  252. if(e.index==0){
  253. var wv = mui.openWindow({
  254. url:'fenpeijianguanshi.html',
  255. id:'fenpeijianguanshi',
  256. extras:{
  257. residentArr:patientInfoArr
  258. }
  259. })
  260. //选择退出的时候(刷新人数,返回居民首页)
  261. }else{
  262. residentList();
  263. residentCount();
  264. //返回居民首页
  265. backPage();
  266. }
  267. }
  268. )
  269. } else{
  270. mui.toast(res.msg);
  271. }
  272. },'POST','',true)
  273. }
  274. juage = false;
  275. })
  276. }
  277. //返回上一个页面
  278. function backPage(){
  279. var wv = plus.webview.getWebviewById('huanzhe-specal.html');
  280. // console.log(wv)
  281. if (wv) {
  282. mui.fire(wv,'refresh');
  283. }
  284. mui.back();
  285. }