EditController.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. var app = angular.module('app',['baseServices','SysTransDefService','commonListService','arrayToolService']);
  2. app.controller("EditController",['$scope','BaseService','SysTransDef','CommonListService','ArrayToolService',function($scope,BaseService,SysTransDef,CommonListService,ArrayToolService){
  3. $scope.CommonList=CommonListService;
  4. $scope.ArrayTool=ArrayToolService;
  5. //对象
  6. $scope.prop={};
  7. $scope.prop.state=1;
  8. //页面用到的参数或临时变量
  9. $scope.param={};
  10. //检查sql语句的合法性
  11. $scope.checkSqlValidity=function(sql){
  12. sql=sql.replace(/{authorId}/g,"1");//先给当前用户随便赋值
  13. SqlUtil.checkValidity(sql,"LOCAL",false);
  14. }
  15. //初始化
  16. if(id!=""){
  17. SysTransDef.detail({id:id},function(data){
  18. $scope.prop=data;
  19. //初始化脚本编辑器
  20. InitMirror.getById("selectSql").insertCode(data.selectSql);
  21. InitMirror.getById("updateSql").insertCode(data.updateSql);
  22. InitMirror.getById("logContent").insertCode(data.logContent);
  23. });
  24. }
  25. //保存
  26. $scope.save=function(){
  27. var frm=$('#frmSubmit').form();
  28. if(!frm.valid()) return;
  29. $scope.prop.selectSql = InitMirror.getById("selectSql").getCode();
  30. $scope.prop.updateSql = InitMirror.getById("updateSql").getCode();
  31. $scope.prop.logContent = InitMirror.getById("logContent").getCode();
  32. SysTransDef.save($scope.prop,function(data){
  33. if(data.result==1){
  34. $.ligerDialog.confirm(data.message+",是否继续操作", "提示信息",
  35. function(rtn) {
  36. if (rtn) {
  37. window.location.reload();
  38. } else {
  39. window.location.href="list.ht";
  40. }
  41. });
  42. }else{
  43. $.ligerDialog.err("操作结果","出错信息",data.message);
  44. }
  45. });
  46. }
  47. //点击常用变量
  48. $scope.clickField=function(field){
  49. InitMirror.editor.insertCode(field.value);
  50. }
  51. //设置常用字段
  52. $scope.commonField=[
  53. {
  54. key:"授权人ID",
  55. value:"{authorId}"
  56. },
  57. {
  58. key:"授权人名称",
  59. value:"{authorName}"
  60. },
  61. {
  62. key:"目的人ID",
  63. value:"{targetPersonId}"
  64. },
  65. {
  66. key:"目的人名称",
  67. value:"{targetPersonName}"
  68. },
  69. {
  70. key:"所选id列表','分割",
  71. value:"{ids}"
  72. },
  73. {
  74. key:"所选name列表','分割",
  75. value:"{names}"
  76. }
  77. ];
  78. }]);