(function ($app) { $app.module('ylmis').controller('buildingListCtrl', function ($scope, $http, $filter, $modal, $ocLazyLoad, $alert, $loading, $state, excelPopup, $bsRouterState, popupReport) { $state.params = $bsRouterState.$params($scope); $scope.isShow = false; $scope.dataList = []; //初始化查询参数 $scope.selectparams = { name: null, pageIndex: 1, pageSize: 50, }; //查询 $scope.search = function () { $scope.loadData(); }; //加载列表数据 $scope.loadData = function () { $loading.show(); $http ({ method: 'get', url: '../../api/build/building/GetBuildingList', params: $scope.selectparams }).then(function (result) { $loading.hide(); $scope.dataList = result.data.Data; }, function (resp) { $loading.hide(); $scope.showMsg('错误', '服务器错误'); }); }; $scope.add = function () { $scope.editBuilding(null, '新增大楼信息'); }; $scope.edit = function (Id) { $scope.editBuilding(Id, '修改大楼信息'); }; $scope.editBuilding = function (id, title) { editBuildingModal.params = { buildingId: id, title: title, }; editBuildingModal.parentLoad = $scope.loadData; editBuildingModal.$promise.then(editBuildingModal.show); }; editBuildingCtrl.$inject = ['$scope', '$http', '$filter', '$loading']; editBuildingModal = $modal({ resolve: { load: ['$ocLazyLoad', function ($ocLazyLoad) { }] }, scope: $scope, controller: editBuildingCtrl, templateUrl: '../main/building/edit.html', show: false, animation: 'am-fade-and-slide-top' }); $scope.delete = function (id) { var ids = $.map($filter('filter')($scope.dataList, { rowChecked: true }), function (x) { return x.BuildingId; });; if (ids.length < 1) { $scope.showMsg('提示', '请选择要删除的信息。'); return false; } if (confirm("确认删除?")) { $http.post('../../api/build/building/DeleteBuilding', { buildingIds: ids }).then(function (res) { if (res.data.IsSuccess) { $scope.loadData(); $scope.showMsg('成功', '删除成功'); } else { $scope.showMsg('错误', res.data.Message); } }); } }; $scope.loadData(); }); })(angular);