(function ($app) { $app.module('ylmis').controller('announcementCtrl', function ($scope, $http, $filter, $modal, $ocLazyLoad, $alert, $loading, $state, AuthUser, $bsRouterState) { $scope.dataList = []; $state.params = $bsRouterState.$params($scope); //初始化查询参数 $scope.selectparams = { title: '', pageIndex: 1, pageSize: 10, startDate: moment().startOf('day').toDate(), endDate: moment().startOf('day').toDate() }; $scope.pageInfo = { ptotal: 0 }; //查询 $scope.search = function () { $scope.loadData(); }; //加载列表数据 $scope.loadData = function () { $http ({ method: 'post', url: '../../api/systemsetting/Announce/GetAnnounceList', data: $scope.selectparams }).then(function (result) { $scope.dataList = result.data.Data.rows; $scope.pageInfo.ptotal = result.data.Data.total; }); }; $scope.showMsg = function (title, content) { $alert({ title: title + ':', content: content, placement: 'top', type: 'info', show: true, duration: 3 }); }; $scope.addAnnounce = function () { $scope.edit(null, '发布公告'); }; $scope.editAnnounce = function (announcementID) { $scope.edit(announcementID, '修改公告'); }; $scope.delAnnounce = function () { if (confirm("是否要删除该公告?")) { var ids = $.map($filter('filter')($scope.dataList, { rowChecked: true }), function (x) { return x.AnnouncementID; }); if (ids.length <= 0) { $scope.showMsg("消息", "请选择需要删除的数据"); return false; } $http.post('../../api/systemsetting/Announce/Delete', { announceIDs: ids }).then(function (res) { if (res.data.IsSuccess) { $scope.loadData(); $scope.showMsg('成功', '删除成功'); } else { $scope.showMsg('错误', res.data.Message); } }); } }; $scope.edit = function (id, title) { announceModal.params = { announceID: id, title: title }; announceModal.parentLoad = $scope.loadData; announceModal.$promise.then(announceModal.show); }; editAnnounceCtrl.$inject = ['$scope', '$http', '$filter', '$loading']; //定义模态框 announceModal = $modal({ resolve: { load: ['$ocLazyLoad', function ($ocLazyLoad) { }] }, scope: $scope, controller: editAnnounceCtrl, templateUrl: '../main/systemsetting/announcement/edit.html', show: false, animation: 'am-fade-and-slide-top' }); $scope.loadData(); }); })(angular);