2016-09-11 18:40:03 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular.module('warehost')
|
|
|
|
.controller('PageWebCtrl',function(session,config,alert,NgTableParams,$scope,$rootScope,$http,$stateParams){
|
2016-09-27 11:44:48 +02:00
|
|
|
$scope.data = [];
|
|
|
|
$scope.menulist = [];
|
2016-09-11 18:40:03 +02:00
|
|
|
alert.set({});
|
|
|
|
$scope.obj = {};
|
|
|
|
|
|
|
|
function resetObj(){
|
|
|
|
$scope.obj = {};
|
|
|
|
}
|
|
|
|
function load(){
|
2016-09-27 11:44:48 +02:00
|
|
|
$http.get(config.api+'/web/website/'+$stateParams.websiteid+'/menu/list').then(function(res){
|
|
|
|
$scope.menulist = res.data.data;
|
|
|
|
$http.get(config.api+'/web/website/'+$stateParams.websiteid+'/page').then(function(res){
|
|
|
|
session.set(res);
|
|
|
|
$scope.data = res.data.data;
|
|
|
|
});
|
2016-09-11 18:40:03 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
function submitresult(res){
|
|
|
|
session.set(res);
|
|
|
|
alert.set(res);
|
|
|
|
if(res.data.data){
|
2016-09-27 11:44:48 +02:00
|
|
|
load();
|
2016-09-11 18:40:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
resetObj();
|
|
|
|
load();
|
|
|
|
|
|
|
|
$scope.edit = function(a){
|
2016-09-27 11:44:48 +02:00
|
|
|
$scope.obj = a;
|
2016-09-11 18:40:03 +02:00
|
|
|
};
|
|
|
|
$scope.add = function(){
|
2016-09-27 11:44:48 +02:00
|
|
|
$scope.obj = {};
|
|
|
|
}
|
|
|
|
$scope.save = function(){
|
|
|
|
if($scope.obj.ID){
|
|
|
|
$http.put(config.api+'/web/website/'+$stateParams.websiteid+'/page/'+$scope.obj.ID,$scope.obj).then(submitresult);
|
|
|
|
}else{
|
|
|
|
$http.post(config.api+'/web/website/'+$stateParams.websiteid+'/page',$scope.obj).then(submitresult);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
$scope.delete = function(a){
|
|
|
|
$http.delete(config.api+'/web/website/'+$stateParams.websiteid+'/page/'+a.ID).then(submitresult);
|
2016-09-11 18:40:03 +02:00
|
|
|
};
|
|
|
|
});
|