my-equipments.js 2.9 KB

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