basic2.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. var SVR_URL = "/server/"; //http://172.30.84.3:8803
  2. if(location.host.indexOf("niimei") === -1){
  3. SVR_URL = "http://172.30.84.3:8803/server/";
  4. }
  5. function get_data(url, callback) {
  6. $.ajax({
  7. url: SVR_URL + url,
  8. apiName: url,
  9. sendTime: new Date()
  10. }).done(callback).fail(on_fail);
  11. }
  12. function on_fail(msg) {
  13. alert("很抱歉,网络错误,请查看Console");
  14. console.log("----- 网络请求失败 ---------")
  15. console.log(JSON.stringify(this));
  16. console.log("----------------------------")
  17. }
  18. function on_data_success(obj, status) {
  19. }
  20. function first_parse(ajax, obj) {
  21. if (typeof obj === "string") {
  22. obj = JSON.parse(obj);
  23. }
  24. if (typeof obj !== "object") {
  25. console.log(ajax);
  26. throw "Error ! Parsing JSON failed ." + JSON.stringify(obj);
  27. }
  28. if (obj.ret == "10000" || obj.ret == 10000 || obj.ret == 1000) {
  29. return obj.model;
  30. } else {
  31. console.log(ajax);
  32. throw "Error ! Server returned error." + JSON.stringify(obj);
  33. }
  34. }
  35. function on_document_load() {
  36. firsttime_load_spots_data();
  37. secondtime_load_spots_data();
  38. }
  39. function firsttime_load_spots_data() {
  40. get_data("fcFlow/list", first_success)
  41. }
  42. var flowID=[];
  43. var flowname=[];
  44. var periodID=[];
  45. var periodname=[];
  46. function first_success(obj, sta) {
  47. var output = first_parse(this, obj);
  48. //在这里排序 spo\
  49. console.log(" output : ");
  50. console.log(output);
  51. var i,j,k;
  52. j=0;
  53. k=0;
  54. for(i=0;i<output.list.length;i++){
  55. if(userId==output.list[i].flowMasterId){
  56. flowID[j]=output.list[i].flowId;
  57. flowname[j]=output.list[i].flowName;
  58. j++;
  59. }
  60. else {
  61. k++;
  62. }
  63. }
  64. if(k==output.list.length-1){
  65. alert("无权限访问!");
  66. }
  67. showEachSpot();
  68. showEachSpot1();
  69. }
  70. function secondtime_load_spots_data() {
  71. get_data("fcWorkPeriod/list", second_success);
  72. }
  73. function thirdtime_load_spots_data() {
  74. get_data("fcWorkSchedule/list", third_success);
  75. }
  76. function second_success(obj, sta) {
  77. var history = first_parse(this, obj);
  78. var i, j;
  79. console.log(" history : ");
  80. console.log(history);
  81. for(i=0;i<history.length;i++){
  82. periodID[i]=history[i].periodId;
  83. periodname[i]=history[i].periodName;
  84. }
  85. thirdtime_load_spots_data();
  86. }
  87. var scheduleID;
  88. function second_success(obj, sta) {
  89. var history = first_parse(this, obj);
  90. var i, j;
  91. console.log(" history : ");
  92. console.log(history);
  93. for(i=0;i<history.list.length;i++){
  94. if(flowID[i]==history.list[i].flowId&&periodID[i]==history.list[i].periodId){
  95. scheduleID=history.list[i].scheduleId;
  96. }
  97. }
  98. }