schedule_info.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /**
  2. * 初始化定时任务详情对话框
  3. */
  4. var ScheduleInfoDlg = {
  5. scheduleInfoData : {}
  6. };
  7. /**
  8. * 清除数据
  9. */
  10. ScheduleInfoDlg.clearData = function() {
  11. this.scheduleInfoData = {};
  12. }
  13. /**
  14. * 设置对话框中的数据
  15. *
  16. * @param key 数据的名称
  17. * @param val 数据的具体值
  18. */
  19. ScheduleInfoDlg.set = function(key, val) {
  20. this.scheduleInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
  21. return this;
  22. }
  23. /**
  24. * 设置对话框中的数据
  25. *
  26. * @param key 数据的名称
  27. * @param val 数据的具体值
  28. */
  29. ScheduleInfoDlg.get = function(key) {
  30. return $("#" + key).val();
  31. }
  32. /**
  33. * 关闭此对话框
  34. */
  35. ScheduleInfoDlg.close = function() {
  36. parent.layer.close(window.parent.Schedule.layerIndex);
  37. }
  38. /**
  39. * 收集数据
  40. */
  41. ScheduleInfoDlg.collectData = function() {
  42. this
  43. .set('id')
  44. .set('name')
  45. .set('url')
  46. .set('timeStr')
  47. .set('state')
  48. .set('description');
  49. }
  50. /**
  51. * 提交添加
  52. */
  53. ScheduleInfoDlg.addSubmit = function() {
  54. this.clearData();
  55. this.collectData();
  56. //提交信息
  57. var ajax = new $ax(Feng.ctxPath + "/schedule/add", function(data){
  58. Feng.success("添加成功!");
  59. window.parent.Schedule.table.refresh();
  60. ScheduleInfoDlg.close();
  61. },function(data){
  62. Feng.error("添加失败!" + data.responseJSON.message + "!");
  63. });
  64. ajax.set(this.scheduleInfoData);
  65. ajax.start();
  66. }
  67. /**
  68. * 提交修改
  69. */
  70. ScheduleInfoDlg.editSubmit = function() {
  71. this.clearData();
  72. this.collectData();
  73. //提交信息
  74. var ajax = new $ax(Feng.ctxPath + "/schedule/update", function(data){
  75. Feng.success("修改成功!");
  76. window.parent.Schedule.table.refresh();
  77. ScheduleInfoDlg.close();
  78. },function(data){
  79. Feng.error("修改失败!" + data.responseJSON.message + "!");
  80. });
  81. ajax.set(this.scheduleInfoData);
  82. ajax.start();
  83. }
  84. $(function() {
  85. $("select").each(function () {
  86. $(this).val($(this).attr("selectVal"));
  87. });
  88. });