fp-common.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. var searchVal = "";
  2. function html_encode(str){
  3. var s = "";
  4. if (str.length == 0) return "";
  5. s = str.replace(/&#60;label class=c-17b3ec&#62;/g, '<label class="c-17b3ec">');
  6. s = s.replace(/&#60;\/label&#62;/g, "</label>");
  7. return s;
  8. }
  9. template.helper("setName", function filters(n, t){
  10. if(searchVal && t=="sx"){
  11. var arr = n.split(searchVal);
  12. return arr.join('<label class=c-17b3ec>'+searchVal+'</label>');
  13. }
  14. return n;
  15. })
  16. /*template.helper("setName", function filters(n, t, i){
  17. if(t=='sx' && !i && searchVal){
  18. var arr = n.split(searchVal);
  19. return arr.join('&lt;label style="color:#17b3ec"&gt;'+searchVal+'&lt;/label&gt;');
  20. } else if(i && t!='sx')
  21. return n;
  22. return "";
  23. })*/
  24. template.helper("setAddress", function filters(n){
  25. var arr = n.split(searchVal);
  26. return arr.join('<label class=c-17b3ec>'+searchVal+'</label>');
  27. })
  28. /**
  29. * 下一步操作
  30. */
  31. function submit(isAll){
  32. if(isAll == 1){
  33. if(!$('.checked-num').hasClass('disabled'))
  34. to_next("", 1);
  35. return;
  36. }
  37. if(num<=0)
  38. return;
  39. plus.nativeUI.showWaiting();
  40. var patients = [];
  41. for(var k in checked){
  42. patients.push(checked[k]);
  43. }
  44. to_next(patients);
  45. plus.nativeUI.closeWaiting();
  46. }
  47. function to_next(patients, isAll){
  48. mui.openWindow({
  49. id: "xuanzejieshouyisheng.html",
  50. url: "xuanzejieshouyisheng.html",
  51. extras: {
  52. jgs: self.jgs,
  53. patients: patients,
  54. docCode: docCode,
  55. teamCode: teamCode,
  56. type: "分配",
  57. isAll: isAll || ""
  58. }
  59. });
  60. }
  61. function remove(ls, isDom){
  62. var patient, delNum = 0;
  63. if(isDom){
  64. $.each(ls, function(i, v) {
  65. patient = JSON.parse($(v).attr('data-info'));
  66. if(checked[patient.code]){
  67. delNum++;
  68. delete checked[patient.code];
  69. }
  70. });
  71. } else {
  72. $.each(ls, function(i, v) {
  73. if(checked[v.code]){
  74. delNum++;
  75. delete checked[v.code];
  76. }
  77. });
  78. }
  79. num = num - delNum;
  80. }
  81. function add(ls, isDom){
  82. var patient, addNum = 0;
  83. if(isDom){
  84. $.each(ls, function(i, v) {
  85. patient = JSON.parse($(v).attr('data-info'));
  86. if(!checked[patient.code]){
  87. addNum++;
  88. checked[patient.code] = patient;
  89. }
  90. });
  91. } else {
  92. $.each(ls, function(i, v) {
  93. if(!checked[v.code]){
  94. addNum++;
  95. checked[v.code] = v;
  96. }
  97. });
  98. }
  99. num = num + addNum;
  100. }
  101. function refreshTotal(){
  102. $('.link label').html(num);
  103. $('.link').toggleClass('c-ccc', num<=0);
  104. }
  105. $('.doc-list').on('tap', '.doc-item', function(){
  106. $('.search-box input').blur();
  107. $(this).toggleClass('checked');
  108. var info = JSON.parse($(this).attr('data-info'));
  109. var isAdd = false;
  110. if($(this).hasClass('checked')){
  111. add([info]);
  112. isAdd = true;
  113. } else {
  114. remove([info]);
  115. }
  116. refreshTotal();
  117. var type = $(this).attr('data-type');
  118. if(type == "sx"){
  119. $('#lscroller .doc-list').find('.doc-item[data-code="'+ info.code +'"]').toggleClass("checked", isAdd);
  120. $('#s-addr .doc-list').find('.doc-item[data-code="'+ info.code +'"]').toggleClass("checked", isAdd);
  121. } else if(type == "sa"){
  122. $('#s-xm .doc-list').find('.doc-item[data-code="'+ info.code +'"]').toggleClass("checked", isAdd);
  123. $('#lscroller .doc-list').find('.doc-item[data-code="'+ info.code +'"]').toggleClass("checked", isAdd);
  124. }
  125. })
  126. $('#allSel').on('tap', function(){
  127. $(this).toggleClass('checked');
  128. if($(this).hasClass('checked')){
  129. $(this).next().html("取消全选");
  130. $('#listDiv .doc-list').find('.doc-item').addClass('checked');
  131. add($('#listDiv .doc-list').find('.doc-item'), true);
  132. } else {
  133. $(this).next().html("全选");
  134. $('#listDiv .doc-list').find('.doc-item').removeClass('checked');
  135. remove($('#listDiv .doc-list').find('.doc-item'), true);
  136. }
  137. refreshTotal();
  138. })