BillAdminCtrl.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. define(['app/app'], function(app) {
  2. 'use strict'
  3. app.register.controller('BillAdminCtrl', ['$scope','BaseService', 'Bill', 'toaster', '$modal', '$state', function($scope, BaseService, Bill, toaster, $modal, $state) {
  4. BaseService.scrollBackToTop();
  5. $scope.getData = function() {
  6. Bill.getListPersonal(null, function(data) {
  7. $scope.normalBill = {};
  8. $scope.specialBill = {};
  9. angular.forEach(data, function(bill) {
  10. if(bill.kind == 1205) {
  11. $scope.specialBill = bill;
  12. } else {
  13. $scope.normalBill = bill;
  14. }
  15. });
  16. }, function(response) {
  17. toaster.pop('error', '获取发票信息失败 ' + response.data);
  18. });
  19. }
  20. $scope.getData();
  21. $scope.deleteById = function(id) {
  22. var bool = confirm("确定要删除吗?");
  23. if(!bool) {
  24. return ;
  25. }
  26. Bill.deleteById({id: id}, function(data) {
  27. toaster.pop('success', '删除成功');
  28. $scope.getData();
  29. }, function(reponse) {
  30. toaster.pop('error', '删除发票资料失败');
  31. });
  32. }
  33. $scope.detail = function(bill) {
  34. var modalInstance = $modal.open({
  35. templateUrl : 'static/view/common/billInfoModal.html',
  36. controller : 'BillInfoCtrl',
  37. resolve : {
  38. bill : function() {
  39. //深拷贝一份
  40. return angular.copy(bill);
  41. }
  42. }
  43. });
  44. }
  45. $scope.revise = function(id) {
  46. $state.go('bill_input', {id: id});
  47. }
  48. }]);
  49. app.register.controller('BillInfoCtrl', ['$scope', '$modalInstance', 'bill', function($scope, $modalInstance, bill) {
  50. $scope.bill = bill;
  51. $scope.dismiss = function() {
  52. $modalInstance.dismiss();
  53. }
  54. }]);
  55. })