|
|
@@ -2,9 +2,9 @@
|
|
|
* index
|
|
|
*
|
|
|
*/
|
|
|
-define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'file-upload', 'common/directives', 'common/services', 'toaster', 'ngSanitize', 'services/Project', 'services/Activity', 'services/Organization', 'ui-form', 'services/User'], function(angularAMD) {
|
|
|
+define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'file-upload', 'common/directives', 'common/services', 'toaster', 'ngSanitize', 'services/Project', 'services/Activity', 'services/Organization', 'ui-form', 'services/User', 'services/Message'], function(angularAMD) {
|
|
|
'use strict';
|
|
|
- var app = angular.module('myApp', [ 'ui.router', 'ui.bootstrap', 'ng.local', 'ngTable', 'angularFileUpload', 'common.directives', 'common.services', 'toaster', 'ngSanitize', 'ProjectService', 'ActivityService', 'OrganizationService', 'ui.form', 'UserService']);
|
|
|
+ var app = angular.module('myApp', [ 'ui.router', 'ui.bootstrap', 'ng.local', 'ngTable', 'angularFileUpload', 'common.directives', 'common.services', 'toaster', 'ngSanitize', 'ProjectService', 'ActivityService', 'OrganizationService', 'ui.form', 'UserService', 'MessageService']);
|
|
|
app.init = function() {
|
|
|
angularAMD.bootstrap(app);
|
|
|
};
|
|
|
@@ -141,9 +141,35 @@ define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'file-
|
|
|
title : '用户列表',
|
|
|
templateUrl : 'static/view/user/user_list.html',
|
|
|
controller : 'UserListCtrl'
|
|
|
+ }).state("editMessage", {
|
|
|
+ url : '/message/new',
|
|
|
+ title : '编辑消息',
|
|
|
+ templateUrl : 'static/view/message/message_edit.html',
|
|
|
+ controller : 'MessageNewCtrl'
|
|
|
+ }).state("messageList", {
|
|
|
+ url : '/message/list',
|
|
|
+ title : '消息列表',
|
|
|
+ templateUrl : 'static/view/message/message_list.html',
|
|
|
+ controller : 'MessageListCtrl'
|
|
|
});
|
|
|
}]);
|
|
|
|
|
|
+ // 富文本编辑器配置
|
|
|
+ var editorConfig = {
|
|
|
+ dialogsInBody: true,
|
|
|
+ lang: 'zh-CN',
|
|
|
+ toolbar:[
|
|
|
+ ['edit',['undo','redo']],
|
|
|
+ ['style',['bold','italic','underline','clear' ]],
|
|
|
+ ['para',['ul','ol','paragraph']],
|
|
|
+ ['style', ['style']],
|
|
|
+ ['color',['color']],
|
|
|
+ ['table', ['table']],
|
|
|
+ ['insert', ['link', 'picture', 'hr']],
|
|
|
+ ['view', ['fullscreen', 'codeview']]
|
|
|
+ ]
|
|
|
+ };
|
|
|
+
|
|
|
// html转义
|
|
|
var htmlEncode = function(sHtml) {
|
|
|
return sHtml.replace(/[<>&"]/g,function(c){return {'<':'<','>':'>','&':'&','"':'"'}[c];});
|
|
|
@@ -1412,6 +1438,7 @@ define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'file-
|
|
|
BaseService.scrollBackToTop();
|
|
|
$rootScope.tree = 'project';
|
|
|
$rootScope.thief = 'new';
|
|
|
+ $scope.editorConfig = editorConfig;
|
|
|
// 默认捐助领域
|
|
|
$scope.defaultAreas = ['疾病援助', '扶贫/救灾', '教育/助学' , '环境/动物保护', '其他'];
|
|
|
|
|
|
@@ -2373,6 +2400,7 @@ define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'file-
|
|
|
$rootScope.tree = 'activity';
|
|
|
$rootScope.thief = 'new';
|
|
|
$scope.loading = true;
|
|
|
+ $scope.editorConfig = editorConfig;
|
|
|
$scope.activity = {
|
|
|
awards:[],
|
|
|
projects: []
|
|
|
@@ -3250,5 +3278,361 @@ define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'file-
|
|
|
};
|
|
|
}]);
|
|
|
|
|
|
+ /**
|
|
|
+ * 新增消息
|
|
|
+ */
|
|
|
+ app.controller('MessageNewCtrl', ['$scope', 'BaseService', 'toaster', 'Message', '$http', '$upload', '$rootScope', '$modal',
|
|
|
+ function($scope, BaseService, toaster, Message, $http, $upload, $rootScope, $modal) {
|
|
|
+ BaseService.scrollBackToTop();
|
|
|
+ $rootScope.tree = 'message';
|
|
|
+ $rootScope.thief = 'new';
|
|
|
+ $scope.loading = true;
|
|
|
+ $scope.editorConfig = editorConfig;
|
|
|
+
|
|
|
+ $scope.message = {};
|
|
|
+ // 默认按角色类型发送
|
|
|
+ $scope.ifPersonal = 0;
|
|
|
+
|
|
|
+ // 日期选择
|
|
|
+ $scope.openDatePicker = function ($event, item, openParam) {
|
|
|
+ $event.preventDefault();
|
|
|
+ $event.stopPropagation();
|
|
|
+ item[openParam] = !item[openParam];
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 选择接收对象
|
|
|
+ */
|
|
|
+ $scope.selectReceiver = function (ifPersonal) {
|
|
|
+ if (ifPersonal === 1) {
|
|
|
+ // 指定用户模态框
|
|
|
+
|
|
|
+ } else {
|
|
|
+ // 按角色类型模态框
|
|
|
+ $modal.open({
|
|
|
+ animation: true,
|
|
|
+ size: 'lg',
|
|
|
+ templateUrl: 'static/view/message/select_receiver_role.html',
|
|
|
+ controller: 'RoleReceiverChooseCtrl',
|
|
|
+ // resolve: {
|
|
|
+ // message: function () {
|
|
|
+ // return $scope.message;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ }).result.then(function (data) {
|
|
|
+ //TODO 选择接收对象
|
|
|
+ }, function () {
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除接受对象
|
|
|
+ */
|
|
|
+ $scope.deleteReceiver = function() {
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ // 获取用户列表
|
|
|
+ var getUsers= function() {
|
|
|
+ };
|
|
|
+ getUsers();
|
|
|
+
|
|
|
+ // 搜索项目
|
|
|
+ $scope.onSearch = function() {
|
|
|
+ getUsers();
|
|
|
+ };
|
|
|
+
|
|
|
+ // 添加选中
|
|
|
+ $scope.addSelected = function() {
|
|
|
+ var i = 0;
|
|
|
+ for (i; i< $scope.projects.length; i++) {
|
|
|
+ var project = $scope.projects[i];
|
|
|
+ if (project.checked) {
|
|
|
+ project.checked = false;
|
|
|
+ if (angular.isUndefined($scope.selectedProjects)) {
|
|
|
+ $scope.selectedProjects = [];
|
|
|
+ }
|
|
|
+ $scope.selectedProjects.push(project);
|
|
|
+ $scope.projects.splice(i, 1);
|
|
|
+ i = i-1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 删除选中
|
|
|
+ $scope.deleteSelected = function() {
|
|
|
+ var i = 0;
|
|
|
+ for (i; i< $scope.selectedProjects.length; i++) {
|
|
|
+ var project = $scope.selectedProjects[i];
|
|
|
+ if (project.checked) {
|
|
|
+ project.checked = false;
|
|
|
+ $scope.projects.push(project);
|
|
|
+ $scope.selectedProjects.splice(i, 1);
|
|
|
+ i = i -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 取消
|
|
|
+ $scope.cancelSelected = function() {
|
|
|
+ $scope.projects = angular.copy($scope.tempProjects);
|
|
|
+ $scope.selectedProjects = angular.copy($scope.tempSelectedProjects);
|
|
|
+ };
|
|
|
+
|
|
|
+ // 保存
|
|
|
+ $scope.saveSelected = function() {
|
|
|
+ $scope.tempProjects = angular.copy($scope.projects);
|
|
|
+ $scope.tempSelectedProjects = angular.copy($scope.selectedProjects);
|
|
|
+ };
|
|
|
+
|
|
|
+ //TODO 奖品图片上传(修改编辑器图片上传可参考)
|
|
|
+ $scope.uploadPrizeImg = function(award, index) {
|
|
|
+ $scope.loading = true;
|
|
|
+ var files = award.prizeImgs, file = files && files.length > 0 ? files[0] : null;
|
|
|
+ $upload.upload({
|
|
|
+ url: 'activity/upload/prizeImg',
|
|
|
+ method: 'POST',
|
|
|
+ file: file
|
|
|
+ }).success(function (data) {
|
|
|
+ $scope.awards[index].img = data.path;
|
|
|
+ $scope.loading = false;
|
|
|
+ }).error(function (data) {
|
|
|
+ $scope.loading = false;
|
|
|
+ // toaster.pop('error', '错误', data);
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ //TODO 发布通知
|
|
|
+ $scope.publishMessage = function(invalid) {
|
|
|
+ if (invalid == true) {
|
|
|
+ $scope.submited = true;
|
|
|
+ BaseService.scrollBackToTop();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $scope.loading = true;
|
|
|
+ var projectList = [];
|
|
|
+ angular.forEach($scope.selectedProjects, function (project) {
|
|
|
+ projectList.push(project);
|
|
|
+ });
|
|
|
+ $scope.activity.projects = projectList;
|
|
|
+ $scope.activity.awards = $scope.awards;
|
|
|
+ var url;
|
|
|
+ if (type) {
|
|
|
+ url = 'activity/submit';
|
|
|
+ } else {
|
|
|
+ url = 'activity/save';
|
|
|
+ }
|
|
|
+ var data = new FormData();
|
|
|
+ data.append('actImg', $scope.actImg);
|
|
|
+ data.append('banner', $scope.banner);
|
|
|
+ // data.append('award1', $scope.award1);
|
|
|
+ // data.append('award2', $scope.award2);
|
|
|
+ // data.append('award3', $scope.award3);
|
|
|
+ // data.append('award4', $scope.award4);
|
|
|
+ data.append('jsonStr', JSON.stringify($scope.activity));
|
|
|
+ $http({
|
|
|
+ headers: {
|
|
|
+ 'Content-Type': undefined
|
|
|
+ },
|
|
|
+ method: 'POST',
|
|
|
+ processData: false,
|
|
|
+ async: false,
|
|
|
+ url: url,
|
|
|
+ data: data
|
|
|
+ }).success(function (data) {
|
|
|
+ if (type) {
|
|
|
+ toaster.pop('success', '发布成功');
|
|
|
+ } else {
|
|
|
+ toaster.pop('success', '保存成功');
|
|
|
+ }
|
|
|
+ $scope.loading = false;
|
|
|
+ window.location.hash = '#/activity';
|
|
|
+ }).error(function (data) {
|
|
|
+ $scope.loadingShow = false;
|
|
|
+ toaster.pop('error', '出现错误,操作失败');
|
|
|
+ });
|
|
|
+ // }
|
|
|
+ }
|
|
|
+
|
|
|
+ }]);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 选择接收对象
|
|
|
+ */
|
|
|
+ app.controller('RoleReceiverChooseCtrl', ['$scope', 'BaseService', 'toaster', 'Message', '$http', '$upload', '$rootScope', '$modal', 'ngTableParams',
|
|
|
+ function($scope, BaseService, toaster, Message, $http, $upload, $rootScope, $modal, ngTableParams) {
|
|
|
+ $scope.loading = true;
|
|
|
+ $scope.active = 'personal';
|
|
|
+ $scope.orgs = [];
|
|
|
+ $scope.checkedAll = false;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改用户类型
|
|
|
+ * @param value 类型
|
|
|
+ */
|
|
|
+ $scope.setActive = function(value) {
|
|
|
+ if ($scope.active !== value) {
|
|
|
+ $scope.active = value;
|
|
|
+ if ($scope.userParams.page === 1) {
|
|
|
+ $scope.userParams.reload();
|
|
|
+ } else {
|
|
|
+ $scope.userParams.page(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 全选
|
|
|
+ */
|
|
|
+ $scope.checkAll = function() {
|
|
|
+ $scope.checkedAll = !$scope.checkedAll;
|
|
|
+ angular.forEach($scope.orgs, function(org) {
|
|
|
+ org.checked = $scope.checkedAll;
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据数据类型获取用户列表
|
|
|
+ */
|
|
|
+ $scope.loading = false;
|
|
|
+ }]);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 消息列表
|
|
|
+ */
|
|
|
+ app.controller('MessageListCtrl', ['$scope', '$rootScope', 'toaster', 'ngTableParams', 'BaseService', 'Message', '$modal',
|
|
|
+ function ($scope, $rootScope, toaster, ngTableParams, BaseService, Message, $modal) {
|
|
|
+ BaseService.scrollBackToTop();
|
|
|
+ $rootScope.tree = 'message';
|
|
|
+ $rootScope.thief = 'list';
|
|
|
+
|
|
|
+ $scope.keyword = '';
|
|
|
+
|
|
|
+ $scope.fromDate = null;
|
|
|
+ // 设置时间过滤
|
|
|
+ $scope.setTime = function(type) {
|
|
|
+ var fromDate = new Date();
|
|
|
+ switch (type) {
|
|
|
+ // 最近6小时
|
|
|
+ case '6' :
|
|
|
+ fromDate.setHours(fromDate.getHours() - 6) ;
|
|
|
+ $scope.fromDate = fromDate;
|
|
|
+ break;
|
|
|
+ // 最近24小时
|
|
|
+ case '24' :
|
|
|
+ fromDate.setDate(fromDate.getDate() - 1) ;
|
|
|
+ $scope.fromDate = fromDate;
|
|
|
+ break;
|
|
|
+ // 最近3天
|
|
|
+ case '3' :
|
|
|
+ fromDate.setDate(fromDate.getDate() - 3) ;
|
|
|
+ $scope.fromDate = fromDate;
|
|
|
+ break;
|
|
|
+ // 最近7天
|
|
|
+ case '7' :
|
|
|
+ fromDate.setDate(fromDate.getDate() - 7) ;
|
|
|
+ $scope.fromDate = fromDate;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ $scope.messageParams.reload();
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.reload = function() {
|
|
|
+ if ($scope.messageParams.page() == 1)
|
|
|
+ $scope.messageParams.reload();
|
|
|
+ else
|
|
|
+ $scope.messageParams.page(1);
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.messageParams = new ngTableParams({
|
|
|
+ page: 1,
|
|
|
+ count: 10,
|
|
|
+ sorting: {
|
|
|
+ 'id': 'desc'
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ total: 0,
|
|
|
+ counts: [],
|
|
|
+ getData: function ($defer, params) {
|
|
|
+ $scope.loading = true;
|
|
|
+ var pageParams = params.url();
|
|
|
+ var realActive = {};
|
|
|
+ pageParams.searchFilter = { // 筛选条件
|
|
|
+ keyword: $scope.keyword,
|
|
|
+ fromDate : null !== $scope.fromDate ? $scope.fromDate.getTime(): null,
|
|
|
+ };
|
|
|
+ Message.getAll.call(null, BaseService.parseParams(pageParams), function (page) {
|
|
|
+ $scope.loading = false;
|
|
|
+ if (page) {
|
|
|
+ params.total(page.totalElements);
|
|
|
+ $defer.resolve(page.content);
|
|
|
+ // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
|
|
|
+ }
|
|
|
+ }, function (response) {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '数据加载失败', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $scope.onSearch = function () {
|
|
|
+ if ($scope.messageParams.page() == 1)
|
|
|
+ $scope.messageParams.reload();
|
|
|
+ else
|
|
|
+ $scope.messageParams.page(1);
|
|
|
+ };
|
|
|
+
|
|
|
+ // 弹出详情页模态框
|
|
|
+ $scope.showDetail = function (message) {
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ templateUrl: 'static/view/message/message_detail.html',
|
|
|
+ controller: 'MessageDetailCtrl',
|
|
|
+ size: 'lg',
|
|
|
+ resolve: {
|
|
|
+ message: function () {
|
|
|
+ return message;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ modalInstance.result.then(function(data){
|
|
|
+ $scope.messageParams.reload();
|
|
|
+ }, function(){
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ }]);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 消息详情框
|
|
|
+ */
|
|
|
+ app.controller('MessageDetailCtrl', ['$scope', 'Message', 'toaster', '$modalInstance', 'BaseService', 'message',
|
|
|
+ function($scope, Message, toaster, $modalInstance, BaseService, message, $modal) {
|
|
|
+
|
|
|
+ $scope.message = message;
|
|
|
+
|
|
|
+ $scope.cancel= function() {
|
|
|
+ $modalInstance.dismiss();
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.delete = function(id) {
|
|
|
+ Message.delete({id: id}, {}, function(data) {
|
|
|
+ if (data.success) {
|
|
|
+ toaster.pop('success', data.success);
|
|
|
+ $modalInstance.close(data);
|
|
|
+ }
|
|
|
+ if (data.error) {
|
|
|
+ toaster.pop('error', data.error);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+ }]);
|
|
|
+
|
|
|
+
|
|
|
return app;
|
|
|
});
|