main.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. $("#tempId td:first a").click(function () {
  17. $('#comple-ration').modal('hide');
  18. setTimeout(function () {
  19. let newHref = "/complementaryRation/ration?repository="+id;
  20. let newTab = window.open('about:blank');
  21. CommonAjax.get(newHref, [], function () {
  22. newTab.location.href = newHref;
  23. });
  24. }, 200);
  25. });
  26. $("#tempId").attr("id", id);
  27. }
  28. }
  29. };
  30. let ration_lib = projectObj.project.projectInfo.engineeringInfo.ration_lib;
  31. let ids = [];
  32. for(lib of ration_lib){
  33. ids.push(parseInt(lib.id));
  34. }
  35. CommonAjax.post('/complementaryRation/api/getRationLibs', {user_id: userID, ids: ids}, scFunc);
  36. }
  37. };
  38. $(document).ready(function () {
  39. $('#comple-ration').on('shown.bs.modal', function () {
  40. compleRationMain.getRationLibs();
  41. });
  42. });