selectRoom.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. var selectRoomCtrl = function ($scope, $http, AuthUser, flowaudit, $loading, $uuid, $modal) {
  2. $scope.params = selectRoomModal.params;
  3. $scope.selectRoomBack = selectRoomModal.selectRoomBack;
  4. $scope.isShow = true;
  5. $scope.dataList = [];
  6. $scope.selectList = [];
  7. $scope.buildingList = [];
  8. $scope.floorList = [];
  9. $scope.pageInfo = { ptotal: 0 };
  10. //查询参数
  11. $scope.selectparams = {
  12. name: null,
  13. buildingId: null,
  14. floorId: null,
  15. pageIndex: 1,
  16. pageSize: 10,
  17. };
  18. $scope.search = function () {
  19. $scope.getRoomList();
  20. };
  21. $scope.getRoomList = function () {
  22. $loading.show();
  23. $http
  24. ({
  25. method: 'get', url: '../../api/build/room/GetRoomList', params: $scope.selectparams
  26. }).then(function (result) {
  27. $loading.hide();
  28. $scope.dataList = result.data.Data.rows;
  29. $scope.pageInfo.ptotal = result.data.Data.total;
  30. }, function (resp) {
  31. $loading.hide();
  32. $scope.showMsg('错误', '服务器错误');
  33. });
  34. };
  35. $scope.save = function () {
  36. if ($scope.selectList.length == 0) {
  37. $scope.showMsg('提示', '请选择需要添加的房间!');
  38. return false;
  39. }
  40. $scope.selectRoomBack($scope.selectList);
  41. $scope.$hide();
  42. };
  43. $scope.select = function () {
  44. var checkList = $scope.dataList.filter(e => e.rowChecked == true);
  45. if (checkList.length <= 0) {
  46. $scope.showMsg('提示', '请选择需要添加的房间!');
  47. return false;
  48. }
  49. var copyDataList = [];
  50. angular.copy(checkList, copyDataList);
  51. copyDataList.forEach(item => {
  52. item.rowChecked = false;
  53. if ($scope.selectList.filter(e => e.BuildingFloorRoomId == item.BuildingFloorRoomId).length == 0)
  54. $scope.selectList.push(item);
  55. });
  56. };
  57. $scope.remove = function (index) {
  58. if (index != null)
  59. $scope.selectList.splice(index, 1);
  60. else
  61. $scope.selectList.forEach(item => {
  62. if (item.rowChecked == true)
  63. $scope.selectList = $scope.selectList.filter(e => e.BuildingFloorRoomId != item.BuildingFloorRoomId);
  64. });
  65. };
  66. $scope.getBuildingList = function () {
  67. $http({
  68. method: "get",
  69. url: "../../api/build/building/GetBuildingList",
  70. params: {
  71. }
  72. }).then(function (result) {
  73. $scope.buildingList = result.data.Data;
  74. }, function (resp) {
  75. });
  76. };
  77. $scope.getFloorList = function () {
  78. if ($scope.selectparams.buildingId) {
  79. $http({
  80. method: "get",
  81. url: "../../api/build/building/GetFloorList",
  82. params: {
  83. buildingId: $scope.selectparams.buildingId
  84. }
  85. }).then(function (result) {
  86. $scope.floorList = result.data.Data;
  87. }, function (resp) {
  88. });
  89. }
  90. else {
  91. $scope.floorList = [];
  92. }
  93. };
  94. $scope.getBuildingList();
  95. };
  96. var selectRoomModal;