From 13cec9138a0320f71377dbf4d0238bd912e60c4a Mon Sep 17 00:00:00 2001 From: liuxinxin Date: Wed, 6 Nov 2019 13:55:03 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90R=E3=80=91=E5=B9=BF=E5=91=8A=E4=BD=8D?= =?UTF-8?q?=E5=B1=8F=E8=94=BD=E5=90=8C=E8=A1=8C=E4=B8=9A=E5=95=86=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/ui/static/cms/cms.js | 237 ++++++++++++++++-- .../static/cms/templates/article_editor.html | 84 ++++++- 2 files changed, 283 insertions(+), 38 deletions(-) diff --git a/src/main/ui/static/cms/cms.js b/src/main/ui/static/cms/cms.js index 59c8b043a..31cfc7030 100644 --- a/src/main/ui/static/cms/cms.js +++ b/src/main/ui/static/cms/cms.js @@ -255,10 +255,32 @@ define(['angular', 'uiRouter', 'static/commons/angular-ueditor'], function (angu } }]); - app.controller('cmsAddArticleCtrl', ['$scope', '$http', '$state', '$stateParams', 'commonDialog', function ($scope, $http, $state, $stateParams, commonDialog) { + app.controller('cmsAddArticleCtrl', ['$scope', '$http', '$state', '$stateParams', 'commonDialog','industryMap','stateMap', function ($scope, $http, $state, $stateParams, commonDialog,industryMap,stateMap) { + $scope.industries = industryMap.configs(); + $scope.states = stateMap.configs(); + + $scope.publishall = 1; + $scope.saveArticle = function () { + $scope.article.publishall = $scope.publishall; + if( $scope.publishall == 0){ + if($scope.select_industries.length <= 0 || $scope.select_industries == "") { + alert("所推送的行业不能为空"); + return; + } + if($scope.select_states.length <= 0 || $scope.select_states == "") { + alert("所推送的地区不能为空"); + return; + } + $scope.article.selectIndustries = $scope.select_industries.join(','); + $scope.article.selectStates = $scope.select_states.join(','); + if ($scope.select_clients) { + $scope.article.selectClients = $scope.select_clients.join(','); + } + + } $scope.article.reference = $scope.reference; - $scope.article.royalpay_industry = $scope.royalpay_industry; + $http.post('/app/cms/categories/' + $stateParams.catId + '/articles', $scope.article).then(function (resp) { $state.go('^.article_view', {articleId: resp.data.article_id}); }, function (resp) { @@ -266,35 +288,131 @@ define(['angular', 'uiRouter', 'static/commons/angular-ueditor'], function (angu }) }; - $scope.loadRoyalpayindustry = function () { - $http.get('/static/data/rp_industry_apply.json').then(function (resp) { - $scope.royalpayindustry = resp.data; - }) + $scope.params = {textType: 'all', org_name: 'ALL'}; + $scope.loadPartners = function (page) { + var params = angular.copy($scope.params); + params.page = page || $scope.pagination.page || 1; + $http.get('/sys/partners', {params: params}).then(function (resp) { + $scope.partners = resp.data.data; + $scope.pagination = resp.data.pagination; + }); }; - $scope.loadRoyalpayindustry(); - $scope.onRoyalPayIndustrySelect = function (selectedItem) { - $scope.royalpay_label = selectedItem.label; - $scope.royalpay_industry = selectedItem.mccCode; - }; + $scope.toggleSelectIndustries = function (industry) { + if (!$scope.select_industries) { + $scope.select_industries = []; + } + var $idx = $scope.select_industries.indexOf(industry); + if ($idx >= 0) { + $scope.select_industries.splice($idx, 1); + } else { + $scope.select_industries.push(industry); + $scope.select_industries.sort(compare); + } + } + $scope.selectAllIndustries = function() { + for(var i=0;i<$scope.industries.length;i++) { + $scope.toggleSelectIndustries($scope.industries[i].value) + } + } + $scope.selectAllIndustries(); + + $scope.toggleStates =function(state){ + if (!$scope.select_states) { + $scope.select_states = []; + } + var $idx = $scope.select_states.indexOf(state); + if ($idx >= 0) { + $scope.select_states.splice($idx, 1); + } else { + $scope.select_states.push(state); + $scope.select_states.sort(compare); + } + } + $scope.selectAllIndustries = function() { + for(var i=0;i<$scope.states.length;i++) { + $scope.toggleStates($scope.states[i].value) + } + } + $scope.selectAllIndustries(); + + $scope.toggleClient =function(client_moniker){ + if (!$scope.select_clients) { + $scope.select_clients = []; + } + var $idx = $scope.select_clients.indexOf(client_moniker); + if ($idx >= 0) { + $scope.select_clients.splice($idx, 1); + } else { + $scope.select_clients.push(client_moniker); + $scope.select_clients.sort(compare); + } + } + + var compare = function (x, y) { + x = parseInt(x); + y = parseInt(y); + if (x < y) { + return -1; + } else if (x > y) { + return 1; + } else { + return 0; + } + } }]); - app.controller('cmsArticleEditCtrl', ['$scope', '$http', '$state', '$stateParams', 'commonDialog', 'article', function ($scope, $http, $state, $stateParams, commonDialog, article) { + app.controller('cmsArticleEditCtrl', ['$scope', '$http', '$state', '$stateParams', 'commonDialog', 'article', 'industryMap','stateMap',function ($scope, $http, $state, $stateParams, commonDialog, article,industryMap,stateMap) { $scope.article = article.data; + + $scope.industries = industryMap.configs(); + $scope.states = stateMap.configs(); + + if($scope.article.publishall){ + $scope.publishall = $scope.article.publishall; + }else{ + $scope.publishall = 1 + } + + if ($scope.article.select_industries) { + $scope.select_industries = $scope.article.select_industries.split(","); + } + if($scope.article.select_clients){ + $scope.select_clients = $scope.article.select_clients.split(","); + } + if($scope.article.select_states){ + $scope.select_states = $scope.article.select_states.split(","); + } + + if ($scope.article.reference) { $scope.reference = JSON.parse($scope.article.reference); } else { $scope.reference = {}; } - if($scope.article.royalpay_industry){ - $scope.royalpay_industry = $scope.article.royalpay_industry; - } - $scope.saveArticle = function () { + + $scope.article.publishall = $scope.publishall; + if( $scope.publishall == 0){ + if($scope.select_industries.length <= 0 || $scope.select_industries == "") { + alert("所推送的行业不能为空"); + return; + } + if($scope.select_states.length <= 0 || $scope.select_states == "") { + alert("所推送的地区不能为空"); + return; + } + $scope.article.select_industries = $scope.select_industries.join(','); + $scope.article.select_states = $scope.select_states.join(','); + if ($scope.select_clients) { + $scope.article.select_clients = $scope.select_clients.join(','); + } + + } $scope.article.reference = $scope.reference; - $scope.article.royalpay_industry = $scope.royalpay_industry; + $http.put('/app/cms/categories/' + $stateParams.catId + '/articles/' + $stateParams.articleId, $scope.article).then(function (resp) { $state.go('^.article_view', {articleId: $stateParams.articleId}); }, function (resp) { @@ -302,17 +420,84 @@ define(['angular', 'uiRouter', 'static/commons/angular-ueditor'], function (angu }) }; - $scope.loadRoyalpayindustry = function () { - $http.get('/static/data/rp_industry_apply.json').then(function (resp) { - $scope.royalpayindustry = resp.data; - }) + $scope.params = {textType: 'all', org_name: 'ALL'}; + $scope.loadPartners = function (page) { + var params = angular.copy($scope.params); + params.page = page || $scope.pagination.page || 1; + $http.get('/sys/partners', {params: params}).then(function (resp) { + $scope.partners = resp.data.data; + $scope.pagination = resp.data.pagination; + }); }; - $scope.loadRoyalpayindustry(); - $scope.onRoyalPayIndustrySelect = function (selectedItem) { - $scope.royalpay_label = selectedItem.label; - $scope.royalpay_industry = selectedItem.mccCode; - }; + $scope.toggleSelectIndustries = function (industry) { + if (!$scope.select_industries) { + $scope.select_industries = []; + } + var $idx = $scope.select_industries.indexOf(industry); + if ($idx >= 0) { + $scope.select_industries.splice($idx, 1); + } else { + $scope.select_industries.push(industry); + $scope.select_industries.sort(compare); + } + } + $scope.selectAllIndustries = function() { + for(var i=0;i<$scope.industries.length;i++) { + $scope.toggleSelectIndustries($scope.industries[i].value) + } + } + if(!$scope.article.publishall){ + $scope.selectAllIndustries(); + } + + + $scope.toggleStates =function(state){ + if (!$scope.select_states) { + $scope.select_states = []; + } + var $idx = $scope.select_states.indexOf(state); + if ($idx >= 0) { + $scope.select_states.splice($idx, 1); + } else { + $scope.select_states.push(state); + $scope.select_states.sort(compare); + } + } + $scope.selectAllIndustries = function() { + for(var i=0;i<$scope.states.length;i++) { + $scope.toggleStates($scope.states[i].value) + } + } + if(!$scope.article.publishall){ + $scope.selectAllIndustries(); + } + + $scope.toggleClient =function(client_moniker){ + if (!$scope.select_clients) { + $scope.select_clients = []; + } + var $idx = $scope.select_clients.indexOf(client_moniker); + if ($idx >= 0) { + $scope.select_clients.splice($idx, 1); + } else { + $scope.select_clients.push(client_moniker); + $scope.select_clients.sort(compare); + } + } + + var compare = function (x, y) { + x = parseInt(x); + y = parseInt(y); + if (x < y) { + return -1; + } else if (x > y) { + return 1; + } else { + return 0; + } + } + }]); diff --git a/src/main/ui/static/cms/templates/article_editor.html b/src/main/ui/static/cms/templates/article_editor.html index 3130a961d..3ecb724f2 100644 --- a/src/main/ui/static/cms/templates/article_editor.html +++ b/src/main/ui/static/cms/templates/article_editor.html @@ -77,21 +77,81 @@
- -
- -
-

Required - Field

+ +
+
+ + +
+
+ + +
+ +
+ +
+ +    + +
+
+ +
+ +    + +
+
+
+ +
+ +    + +
+
+ + +
+ +
+ +
+ +
+ + +
+ +
+ +    + +
+
+ + +