diff --git a/pom.xml b/pom.xml index b822fce08..bf3941b5e 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 4.0.0 manage - 1.2.77 + 1.2.78 UTF-8 1.6.1 diff --git a/src/main/ui/static/cms/cms.js b/src/main/ui/static/cms/cms.js index d3aeea811..6aca78a6a 100644 --- a/src/main/ui/static/cms/cms.js +++ b/src/main/ui/static/cms/cms.js @@ -255,11 +255,41 @@ define(['angular', 'uiRouter', 'static/commons/angular-ueditor'], function (angu } }]); - app.controller('cmsAddArticleCtrl', ['$scope', '$http', '$state', '$stateParams', 'commonDialog','industryMap','stateMap', function ($scope, $http, $state, $stateParams, commonDialog,industryMap,stateMap) { + app.controller('cmsAddArticleCtrl', ['$scope', '$http', '$state', '$stateParams', 'commonDialog','industryMap','stateMap','Upload', function ($scope, $http, $state, $stateParams, commonDialog,industryMap,stateMap,Upload) { + $scope.catId = $scope.catId $scope.industries = industryMap.configs(); $scope.states = stateMap.configs(); - $scope.publishall = 1; + $scope.isImage = true; + $scope.uploadImageFile = function (file) { + if(typeof $scope.article =='undefined'){ + $scope.article={} + } + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.imageFileProgress = {value: 0}; + Upload.upload({ + url: '/attachment/files', + data: {file: file} + }).then(function (resp) { + delete $scope.imageFileProgress; + $scope.article.image = resp.data.url; + if ($scope.article.image.endsWith('pdf')) { + $scope.isImage = false; + } else { + $scope.isImage = true; + } + }, function (resp) { + delete $scope.imageFileProgress; + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, function (evt) { + $scope.imageFileProgress.value = parseInt(100 * evt.loaded / evt.total); + }) + } + } + }; $scope.saveArticle = function () { $scope.article.publishall = $scope.publishall; @@ -279,6 +309,10 @@ define(['angular', 'uiRouter', 'static/commons/angular-ueditor'], function (angu } } + if($scope.catId=='news' && $scope.article.image==null){ + alert("请上传封面图"); + return; + } $scope.article.reference = $scope.reference; $http.post('/app/cms/categories/' + $stateParams.catId + '/articles', $scope.article).then(function (resp) { @@ -363,8 +397,9 @@ define(['angular', 'uiRouter', 'static/commons/angular-ueditor'], function (angu }]); - app.controller('cmsArticleEditCtrl', ['$scope', '$http', '$state', '$stateParams', 'commonDialog', 'article', 'industryMap','stateMap',function ($scope, $http, $state, $stateParams, commonDialog, article,industryMap,stateMap) { + app.controller('cmsArticleEditCtrl', ['$scope', '$http', '$state', '$stateParams', 'commonDialog', 'article', 'industryMap','stateMap','Upload',function ($scope, $http, $state, $stateParams, commonDialog, article,industryMap,stateMap,Upload) { $scope.article = article.data; + $scope.catId=$stateParams.catId; $scope.article.publishall = $scope.article.publishall +""; $scope.industries = industryMap.configs(); @@ -393,8 +428,39 @@ define(['angular', 'uiRouter', 'static/commons/angular-ueditor'], function (angu $scope.reference = {}; } - $scope.saveArticle = function () { + $scope.isImage = true; + if ($scope.article.image && $scope.article.image.endsWith('pdf')) { + $scope.isImage = false; + } + $scope.uploadImageFile = function (file) { + if (file != null) { + if (file.size > 3 * 1024 * 1024) { + commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB,请压缩后重试', type: 'error'}) + } else { + $scope.imageFileProgress = {value: 0}; + Upload.upload({ + url: '/attachment/files', + data: {file: file} + }).then(function (resp) { + delete $scope.imageFileProgress; + $scope.article.image = resp.data.url; + if ($scope.article.image.endsWith('pdf')) { + $scope.isImage = false; + } else { + $scope.isImage = true; + } + }, function (resp) { + delete $scope.imageFileProgress; + commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'}) + }, function (evt) { + $scope.imageFileProgress.value = parseInt(100 * evt.loaded / evt.total); + }) + } + } + }; + + $scope.saveArticle = function () { $scope.article.publishall = $scope.publishall; if( $scope.publishall == 0){ if($scope.select_industries.length <= 0 || $scope.select_industries == "") { @@ -412,8 +478,11 @@ define(['angular', 'uiRouter', 'static/commons/angular-ueditor'], function (angu } } + if($scope.catId=='news' && $scope.article.image==null){ + alert("请上传封面图"); + return; + } $scope.article.reference = $scope.reference; - $http.put('/app/cms/categories/' + $stateParams.catId + '/articles/' + $stateParams.articleId, $scope.article).then(function (resp) { $state.go('^.article_view', {articleId: $stateParams.articleId}); }, function (resp) { diff --git a/src/main/ui/static/cms/templates/article_editor.html b/src/main/ui/static/cms/templates/article_editor.html index 64c185d1b..a223d0c4e 100644 --- a/src/main/ui/static/cms/templates/article_editor.html +++ b/src/main/ui/static/cms/templates/article_editor.html @@ -16,6 +16,20 @@ +
+ +
+
+ +
+ + + +
+