|
|
@@ -142,6 +142,11 @@ define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'file-
|
|
|
});
|
|
|
}]);
|
|
|
|
|
|
+ // html转义
|
|
|
+ var htmlEncode = function(sHtml) {
|
|
|
+ return sHtml.replace(/[<>&"]/g,function(c){return {'<':'<','>':'>','&':'&','"':'"'}[c];});
|
|
|
+ };
|
|
|
+
|
|
|
/**
|
|
|
* 项目列表
|
|
|
*/
|
|
|
@@ -293,11 +298,11 @@ define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'file-
|
|
|
app.controller('ProjectDetailCtrl', ['$scope', 'Project', 'toaster', '$modalInstance', 'BaseService', 'id', '$modal',
|
|
|
function($scope, Project, toaster, $modalInstance, BaseService, id, $modal) {
|
|
|
|
|
|
-
|
|
|
var loadData = function() {
|
|
|
// 获取项目详情
|
|
|
Project.getDetailById({id :id}, {}, function(data) {
|
|
|
$scope.project = data;
|
|
|
+ $scope.project.introduction = htmlEncode($scope.project.introduction);
|
|
|
}, function() {
|
|
|
toaster.pop('error', '详情加载失败');
|
|
|
});
|
|
|
@@ -1518,12 +1523,12 @@ define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'file-
|
|
|
/**
|
|
|
* 活动发起
|
|
|
*/
|
|
|
- app.controller('ActivityNewCtrl', ['$scope', 'BaseService', 'toaster', 'Activity', '$http',
|
|
|
- function($scope, BaseService, toaster, Activity, $http) {
|
|
|
+ app.controller('ActivityNewCtrl', ['$scope', 'BaseService', 'toaster', 'Activity', '$http', '$upload',
|
|
|
+ function($scope, BaseService, toaster, Activity, $http, $upload) {
|
|
|
|
|
|
$scope.activity = {
|
|
|
awards:[],
|
|
|
- projectQualificationList: []
|
|
|
+ projects: []
|
|
|
};
|
|
|
$scope.awards = [];
|
|
|
$scope.projects = [];
|
|
|
@@ -1579,6 +1584,12 @@ define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'file-
|
|
|
|
|
|
// 删除某一奖品
|
|
|
$scope.deleteAward = function($index) {
|
|
|
+ var path = $scope.awards[$index].img;
|
|
|
+ if (!angular.isUndefined(path)) {
|
|
|
+ Activity.deletePrizeImg({path: path}, {}, function(data) {
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
$scope.awards.splice($index, 1);
|
|
|
};
|
|
|
|
|
|
@@ -1666,32 +1677,45 @@ define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'file-
|
|
|
// 图片上传
|
|
|
$scope.fileChanged = function(ele, value){
|
|
|
if (value == 0) {
|
|
|
- $scope.coverImg = ele.files[0];
|
|
|
+ $scope.actImg = ele.files[0];
|
|
|
} else if (value == 1) {
|
|
|
$scope.banner = ele.files[0];
|
|
|
- } else if (value == 2) {
|
|
|
- $scope.award1 = ele.files[0];
|
|
|
- } else if (value == 3) {
|
|
|
- $scope.award2 = ele.files[0];
|
|
|
- } else if (value == 4) {
|
|
|
- $scope.award3 = ele.files[0];
|
|
|
- } else if (value == 5) {
|
|
|
- $scope.award4 = ele.files[0];
|
|
|
+ // } else if (value == 2) {
|
|
|
+ // $scope.award1 = ele.files[0];
|
|
|
+ // } else if (value == 3) {
|
|
|
+ // $scope.award2 = ele.files[0];
|
|
|
+ // } else if (value == 4) {
|
|
|
+ // $scope.award3 = ele.files[0];
|
|
|
+ // } else if (value == 5) {
|
|
|
+ // $scope.award4 = ele.files[0];
|
|
|
}
|
|
|
$scope.$apply();
|
|
|
};
|
|
|
|
|
|
+ $scope.uploadPrizeImg = function(award, index) {
|
|
|
+ $scope.loading = true;
|
|
|
+ var files = award.prizeImgs, file = files && files.length > 0 ? files[0] : null;
|
|
|
+ console.log(file);
|
|
|
+ $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);
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
// 保存 或 提交
|
|
|
$scope.submit = function(type) {
|
|
|
- var projectQualificationList = [];
|
|
|
+ var projectList = [];
|
|
|
angular.forEach($scope.selectedProjects, function(project) {
|
|
|
- var projectQualification = {};
|
|
|
- projectQualification.activityId = $scope.activity.id;
|
|
|
- projectQualification.proId = project.id;
|
|
|
- projectQualification.name = project.name;
|
|
|
- projectQualificationList.push(projectQualification);
|
|
|
+ projectList.push(project);
|
|
|
});
|
|
|
- $scope.activity.projectQualificationList = projectQualificationList;
|
|
|
+ $scope.activity.projects = projectList;
|
|
|
$scope.activity.awards = $scope.awards;
|
|
|
var url;
|
|
|
if (type) {
|
|
|
@@ -1700,12 +1724,12 @@ define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'file-
|
|
|
url = 'activity/save';
|
|
|
}
|
|
|
var data = new FormData();
|
|
|
- data.append('coverImg', $scope.coverImg);
|
|
|
+ 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('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: {
|
|
|
@@ -1722,7 +1746,7 @@ define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'file-
|
|
|
} else {
|
|
|
toaster.pop('success', '保存成功');
|
|
|
}
|
|
|
- window.location.hash='#/';
|
|
|
+ window.location.href='#/activity';
|
|
|
}).error(function (data) {
|
|
|
$scope.loadingShow = false;
|
|
|
toaster.pop('error', '出现错误,操作失败');
|