choose-junmin-multiple.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. mui.init();
  2. var title,
  3. type, //plan: 检测方案, target:控制目标, article: 健康文章
  4. teamCode,
  5. disease = '-1', //初始默认选中全部病种
  6. deviceType = '-1', //初始默认全部
  7. listLoaded = false,
  8. page = [],
  9. pagesize = 10,
  10. multiPeopleCodes = []; //批量分配时选中的居民code
  11. mui.plusReady(function(){
  12. var self = plus.webview.currentWebview();
  13. title = self.title;
  14. type = self.type;
  15. teamCode = self.teamCode;
  16. $("#title").text(title+'-选择居民');
  17. initScroller();
  18. queryPeopleNum();
  19. fillSickDropdown();
  20. fillDeviceDropdown();
  21. bindEvents();
  22. })
  23. //查询人数
  24. function queryPeopleNum(){
  25. var url = "doctor/scheme/get/disease/patientcodes",
  26. params = {
  27. teamCode: teamCode,
  28. disease: disease,
  29. diseaseCondition: '-1', //全部居民,不区分绿黄红标居民
  30. deviceType: deviceType,
  31. trackFlag: 1 //重点关注居民
  32. };
  33. plus.nativeUI.showWaiting();
  34. sendGet(url, params, null, function(res){
  35. if(res.status==200){
  36. multiPeopleCodes = res.data;
  37. $('#allNum').text('全部'+multiPeopleCodes.length+'人');
  38. $("#multiSend span").text('('+multiPeopleCodes.length+'人)')
  39. }else{
  40. mui.toast("查询失败");
  41. }
  42. plus.nativeUI.closeWaiting();
  43. }, true);
  44. }
  45. //获得居民分组数量
  46. function getPatientGroupNum(){
  47. var url = "doctor/patient_label_info/label_patient_amount",
  48. params = {
  49. labelType: 3,
  50. teamCode: teamCode,
  51. isSlowDisease: true,
  52. diseaseCondition: '',
  53. trackFlag: 1 // 重点关注居民
  54. };
  55. plus.nativeUI.showWaiting();
  56. sendGet(url, params, null, function(res){
  57. if(res.status == 200){
  58. listLoaded = true;
  59. for(i=0; i<res.data.length; i++){
  60. page.push(1);
  61. }
  62. var html = template('pati_group_tmpl', {list: res.data});
  63. $("#pati_list").empty().append(html);
  64. }else{
  65. mui.toast(res.msg);
  66. }
  67. plus.nativeUI.closeWaiting();
  68. }, true)
  69. }
  70. //获得居民列表数据
  71. function getPatientList(index, code){
  72. var url = "doctor/patient_label_info/patients_by_label",
  73. params = {
  74. teamCode: teamCode,
  75. labelType: 3,
  76. labelCode: code,
  77. page: page[index],
  78. pagesize: pagesize,
  79. isSlowDisease:true,
  80. trackFlag: 1
  81. };
  82. var $group = $(".patient-list").eq(index);
  83. plus.nativeUI.showWaiting();
  84. sendGet(url, params, null, function(res){
  85. if(res.status == 200){
  86. if(res.data.length < pagesize){
  87. if(page[index] == 1){
  88. $group.find(".load-more").hide();
  89. }else{
  90. $group.find(".load-more").attr("noMore", 'true').text("没有更多了");
  91. }
  92. }else{
  93. page[index] ++;
  94. $group.find(".load-more").show();
  95. }
  96. var html = template('pati_list_tmpl', {list: res.data});
  97. $group.find(".n-list").append(html);
  98. }else{
  99. mui.toast(res.msg);
  100. }
  101. plus.nativeUI.closeWaiting();
  102. }, true);
  103. }
  104. //慢病类型
  105. function fillSickDropdown(){
  106. $('#selSick').mobiscroll({
  107. theme: 'ios',
  108. lang: 'zh',
  109. customWheels: true,
  110. wheels: [
  111. [{
  112. keys: ['-1', '1', '2'],
  113. values: ['全部病种', '高血压', '糖尿病']
  114. }]
  115. ],
  116. onSelect: function(valueText, inst) {
  117. var dd = eval("[" + valueText + "]");
  118. $(this).text(dd[0].values);
  119. $(this).attr('data-val',dd[0].keys);
  120. disease = dd[0].keys;
  121. queryPeopleNum();
  122. }
  123. })
  124. }
  125. //设备绑定
  126. function fillDeviceDropdown(){
  127. $('#selDevice').mobiscroll({
  128. theme: 'ios',
  129. lang: 'zh',
  130. customWheels: true,
  131. wheels: [
  132. [{
  133. keys: ['-1', '1', '0'],
  134. values: ['全部', '已绑定', '未绑定']
  135. }]
  136. ],
  137. onSelect: function(valueText, inst) {
  138. var dd = eval("[" + valueText + "]");
  139. $(this).text(dd[0].values);
  140. $(this).attr('data-val',dd[0].keys);
  141. deviceType = dd[0].keys;
  142. queryPeopleNum();
  143. }
  144. })
  145. }
  146. //计算页面中选中的居民数量
  147. function getPeopleSum(){
  148. var $list = $(".icon-checkbox2:checked"),
  149. len = $list.length;
  150. $("#listSend span").text('('+len+'人)');
  151. }
  152. function bindEvents(){
  153. document.querySelector('#slider').addEventListener('slide', function(event) {
  154. if (event.detail.slideNumber === 1){
  155. if(!listLoaded){
  156. //获得居民列表数据
  157. getPatientGroupNum();
  158. }
  159. }
  160. });
  161. $("#pati_list").on('tap', ".patient-type", function(){
  162. var $this = $(this),
  163. $parent = $this.parent(),
  164. group = $parent.data("group"),
  165. index = $parent.index(),
  166. $ul = $parent.find("ul"),
  167. $arrow = $this.find(".ui-arrow");
  168. if($arrow.hasClass("ui-arrow-b")){
  169. if($ul.find("li").length == 0){
  170. getPatientList(index, group);
  171. }
  172. $ul.show();
  173. $arrow.addClass("ui-arrow-t");
  174. $arrow.removeClass("ui-arrow-b");
  175. }else{
  176. $ul.hide();
  177. $arrow.addClass("ui-arrow-b");
  178. $arrow.removeClass("ui-arrow-t");
  179. }
  180. });
  181. //加载更多操作
  182. $("#pati_list").on('tap', '.load-more', function(e){
  183. e.stopPropagation();
  184. var $parent = $(this).parent(),
  185. group = $parent.data("group"),
  186. index = $parent.index();
  187. if($(this).attr("noMore") == 'true'){
  188. return false;
  189. }
  190. getPatientList(index, group);
  191. });
  192. //选中列表中的居民信息
  193. $("#pati_list").on('change', ".icon-checkbox2", function(){
  194. var $this = $(this),
  195. code = $this.data("id");
  196. getPeopleSum();
  197. });
  198. //下一步
  199. $("#slider").on('tap', '#multiSend', function(){
  200. if(multiPeopleCodes.length==0){
  201. mui.toast('至少选一个居民');
  202. return false;
  203. }
  204. //type - plan: 检测方案, target:控制目标, article: 健康文章
  205. if(type == 'plan'){
  206. mui.openWindow({
  207. id: "jc-xuanzefangan",
  208. url: "jc-xuanzefangan.html",
  209. extras: {
  210. pCodes:multiPeopleCodes
  211. }
  212. })
  213. }else if(type == 'target'){
  214. mui.openWindow({
  215. id: "control-goal-multi",
  216. url: "control-goal-multi.html",
  217. extras: {
  218. pCodes:multiPeopleCodes
  219. }
  220. })
  221. }else if(type == 'article'){
  222. mui.openWindow({
  223. id: "article-store",
  224. url: "../../jkjy/html/article-store.html",
  225. extras: {
  226. pCodes:multiPeopleCodes,
  227. referrer: 'manbing'
  228. }
  229. })
  230. }
  231. });
  232. //列表页点击下一步
  233. $("#slider").on('tap', '#listSend', function(){
  234. var $list = $(".icon-checkbox2:checked"),
  235. len = $list.length;
  236. if(len==0){
  237. mui.toast('至少选一个居民');
  238. return false;
  239. }
  240. var list = [];
  241. for(i=0; i<len; i++){
  242. var $item = $($list[i]),
  243. code = $item.data("id");
  244. if(list.indexOf(code) == -1){
  245. list.push(code);
  246. }
  247. }
  248. //type - plan: 检测方案, target:控制目标, article: 健康文章
  249. if(type == 'plan'){
  250. mui.openWindow({
  251. id: "jc-xuanzefangan",
  252. url: "jc-xuanzefangan.html",
  253. extras: {
  254. pCodes:list
  255. }
  256. })
  257. }else if(type == 'target'){
  258. mui.openWindow({
  259. id: "control-goal-multi",
  260. url: "control-goal-multi.html",
  261. extras: {
  262. pCodes:list
  263. }
  264. })
  265. }else if(type == 'article'){
  266. mui.openWindow({
  267. id: "article-store",
  268. url: "../../jkjy/html/article-store.html",
  269. extras: {
  270. pCodes:list,
  271. referrer: 'manbing'
  272. }
  273. })
  274. }
  275. })
  276. template.helper('getImgUrl', function(str){
  277. return getImgUrl(str);
  278. });
  279. template.helper("setExpenses", function(str){
  280. switch(str) {
  281. case "1":
  282. return "已缴费";
  283. case "2":
  284. return "已退费";
  285. default:
  286. return "未缴费"
  287. }
  288. });
  289. }
  290. function initScroller(){
  291. //阻尼系数
  292. var deceleration = mui.os.ios?0.003:0.0009;
  293. mui('.mui-scroll-wrapper').scroll({
  294. bounce: false,
  295. indicators: true, //是否显示滚动条
  296. deceleration:deceleration
  297. });
  298. }