main.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * Created by Zhong on 2017/12/22.
  3. */
  4. let compleRationMain = {
  5. getRationLibs: function () {
  6. let scFunc = function (rstData) {
  7. $("#comple_ration_table").empty();
  8. for(let i = 0; i < rstData.length; i++){
  9. if(rstData[i].gljLib !== undefined && rstData[i].gljLib && rstData[i].gljLib != -1){
  10. let id = rstData[i].ID;
  11. let libName = rstData[i].dispName;
  12. $("#comple_ration_table").append(
  13. "<tr id='tempId'>" +
  14. "<td><a href='javascript:void(0);'>"+libName+"</a></td></tr>"
  15. );
  16. var newHref = "/complementaryRation/ration?repository="+id;
  17. $("#tempId td:first a").click(function () {
  18. $('#comple-ration').modal('hide');
  19. setTimeout(function () {
  20. let newHref = "/complementaryRation/ration?repository="+id;
  21. let newTab = window.open('about:blank');
  22. CommonAjax.get(newHref, [], function () {
  23. newTab.location.href = newHref;
  24. });
  25. }, 200);
  26. });
  27. $("#tempId").attr("id", id);
  28. }
  29. }
  30. };
  31. let ration_lib = projectInfoObj.projectInfo.engineeringInfo.ration_lib;
  32. let ids = [];
  33. for(lib of ration_lib){
  34. ids.push(parseInt(lib.id));
  35. }
  36. CommonAjax.post('/complementaryRation/api/getRationLibs', {user_id: userID, ids: ids}, scFunc);
  37. }
  38. };
  39. $(document).ready(function () {
  40. $('#comple-ration').on('shown.bs.modal', function () {
  41. compleRationMain.getRationLibs();
  42. });
  43. });