index.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. (function ($ang, win, cryptoJS) {
  2. 'use strict';
  3. $ang.module('ylmis').factory('$desData', ['$filter', function ($filter) {
  4. var dk = 'MMmmHHss';
  5. var result = {};
  6. result.GetToken = function (val) {
  7. var data = { token: '', tm: new Date() };
  8. var tms = $filter('date')(data.tm, dk);
  9. var wkey = cryptoJS.enc.Utf8.parse(tms);
  10. var encrypted = cryptoJS.DES.encrypt(val, wkey, {
  11. mode: cryptoJS.mode.ECB,
  12. padding: cryptoJS.pad.Pkcs7
  13. }).toString();
  14. data.token = encrypted.toString();
  15. return data;
  16. };
  17. return result;
  18. }]).controller('execsqlCtrl', function ($scope, $http, $loading, $desData) {
  19. $scope.vercode = "";
  20. $scope.selectSql = "";
  21. $scope.selectResult = "";
  22. $scope.selectColumnList = [];
  23. $scope.insertSql = "";
  24. $scope.updateSql = "";
  25. $scope.deleteSql = "";
  26. $scope.selectMsg = "";
  27. $scope.insertMsg = "";
  28. $scope.updateMsg = "";
  29. $scope.deleteMsg = "";
  30. $scope.execSelectSql = function () {
  31. if ($scope.selectSql && $scope.vercode) {
  32. if (confirm("确认执行?")) {
  33. $scope.selectResult = "";
  34. $scope.selectColumnList = [];
  35. $scope.selectMsg = "";
  36. $loading.show();
  37. $http({
  38. method: "post",
  39. url: "../../api/systemsetting/ExecSql/select",
  40. data: $desData.GetToken($scope.selectSql + '|' + $.md5($scope.vercode))
  41. }).then(function (result) {
  42. $scope.vercode = "";
  43. $loading.hide();
  44. if (result.data.IsSuccess) {
  45. $scope.selectMsg = "成功";
  46. $scope.selectResult = result.data.Data;
  47. if ($scope.selectResult.length > 0) {
  48. Object.keys($scope.selectResult[0]).forEach(it =>
  49. {
  50. $scope.selectColumnList.push(it);
  51. });
  52. }
  53. } else {
  54. $scope.selectMsg = "失败:" + result.data.Message;
  55. }
  56. }, function (resp) {
  57. $loading.hide();
  58. $scope.selectMsg = "错误:" + '服务器错误,' + resp.data.Message
  59. })
  60. }
  61. }
  62. };
  63. $scope.execInsertSql = function () {
  64. if ($scope.insertSql && $scope.vercode) {
  65. if (confirm("确认执行?")) {
  66. $loading.show();
  67. $scope.insertMsg = "";
  68. $http({
  69. method: "post",
  70. url: "../../api/systemsetting/ExecSql/insert",
  71. data: $desData.GetToken($scope.insertSql + '|' + $.md5($scope.vercode))
  72. }).then(function (result) {
  73. $scope.vercode = "";
  74. $loading.hide();
  75. if (result.data.IsSuccess) {
  76. $scope.insertMsg = "成功";
  77. } else {
  78. $scope.insertMsg = "失败:" + result.data.Message;
  79. }
  80. }, function (resp) {
  81. $loading.hide();
  82. $scope.insertMsg = "错误:" + '服务器错误,' + resp.data.Message
  83. })
  84. }
  85. }
  86. };
  87. $scope.execUpdateSql = function () {
  88. if ($scope.updateSql && $scope.vercode) {
  89. if (confirm("确认执行?")) {
  90. $loading.show();
  91. $scope.updateMsg = "";
  92. $http({
  93. method: "post",
  94. url: "../../api/systemsetting/ExecSql/update",
  95. data: $desData.GetToken($scope.updateSql + '|' + $.md5($scope.vercode))
  96. }).then(function (result) {
  97. $scope.vercode = "";
  98. $loading.hide();
  99. if (result.data.IsSuccess) {
  100. $scope.updateMsg = "成功";
  101. } else {
  102. $scope.updateMsg = "失败:" + result.data.Message;
  103. }
  104. }, function (resp) {
  105. $loading.hide();
  106. $scope.updateMsg = "错误:" + '服务器错误,' + resp.data.Message
  107. })
  108. }
  109. }
  110. };
  111. $scope.execDeleteSql = function () {
  112. if ($scope.deleteSql && $scope.vercode) {
  113. if (confirm("确认执行?")) {
  114. $loading.show();
  115. $scope.deleteMsg = "";
  116. $http({
  117. method: "post",
  118. url: "../../api/systemsetting/ExecSql/delete",
  119. data: $desData.GetToken($scope.deleteSql + '|' + $.md5($scope.vercode))
  120. }).then(function (result) {
  121. $scope.vercode = "";
  122. $loading.hide();
  123. if (result.data.IsSuccess) {
  124. $scope.deleteMsg = "成功";
  125. } else {
  126. $scope.deleteMsg = "失败:" + result.data.Message;
  127. }
  128. }, function (resp) {
  129. $loading.hide();
  130. $scope.deleteMsg = "错误:" + '服务器错误,' + resp.data.Message
  131. })
  132. }
  133. }
  134. };
  135. });
  136. })(angular, this, CryptoJS);