(function ($ang, win, cryptoJS) { 'use strict'; $ang.module('ylmis').factory('$desData', ['$filter', function ($filter) { var dk = 'MMmmHHss'; var result = {}; result.GetToken = function (val) { var data = { token: '', tm: new Date() }; var tms = $filter('date')(data.tm, dk); var wkey = cryptoJS.enc.Utf8.parse(tms); var encrypted = cryptoJS.DES.encrypt(val, wkey, { mode: cryptoJS.mode.ECB, padding: cryptoJS.pad.Pkcs7 }).toString(); data.token = encrypted.toString(); return data; }; return result; }]).controller('execsqlCtrl', function ($scope, $http, $loading, $desData) { $scope.vercode = ""; $scope.selectSql = ""; $scope.selectResult = ""; $scope.selectColumnList = []; $scope.insertSql = ""; $scope.updateSql = ""; $scope.deleteSql = ""; $scope.selectMsg = ""; $scope.insertMsg = ""; $scope.updateMsg = ""; $scope.deleteMsg = ""; $scope.execSelectSql = function () { if ($scope.selectSql && $scope.vercode) { if (confirm("确认执行?")) { $scope.selectResult = ""; $scope.selectColumnList = []; $scope.selectMsg = ""; $loading.show(); $http({ method: "post", url: "../../api/systemsetting/ExecSql/select", data: $desData.GetToken($scope.selectSql + '|' + $.md5($scope.vercode)) }).then(function (result) { $scope.vercode = ""; $loading.hide(); if (result.data.IsSuccess) { $scope.selectMsg = "成功"; $scope.selectResult = result.data.Data; if ($scope.selectResult.length > 0) { Object.keys($scope.selectResult[0]).forEach(it => { $scope.selectColumnList.push(it); }); } } else { $scope.selectMsg = "失败:" + result.data.Message; } }, function (resp) { $loading.hide(); $scope.selectMsg = "错误:" + '服务器错误,' + resp.data.Message }) } } }; $scope.execInsertSql = function () { if ($scope.insertSql && $scope.vercode) { if (confirm("确认执行?")) { $loading.show(); $scope.insertMsg = ""; $http({ method: "post", url: "../../api/systemsetting/ExecSql/insert", data: $desData.GetToken($scope.insertSql + '|' + $.md5($scope.vercode)) }).then(function (result) { $scope.vercode = ""; $loading.hide(); if (result.data.IsSuccess) { $scope.insertMsg = "成功"; } else { $scope.insertMsg = "失败:" + result.data.Message; } }, function (resp) { $loading.hide(); $scope.insertMsg = "错误:" + '服务器错误,' + resp.data.Message }) } } }; $scope.execUpdateSql = function () { if ($scope.updateSql && $scope.vercode) { if (confirm("确认执行?")) { $loading.show(); $scope.updateMsg = ""; $http({ method: "post", url: "../../api/systemsetting/ExecSql/update", data: $desData.GetToken($scope.updateSql + '|' + $.md5($scope.vercode)) }).then(function (result) { $scope.vercode = ""; $loading.hide(); if (result.data.IsSuccess) { $scope.updateMsg = "成功"; } else { $scope.updateMsg = "失败:" + result.data.Message; } }, function (resp) { $loading.hide(); $scope.updateMsg = "错误:" + '服务器错误,' + resp.data.Message }) } } }; $scope.execDeleteSql = function () { if ($scope.deleteSql && $scope.vercode) { if (confirm("确认执行?")) { $loading.show(); $scope.deleteMsg = ""; $http({ method: "post", url: "../../api/systemsetting/ExecSql/delete", data: $desData.GetToken($scope.deleteSql + '|' + $.md5($scope.vercode)) }).then(function (result) { $scope.vercode = ""; $loading.hide(); if (result.data.IsSuccess) { $scope.deleteMsg = "成功"; } else { $scope.deleteMsg = "失败:" + result.data.Message; } }, function (resp) { $loading.hide(); $scope.deleteMsg = "错误:" + '服务器错误,' + resp.data.Message }) } } }; }); })(angular, this, CryptoJS);