map-index.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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.isShowNow = false;
  9. $scope.nowBuilding = {};
  10. $scope.floorList = [{ FloorName: "一楼", checked: true }, { FloorName: "二楼", checked: false }, { FloorName: "三楼", checked: false }, { FloorName: "四楼", checked: false }, { FloorName: "五楼", checked: false }];
  11. $scope.roomList = [{ FloorName: "一楼", RoomName: "101" }, { FloorName: "一楼", RoomName: "102" }, { FloorName: "一楼", RoomName: "103" }, { FloorName: "一楼", RoomName: "104" }, { FloorName: "一楼", RoomName: "105" },
  12. { FloorName: "二楼", RoomName: "201" }, { FloorName: "二楼", RoomName: "202" }, { FloorName: "二楼", RoomName: "203" }, { FloorName: "二楼", RoomName: "204" }, { FloorName: "二楼", RoomName: "205" },
  13. { FloorName: "三楼", RoomName: "301" }, { FloorName: "三楼", RoomName: "302" }, { FloorName: "三楼", RoomName: "303" }, { FloorName: "三楼", RoomName: "304" }, { FloorName: "三楼", RoomName: "305" },
  14. { FloorName: "四楼", RoomName: "401" }, { FloorName: "四楼", RoomName: "402" }, { FloorName: "四楼", RoomName: "403" }, { FloorName: "四楼", RoomName: "404" }, { FloorName: "四楼", RoomName: "405" },
  15. { FloorName: "五楼", RoomName: "501" }, { FloorName: "五楼", RoomName: "502" }, { FloorName: "五楼", RoomName: "503" }, { FloorName: "五楼", RoomName: "504" }, { FloorName: "五楼", RoomName: "505" }];
  16. $("#mapimg").css("height", $(window).height());
  17. $scope.mapImgClick = function (e) {
  18. $scope.isShowNow = false;
  19. var buildingList = $scope.buildingXYAxisList.filter(x => e.offsetX >= x.MinXAxis && e.offsetX <= x.MaxXAxis && e.offsetY >= x.MinYAxis && e.offsetY <= x.MaxYAxis);
  20. if (buildingList.length > 0) {
  21. $scope.goBuilding(buildingList[0]);
  22. }
  23. };
  24. $scope.searchBuilding = function () {
  25. $scope.isShowNow = false;
  26. var buildingList = $scope.buildingXYAxisList.filter(x => x.BuildingName.indexOf($scope.searchInput) >= 0);
  27. if (buildingList.length > 0) {
  28. $scope.goBuilding(buildingList[0]);
  29. }
  30. };
  31. $scope.goBuilding = function (building) {
  32. $scope.nowBuilding = building;
  33. var img = $("#mapimg")[0];
  34. $scope.nowPositionStyle.left = (img.offsetLeft + building.MinXAxis) + "px";
  35. $scope.nowPositionStyle.top = (img.offsetTop + building.MinYAxis) + "px";
  36. $scope.nowPositionStyle.width = (building.MaxXAxis - building.MinXAxis) + "px";
  37. $scope.nowPositionStyle.height = (building.MaxYAxis - building.MinYAxis) + "px";
  38. $scope.coordinateStyle.left = (img.offsetLeft + building.XCenter - 22) + "px";
  39. $scope.coordinateStyle.top = (img.offsetTop + building.YCenter - 73) + "px";
  40. $scope.modalStyle.left = (img.offsetLeft + building.MaxXAxis) + "px";
  41. $scope.modalStyle.top = (img.offsetTop + building.MinYAxis) > 400 ? (img.offsetTop + building.MinYAxis - 420) : 20 + "px";
  42. $scope.isShowNow = true;
  43. $(".card-content").scrollTop(0);
  44. }
  45. $scope.floorClick = function (clickData) {
  46. var totalRoom = 0;
  47. var index = $scope.floorList.indexOf(clickData);
  48. $scope.floorList.forEach((f, i) => {
  49. f.checked = clickData.FloorName == f.FloorName;
  50. if (i <= index) {
  51. totalRoom += $scope.roomList.filter(e => e.FloorName == f.FloorName).length;
  52. }
  53. });
  54. $(".card-content").scrollTop(index == 0 ? 0 : totalRoom * 30);
  55. };
  56. /*$(document).ready(function () {
  57. $('#card-content').scroll(function () {
  58. var scrollTop = $("#card-content").scrollTop();
  59. var nowIndex = parseInt(scrollTop / 30);
  60. console.log(nowIndex);
  61. if (nowIndex < $scope.roomList.length) {
  62. var room = $scope.roomList[nowIndex];
  63. console.log(room);
  64. if (room) {
  65. $scope.floorList.forEach((f, i) => {
  66. f.checked = room.FloorName == f.FloorName;
  67. });
  68. }
  69. }
  70. });
  71. });*/
  72. // 定义滚动事件的处理函数
  73. var scrollHandler = function () {
  74. var scrollTop = $("#card-content").scrollTop();
  75. var nowIndex = parseInt(scrollTop / 30);
  76. if (nowIndex < $scope.roomList.length) {
  77. var room = $scope.roomList[nowIndex];
  78. if (room) {
  79. $scope.floorList.forEach((f, i) => {
  80. f.checked = room.FloorName == f.FloorName;
  81. });
  82. }
  83. }
  84. console.log($scope.floorList);
  85. };
  86. angular.element($("#card-content")).on('scroll', scrollHandler);
  87. //加载列表数据
  88. $scope.getBuildingXYAxisList = function () {
  89. $http
  90. ({
  91. method: 'get', url: '../../api/build/building/GetBuildingXyAxisGroupList', params: {}
  92. }).then(function (result) {
  93. $scope.buildingXYAxisList = result.data.Data;
  94. }, function (resp) {
  95. });
  96. };
  97. $scope.getBuildingXYAxisList();
  98. });
  99. })(angular);