Upd:添加新闻增加标题字段,该字段只针对news创建使用

master
duLingLing 5 years ago
parent 06561d3c67
commit 7547ba954b

@ -9,7 +9,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>manage</artifactId>
<version>1.2.77</version>
<version>1.2.78</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jib-maven-plugin.version>1.6.1</jib-maven-plugin.version>

@ -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) {

@ -16,6 +16,20 @@
<input ng-model="article.page_title" type="text" name="ptitle" id="ptitle-input" class="form-control">
</div>
</div>
<div class="form-group" ng-if="catId=='news'">
<label class="col-md-2 control-label">Cover Image</label>
<div class="col-sm-4">
<div class="form-control-static">
<button class="btn btn-primary" type="button"
ngf-select="uploadImageFile($file)">
<i class="fa fa-upload"></i> Upload
</button>
</div>
<uib-progressbar value="bankFileProgress.value" ng-if="imageFileProgress"></uib-progressbar>
<a ng-if="isImage" target="_blank" ng-href="{{article.image}}">
<img ng-src="{{article.image}}" class="col-sm-8"></a>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="kw-input">HTML Keywords</label>
<div class="col-md-10">

Loading…
Cancel
Save