edit.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. var editDepOrServiceCtrl = function ($scope, $http, $filter, $loading, $modal) {
  2. $scope.params = editDepOrServiceModal.params;
  3. $scope.parentLoad = editDepOrServiceModal.parentLoad;
  4. $scope.dataModel = { BuildingId: null };
  5. $scope.roomList = [];
  6. $scope.imgConfig = null;
  7. $scope.loadData = function () {
  8. $loading.show();
  9. $http({
  10. method: "get",
  11. url: "../../api/build/DepOrService/GetDepOrServicePointById",
  12. params: {
  13. depOrServicePointId: $scope.params.depOrServicePointId
  14. }
  15. }).then(function (result) {
  16. $loading.hide();
  17. $scope.dataModel = result.data.Data;
  18. $scope.getRoomList();
  19. $scope.setFileModel();
  20. }, function (resp) {
  21. $loading.hide();
  22. $scope.showMsg('错误', '服务器错误');
  23. });
  24. }
  25. $scope.save = function (isflag) {
  26. if (!isflag) {
  27. $scope.showMsg('提示', '请填写相关信息');
  28. return false;
  29. }
  30. if (isflag) {
  31. var roomIds = $.map($filter('filter')($scope.roomList, { }), function (x) { return x.BuildingFloorRoomId; });
  32. $loading.show();
  33. $http({
  34. method: "post",
  35. url: "../../api/build/DepOrService/Save",
  36. data: {
  37. data: $scope.dataModel,
  38. roomIdList: roomIds
  39. }
  40. }).then(function (result) {
  41. $loading.hide();
  42. if (result.data.IsSuccess) {
  43. $scope.showMsg('成功', "操作成功!");
  44. $scope.parentLoad();
  45. $scope.$hide();
  46. } else {
  47. $scope.showMsg('失败', result.data.Message);
  48. }
  49. }, function (resp) {
  50. $loading.hide();
  51. $scope.showMsg('错误', '服务器错误,' + resp.data.message);
  52. })
  53. }
  54. };
  55. $scope.selectRoomBack = function (selectList) {
  56. selectList.forEach(room => {
  57. if ($scope.roomList.filter(e => e.BuildingFloorRoomId == room.BuildingFloorRoomId).length == 0) {
  58. $scope.roomList.push(room);
  59. }
  60. });
  61. };
  62. $scope.selectRoom = function () {
  63. selectRoomCtrl.$inject = ['$scope', '$http', 'AuthUser', 'flowaudit', '$loading', '$uuid'];
  64. selectRoomModal = $modal({
  65. resolve: {
  66. load: ['$ocLazyLoad', function ($ocLazyLoad) {
  67. }]
  68. },
  69. scope: $scope,
  70. controller: selectRoomCtrl,
  71. templateUrl: '../main/depOrService/selectRoom.html',
  72. show: false,
  73. animation: 'am-fade-and-slide-top'
  74. });
  75. selectRoomModal.params = {
  76. };
  77. selectRoomModal.selectRoomBack = $scope.selectRoomBack;
  78. selectRoomModal.$promise.then(selectRoomModal.show);
  79. };
  80. $scope.deleteRoom = function (index) {
  81. $scope.roomList.splice(index, 1);
  82. };
  83. $scope.setFileModel = function () {
  84. $scope.imgConfig = {
  85. filerefid: $scope.dataModel.DepartmentOrServicePointId || undefined,
  86. filetypeid: 1,
  87. readonly: false,
  88. ismulti: false,
  89. imgList: []
  90. };
  91. };
  92. $scope.getRoomList = function () {
  93. $http({
  94. method: "get",
  95. url: "../../api/build/DepOrService/GetRoomList",
  96. params: {
  97. depOrServicePointId: $scope.dataModel.DepartmentOrServicePointId
  98. }
  99. }).then(function (result) {
  100. $scope.roomList = result.data.Data;
  101. }, function (resp) {
  102. });
  103. };
  104. $scope.loadData();
  105. };
  106. //定义模态框
  107. var editDepOrServiceModal;