reportArtifactLinks.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. function reportArtifactUrl(item = {}, kind) {
  2. if (kind === 'background') return item.backgroundReportUrl || ''
  3. if (kind === 'professional') return item.professionalReportUrl || ''
  4. if (kind === 'public') return item.publicReportUrl || item.fileUrl || ''
  5. return ''
  6. }
  7. function reportArtifactLinks(item = {}) {
  8. return {
  9. background: reportArtifactUrl(item, 'background'),
  10. professional: reportArtifactUrl(item, 'professional'),
  11. public: reportArtifactUrl(item, 'public')
  12. }
  13. }
  14. function reportArtifactDownloadUrl(url) {
  15. if (!url) return ''
  16. const separator = url.indexOf('?') >= 0 ? '&' : '?'
  17. return `${url}${separator}_download=${Date.now()}`
  18. }
  19. function safeTeamName(item = {}) {
  20. const teamName = String(item.teamName || '').trim()
  21. const safeName = teamName.replace(/[\u0000-\u001f\\/:*?"<>|]/g, '_')
  22. return Array.from(safeName || '未命名团队').slice(0, 60).join('')
  23. }
  24. function reportPreviewName(item = {}, kind) {
  25. const teamName = safeTeamName(item)
  26. if (kind === 'background') return `${teamName}_团队背景信息报告`
  27. if (kind === 'professional') return `${teamName}_PERILL评估报告_教练版`
  28. if (kind === 'public' && String(item.type) === '1') return `${teamName}_PERILL评估报告_个人版`
  29. if (kind === 'public') return `${teamName}_PERILL评估报告_团队版`
  30. return `${teamName}_PERILL评估报告`
  31. }
  32. function reportSelectorLabel(item = {}, kind) {
  33. if (kind === 'background') return '背景报告'
  34. if (kind === 'professional') return '教练报告'
  35. if (kind === 'public' && String(item.type) === '1') return '个人版报告'
  36. return '团队版报告'
  37. }
  38. module.exports = {
  39. reportArtifactUrl,
  40. reportArtifactLinks,
  41. reportArtifactDownloadUrl,
  42. reportPreviewName,
  43. reportSelectorLabel
  44. }