var editDepOrServiceCtrl = function ($scope, $http, $filter, $loading, $modal) { $scope.params = editDepOrServiceModal.params; $scope.parentLoad = editDepOrServiceModal.parentLoad; $scope.dataModel = { BuildingId: null }; $scope.roomList = []; $scope.imgConfig = null; $scope.loadData = function () { $loading.show(); $http({ method: "get", url: "../../api/build/DepOrService/GetDepOrServicePointById", params: { depOrServicePointId: $scope.params.depOrServicePointId } }).then(function (result) { $loading.hide(); $scope.dataModel = result.data.Data; $scope.getRoomList(); $scope.setFileModel(); }, function (resp) { $loading.hide(); $scope.showMsg('错误', '服务器错误'); }); } $scope.save = function (isflag) { if (!isflag) { $scope.showMsg('提示', '请填写相关信息'); return false; } if (isflag) { var roomIds = $.map($filter('filter')($scope.roomList, { }), function (x) { return x.BuildingFloorRoomId; }); $loading.show(); $http({ method: "post", url: "../../api/build/DepOrService/Save", data: { data: $scope.dataModel, roomIdList: roomIds } }).then(function (result) { $loading.hide(); if (result.data.IsSuccess) { $scope.showMsg('成功', "操作成功!"); $scope.parentLoad(); $scope.$hide(); } else { $scope.showMsg('失败', result.data.Message); } }, function (resp) { $loading.hide(); $scope.showMsg('错误', '服务器错误,' + resp.data.message); }) } }; $scope.selectRoomBack = function (selectList) { selectList.forEach(room => { if ($scope.roomList.filter(e => e.BuildingFloorRoomId == room.BuildingFloorRoomId).length == 0) { $scope.roomList.push(room); } }); }; $scope.selectRoom = function () { selectRoomCtrl.$inject = ['$scope', '$http', 'AuthUser', 'flowaudit', '$loading', '$uuid']; selectRoomModal = $modal({ resolve: { load: ['$ocLazyLoad', function ($ocLazyLoad) { }] }, scope: $scope, controller: selectRoomCtrl, templateUrl: '../main/depOrService/selectRoom.html', show: false, animation: 'am-fade-and-slide-top' }); selectRoomModal.params = { }; selectRoomModal.selectRoomBack = $scope.selectRoomBack; selectRoomModal.$promise.then(selectRoomModal.show); }; $scope.deleteRoom = function (index) { $scope.roomList.splice(index, 1); }; $scope.setFileModel = function () { $scope.imgConfig = { filerefid: $scope.dataModel.DepartmentOrServicePointId || undefined, filetypeid: 1, readonly: false, ismulti: false, imgList: [] }; }; $scope.getRoomList = function () { $http({ method: "get", url: "../../api/build/DepOrService/GetRoomList", params: { depOrServicePointId: $scope.dataModel.DepartmentOrServicePointId } }).then(function (result) { $scope.roomList = result.data.Data; }, function (resp) { }); }; $scope.loadData(); }; //定义模态框 var editDepOrServiceModal;