map-index.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. }
  34. }
  35. };
  36. $scope.goBuilding = function (building) {
  37. $scope.nowBuilding = building;
  38. var img = $("#mapimg")[0];
  39. $scope.nowPositionStyle.left = (img.offsetLeft + building.MinXAxis) + "px";
  40. $scope.nowPositionStyle.top = (img.offsetTop + building.MinYAxis) + "px";
  41. $scope.nowPositionStyle.width = (building.MaxXAxis - building.MinXAxis) + "px";
  42. $scope.nowPositionStyle.height = (building.MaxYAxis - building.MinYAxis) + "px";
  43. $scope.coordinateStyle.left = (img.offsetLeft + building.XCenter - 22) + "px";
  44. $scope.coordinateStyle.top = (img.offsetTop + building.YCenter - 73) + "px";
  45. $scope.modalStyle.left = (img.offsetLeft + building.MaxXAxis) + "px";
  46. $scope.modalStyle.top = (img.offsetTop + building.MinYAxis) > 400 ? (img.offsetTop + building.MinYAxis - 420) : 20 + "px";
  47. $scope.isShowMark = true;
  48. $scope.isShowNowModal = true;
  49. $scope.showModalType = 1;
  50. $(".card-content").scrollTop(0);
  51. $scope.floorList = $scope.allFloorList.filter(e => e.BuildingId == $scope.nowBuilding.BuildingId);
  52. $scope.floorList.forEach((f, i) => {
  53. f.checked = i == 0;
  54. });
  55. $scope.roomList = $scope.allRoomList.filter(e => e.BuildingId == $scope.nowBuilding.BuildingId);
  56. }
  57. $scope.floorClick = function (clickData) {
  58. var totalRoom = 0;
  59. var index = $scope.floorList.indexOf(clickData);
  60. $scope.floorList.forEach((f, i) => {
  61. f.checked = clickData.Name == f.Name;
  62. if (i < index) {
  63. totalRoom += $scope.roomList.filter(e => e.FloorName == f.Name).length;
  64. }
  65. });
  66. $(".card-content").scrollTop(index == 0 ? 0 : totalRoom * 40);
  67. };
  68. // 定义滚动事件的处理函数
  69. var scrollHandler = function () {
  70. var scrollTop = $("#card-content").scrollTop();
  71. var nowIndex = parseInt(scrollTop / 40);
  72. if (nowIndex < $scope.roomList.length) {
  73. var room = $scope.roomList[nowIndex];
  74. if (room) {
  75. $scope.floorList.forEach((f, i) => {
  76. f.checked = room.FloorName == f.Name;
  77. });
  78. }
  79. }
  80. $scope.$apply();
  81. };
  82. angular.element($("#card-content")).on('scroll', scrollHandler);
  83. $scope.showModal = function () {
  84. $scope.isShowNowModal = true;
  85. $scope.showModalType = 1;
  86. };
  87. $scope.showRoom = function (room) {
  88. $scope.roomModel = room;
  89. $scope.showModalType = 2;
  90. };
  91. $scope.coloseRoom = function () {
  92. $scope.showModalType = 1;
  93. };
  94. //加载列表数据
  95. $scope.getBuildingXYAxisList = function () {
  96. $http
  97. ({
  98. method: 'get', url: '../../api/build/building/GetBuildingXyAxisGroupList', params: {}
  99. }).then(function (result) {
  100. $scope.buildingXYAxisList = result.data.Data;
  101. }, function (resp) {
  102. });
  103. };
  104. $scope.getFloorList = function () {
  105. $http({
  106. method: "get",
  107. url: "../../api/build/building/GetFloorList",
  108. params: {
  109. }
  110. }).then(function (result) {
  111. $scope.allFloorList = result.data.Data;
  112. }, function (resp) {
  113. });
  114. };
  115. $scope.getRoomDepOrServiceList = function () {
  116. $http({
  117. method: "get",
  118. url: "../../api/build/room/GetRoomDepOrServiceList",
  119. params: {
  120. }
  121. }).then(function (result) {
  122. $scope.allRoomList = result.data.Data;
  123. }, function (resp) {
  124. });
  125. };
  126. $scope.getBuildingXYAxisList();
  127. $scope.getFloorList();
  128. $scope.getRoomDepOrServiceList();
  129. });
  130. })(angular);