browse.ui.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. window.programMenuOnClick = function(data, url)
  2. {
  3. location.href = url.replace('%d', data.item.key);
  4. }
  5. window.renderCell = function(result, {col, row})
  6. {
  7. if(col.name === 'name')
  8. {
  9. if(row.data.delay > 0)
  10. {
  11. result[0].props.className = 'overflow-hidden';
  12. result[result.length] = {html:'<span class="label danger-pale ml-1 flex-none nowrap">' + delayWarning.replace('%s', row.data.delay) + '</span>', className:'flex items-end', style:{flexDirection:"column"}};
  13. }
  14. return result;
  15. }
  16. if(col.name === 'invested')
  17. {
  18. result[result.length] = {html:'<span class="text-gray text-xs">' + langManDay + '</span>'};
  19. return result;
  20. }
  21. return result;
  22. }
  23. $(document).off('click', '#table-project-browse .batch-btn').on('click', '#table-project-browse .batch-btn', function()
  24. {
  25. const dtable = zui.DTable.query($(this).target);
  26. const checkedList = dtable.$.getChecks();
  27. if(!checkedList.length) return;
  28. const form = new FormData();
  29. const url = $(this).data('url');
  30. checkedList.forEach((id) => form.append('projectIdList[]', id));
  31. postAndLoadPage(url, form);
  32. }).off('click', '#actionBar .export').on('click', '#actionBar .export', function()
  33. {
  34. const dtable = zui.DTable.query($('#table-project-browse'));
  35. const checkedList = dtable ? dtable.$.getChecks() : [];
  36. if(!checkedList.length) return;
  37. $.cookie.set('checkedItem', checkedList, {expires:config.cookieLife, path:config.webRoot});
  38. });
  39. $(document).off('click', '.switchButton').on('click', '.switchButton', function()
  40. {
  41. var projectType = $(this).attr('data-type');
  42. $.cookie.set('projectType', projectType, {expires:config.cookieLife, path:config.webRoot});
  43. loadCurrentPage();
  44. });
  45. $(document).on('click', 'input[name=involved]', function()
  46. {
  47. var involved = $(this).is(':checked') ? 1 : 0;
  48. $.cookie.set('involved', involved, {expires:config.cookieLife, path:config.webRoot});
  49. loadTable();
  50. });
  51. /**
  52. * 提示并删除项目。
  53. * Delete project with tips.
  54. *
  55. * @param int projectID
  56. * @param string projectName
  57. * @access public
  58. * @return void
  59. */
  60. window.confirmDelete = function(projectID, projectName)
  61. {
  62. zui.Modal.confirm({message: confirmDeleteTip.replace('%s', projectName), icon:'icon-exclamation-sign', iconClass: 'warning-pale rounded-full icon-2x'}).then((res) =>
  63. {
  64. if(res) $.ajaxSubmit({url: $.createLink('project', 'delete', 'projectID=' + projectID)});
  65. });
  66. }
  67. window.changeProgram = function()
  68. {
  69. const programID = $('input[name=programID]').val();
  70. const link = $.createLink('project', 'browse', 'programID=' + programID + '&browseType=' + browseType + '&param=' + param + '&orderBy=order_asc&recTotal=' + recTotal + '&recPerPage=' + recPerPage + '&pageID=' + pageID);
  71. loadPage(link);
  72. }