my-equipments.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. var d = dialog({contentType:'load', skin:'bk-popup'});
  2. var pagetype = 14;
  3. $(function() {
  4. queryList();
  5. });
  6. function queryList() {
  7. d.show();
  8. //拼请求内容
  9. var params = {};
  10. params.id = 0;
  11. params.pagesize = 60;
  12. //发送ajax请求
  13. sendPost("patient/device/list", params, "json", "post", queryListFailed, queryListSuccesss);
  14. }
  15. function queryListFailed(res) {
  16. d.close().remove();
  17. if (res && res.msg) {
  18. var d1 = dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg});
  19. d1.show();
  20. } else {
  21. var d2 = dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'});
  22. d2.show();
  23. }
  24. }
  25. function queryListSuccesss(res) {
  26. if (res.status == 200) {
  27. if(res.data.list.length==0){
  28. //没有一个设备
  29. var _htm = "<li id='tishi_add' class='c-list-text c-list-link' >"
  30. _htm+= "<div class='c-list-key'style='margin:0 auto;'>您还没有设备,赶快添加吧</div>"
  31. _htm+="</li>"
  32. $("#equ_list").html(_htm);
  33. }else{
  34. //有设备
  35. showList(res.data.list);
  36. }
  37. d.close().remove();
  38. } else {
  39. //非200则为失败
  40. queryListFailed(res);
  41. }
  42. }
  43. /**
  44. * 清空tbody
  45. */
  46. function clearHTML() {
  47. $("#equ_list").html("");
  48. }
  49. /**
  50. * 显示查询结果
  51. * @param {Object} list
  52. */
  53. function showList(list) {
  54. clearHTML();
  55. var _html = "";
  56. for (var i = 0; i < list.length; i++) {
  57. var data = list[i];
  58. if (!data) {
  59. continue;
  60. }
  61. _html+="<li class='c-list-text c-list-link' attr_code="+data.code+" attr_name="+data.name+" attr_sn="+data.sn+">"
  62. _html+="<div class='c-list-key'>"+data.name+"</div>"
  63. _html+="<div class='c-list-info c-t-right'>"+data.sn+"</div>"
  64. _html+="<span class='list-icon arrow-right'></span>"
  65. _html+="</li>";
  66. }
  67. $("#equ_list").html(_html);
  68. $("#equ_list").on("click","li",function(){
  69. var attr_code = $(this).attr('attr_code');
  70. var attr_name = $(this).attr('attr_name');
  71. var attr_sn = $(this).attr('attr_sn');
  72. //获取现在有的设备类别以及名称
  73. var params = {}
  74. params.code = attr_code;
  75. var dev_list={};
  76. //发送ajax请求, 查询设备列表信息
  77. sendPost("patient/device/info", params, "json", "post", queryListFailed,device_info_Successs);
  78. function device_info_Successs(res){
  79. var category=res.data.category;
  80. var type_name='';
  81. //发送ajax请求, 查询设备类型
  82. sendPost("patient/device/category"," ", "json", "post", queryListFailed,device_type_Successs);
  83. function device_type_Successs(reso){
  84. dev_list=reso.list;
  85. for(var i=0;i<reso.list.length;i++){
  86. if(reso.list[i].code==category){
  87. type_name=reso.list[i].name;
  88. var befor_url="equipment-detail.html";
  89. //拼接url参数
  90. var _url=""+befor_url+"?code="+attr_code+"&category="+category+"&type_name="+type_name+"&name="+attr_name+"&sn="+attr_sn+"";
  91. //字符串转码(中文)
  92. var e_url = encodeURI(encodeURI(_url));
  93. window.location.href=e_url;
  94. }
  95. }
  96. }
  97. }
  98. })
  99. }