edit.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. var editRoomCtrl = function ($scope, $http, $filter, $loading) {
  2. $scope.params = editRoomModal.params;
  3. $scope.parentLoad = editRoomModal.parentLoad;
  4. $scope.dataModel = { BuildingId:null};
  5. $scope.buildingList = [];
  6. $scope.floorList = [];
  7. $scope.loadData = function () {
  8. $loading.show();
  9. $http({
  10. method: "get",
  11. url: "../../api/build/room/GetRoomById",
  12. params: {
  13. roomId: $scope.params.roomId
  14. }
  15. }).then(function (result) {
  16. $loading.hide();
  17. $scope.dataModel = result.data.Data;
  18. $scope.getBuildingList();
  19. $scope.getFloorList();
  20. }, function (resp) {
  21. $loading.hide();
  22. $scope.showMsg('错误', '服务器错误');
  23. });
  24. }
  25. $scope.getBuildingList = function () {
  26. $http({
  27. method: "get",
  28. url: "../../api/build/building/GetBuildingList",
  29. params: {
  30. }
  31. }).then(function (result) {
  32. $scope.buildingList = result.data.Data;
  33. }, function (resp) {
  34. });
  35. };
  36. $scope.getFloorList = function () {
  37. if ($scope.dataModel.BuildingId) {
  38. $http({
  39. method: "get",
  40. url: "../../api/build/building/GetFloorList",
  41. params: {
  42. buildingId: $scope.dataModel.BuildingId
  43. }
  44. }).then(function (result) {
  45. $scope.floorList = result.data.Data;
  46. }, function (resp) {
  47. });
  48. }
  49. else {
  50. $scope.floorList = [];
  51. }
  52. };
  53. $scope.save = function (isflag) {
  54. if (!isflag) {
  55. $scope.showMsg('提示', '请填写相关信息');
  56. return false;
  57. }
  58. if (isflag) {
  59. $loading.show();
  60. $http({
  61. method: "post",
  62. url: "../../api/build/room/Save",
  63. data: {
  64. data: $scope.dataModel
  65. }
  66. }).then(function (result) {
  67. $loading.hide();
  68. if (result.data.IsSuccess) {
  69. $scope.showMsg('成功', "操作成功!");
  70. $scope.parentLoad();
  71. $scope.$hide();
  72. } else {
  73. $scope.showMsg('失败', result.data.Message);
  74. }
  75. }, function (resp) {
  76. $loading.hide();
  77. $scope.showMsg('错误', '服务器错误,' + resp.data.message);
  78. })
  79. }
  80. };
  81. $scope.loadData();
  82. };
  83. //定义模态框
  84. var editRoomModal;