您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

pkguidedit.controller.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. angular.module('app')
  2. .controller('PkGuidEditController', ['$scope', '$state', '$mdDialog', 'pkGuidBusiness', 'AppUtilsBusiness',
  3. function ($scope, $state, $mdDialog, pkGuidBusiness, AppUtilsBusiness) {
  4. $scope.pkguid = null;
  5. $scope.defaultPkguid = {
  6. id: null,
  7. someText: "Test.",
  8. someInt: 42
  9. };
  10. $scope.running = false;
  11. $scope.error = null;
  12. $scope.setTitle = function()
  13. {
  14. if ($scope.pkguid.id != null) {
  15. AppUtilsBusiness.setTitle(AppUtilsBusiness.tr('pkguid.edit.title', {text: $scope.pkguid.someText}));
  16. AppUtilsBusiness.setToolbarTitle(AppUtilsBusiness.tr('pkguid.edit.toolbarTitle', {text: $scope.pkguid.someText}));
  17. }
  18. };
  19. $scope.submit = function () {
  20. $scope.error = null;
  21. $scope.running = true;
  22. if ($scope.pkguid.id == null) {
  23. pkGuidBusiness.addDbo($scope.pkguid).then(function (data) {
  24. $scope.running = false;
  25. $state.go('pkguid_edit', {pkguid: data, id: data.id});
  26. }, function (error) {
  27. $scope.running = false;
  28. $scope.error = error;
  29. });
  30. }
  31. else {
  32. pkGuidBusiness.editSingleByIdDbo($scope.pkguid.id, $scope.pkguid).then(function (data) {
  33. $scope.running = false;
  34. $scope.pkguid = data;
  35. $scope.setTitle();
  36. }, function (error) {
  37. $scope.running = false;
  38. $scope.error = error;
  39. });
  40. }
  41. };
  42. if ($state.params != null) {
  43. if ($state.params.pkguid != null) {
  44. $scope.pkguid = $state.params.pkguid;
  45. $scope.setTitle();
  46. }
  47. else if ($state.params.id != null) {
  48. $scope.running = true;
  49. pkGuidBusiness.getSingleById($state.params.id).then(function(data)
  50. {
  51. $scope.running = false;
  52. $scope.pkguid = data;
  53. $scope.setTitle();
  54. }, function (error) {
  55. $scope.running = false;
  56. $scope.error = error;
  57. $scope.pkguid = null;
  58. $scope.setTitle();
  59. });
  60. }
  61. else {
  62. $scope.pkguid = angular.copy($scope.defaultPkguid);
  63. $scope.setTitle();
  64. }
  65. }
  66. else {
  67. $scope.pkguid = angular.copy($scope.defaultPkguid);
  68. $scope.setTitle();
  69. }
  70. }]);