map-index.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. (function ($app) {
  2. $app.module('ylmis').controller('mapIndexCtrl', function ($scope, $http, $filter, $modal, $ocLazyLoad, $alert, $loading, $state, excelPopup, $bsRouterState, popupReport) {
  3. $scope.buildingXYAxisList = [];
  4. $scope.searchInput = "";
  5. $scope.nowPositionStyle = { "left": "0", "top": "0", "width": "0", "height": "0" };
  6. $scope.coordinateStyle = { "left": "0", "top": "0" };
  7. $scope.modalStyle = { "left": "0", "top": "0" };
  8. $scope.isShowMark = false;
  9. $scope.isShowNowModal = false;
  10. $scope.showModalType = 1;
  11. $scope.nowBuilding = {};
  12. $scope.allFloorList = [];
  13. $scope.allRoomList = [];
  14. $scope.floorList = [];
  15. $scope.roomList = [];
  16. $scope.roomModel = [];
  17. $("#mapimg").css("height", $(window).height());
  18. $scope.mapImgClick = function (e) {
  19. $scope.isShowMark = false;
  20. $scope.isShowNowModal = false;
  21. var buildingList = $scope.buildingXYAxisList.filter(x => e.offsetX >= x.MinXAxis && e.offsetX <= x.MaxXAxis && e.offsetY >= x.MinYAxis && e.offsetY <= x.MaxYAxis);
  22. if (buildingList.length > 0) {
  23. $scope.goBuilding(buildingList[0]);
  24. }
  25. };
  26. $scope.searchBuilding = function () {
  27. $scope.isShowMark = false;
  28. $scope.isShowNowModal = false;
  29. if ($scope.searchInput) {
  30. var buildingList = $scope.buildingXYAxisList.filter(x => x.BuildingName.indexOf($scope.searchInput) >= 0);
  31. if (buildingList.length > 0) {
  32. $scope.goBuilding(buildingList[0]);
  33. return;
  34. }
  35. var searchRoomList = $scope.allRoomList.filter(x => x.DepartmentOrServiceName.indexOf($scope.searchInput) >= 0);
  36. if (searchRoomList.length > 0) {
  37. buildingList = $scope.buildingXYAxisList.filter(x => x.BuildingId == searchRoomList[0].BuildingId);
  38. if (buildingList.length > 0) {
  39. $scope.goBuilding(buildingList[0]);
  40. return;
  41. }
  42. }
  43. }
  44. };
  45. $scope.goBuilding = function (building) {
  46. $scope.nowBuilding = building;
  47. var img = $("#mapimg")[0];
  48. $scope.nowPositionStyle.left = (img.offsetLeft + building.MinXAxis) + "px";
  49. $scope.nowPositionStyle.top = (img.offsetTop + building.MinYAxis) + "px";
  50. $scope.nowPositionStyle.width = (building.MaxXAxis - building.MinXAxis) + "px";
  51. $scope.nowPositionStyle.height = (building.MaxYAxis - building.MinYAxis) + "px";
  52. $scope.coordinateStyle.left = (img.offsetLeft + building.XCenter - 22) + "px";
  53. $scope.coordinateStyle.top = (img.offsetTop + building.YCenter - 73) + "px";
  54. $scope.modalStyle.left = (img.offsetLeft + building.MaxXAxis) + "px";
  55. $scope.modalStyle.top = (img.offsetTop + building.MinYAxis) > 400 ? (img.offsetTop + building.MinYAxis - 420) : 20 + "px";
  56. $scope.isShowMark = true;
  57. $scope.isShowNowModal = true;
  58. $scope.showModalType = 1;
  59. $(".card-content").scrollTop(0);
  60. $scope.floorList = $scope.allFloorList.filter(e => e.BuildingId == $scope.nowBuilding.BuildingId);
  61. $scope.floorList.forEach((f, i) => {
  62. f.checked = i == 0;
  63. });
  64. $scope.roomList = $scope.allRoomList.filter(e => e.BuildingId == $scope.nowBuilding.BuildingId);
  65. }
  66. $scope.floorClick = function (clickData) {
  67. var totalRoom = 0;
  68. var index = $scope.floorList.indexOf(clickData);
  69. $scope.floorList.forEach((f, i) => {
  70. f.checked = clickData.Name == f.Name;
  71. if (i < index) {
  72. totalRoom += $scope.roomList.filter(e => e.FloorName == f.Name).length;
  73. }
  74. });
  75. $(".card-content").scrollTop(index == 0 ? 0 : totalRoom * 40);
  76. };
  77. // 定义滚动事件的处理函数
  78. var scrollHandler = function () {
  79. var scrollTop = $("#card-content").scrollTop();
  80. var nowIndex = parseInt(scrollTop / 40);
  81. if (nowIndex < $scope.roomList.length) {
  82. var room = $scope.roomList[nowIndex];
  83. if (room) {
  84. $scope.floorList.forEach((f, i) => {
  85. f.checked = room.FloorName == f.Name;
  86. });
  87. }
  88. }
  89. $scope.$apply();
  90. };
  91. angular.element($("#card-content")).on('scroll', scrollHandler);
  92. $scope.showModal = function () {
  93. $scope.isShowNowModal = true;
  94. $scope.showModalType = 1;
  95. };
  96. $scope.showRoom = function (room) {
  97. $scope.roomModel = room;
  98. $scope.showModalType = 2;
  99. };
  100. $scope.coloseRoom = function () {
  101. $scope.showModalType = 1;
  102. };
  103. //加载列表数据
  104. $scope.getBuildingXYAxisList = function () {
  105. $http
  106. ({
  107. method: 'get', url: '../../api/build/building/GetBuildingXyAxisGroupList', params: {}
  108. }).then(function (result) {
  109. $scope.buildingXYAxisList = result.data.Data;
  110. }, function (resp) {
  111. });
  112. };
  113. $scope.getFloorList = function () {
  114. $http({
  115. method: "get",
  116. url: "../../api/build/building/GetFloorList",
  117. params: {
  118. }
  119. }).then(function (result) {
  120. $scope.allFloorList = result.data.Data;
  121. }, function (resp) {
  122. });
  123. };
  124. $scope.getRoomDepOrServiceList = function () {
  125. $http({
  126. method: "get",
  127. url: "../../api/build/room/GetRoomDepOrServiceList",
  128. params: {
  129. }
  130. }).then(function (result) {
  131. $scope.allRoomList = result.data.Data;
  132. }, function (resp) {
  133. });
  134. };
  135. $scope.getBuildingXYAxisList();
  136. $scope.getFloorList();
  137. $scope.getRoomDepOrServiceList();
  138. });
  139. })(angular);