pm_ajax.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /**
  2. * Created by Mai on 2017/3/8.
  3. */
  4. // 获取用户全部项目数据
  5. var GetAllProjectData = function (callback) {
  6. $.ajax({
  7. type:"POST",
  8. url: '/pm/api/getProjects',
  9. data: {'data': JSON.stringify({"user_id": userID, "compilation": compilationData._id})},
  10. dataType: 'json',
  11. cache: false,
  12. timeout: 50000,
  13. success: function(result){
  14. if (result.error === 0) {
  15. callback(result.data);
  16. //Tree = $.fn.treeTable.init(table, ProjTreeSetting, result.data);
  17. } else {
  18. alert('error: ' + result.message);
  19. }
  20. },
  21. error: function(jqXHR, textStatus, errorThrown){
  22. alert('error ' + textStatus + " " + errorThrown);
  23. }
  24. });
  25. }
  26. // 更新数据到服务器
  27. var UpdateProjectData = function (updateData, callback, errCB) {
  28. $.ajax({
  29. type:"POST",
  30. url: '/pm/api/updateProjects',
  31. data: {'data': JSON.stringify({"user_id": userID, "updateData": updateData})},
  32. dataType: 'json',
  33. cache: false,
  34. timeout: 50000,
  35. success: function(result){
  36. if (result.error === 0) {
  37. callback(result.data);
  38. } else {
  39. if (errCB) {
  40. errCB();
  41. }
  42. alert('error: ' + result.message);
  43. }
  44. },
  45. error: function(jqXHR, textStatus, errorThrown){
  46. if (errCB) {
  47. errCB();
  48. }
  49. alert('error ' + textStatus + " " + errorThrown);
  50. }
  51. });
  52. };
  53. // 重命名项目
  54. var RenameProject_ajax = function(projId, newName, callback) {
  55. $.ajax({
  56. type: "POST",
  57. url: '/pm/api/renameProject',
  58. data: {'data': JSON.stringify({"user_id": userID, "id": projId, "newName": newName})},
  59. dataType: 'json',
  60. cache: false,
  61. timeout: 15000,
  62. success: function(result){
  63. if (result.error === 0) {
  64. callback();
  65. } else {
  66. alert('error' + result.message);
  67. }
  68. },
  69. error: function(iqXHR, textStatus, errorThrown){
  70. alert('error ' + textStatus + " " + errorThrown)
  71. }
  72. });
  73. };
  74. // 打开项目前,提交数据
  75. var BeforeOpenProject = function (projId, updateData, callback) {
  76. $.ajax({
  77. type: "POST",
  78. url: '/pm/api/beforeOpenProject',
  79. data: {'data': JSON.stringify({"user_id": userID, "proj_id": projId, "updateData": updateData})},
  80. dataType: 'json',
  81. cache: false,
  82. timeout: 15000,
  83. success: function (result) {
  84. if (result.error === 0) {
  85. callback();
  86. } else {
  87. alert('error' + result.message);
  88. }
  89. },
  90. error: function(iqXHR, textStatus, errorThrown){
  91. alert('error ' + textStatus + " " + errorThrown)
  92. }
  93. });
  94. }
  95. function moveProjects(data,callback) {
  96. CommonAjax.post( '/pm/api/moveProject',data,callback)
  97. }