(function ($app) { $app.module('ylmis').controller('depOrServiceCtrl', function ($scope, $http, $filter, $modal, $ocLazyLoad, $alert, $loading, $state, excelPopup, $bsRouterState, popupReport) { $state.params = $bsRouterState.$params($scope); $scope.isShow = false; $scope.dataList = []; $scope.buildingList = []; $scope.floorList = []; //初始化查询参数 $scope.selectparams = { name: null, buildingId: null, floorId: null, pageIndex: 1, pageSize: 30, }; $scope.pageInfo = { ptotal: 0 }; //查询 $scope.search = function () { $scope.loadData(); }; //加载列表数据 $scope.loadData = function () { $loading.show(); $http ({ method: 'get', url: '../../api/build/DepOrService/GetDepOrServicePointList', params: $scope.selectparams }).then(function (result) { $loading.hide(); $scope.dataList = result.data.Data.rows; $scope.pageInfo.ptotal = result.data.Data.total; }, function (resp) { $loading.hide(); $scope.showMsg('错误', '服务器错误'); }); }; $scope.add = function () { $scope.editDepOrService(null, '新增服务点信息'); }; $scope.edit = function (Id) { $scope.editDepOrService(Id, '修改服务点信息'); }; $scope.editDepOrService = function (id, title) { editDepOrServiceModal.params = { depOrServicePointId: id, title: title, }; editDepOrServiceModal.parentLoad = $scope.loadData; editDepOrServiceModal.$promise.then(editDepOrServiceModal.show); }; editDepOrServiceCtrl.$inject = ['$scope', '$http', '$filter', '$loading','$modal']; editDepOrServiceModal = $modal({ resolve: { load: ['$ocLazyLoad', function ($ocLazyLoad) { }] }, scope: $scope, controller: editDepOrServiceCtrl, templateUrl: '../main/depOrService/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.DepartmentOrServicePointId; });; if (ids.length < 1) { $scope.showMsg('提示', '请选择要删除的信息。'); return false; } if (confirm("确认删除?")) { $http.post('../../api/build/DepOrService/Delete', { depOrServicePointIdList: ids }).then(function (res) { if (res.data.IsSuccess) { $scope.loadData(); $scope.showMsg('成功', '删除成功'); } else { $scope.showMsg('错误', res.data.Message); } }); } }; $scope.getBuildingList = function () { $http({ method: "get", url: "../../api/build/building/GetBuildingList", params: { } }).then(function (result) { $scope.buildingList = result.data.Data; }, function (resp) { }); }; $scope.getFloorList = function () { if ($scope.selectparams.buildingId) { $http({ method: "get", url: "../../api/build/building/GetFloorList", params: { buildingId: $scope.selectparams.buildingId } }).then(function (result) { $scope.floorList = result.data.Data; }, function (resp) { }); } else { $scope.floorList = []; } }; $scope.getBuildingList(); }); })(angular);