list.js 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. (function ($app) {
  2. $app.module('ylmis').controller('announcementCtrl', function ($scope, $http, $filter, $modal, $ocLazyLoad, $alert, $loading, $state, AuthUser, $bsRouterState) {
  3. $scope.dataList = [];
  4. $state.params = $bsRouterState.$params($scope);
  5. //初始化查询参数
  6. $scope.selectparams = {
  7. title: '',
  8. pageIndex: 1,
  9. pageSize: 10,
  10. startDate: moment().startOf('day').toDate(),
  11. endDate: moment().startOf('day').toDate()
  12. };
  13. $scope.pageInfo = { ptotal: 0 };
  14. //查询
  15. $scope.search = function () {
  16. $scope.loadData();
  17. };
  18. //加载列表数据
  19. $scope.loadData = function () {
  20. $http
  21. ({
  22. method: 'post', url: '../../api/systemsetting/Announce/GetAnnounceList', data: $scope.selectparams
  23. }).then(function (result) {
  24. $scope.dataList = result.data.Data.rows;
  25. $scope.pageInfo.ptotal = result.data.Data.total;
  26. });
  27. };
  28. $scope.showMsg = function (title, content) {
  29. $alert({
  30. title: title + ':',
  31. content: content,
  32. placement: 'top',
  33. type: 'info',
  34. show: true,
  35. duration: 3
  36. });
  37. };
  38. $scope.addAnnounce = function () {
  39. $scope.edit(null, '发布公告');
  40. };
  41. $scope.editAnnounce = function (announcementID) {
  42. $scope.edit(announcementID, '修改公告');
  43. };
  44. $scope.delAnnounce = function () {
  45. if (confirm("是否要删除该公告?")) {
  46. var ids = $.map($filter('filter')($scope.dataList, { rowChecked: true }), function (x) { return x.AnnouncementID; });
  47. if (ids.length <= 0) {
  48. $scope.showMsg("消息", "请选择需要删除的数据");
  49. return false;
  50. }
  51. $http.post('../../api/systemsetting/Announce/Delete', { announceIDs: ids }).then(function (res) {
  52. if (res.data.IsSuccess) {
  53. $scope.loadData();
  54. $scope.showMsg('成功', '删除成功');
  55. } else {
  56. $scope.showMsg('错误', res.data.Message);
  57. }
  58. });
  59. }
  60. };
  61. $scope.edit = function (id, title) {
  62. announceModal.params = {
  63. announceID: id,
  64. title: title
  65. };
  66. announceModal.parentLoad = $scope.loadData;
  67. announceModal.$promise.then(announceModal.show);
  68. };
  69. editAnnounceCtrl.$inject = ['$scope', '$http', '$filter', '$loading'];
  70. //定义模态框
  71. announceModal = $modal({
  72. resolve: {
  73. load: ['$ocLazyLoad', function ($ocLazyLoad) {
  74. }]
  75. },
  76. scope: $scope,
  77. controller: editAnnounceCtrl,
  78. templateUrl: '../main/systemsetting/announcement/edit.html',
  79. show: false,
  80. animation: 'am-fade-and-slide-top'
  81. });
  82. $scope.loadData();
  83. });
  84. })(angular);