sum7/warehost-frontend
sum7
/
warehost-frontend
Archived
1
0
Fork 0
This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
warehost-frontend/public/app/web/page.js

50 lines
1.3 KiB
JavaScript

'use strict';
angular.module('warehost')
.controller('PageWebCtrl',function(session,config,alert,NgTableParams,$scope,$rootScope,$http,$stateParams){
$scope.data = [];
$scope.menulist = [];
alert.set({});
$scope.obj = {};
function resetObj(){
$scope.obj = {};
}
function load(){
$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;
});
});
}
function submitresult(res){
session.set(res);
alert.set(res);
if(res.data.data){
load();
}
}
resetObj();
load();
$rootScope.$on('warehost.session',load);
$scope.edit = function(a){
$scope.obj = a;
};
$scope.add = function(){
$scope.obj = {};
};
$scope.save = function(){
if($scope.obj.ID){
$http.patch(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);
};
});