SecQuestionCtrl.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. define(['app/app'], function (app) {
  2. 'use strict';
  3. app.register.controller('SecQuestionCtrl', ['$scope', 'ngTableParams', 'secQuestion', 'toaster', 'BaseService','$modal', function ($scope, ngTableParams, secQuestion, toaster, BaseService,$modal) {
  4. //table设置
  5. $scope.secQuestionTableParams = new ngTableParams({
  6. page : 1,
  7. count : 20
  8. }, {
  9. total : 0,
  10. getData : function ($defer, params) {
  11. const param = BaseService.parseParams(params.url());
  12. //param.status = $scope.status;
  13. //param.keyword = $scope.keyword;
  14. secQuestion.getPageInfo(param, function (data) {
  15. params.total(data.totalElements);
  16. $defer.resolve(data.content);
  17. }, function (response) {
  18. toaster.pop('error', '获取账户信息失败 ', response.data);
  19. });
  20. }
  21. });
  22. // 添加密保问题
  23. $scope.add = function() {
  24. openModal(null) ;
  25. }
  26. //编辑密保问题
  27. $scope.edit = function(id) {
  28. console.info(id);
  29. openModal(id) ;
  30. }
  31. var openModal = function(id) {
  32. var modalInstance = $modal.open({
  33. templateUrl : 'static/view/admin/modal/secQuestion_add_modal.html', //指向上面创建的视图
  34. controller : 'SecQuestionEditCtrl',// 初始化模态范围
  35. size : 'sm', // 大小配置
  36. resolve: {
  37. id: function() {
  38. return id;
  39. }
  40. }
  41. });
  42. modalInstance.opened.then(function(){// 模态窗口打开之后执行的函数
  43. });
  44. modalInstance.result.then(function(updatedProperty){
  45. $scope.propertiesTableParams.reload();
  46. }, function(res){
  47. });
  48. }
  49. //删除密保问题
  50. $scope.deleteSecQuestion = function (id) {
  51. secQuestion.deleteSecQuestion({id:id},function(){
  52. toaster.pop('success', '提示', '删除密保问题成功');
  53. location.reload();
  54. },function(response){
  55. toaster.pop('error', '提示', res.data);
  56. });
  57. }
  58. }]);
  59. app.register.controller('SecQuestionEditCtrl', ['$scope','id', '$modalInstance','ngTableParams', 'secQuestion', 'toaster', 'BaseService', function ($scope, id,$modalInstance,ngTableParams, secQuestion, toaster, BaseService) {
  60. $scope.addModal = true;
  61. $scope.updateModal = false;
  62. if (id) {
  63. secQuestion.get({id : id}, function(data) {
  64. $scope.secQuestion = data
  65. $scope.addModal = false;
  66. $scope.updateModal = true;
  67. }, function(res) {
  68. toaster.pop('error', '提示', '获取密保问题失败,请刷新页面');
  69. });
  70. }
  71. // 确认
  72. $scope.confirm = function() {
  73. // 更新属性
  74. if ($scope.secQuestion.id) {
  75. secQuestion.update({}, $scope.secQuestion, function(data) {
  76. toaster.pop('success', '提示', '修改密保问题成功');
  77. $modalInstance.close();
  78. location.reload();
  79. }, function(res) {
  80. toaster.pop('error', '提示', res.data);
  81. });
  82. } else {
  83. secQuestion.add({}, $scope.secQuestion, function(data) {
  84. toaster.pop('success', '提示', '添加密保问题成功');
  85. $modalInstance.close();
  86. location.reload();
  87. }, function(res) {
  88. toaster.pop('error', '提示', res.data);
  89. });
  90. }
  91. };
  92. $scope.cancel = function() {
  93. $modalInstance.dismiss();
  94. }
  95. }]);
  96. });