list.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. (function ($app) {
  2. $app.module('ylmis').controller('buildingListCtrl', function ($scope, $http, $filter, $modal, $ocLazyLoad, $alert, $loading, $state, excelPopup, $bsRouterState, popupReport) {
  3. $state.params = $bsRouterState.$params($scope);
  4. $scope.isShow = false;
  5. $scope.dataList = [];
  6. //初始化查询参数
  7. $scope.selectparams = {
  8. name: null,
  9. pageIndex: 1,
  10. pageSize: 50,
  11. };
  12. //查询
  13. $scope.search = function () {
  14. $scope.loadData();
  15. };
  16. //加载列表数据
  17. $scope.loadData = function () {
  18. $loading.show();
  19. $http
  20. ({
  21. method: 'get', url: '../../api/build/building/GetBuildingList', params: $scope.selectparams
  22. }).then(function (result) {
  23. $loading.hide();
  24. $scope.dataList = result.data.Data;
  25. }, function (resp) {
  26. $loading.hide();
  27. $scope.showMsg('错误', '服务器错误');
  28. });
  29. };
  30. $scope.add = function () {
  31. $scope.editBuilding(null, '新增大楼信息');
  32. };
  33. $scope.edit = function (Id) {
  34. $scope.editBuilding(Id, '修改大楼信息');
  35. };
  36. $scope.editBuilding = function (id, title) {
  37. editBuildingModal.params = {
  38. buildingId: id,
  39. title: title,
  40. };
  41. editBuildingModal.parentLoad = $scope.loadData;
  42. editBuildingModal.$promise.then(editBuildingModal.show);
  43. };
  44. editBuildingCtrl.$inject = ['$scope', '$http', '$filter', '$loading'];
  45. editBuildingModal = $modal({
  46. resolve: {
  47. load: ['$ocLazyLoad', function ($ocLazyLoad) {
  48. }]
  49. },
  50. scope: $scope,
  51. controller: editBuildingCtrl,
  52. templateUrl: '../main/building/edit.html',
  53. show: false,
  54. animation: 'am-fade-and-slide-top'
  55. });
  56. $scope.delete = function (id) {
  57. var ids = $.map($filter('filter')($scope.dataList, { rowChecked: true }), function (x) { return x.BuildingId; });;
  58. if (ids.length < 1) {
  59. $scope.showMsg('提示', '请选择要删除的信息。');
  60. return false;
  61. }
  62. if (confirm("确认删除?")) {
  63. $http.post('../../api/build/building/DeleteBuilding', { buildingIds: ids }).then(function (res) {
  64. if (res.data.IsSuccess) {
  65. $scope.loadData();
  66. $scope.showMsg('成功', '删除成功');
  67. } else {
  68. $scope.showMsg('错误', res.data.Message);
  69. }
  70. });
  71. }
  72. };
  73. $scope.loadData();
  74. });
  75. })(angular);