| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- function reportArtifactUrl(item = {}, kind) {
- if (kind === 'background') return item.backgroundReportUrl || ''
- if (kind === 'professional') return item.professionalReportUrl || ''
- if (kind === 'public') return item.publicReportUrl || item.fileUrl || ''
- return ''
- }
- function reportArtifactLinks(item = {}) {
- return {
- background: reportArtifactUrl(item, 'background'),
- professional: reportArtifactUrl(item, 'professional'),
- public: reportArtifactUrl(item, 'public')
- }
- }
- function reportArtifactDownloadUrl(url) {
- if (!url) return ''
- const separator = url.indexOf('?') >= 0 ? '&' : '?'
- return `${url}${separator}_download=${Date.now()}`
- }
- function safeTeamName(item = {}) {
- const teamName = String(item.teamName || '').trim()
- const safeName = teamName.replace(/[\u0000-\u001f\\/:*?"<>|]/g, '_')
- return Array.from(safeName || '未命名团队').slice(0, 60).join('')
- }
- function reportPreviewName(item = {}, kind) {
- const teamName = safeTeamName(item)
- if (kind === 'background') return `${teamName}_团队背景信息报告`
- if (kind === 'professional') return `${teamName}_PERILL评估报告_教练版`
- if (kind === 'public' && String(item.type) === '1') return `${teamName}_PERILL评估报告_个人版`
- if (kind === 'public') return `${teamName}_PERILL评估报告_团队版`
- return `${teamName}_PERILL评估报告`
- }
- function reportSelectorLabel(item = {}, kind) {
- if (kind === 'background') return '背景报告'
- if (kind === 'professional') return '教练报告'
- if (kind === 'public' && String(item.type) === '1') return '个人版报告'
- return '团队版报告'
- }
- module.exports = {
- reportArtifactUrl,
- reportArtifactLinks,
- reportArtifactDownloadUrl,
- reportPreviewName,
- reportSelectorLabel
- }
|