pm_ajax.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 GetAllUnitProjectData = function (params, callback) {
  28. $.ajax({
  29. type:"POST",
  30. url: '/pm/api/getAllUnitProjects',
  31. data: {'data': params},
  32. dataType: 'json',
  33. cache: false,
  34. timeout: 50000,
  35. success: function(result){
  36. if (result.error === 0) {
  37. callback(result.data);
  38. //Tree = $.fn.treeTable.init(table, ProjTreeSetting, result.data);
  39. } else {
  40. alert('error: ' + result.message);
  41. }
  42. },
  43. error: function(jqXHR, textStatus, errorThrown){
  44. alert('error ' + textStatus + " " + errorThrown);
  45. }
  46. });
  47. }
  48. // 更新数据到服务器
  49. var UpdateProjectData = function (updateData, callback, errCB) {
  50. const tenderCount = updateData.filter(item => item.updateType === 'new' && item.updateData.projType === projectType.tender).length;
  51. $.ajax({
  52. type:"POST",
  53. url: '/pm/api/updateProjects',
  54. data: {'data': JSON.stringify({"user_id": userID, "updateData": updateData, tenderCount})},
  55. dataType: 'json',
  56. cache: false,
  57. timeout: 50000,
  58. success: function(result){
  59. if (result.error === 0) {
  60. callback(result.data);
  61. } else {
  62. if (errCB) {
  63. errCB();
  64. }
  65. alert(result.message);
  66. }
  67. },
  68. error: function(jqXHR, textStatus, errorThrown){
  69. if (errCB) {
  70. errCB();
  71. }
  72. alert('error ' + textStatus + " " + errorThrown);
  73. }
  74. });
  75. };
  76. // 重命名项目
  77. var RenameProject_ajax = function(projId, newName, callback) {
  78. $.ajax({
  79. type: "POST",
  80. url: '/pm/api/renameProject',
  81. data: {'data': JSON.stringify({"user_id": userID, "id": projId, "newName": newName})},
  82. dataType: 'json',
  83. cache: false,
  84. timeout: 15000,
  85. success: function(result){
  86. if (result.error === 0) {
  87. callback();
  88. } else {
  89. alert('error' + result.message);
  90. }
  91. },
  92. error: function(iqXHR, textStatus, errorThrown){
  93. alert('error ' + textStatus + " " + errorThrown)
  94. }
  95. });
  96. };
  97. // 打开项目前,提交数据
  98. var BeforeOpenProject = function (projId, updateData, callback) {
  99. $.ajax({
  100. type: "POST",
  101. url: '/pm/api/beforeOpenProject',
  102. data: {'data': JSON.stringify({"user_id": userID, "proj_id": projId, "updateData": updateData})},
  103. dataType: 'json',
  104. cache: false,
  105. timeout: 15000,
  106. success: function (result) {
  107. if (result.error === 0) {
  108. callback();
  109. } else {
  110. alert('error' + result.message);
  111. }
  112. },
  113. error: function(iqXHR, textStatus, errorThrown){
  114. alert('error ' + textStatus + " " + errorThrown)
  115. }
  116. });
  117. }
  118. function moveProjects(data,callback) {
  119. CommonAjax.post( '/pm/api/moveProject',data,callback)
  120. }