browse.ui.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. $(document).off('click','.batch-btn').on('click', '.batch-btn', function()
  2. {
  3. const dtable = zui.DTable.query($(this).target);
  4. const checkedList = dtable.$.getChecks(); if(!checkedList.length) return;
  5. const url = $(this).data('url');
  6. const form = new FormData();
  7. checkedList.forEach((id) => form.append('opportunityIDList[]', id));
  8. if($(this).hasClass('ajax-btn'))
  9. {
  10. $.ajaxSubmit({url, data: form});
  11. }
  12. else
  13. {
  14. postAndLoadPage(url, form);
  15. }
  16. }).off('click', '#actionBar .export-btn').on('click', '#actionBar export-btn', function()
  17. {
  18. const dtable = zui.DTable.query($('#table-opportunity-browse'));
  19. const checkedList = dtable ? dtable.$.getChecks() : [];
  20. if(!checkedList.length) return;
  21. $.cookie.set('checkedItem', checkedList, {expires:config.cookieLife, path:config.webRoot});
  22. });
  23. window.getCheckedOpportunityIDList = function()
  24. {
  25. var opportunityIDList = '';
  26. const dtable = zui.DTable.query('#table-opportunity-browse');
  27. $.each(dtable.$.getChecks(), function(index, opportunityID)
  28. {
  29. if(index > 0) opportunityIDList += ',';
  30. opportunityIDList += opportunityID;
  31. });
  32. $('[name=opportunityIDList]').val(opportunityIDList);
  33. }