del-my-equipments.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //mui.plusReady(function() {
  2. queryList();
  3. //});
  4. function queryList() {
  5. // plus.nativeUI.showWaiting();
  6. //拼请求内容
  7. var params = {};
  8. params.id = 0;
  9. params.pagesize = 60;
  10. //发送ajax请求
  11. sendPost("patient/device/list", params, "json", "post", queryListFailed, queryListSuccesss);
  12. }
  13. function queryListFailed(res) {
  14. console.log(res.status);
  15. if (res && res.msg) {
  16. // plus.nativeUI.toast(res.msg);
  17. } else {
  18. // plus.nativeUI.toast("数据加载失败");
  19. }
  20. // plus.nativeUI.closeWaiting();
  21. }
  22. function queryListSuccesss(res) {
  23. if (res.status == 200) {
  24. //成功
  25. // console.log(res.data.list);
  26. showList(res.data.list);
  27. } else {
  28. //非200则为失败
  29. queryListFailed(res);
  30. }
  31. // plus.nativeUI.closeWaiting();
  32. }
  33. /**
  34. * 清空tbody
  35. */
  36. function clearHTML() {
  37. $("#equ_list").html("");
  38. }
  39. /**
  40. * 显示查询结果
  41. * @param {Object} list
  42. */
  43. function showList(list) {
  44. clearHTML();
  45. var _html = "";
  46. for (var i = 0; i < list.length; i++) {
  47. var data = list[i];
  48. if (!data) {
  49. continue;
  50. }
  51. _html+="<li class='c-list-text c-list-link'>"
  52. _html+= "<div class='c-list-key'>"
  53. _html+= "<i class='icon-del mr5' attr_code="+data.code+"></i>"
  54. _html+= "<span>"+data.name+"</span>"
  55. _html+= "</div>"
  56. _html+= "<div class='c-list-info c-t-right'>"+data.sn+"</div>"
  57. _html+= "<span class='list-icon arrow-right'></span>"
  58. _html+="</li>";
  59. // "<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. $(".icon-del").on("click",function(){
  67. var i = $(this);
  68. var attr_code = $(this).attr('attr_code');
  69. dialog({
  70. title:'删除设备信息',
  71. content:'确定删除该设备信息吗?',
  72. ok: function (){
  73. //获取现在有的设备类别以及名称
  74. var params = {}
  75. params.code = attr_code;
  76. //发送ajax请求, 查询设备列表信息
  77. sendPost("patient/device/delete", params, "json", "post", queryListFailed,dele_Successs);
  78. function dele_Successs(res){
  79. console.log("删除成功");
  80. var i = plus.webview.getWebviewById("my-equipments");
  81. // mui.fire(i, "update_info_detail", {
  82. // type_name:params.type_name,
  83. // name:params.name,
  84. // sn:params.sn,
  85. // });
  86. // mui.toast("删除成功");
  87. alert("删除成功");
  88. }
  89. // plus.nativeUI.toast(res.mag);
  90. i.parent().parent().remove();
  91. },
  92. cancel: function () {
  93. // alert("你点了取消")
  94. return;
  95. }
  96. }).showModal();
  97. })
  98. }
  99. //添加数据添加监听
  100. window.addEventListener("update_info_detail", function(e) {
  101. //刷新列表
  102. queryList();
  103. });