pm_ajax.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. const tenderCount = updateData.filter(item => item.updateType === 'new' && item.updateData.projType === projectType.tender).length;
  29. $.ajax({
  30. type:"POST",
  31. url: '/pm/api/updateProjects',
  32. data: {'data': JSON.stringify({"user_id": userID, "updateData": updateData, tenderCount})},
  33. dataType: 'json',
  34. cache: false,
  35. timeout: 50000,
  36. success: function(result){
  37. if (result.error === 0) {
  38. callback(result.data);
  39. } else {
  40. if (errCB) {
  41. errCB();
  42. }
  43. alert(result.message);
  44. }
  45. },
  46. error: function(jqXHR, textStatus, errorThrown){
  47. if (errCB) {
  48. errCB();
  49. }
  50. alert('error ' + textStatus + " " + errorThrown);
  51. }
  52. });
  53. };
  54. // 重命名项目
  55. var RenameProject_ajax = function(projId, newName, callback) {
  56. $.ajax({
  57. type: "POST",
  58. url: '/pm/api/renameProject',
  59. data: {'data': JSON.stringify({"user_id": userID, "id": projId, "newName": newName})},
  60. dataType: 'json',
  61. cache: false,
  62. timeout: 15000,
  63. success: function(result){
  64. if (result.error === 0) {
  65. callback();
  66. } else {
  67. alert('error' + result.message);
  68. }
  69. },
  70. error: function(iqXHR, textStatus, errorThrown){
  71. alert('error ' + textStatus + " " + errorThrown)
  72. }
  73. });
  74. };
  75. // 打开项目前,提交数据
  76. var BeforeOpenProject = function (projId, updateData, callback) {
  77. $.ajax({
  78. type: "POST",
  79. url: '/pm/api/beforeOpenProject',
  80. data: {'data': JSON.stringify({"user_id": userID, "proj_id": projId, "updateData": updateData})},
  81. dataType: 'json',
  82. cache: false,
  83. timeout: 15000,
  84. success: function (result) {
  85. if (result.error === 0) {
  86. callback();
  87. } else {
  88. alert('error' + result.message);
  89. }
  90. },
  91. error: function(iqXHR, textStatus, errorThrown){
  92. alert('error ' + textStatus + " " + errorThrown)
  93. }
  94. });
  95. }
  96. function moveProjects(data,callback) {
  97. CommonAjax.post( '/pm/api/moveProject',data,callback)
  98. }