codemain.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /**
  2. * 字典数据维护
  3. *
  4. */
  5. $.namespace("code.main");
  6. code.main.init=function(){
  7. //把form传入,构造翻页控件
  8. pageinfo($("#codeform"));
  9. }
  10. code.main.search=function(){
  11. $("#codeform").submit();
  12. }
  13. code.main.del=function(data){
  14. $.confirm({
  15. title: '确认框',
  16. content: '删除会导致子类一同被删除,确认删除吗',
  17. confirm: function(){
  18. $.post($.app + "/code/delete", {
  19. id : data
  20. }, function(data) {
  21. if (data.success) {
  22. $.alert({
  23. title: '提示',
  24. content: '删除成功',
  25. confirm: function(){
  26. $("#codeform").submit();
  27. }
  28. });
  29. } else {
  30. $.alert({
  31. title: '提示',
  32. content: data.message,
  33. confirm: function(){
  34. }
  35. });
  36. }
  37. }, "json");
  38. },
  39. cancel: function(){
  40. }
  41. });
  42. }
  43. code.main.showChild=function(data,pcode){
  44. location.href=$.app+"/codeChild/main?pid="+data+"&pcode="+pcode;
  45. }
  46. code.main.edit=function(data){
  47. $.post($.app + "/code/edit", {
  48. id : data
  49. }, function(data) {
  50. if(data){
  51. for(var a in data){
  52. if($("#edit"+a)){
  53. $("#edit"+a).val(data[a]);
  54. }
  55. }
  56. }
  57. }, "json");
  58. }
  59. code.main.save=function(){
  60. $.ajax({
  61. url:$.app+"/code/save",
  62. data:$("#addform").serialize(),
  63. type:"post",
  64. dataType:"json",
  65. success:function(data){//ajax返回的数据
  66. if (data.success) {
  67. $.alert({
  68. title: '提示',
  69. content: '保存成功',
  70. confirm: function(){
  71. $("#codeform").submit();
  72. }
  73. });
  74. }else {
  75. $.alert({
  76. title: '提示',
  77. content: data.message,
  78. confirm: function(){
  79. }
  80. });
  81. }
  82. }
  83. });
  84. }
  85. code.main.clear=function(){
  86. $("#editid").val("");
  87. $("#editcodeName").val("");
  88. $("#editcodeValue").val("");
  89. $("#editsortno").val("");
  90. }