list.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. (function ($app) {
  2. $app.module('ylmis').controller('depOrServiceCtrl', 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. $scope.buildingList = [];
  7. $scope.floorList = [];
  8. //初始化查询参数
  9. $scope.selectparams = {
  10. name: null,
  11. buildingId: null,
  12. floorId: null,
  13. pageIndex: 1,
  14. pageSize: 30,
  15. };
  16. $scope.pageInfo = { ptotal: 0 };
  17. //查询
  18. $scope.search = function () {
  19. $scope.loadData();
  20. };
  21. //加载列表数据
  22. $scope.loadData = function () {
  23. $loading.show();
  24. $http
  25. ({
  26. method: 'get', url: '../../api/build/DepOrService/GetDepOrServicePointList', params: $scope.selectparams
  27. }).then(function (result) {
  28. $loading.hide();
  29. $scope.dataList = result.data.Data.rows;
  30. $scope.pageInfo.ptotal = result.data.Data.total;
  31. }, function (resp) {
  32. $loading.hide();
  33. $scope.showMsg('错误', '服务器错误');
  34. });
  35. };
  36. $scope.add = function () {
  37. $scope.editDepOrService(null, '新增服务点信息');
  38. };
  39. $scope.edit = function (Id) {
  40. $scope.editDepOrService(Id, '修改服务点信息');
  41. };
  42. $scope.editDepOrService = function (id, title) {
  43. editDepOrServiceModal.params = {
  44. depOrServicePointId: id,
  45. title: title,
  46. };
  47. editDepOrServiceModal.parentLoad = $scope.loadData;
  48. editDepOrServiceModal.$promise.then(editDepOrServiceModal.show);
  49. };
  50. editDepOrServiceCtrl.$inject = ['$scope', '$http', '$filter', '$loading','$modal'];
  51. editDepOrServiceModal = $modal({
  52. resolve: {
  53. load: ['$ocLazyLoad', function ($ocLazyLoad) {
  54. }]
  55. },
  56. scope: $scope,
  57. controller: editDepOrServiceCtrl,
  58. templateUrl: '../main/depOrService/edit.html',
  59. show: false,
  60. animation: 'am-fade-and-slide-top'
  61. });
  62. $scope.delete = function (id) {
  63. var ids = $.map($filter('filter')($scope.dataList, { rowChecked: true }), function (x) { return x.DepartmentOrServicePointId; });;
  64. if (ids.length < 1) {
  65. $scope.showMsg('提示', '请选择要删除的信息。');
  66. return false;
  67. }
  68. if (confirm("确认删除?")) {
  69. $http.post('../../api/build/DepOrService/Delete', { depOrServicePointIdList: ids }).then(function (res) {
  70. if (res.data.IsSuccess) {
  71. $scope.loadData();
  72. $scope.showMsg('成功', '删除成功');
  73. } else {
  74. $scope.showMsg('错误', res.data.Message);
  75. }
  76. });
  77. }
  78. };
  79. $scope.getBuildingList = function () {
  80. $http({
  81. method: "get",
  82. url: "../../api/build/building/GetBuildingList",
  83. params: {
  84. }
  85. }).then(function (result) {
  86. $scope.buildingList = result.data.Data;
  87. }, function (resp) {
  88. });
  89. };
  90. $scope.getFloorList = function () {
  91. if ($scope.selectparams.buildingId) {
  92. $http({
  93. method: "get",
  94. url: "../../api/build/building/GetFloorList",
  95. params: {
  96. buildingId: $scope.selectparams.buildingId
  97. }
  98. }).then(function (result) {
  99. $scope.floorList = result.data.Data;
  100. }, function (resp) {
  101. });
  102. }
  103. else {
  104. $scope.floorList = [];
  105. }
  106. };
  107. $scope.getBuildingList();
  108. });
  109. })(angular);