diff --git a/admin/app/controllers/settings/costcenter/costcenter.controller.js b/admin/app/controllers/settings/costcenter/costcenter.controller.js index 3dac6dae..3610e611 100644 --- a/admin/app/controllers/settings/costcenter/costcenter.controller.js +++ b/admin/app/controllers/settings/costcenter/costcenter.controller.js @@ -1,7 +1,14 @@ 'use strict'; -app.controller('CostCenterController', function($scope, $translate,$uibModal, CostCenterService,toaster,SweetAlert) { - +app.controller('CostCenterController', function( + $scope, + $window, + $translate, + $uibModal, + CostCenterService, + toaster, + SweetAlert) { + $scope.cur_user = JSON.parse($window.localStorage.getItem("myems_admin_ui_current_user")); $scope.getAllCostCenters = function() { CostCenterService.getAllCostCenters(function (response) { if (angular.isDefined(response.status) && response.status === 200) { @@ -19,7 +26,8 @@ app.controller('CostCenterController', function($scope, $translate,$uibModal, Co windowClass: "animated fadeIn", }); modalInstance.result.then(function(costcenter) { - CostCenterService.addCostCenter(costcenter, function (response) { + let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token }; + CostCenterService.addCostCenter(costcenter, headers, function (response) { if (angular.isDefined(response.status) && response.status === 201) { toaster.pop({ type: "success", @@ -59,7 +67,8 @@ app.controller('CostCenterController', function($scope, $translate,$uibModal, Co }); modalInstance.result.then(function (modifiedCostCenter) { - CostCenterService.editCostCenter(modifiedCostCenter, function (response){ + let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token }; + CostCenterService.editCostCenter(modifiedCostCenter, headers, function (response){ if(angular.isDefined(response.status) && response.status === 200){ toaster.pop({ type: "success", @@ -96,7 +105,8 @@ app.controller('CostCenterController', function($scope, $translate,$uibModal, Co closeOnCancel: true }, function (isConfirm) { if (isConfirm) { - CostCenterService.deleteCostCenter(costcenter, function (response) { + let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token }; + CostCenterService.deleteCostCenter(costcenter, headers, function (response) { if (angular.isDefined(response.status) && response.status === 204) { toaster.pop({ type: "success", diff --git a/admin/app/controllers/settings/costcenter/costcentertariff.controller.js b/admin/app/controllers/settings/costcenter/costcentertariff.controller.js index 242a58f8..67efe1b8 100644 --- a/admin/app/controllers/settings/costcenter/costcentertariff.controller.js +++ b/admin/app/controllers/settings/costcenter/costcentertariff.controller.js @@ -1,11 +1,14 @@ 'use strict'; -app.controller('CostCenterTariffController', function ($scope, $translate, - CostCenterService, - TariffService, - CostCenterTariffService, - toaster) { - +app.controller('CostCenterTariffController', function ( + $scope, + $window, + $translate, + CostCenterService, + TariffService, + CostCenterTariffService, + toaster) { + $scope.cur_user = JSON.parse($window.localStorage.getItem("myems_admin_ui_current_user")); $scope.getAllCostCenters = function () { CostCenterService.getAllCostCenters(function (response) { if (angular.isDefined(response.status) && response.status === 200) { @@ -51,7 +54,8 @@ app.controller('CostCenterTariffController', function ($scope, $translate, $scope.pairTariff = function (dragEl, dropEl) { var tariffid = angular.element('#' + dragEl).scope().tariff.id; var costcenterid = $scope.currentCostCenter.id; - CostCenterTariffService.addPair(costcenterid, tariffid, function (response) { + let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token }; + CostCenterTariffService.addPair(costcenterid, tariffid, headers, function (response) { if (angular.isDefined(response.status) && response.status === 201) { toaster.pop({ type: "success", @@ -77,7 +81,8 @@ app.controller('CostCenterTariffController', function ($scope, $translate, } var costcentertariffid = angular.element('#' + dragEl).scope().costcentertariff.id; var costcenterid = $scope.currentCostCenter.id; - CostCenterTariffService.deletePair(costcenterid, costcentertariffid, function (response) { + let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token }; + CostCenterTariffService.deletePair(costcenterid, costcentertariffid, headers, function (response) { if (angular.isDefined(response.status) && response.status === 204) { toaster.pop({ type: "success", diff --git a/admin/app/controllers/settings/tariff/flat.controller.js b/admin/app/controllers/settings/tariff/flat.controller.js deleted file mode 100644 index edfe3e16..00000000 --- a/admin/app/controllers/settings/tariff/flat.controller.js +++ /dev/null @@ -1,158 +0,0 @@ -'use strict'; - -app.controller('FlatController', function($scope,$uibModal,$translate, FlatService,toaster,SweetAlert) { - - - $scope.getAllFlats = function() { - FlatService.getAllFlats(function (response) { - if (angular.isDefined(response.status) && response.status === 200) { - $scope.flats = response.data; - } else { - $scope.flats = []; - } - }); - - }; - - $scope.addFlat = function() { - var modalInstance = $uibModal.open({ - templateUrl: 'views/settings/tariff/flat.model.html', - controller: 'ModalAddFlatCtrl', - windowClass: "animated fadeIn", - resolve: { - params:function(){ - return { - flats:angular.copy($scope.flats) - }; - } - } - }); - modalInstance.result.then(function(flat) { - FlatService.addFlat(flat, function(response) { - if (angular.isDefined(response.status) && response.status === 201) { - toaster.pop({ - type: "success", - title: $translate.instant("TOASTER.SUCCESS_TITLE"), - body: $translate.instant("TOASTER.SUCCESS_ADD_BODY", {template: $translate.instant("TOASTER.FLAT")}), - showCloseButton: true, - }); - $scope.getAllFlats(); - } else { - toaster.pop({ - type: "error", - title: $translate.instant("TOASTER.ERROR_ADD_BODY", {template: $translate.instant("TOASTER.FLAT")}), - body: $translate.instant(response.data.description), - showCloseButton: true, - }); - } - }); - }, function() { - - }); - }; - - $scope.editFlat=function(flat){ - var modalInstance = $uibModal.open({ - windowClass: "animated fadeIn", - templateUrl: 'views/settings/tariff/flat.model.html', - controller: 'ModalEditFlatCtrl', - resolve: { - params:function(){ - return { - flat:angular.copy(flat), - flats:angular.copy($scope.flats) - }; - } - } - }); - - modalInstance.result.then(function (modifiedFlat) { - FlatService.editFlat(modifiedFlat, function (response) { - if(angular.isDefined(response.status) && response.status === 200){ - toaster.pop({ - type: "success", - title: $translate.instant("TOASTER.SUCCESS_TITLE"), - body: $translate.instant("TOASTER.SUCCESS_UPDATE_BODY", {template: $translate.instant("TOASTER.FLAT")}), - showCloseButton: true, - }); - $scope.getAllFlats(); - }else{ - toaster.pop({ - type: "error", - title: $translate.instant("TOASTER.ERROR_UPDATE_BODY", {template: $translate.instant("TOASTER.FLAT")}), - body: $translate.instant(response.data.description), - showCloseButton: true, - }); - } - }); - }, function () { - //do nothing; - }); - }; - - $scope.deleteFlat=function(flat){ - SweetAlert.swal({ - title: $translate.instant("SWEET.TITLE"), - text: $translate.instant("SWEET.TEXT"), - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - confirmButtonText: $translate.instant("SWEET.CONFIRM_BUTTON_TEXT"), - cancelButtonText: $translate.instant("SWEET.CANCEL_BUTTON_TEXT"), - closeOnConfirm: true, - closeOnCancel: true }, - function (isConfirm) { - if (isConfirm) { - FlatService.deleteFlat(flat, function (response) { - if (angular.isDefined(response.status) && response.status === 204) { - toaster.pop({ - type: "success", - title: $translate.instant("TOASTER.SUCCESS_TITLE"), - body: $translate.instant("TOASTER.SUCCESS_DELETE_BODY", {template: $translate.instant("TOASTER.FLAT")}), - showCloseButton: true, - }); - $scope.getAllFlats(); - } else { - toaster.pop({ - type: "error", - title: $translate.instant("TOASTER.ERROR_DELETE_BODY", {template: $translate.instant("TOASTER.FLAT")}), - body: $translate.instant(response.data.description), - showCloseButton: true, - }); - } - }); - } - }); - }; - - $scope.getAllFlats(); - - -}); - -app.controller('ModalAddFlatCtrl', function ($scope, $uibModalInstance,params) { - - $scope.operation="添加"; - $scope.flats=params.flats; - $scope.ok = function () { - $uibModalInstance.close($scope.flat); - }; - - $scope.cancel = function () { - $uibModalInstance.dismiss('cancel'); - }; -}); - -app.controller('ModalEditFlatCtrl', function ($scope, $uibModalInstance, params) { - $scope.operation="编辑"; - $scope.flat = params.flat; - $scope.flats=params.flats; - - $scope.ok = function () { - $uibModalInstance.close($scope.flat); - }; - - $scope.cancel = function () { - $uibModalInstance.dismiss('cancel'); - }; -}); \ No newline at end of file diff --git a/admin/app/controllers/settings/tariff/tariff.controller.js b/admin/app/controllers/settings/tariff/tariff.controller.js index 2b43c4f5..88ecd84c 100644 --- a/admin/app/controllers/settings/tariff/tariff.controller.js +++ b/admin/app/controllers/settings/tariff/tariff.controller.js @@ -1,7 +1,17 @@ 'use strict'; -app.controller('TariffController', function($scope,$uibModal,$translate, TARIFF_TYPE, PEAK_TYPE, TariffService, CategoryService, toaster, SweetAlert) { - +app.controller('TariffController', function( + $scope, + $window, + $uibModal, + $translate, + TARIFF_TYPE, + PEAK_TYPE, + TariffService, + CategoryService, + toaster, + SweetAlert) { + $scope.cur_user = JSON.parse($window.localStorage.getItem("myems_admin_ui_current_user")); $scope.getAllCategories = function() { CategoryService.getAllCategories(function (response) { if (angular.isDefined(response.status) && response.status === 200) { @@ -42,7 +52,8 @@ app.controller('TariffController', function($scope,$uibModal,$translate, TARIFF_ } }); modalInstance.result.then(function(tariff) { - TariffService.addTariff(tariff, function (response) { + let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token }; + TariffService.addTariff(tariff, headers, function (response) { if (angular.isDefined(response.status) && response.status === 201) { toaster.pop({ type: "success", @@ -82,7 +93,8 @@ app.controller('TariffController', function($scope,$uibModal,$translate, TARIFF_ }); modalInstance.result.then(function(modifiedTariff) { - TariffService.editTariff(modifiedTariff, function (response) { + let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token }; + TariffService.editTariff(modifiedTariff, headers, function (response) { if (angular.isDefined(response.status) && response.status === 200) { toaster.pop({ type: "success", @@ -119,7 +131,8 @@ app.controller('TariffController', function($scope,$uibModal,$translate, TARIFF_ }, function(isConfirm) { if (isConfirm) { - TariffService.deleteTariff(tariff, function (response) { + let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token }; + TariffService.deleteTariff(tariff, headers, function (response) { if (angular.isDefined(response.status) && response.status === 204) { toaster.pop({ type: "success", diff --git a/admin/app/services/settings/costcenter/costcenter.service.js b/admin/app/services/settings/costcenter/costcenter.service.js index 6adc79cf..fc307150 100644 --- a/admin/app/services/settings/costcenter/costcenter.service.js +++ b/admin/app/services/settings/costcenter/costcenter.service.js @@ -17,24 +17,24 @@ app.factory('CostCenterService', function($http) { callback(response); }); }, - addCostCenter: function(costcenter, callback) { - $http.post(getAPI()+'costcenters',{data:costcenter}) + addCostCenter: function(costcenter, headers, callback) { + $http.post(getAPI()+'costcenters',{data:costcenter}, {headers}) .then(function (response) { callback(response); }, function (response) { callback(response); }); }, - editCostCenter: function(costcenter, callback) { - $http.put(getAPI()+'costcenters/'+costcenter.id,{data:costcenter}) + editCostCenter: function(costcenter, headers, callback) { + $http.put(getAPI()+'costcenters/'+costcenter.id,{data:costcenter}, {headers}) .then(function (response) { callback(response); }, function (response) { callback(response); }); }, - deleteCostCenter: function(costcenter, callback) { - $http.delete(getAPI()+'costcenters/'+costcenter.id) + deleteCostCenter: function(costcenter, headers, callback) { + $http.delete(getAPI()+'costcenters/'+costcenter.id, {headers}) .then(function (response) { callback(response); }, function (response) { diff --git a/admin/app/services/settings/costcenter/costcentertariff.service.js b/admin/app/services/settings/costcenter/costcentertariff.service.js index 532af9f5..7c121a01 100644 --- a/admin/app/services/settings/costcenter/costcentertariff.service.js +++ b/admin/app/services/settings/costcenter/costcentertariff.service.js @@ -1,8 +1,8 @@ 'use strict'; app.factory('CostCenterTariffService', function($http) { return { - addPair: function(costcenterid,tariffid,callback) { - $http.post(getAPI()+'costcenters/'+costcenterid+'/tariffs',{data:{'tariff_id':tariffid}}) + addPair: function(costcenterid, tariffid, headers, callback ) { + $http.post(getAPI()+'costcenters/'+costcenterid+'/tariffs',{data:{'tariff_id':tariffid}}, {headers}) .then(function (response) { callback(response); }, function (response) { @@ -10,8 +10,8 @@ app.factory('CostCenterTariffService', function($http) { }); }, - deletePair: function(costcenterid,tariffid, callback) { - $http.delete(getAPI()+'costcenters/'+costcenterid+'/tariffs/'+tariffid) + deletePair: function(costcenterid, tariffid, headers, callback) { + $http.delete(getAPI()+'costcenters/'+costcenterid+'/tariffs/'+tariffid, {headers}) .then(function (response) { callback(response); }, function (response) { @@ -19,7 +19,7 @@ app.factory('CostCenterTariffService', function($http) { }); }, getTariffsByCostCenterID: function(id, callback) { - $http.get(getAPI()+'costcenters/'+id+'/tariffs') + $http.get(getAPI()+'costcenters/'+id+'/tariffs') .then(function (response) { callback(response); }, function (response) { diff --git a/admin/app/services/settings/tariff/flat.service.js b/admin/app/services/settings/tariff/flat.service.js deleted file mode 100644 index a853302c..00000000 --- a/admin/app/services/settings/tariff/flat.service.js +++ /dev/null @@ -1,53 +0,0 @@ -'use strict'; -app.factory('FlatService', function($http) { - return { - getAllFlats:function(callback){ - $http.get(getAPI()+'flats') - .then(function (response) { - callback(response); - }, function (response) { - callback(response); - }); - }, - searchFlats: function(query, callback) { - $http.get(getAPI()+'flats', { params: { q: query } }) - .then(function (response) { - callback(response); - }, function (response) { - callback(response); - }); - }, - addFlat: function(flat, callback) { - $http.post(getAPI()+'flats',{data:flat}) - .then(function (response) { - callback(response); - }, function (response) { - callback(response); - }); - }, - editFlat: function(flat, callback) { - $http.put(getAPI()+'flats/'+flat.id,{data:flat}) - .then(function (response) { - callback(response); - }, function (response) { - callback(response); - }); - }, - deleteFlat: function(flat, callback) { - $http.delete(getAPI()+'flats/'+flat.id) - .then(function (response) { - callback(response); - }, function (response) { - callback(response); - }); - }, - getFlat: function(id, callback) { - $http.get(getAPI()+'flats/'+id) - .then(function (response) { - callback(response); - }, function (response) { - callback(response); - }); - } - }; -}); \ No newline at end of file diff --git a/admin/app/services/settings/tariff/tariff.service.js b/admin/app/services/settings/tariff/tariff.service.js index ca4be90f..0848f124 100644 --- a/admin/app/services/settings/tariff/tariff.service.js +++ b/admin/app/services/settings/tariff/tariff.service.js @@ -17,24 +17,24 @@ app.factory('TariffService', function($http) { callback(response); }); }, - addTariff: function(tariff, callback) { - $http.post(getAPI()+'tariffs',{data:tariff}) + addTariff: function(tariff, headers, callback) { + $http.post(getAPI()+'tariffs',{data:tariff}, {headers}) .then(function (response) { callback(response); }, function (response) { callback(response); }); }, - editTariff: function(tariff, callback) { - $http.put(getAPI()+'tariffs/'+tariff.id,{data:tariff}) + editTariff: function(tariff, headers, callback) { + $http.put(getAPI()+'tariffs/'+tariff.id,{data:tariff}, {headers}) .then(function (response) { callback(response); }, function (response) { callback(response); }); }, - deleteTariff: function(tariff, callback) { - $http.delete(getAPI()+'tariffs/'+tariff.id) + deleteTariff: function(tariff, headers, callback) { + $http.delete(getAPI()+'tariffs/'+tariff.id, {headers}) .then(function (response) { callback(response); }, function (response) { diff --git a/admin/views/settings/tariff/flat.model.html b/admin/views/settings/tariff/flat.model.html deleted file mode 100644 index 987ab7da..00000000 --- a/admin/views/settings/tariff/flat.model.html +++ /dev/null @@ -1,19 +0,0 @@ -