Bez popisu

equipmentCommon.js 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. //设备名称
  2. function GetEquipName(obj) {
  3. obj.empty();
  4. obj.append('<option selected="selected" value="">请选择设备名称</option>');
  5. $.getJSON(huayi.config.callcenter_url + "equipmentapi/api/equipment/getlistdrop", function(data) {
  6. if (data.state.toLowerCase() == "success") {
  7. var content = data.data;
  8. $(content).each(function(i, n) {
  9. $("<option value='" + n.id + "'>" + n.text + "</option>").appendTo(obj);
  10. })
  11. obj.selectpicker('refresh');
  12. }
  13. })
  14. }
  15. //省市联动
  16. function getProvinceCity(ele1, isasync) {
  17. if (isasync != false) {
  18. isasync = true;
  19. }
  20. $.ajaxSettings.async = isasync;
  21. ele1.empty();
  22. ele1.append('<option selected="selected" value="">请选择省</option>');
  23. $.getJSON(huayi.config.callcenter_url + "equipmentapi/api/equipment/getfivetree", function(data) {
  24. if (data.state.toLowerCase() == "success") {
  25. var province = data.data;
  26. var citys = []; //市
  27. var projects = []; //项目
  28. var builds = []; //楼
  29. var floors = []; //楼层
  30. $(data.data).each(function(i, n) {
  31. $("<option value='" + n.code + "'>" + n.name + "</option>").appendTo(ele1);
  32. ele1.selectpicker('refresh');
  33. if (n.entityJson != null && n.entityJson.length != 0) {
  34. citys.push(n.entityJson);
  35. }
  36. })
  37. //市级信息
  38. $("#province").change(function() {
  39. $("#city").empty();
  40. projects = [];
  41. for (var i = 0; i < citys.length; i++) {
  42. $(citys[i]).each(function(j, v) {
  43. if (v.parentcode > 0) {
  44. if ($("#province").val() == v.parentcode) {
  45. $("<option value='" + v.code + "'>" + v.name + "</option>").appendTo("#city");
  46. if (v.entityJson != null && v.entityJson.length > 0) {
  47. projects.push(v.entityJson);
  48. }
  49. }
  50. }
  51. });
  52. }
  53. $("#city").selectpicker('refresh');
  54. if ($("#province").val() == '') {
  55. $("#city").append('<option selected="selected" value="">请选择所在市</option>');
  56. }
  57. if ($("#city").val() == null) {
  58. $("#city").append('<option selected="selected" value="">暂无数据</option>');
  59. }
  60. $("#city").trigger('change');
  61. })
  62. //项目信息
  63. $("#city").change(function() {
  64. $("#proname").empty();
  65. builds = [];
  66. $('#protype_addText').val('');
  67. $('#protype_addNode').val('');
  68. for (var j = 0; j < projects.length; j++) {
  69. $(projects[j]).each(function(i, n) {
  70. if (n.parentcode > 0) {
  71. if ($("#city").val() == n.parentcode) {
  72. $('#protype_addText').val(n.protypename);
  73. $('#protype_addNode').val(n.protypeid);
  74. $("<option value='" + n.code + "'>" + n.name + "</option>").appendTo("#proname");
  75. if (n.entityJson != null && n.entityJson.length > 0) {
  76. builds.push(n.entityJson);
  77. }
  78. }
  79. }
  80. });
  81. }
  82. $("#proname").selectpicker('refresh');
  83. if ($("#city").val() == '') {
  84. $("#proname").append('<option selected="selected" value="">请选择项目</option>');
  85. }
  86. if ($("#proname").val() == null || $("#proname").val() == '') {
  87. $("#proname").append('<option selected="selected" value="">暂无数据</option>');
  88. }
  89. $("#proname").trigger('change');
  90. })
  91. //楼信息
  92. $("#proname").change(function() {
  93. $("#build").empty();
  94. floors = [];
  95. $('<option selected="selected" value="">请选择楼</option>').appendTo("#build");
  96. for (var g = 0; g < builds.length; g++) {
  97. $(builds[g]).each(function(q, p) {
  98. if (p.parentcode) {
  99. if ($("#proname").val() == p.parentcode) {
  100. $("<option value='" + p.code + "'>" + p.name + "</option>").appendTo("#build");
  101. if (p.entityJson != null && p.entityJson.length > 0) {
  102. floors.push(p.entityJson);
  103. }
  104. }
  105. }
  106. });
  107. }
  108. $("#build").selectpicker('refresh');
  109. if ($("#proname").val() == '') {
  110. $("#build").append('<option selected="selected" value="">请选择楼</option>');
  111. }
  112. // if ($("#build").val() == null || $("#build").val() == '') {
  113. if ($("#build").val() == null) {
  114. $("#build").append('<option selected="selected" value="">暂无数据</option>');
  115. }
  116. $("#build").trigger('change');
  117. })
  118. //楼层信息
  119. $("#build").change(function() {
  120. $("#floor").html('');
  121. $("#floor").append('<option selected="selected" value="">请选择楼层</option>');
  122. for (var k = 0; k < floors.length; k++) {
  123. $(floors[k]).each(function(y, z) {
  124. if (z.parentcode) {
  125. if ($("#build").val() == z.parentcode) {
  126. $("<option value='" + z.code + "'>" + z.name + "</option>").appendTo("#floor");
  127. }
  128. }
  129. });
  130. }
  131. $("#floor").selectpicker('refresh');
  132. if ($("#build").val() == '') {
  133. $("#floor").append('<option selected="selected" value="">请选择楼层</option>');
  134. }
  135. // if ($("#floor").val() == null || $("#floor").val() == '') {
  136. if ($("#floor").val() == null) {
  137. $("#floor").append('<option selected="selected" value="">暂无数据</option>');
  138. }
  139. $("#floor").trigger('change');
  140. })
  141. }
  142. if (!isasync) {
  143. $.ajaxSettings.async = true;
  144. }
  145. })
  146. }