File size: 7,823 Bytes
61fd574
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
import { useState } from 'react'

const RADIUS = 40
const CIRCUMFERENCE = 2 * Math.PI * RADIUS

function MatchRing({ rate }) {
  const color = rate >= 80 ? '#10B981' : rate >= 60 ? '#F59E0B' : '#EF4444'
  const offset = CIRCUMFERENCE * (1 - rate / 100)

  return (
    <svg width="96" height="96" viewBox="0 0 96 96">
      <circle cx="48" cy="48" r={RADIUS} fill="none" stroke="#E5E7EB" strokeWidth="8" />
      <circle
        cx="48" cy="48" r={RADIUS}
        fill="none"
        stroke={color}
        strokeWidth="8"
        strokeDasharray={CIRCUMFERENCE}
        strokeDashoffset={offset}
        strokeLinecap="round"
        transform="rotate(-90 48 48)"
        style={{ transition: 'stroke-dashoffset 0.6s ease' }}
      />
      <text
        x="48" y="48"
        textAnchor="middle"
        dominantBaseline="central"
        fontSize="20"
        fontWeight="700"
        fill={color}
      >
        {rate}%
      </text>
    </svg>
  )
}

function MatchBreakdown({ detail, rate }) {
  if (!detail) return null
  const bars = [
    { key: 'semantic', label: '语义匹配', weight: 40, color: '#6366F1' },
    { key: 'tags', label: '技能匹配', weight: 35, color: '#10B981' },
    { key: 'education', label: '学历匹配', weight: 25, color: '#F59E0B' },
  ]
  return (
    <div className="mt-16" style={{ padding: '12px 16px', backgroundColor: '#FFFFFF', borderRadius: 'var(--radius-sm)', border: '1px solid #E5E7EB' }}>
      <div className="flex-between mb-8">
        <h4 className="font-bold text-sm">匹配度计算</h4>
        <span className="text-xs text-light">总分 = 语义×40% + 技能×35% + 学历×25%</span>
      </div>
      {bars.map(b => {
        const val = detail[b.key] || 0
        const pct = Math.round(val * 100)
        return (
          <div key={b.key} className="flex items-center gap-8 mb-6">
            <span className="text-xs" style={{ width: 56, flexShrink: 0 }}>{b.label}</span>
            <div style={{ flex: 1, height: 8, backgroundColor: '#F3F4F6', borderRadius: 4, overflow: 'hidden' }}>
              <div style={{ width: pct + '%', height: '100%', backgroundColor: b.color, borderRadius: 4, transition: 'width 0.5s ease' }} />
            </div>
            <span className="text-xs font-bold" style={{ width: 32, textAlign: 'right', color: b.color }}>{pct}%</span>
            <span className="text-xs text-light" style={{ width: 28, textAlign: 'right' }}>×{b.weight}%</span>
          </div>
        )
      })}
      <div className="flex-between mt-8" style={{ borderTop: '1px solid #E5E7EB', paddingTop: 8 }}>
        <span className="text-sm font-bold">最终匹配度</span>
        <span className="text-sm font-bold" style={{ color: rate >= 80 ? '#10B981' : rate >= 60 ? '#F59E0B' : '#EF4444' }}>{rate}%</span>
      </div>
    </div>
  )
}
function ExpectationSignals({ signals }) {
  if (!signals || signals.length === 0) return null
  return (
    <div className="mt-12">
      <h4 className="font-bold text-sm mb-8">岗位画像</h4>
      <div className="flex flex-wrap gap-8">
        {signals.map((signal, i) => (
          <div key={i} className="tag" style={{
            display: 'flex', flexDirection: 'column', gap: 4,
            padding: '8px 12px', backgroundColor: '#EEF2FF',
            border: '1px solid #C7D2FE', borderRadius: 'var(--radius-sm)'
          }}>
            <span className="text-sm font-bold" style={{ color: '#4338CA' }}>{signal.name || signal.tag}</span>
            {signal.evidence && (
              <span className="text-xs text-secondary">{signal.evidence}</span>
            )}
            {signal.confidence !== undefined && (
              <div className="flex items-center gap-4">
                <span className="text-xs text-light">置信度</span>
                <div style={{
                  flex: 1, height: 6, backgroundColor: '#E5E7EB',
                  borderRadius: 3, overflow: 'hidden'
                }}>
                  <div style={{
                    width: `${Math.round(signal.confidence * 100)}%`,
                    height: '100%', backgroundColor: '#6366F1',
                    borderRadius: 3, transition: 'width 0.4s ease'
                  }} />
                </div>
                <span className="text-xs font-bold" style={{ color: '#4338CA' }}>
                  {Math.round(signal.confidence * 100)}%
                </span>
              </div>
            )}
          </div>
        ))}
      </div>
    </div>
  )
}

function JobCard({ job, onClick, lowMatchWarning, showMatch = true, onUploadClick }) {
  const { job_id, name: title, company, city, match_rate, match_detail, tags = [], description, requirements, expectation_signals } = job
  const [expanded, setExpanded] = useState(false)

  const visibleTags = tags.slice(0, 3)
  const extraCount = tags.length - 3
  const descSummary = description && description.length > 80
    ? description.slice(0, 80) + '...'
    : description

  return (
    <div className="card">
      <div style={{ cursor: 'pointer' }} onClick={() => setExpanded(!expanded)}>
        <div className="gap-16" style={{ display: 'flex', alignItems: 'center' }}>
          {showMatch && (
            <div style={{ flexShrink: 0 }}>
              <MatchRing rate={match_rate} />
            </div>
          )}
          <div style={{ flex: 1, minWidth: 0 }}>
            <h3 className="font-bold text-lg">{title}</h3>
            <p className="text-secondary mt-8">{company}</p>
            <div className="flex flex-wrap gap-8" style={{ marginTop: 12 }}>
              <span className="text-sm text-secondary">{city}</span>
              {visibleTags.map((tag, i) => (
                <span key={i} className="tag">{tag}</span>
              ))}
              {extraCount > 0 && (
                <span className="text-sm text-light">+{extraCount}</span>
              )}
            </div>
          </div>
        </div>
        {showMatch && lowMatchWarning && (
          <div className="text-sm text-warning" style={{ marginTop: 12 }}>
            {match_rate < 60 ? '匹配度较低,别灰心,看看建议提升一下吧' : '匹配度较低'}
          </div>
        )}
        {descSummary && (
          <p className="text-sm text-secondary mt-12" style={{ lineHeight: 1.5 }}>{descSummary}</p>
        )}
      </div>

      {expanded && (
        <div style={{ marginTop: 12, padding: 16, backgroundColor: '#F9FAFB', borderRadius: 'var(--radius-sm)' }}>
          {description && (
            <div className="mb-12">
              <h4 className="font-bold text-sm mb-4">职位描述</h4>
              <p className="text-sm text-secondary">{description}</p>
            </div>
          )}
          {requirements && (
            <div className="mb-12">
              <h4 className="font-bold text-sm mb-4">职位要求</h4>
              <p className="text-sm text-secondary">{requirements}</p>
            </div>
          )}
          {showMatch && match_detail && <MatchBreakdown detail={match_detail} rate={match_rate} />}
          <ExpectationSignals signals={expectation_signals} />
          <div className="mt-12 flex gap-8" style={{ justifyContent: 'center' }}>
            {showMatch ? (
              <button className="btn btn-primary btn-sm" onClick={(e) => { e.stopPropagation(); onClick && onClick(job_id, { job_id, name: title, company, city, match_rate, tags, description, requirements, expectation_signals }) }}>
                查看匹配诊断
              </button>
            ) : (
              <button className="btn btn-primary btn-sm" onClick={(e) => { e.stopPropagation(); onUploadClick && onUploadClick() }}>
                上传简历后使用匹配
              </button>
            )}
          </div>
        </div>
      )}
    </div>
  )
}

export default JobCard