sysQuerySqlController.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. var sysQuerySqlApp = angular.module('sysQuerySqlApp', [ 'baseServices','DataRightsApp','sysQuerySqlServiceApp' ]);
  2. sysQuerySqlApp.controller('sysQuerySqlCtrl',['$scope','BaseService','sysQuerySqlService','$timeout',function($scope,BaseService,sysQuerySqlService,$timeout){
  3. var service = sysQuerySqlService;
  4. $scope.buttonKey = 'urlParams';
  5. $scope.service = service;
  6. $timeout(function(){
  7. $scope.tab =$("#tab").ligerTab({contextmenu:false});
  8. $scope.hasInitTab = 124;
  9. $scope.$digest();
  10. },100)
  11. service.init($scope);
  12. $scope.save = function(){
  13. var form = $('#sysQuerySqlForm');
  14. if (!form.valid()) return;
  15. if (service.validSql(false)) {
  16. service.customFormSubmit($scope.buttonKey);
  17. }
  18. }
  19. }])
  20. .controller('sysQuerySqlDefCtrl',['$scope','sysQuerySqlService','$timeout',function($scope,sysQuerySqlService,$timeout){
  21. var service = sysQuerySqlService;
  22. $scope.buttonKey = 'buttonDef';
  23. $scope.service = service;
  24. $timeout(function(){
  25. $scope.tab =$("#tab").ligerTab({contextmenu:false});
  26. $scope.hasInitTab = 124;
  27. $scope.$digest();
  28. },100);
  29. service.init($scope);
  30. $scope.save = function(){
  31. var form = $('#sysQuerySqlForm');
  32. if (!form.valid()) return;
  33. if (service.validSql(false)) {
  34. service.customFormSubmit($scope.buttonKey);
  35. }
  36. }
  37. $scope.setVirtualField = function(isVirtual){
  38. if(!isVirtual) return;
  39. }
  40. //sysQueryFields
  41. }])
  42. .controller('sysQuerySqlUrlCtrl',['$scope','sysQuerySqlService','dataRightsService',function($scope,sysQuerySqlService,dataRightsService){
  43. var dialog = frameElement.dialog; //调用页面的dialog对象(ligerui对象)
  44. var conf =dialog.get('conf');
  45. var service = sysQuerySqlService;
  46. $scope.service = service;
  47. $scope.service.util = dataRightsService;
  48. $scope.sysQueryFields = conf.sysQueryFields;
  49. $scope.urlParams = conf.urlParams?parseToJson(conf.urlParams):[];
  50. $scope.save = function(){
  51. dialog.get('sucCall')(JSON2.stringify($scope.urlParams));
  52. dialog.close();
  53. }
  54. $scope.close = function(){
  55. dialog.close();
  56. }
  57. $scope.add = function(){
  58. $scope.urlParams.push({});
  59. }
  60. }])
  61. .directive('fieldSort', ['$timeout',function($timeout){
  62. function sortNumber(row1, row2){
  63. return row1.sn - row2.sn;
  64. }
  65. var link = function($scope, $element, $attrs, $ctrl){
  66. var field=$attrs.ngModel;
  67. var timeout;
  68. $scope.$watch(field,function(newVal){
  69. if (timeout) {
  70. $timeout.cancel(timeout);
  71. }
  72. timeout = $timeout(function() {
  73. var rows=$scope.$parent.sysQueryFields;
  74. rows.sort(sortNumber)
  75. }, 500);
  76. });
  77. }
  78. return {
  79. require:"ngModel",
  80. link:link
  81. }
  82. }]);