linchuangzhenduan.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. mui.plusReady(function(){
  2. var $ul = $('.lc-list'),
  3. $del = $('.u-icon-delete'),
  4. $input = $('#search-input'),
  5. $head = $('.lc-select');
  6. var self=plus.webview.currentWebview();
  7. var diagnosis = self.diagnosis;
  8. var $noResultWrap = $('#no_result_wrap');
  9. if(diagnosis.length>0){
  10. var html='';
  11. $.map(diagnosis,function(item,index){
  12. html +='<li data-id="'+item.code+'">'+item.name+'</li>'
  13. })
  14. $head.append(html).show()
  15. }
  16. $input.on('input',function(){
  17. var $val = $(this).val().trim();
  18. $noResultWrap.hide()
  19. $del.hide()
  20. $ul.empty().hide()
  21. if($val.length>0){
  22. $del.show();
  23. searchText($val)
  24. }
  25. })
  26. function searchText(nameKey){
  27. var params = {
  28. nameKey:nameKey
  29. }
  30. sendPost("doctor/prescriptionInfo/getIcd10Info",params, function(){
  31. mui.toast("获取数据失败");
  32. }, function(res){
  33. if(res.status == 200){
  34. if(res.data.length>0){
  35. var html = template('result_tmp',{data:res.data});
  36. $ul.html(html).show();
  37. findKeyName();
  38. }else{
  39. $noResultWrap.show()
  40. $ul.empty().hide()
  41. }
  42. }else{
  43. mui.toast("获取数据失败");
  44. }
  45. },'get')
  46. }
  47. mui('.mui-scroll-wrapper').scroll({
  48. bounce: false
  49. })
  50. //变色 添加
  51. $ul.on('tap','li',function(){
  52. var $this = $(this);
  53. if($this.hasClass('active')){
  54. $this.removeClass('active')
  55. for(var i=0;i<$head.find('li').length;i++){
  56. var $one = $head.find('li').eq(i)
  57. if($one.attr('data-id')==$this.attr('data-id')){
  58. $one.remove();
  59. }
  60. }
  61. }else{
  62. if($head.find('li').length<3){
  63. $this.addClass('active')
  64. $head.append('<li data-id="'+$this.attr('data-id')+'">'+$this.text()+'</li>')
  65. }else{
  66. mui.toast('最多只能三个')
  67. }
  68. }
  69. showHead()
  70. })
  71. //删除
  72. $head.on('tap','li',function(){
  73. var $this = $(this);
  74. $this.remove();
  75. $noResultWrap.hide()
  76. $ul.empty().hide()
  77. showHead()
  78. })
  79. function showHead(){
  80. if($head.find('li').length == 0){
  81. $head.hide()
  82. }else{
  83. $head.show()
  84. }
  85. //计算高度
  86. $('.mui-scroll-wrapper').css('top',$head.height()+107)
  87. }
  88. //清空
  89. $del.click(function(){
  90. $input.val('')
  91. $del.hide()
  92. $noResultWrap.hide()
  93. $ul.empty().hide()
  94. })
  95. //循环列表
  96. function findKeyName(){
  97. for(var i=0;i<$head.find('li').length;i++){
  98. var $one = $head.find('li').eq(i)
  99. for(var j=0;j<$ul.find('li').length;j++){
  100. var $this = $ul.find('li').eq(j)
  101. if($one.attr('data-id')==$this.attr('data-id')){
  102. $this.addClass('active')
  103. }
  104. }
  105. }
  106. }
  107. //确定
  108. $('.header-link').click(function(){
  109. if($head.find('li').length == 0){
  110. mui.toast('临床诊断不能为空')
  111. return
  112. }
  113. var arr = []
  114. for(var i=0;i<$head.find('li').length;i++){
  115. var $one = $head.find('li').eq(i)
  116. var obj={}
  117. obj.name = $one.text();
  118. obj.code = $one.attr('data-id');
  119. arr.push(obj);
  120. }
  121. plus.storage.setItem("reviseDiagnosis",JSON.stringify(arr))
  122. //新增
  123. var page = plus.webview.getWebviewById("change-chufang2");
  124. if(page){
  125. mui.fire(page, "reviseDiagnosis");
  126. }
  127. mui.back();
  128. })
  129. })