Digital Office Automation System Backend
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

jobcode.index.1.js 2.2KB

1 day ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. $(function() {
  2. // init code editor
  3. var codeEditor;
  4. function initIde(glueSource) {
  5. if (codeEditor == null) {
  6. codeEditor = CodeMirror(document.getElementById("ideWindow"), {
  7. mode : ideMode,
  8. lineNumbers : true,
  9. matchBrackets : true,
  10. value: glueSource
  11. });
  12. } else {
  13. codeEditor.setValue(glueSource);
  14. }
  15. }
  16. initIde($("#version_now").val());
  17. // code change
  18. $(".source_version").click(function(){
  19. var sourceId = $(this).attr('version');
  20. var temp = $( "#" + sourceId ).val();
  21. //codeEditor.setValue('');
  22. initIde(temp);
  23. });
  24. // code source save
  25. $("#save").click(function() {
  26. $('#saveModal').modal({backdrop: false, keyboard: false}).modal('show');
  27. });
  28. $("#saveModal .ok").click(function() {
  29. var glueSource = codeEditor.getValue();
  30. var glueRemark = $("#glueRemark").val();
  31. if (!glueRemark) {
  32. layer.open({
  33. title: I18n.system_tips,
  34. btn: [ I18n.system_ok],
  35. content: I18n.system_please_input + I18n.jobinfo_glue_remark ,
  36. icon: '2'
  37. });
  38. return;
  39. }
  40. if (glueRemark.length <4 || glueRemark.length > 100) {
  41. layer.open({
  42. title: I18n.system_tips ,
  43. btn: [ I18n.system_ok ],
  44. content: I18n.jobinfo_glue_remark_limit ,
  45. icon: '2'
  46. });
  47. return;
  48. }
  49. $.ajax({
  50. type : 'POST',
  51. url : base_url + '/jobcode/save',
  52. data : {
  53. 'id' : id,
  54. 'glueSource' : glueSource,
  55. 'glueRemark' : glueRemark
  56. },
  57. dataType : "json",
  58. success : function(data){
  59. if (data.code == 200) {
  60. layer.open({
  61. title: I18n.system_tips,
  62. btn: [ I18n.system_ok ],
  63. content: (I18n.system_save + I18n.system_success) ,
  64. icon: '1',
  65. end: function(layero, index){
  66. //$(window).unbind('beforeunload');
  67. window.location.reload();
  68. }
  69. });
  70. } else {
  71. layer.open({
  72. title: I18n.system_tips,
  73. btn: [ I18n.system_ok ],
  74. content: (data.msg || (I18n.system_save + I18n.system_fail) ),
  75. icon: '2'
  76. });
  77. }
  78. }
  79. });
  80. });
  81. // before upload
  82. /*$(window).bind('beforeunload',function(){
  83. return 'Glue尚未保存,确定离开Glue编辑器?';
  84. });*/
  85. });