Files
FootPrint/sync-server/www/assets/ResumePage-Cw9JFOLR.js
T

17 lines
11 KiB
JavaScript

import{c as N,d as F,f as C,r as k,j as e,B as w,ae as R,H as B,aa as D,ac as M,a6 as L,ad as q,v as H}from"./index-DkrEeFZh.js";import{C as O,a as A,b as W}from"./card-DdglV9lU.js";/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const K=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Q=N("ArrowDown",K);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const V=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],$=N("ArrowUp",V);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const G=[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]],J=N("Printer",G),v=[{key:"info",defaultTitle:"基本信息",fixed:!0},{key:"education",defaultTitle:"教育背景",types:["学业"]},{key:"skills",defaultTitle:"技能证书",types:["证书技能"]},{key:"awards",defaultTitle:"荣誉奖项",types:["荣誉惩处"]},{key:"competition",defaultTitle:"竞赛经历",types:["竞赛"]},{key:"research",defaultTitle:"科研经历",types:["科研"]},{key:"practice",defaultTitle:"实践经历",types:["志愿公益","实习实践","学生工作"]},{key:"activity",defaultTitle:"文体活动",types:["文体活动"]},{key:"other",defaultTitle:"其他经历"},{key:"self",defaultTitle:"自我评价",fixed:!0}];function _(){return{sections:v.map(x=>({key:x.key,enabled:!0,title:x.defaultTitle}))}}function S(x,a,c){var f;const r=(f=c==null?void 0:c.sections)!=null&&f.length?c.sections:_().sections,t=new Map(v.map(s=>[s.key,s])),n=[];for(const s of r){if(!s.enabled)continue;const y=t.get(s.key);if(s.key==="info"){n.push({key:s.key,title:s.title,text:"info"});continue}if(s.key==="self"){n.push({key:s.key,title:s.title,text:(a==null?void 0:a.selfIntro)||""});continue}const g=y==null?void 0:y.types;if(!g)continue;const l=x.filter(m=>g.includes(m.type_name)&&m.status!=="draft");l.length&&(l.sort((m,u)=>(u.start_date??u.created_at).localeCompare(m.start_date??m.created_at)),n.push({key:s.key,title:s.title,items:l.map(m=>({row:m}))}))}return n}function X(x,a,c){const r=s=>s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),t=a??{},n=x.map(s=>{let y="";return s.key==="info"?y='<table style="width:100%;border-collapse:collapse;font-size:12pt">'+[["姓名",t.name??""],["性别",t.gender??""],["出生年月",t.birth??""],["民族",t.nation??""],["籍贯",t.native??""],["政治面貌",t.political??""],["学校",t.school??""],["学院",t.college??""],["专业",t.major??""],["班级",t.className??""],["学号",t.studentId??""],["学历",t.degree??""],["手机",t.phone??""],["邮箱",t.email??""]].filter(l=>l[1]!=="").map(([l,m],u)=>(u%2===0?"<tr>":"")+'<td style="width:80px;padding:3px 6px;color:#555">'+r(String(l))+'</td><td style="padding:3px 6px">'+r(String(m))+"</td>"+(u%2===1?"</tr>":"")).join("")+"</table>":s.items?y='<div style="margin-bottom:6pt">'+s.items.map(g=>{const l=g.row,m=(l.start_date??l.created_at).slice(0,10),u=[l.organizer,l.level,l.award_grade].filter(j=>j!=null&&j!=="").map(j=>r(String(j))).join(" · ");return'<div style="margin-bottom:7pt"><div style="display:flex;justify-content:space-between"><b style="font-size:12pt">'+r(l.title)+'</b><span style="color:#666;font-size:10.5pt">'+r(m)+"</span></div>"+(u?'<div style="color:#666;font-size:10.5pt">'+u+"</div>":"")+(l.result?'<div style="color:#177245;font-size:11pt">'+r(l.result)+"</div>":"")+"</div>"}).join("")+"</div>":s.text&&(y='<p style="font-size:12pt;line-height:1.7;margin:0">'+r(s.text)+"</p>"),'<h2 style="font-size:14pt;border-bottom:1.5pt solid #333;padding-bottom:3pt;margin:14pt 0 7pt">'+r(s.title)+"</h2>"+y}).join(""),f=c&&t.photoUrl?'<div style="text-align:right"><img src="'+r(t.photoUrl)+'" alt="证件照" style="width:90pt;height:120pt;object-fit:cover" /></div>':"";return'<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word"><head><meta charset="utf-8"><title>个人简历</title></head><body style="font-family:SimSun,Calibri,sans-serif;margin:36pt"><div style="display:flex;justify-content:space-between;align-items:flex-start"><h1 style="font-size:20pt;margin:0 0 4pt">'+r(t.name||"个人简历")+"</h1>"+f+"</div>"+(t.major||t.school?'<div style="color:#555;font-size:11pt;margin-bottom:8pt">'+[t.school,t.college,t.major,t.degree].filter(s=>!!s).map(s=>r(String(s))).join(" · ")+"</div>":"")+n+"</body></html>"}const Y=Object.freeze(Object.defineProperty({__proto__:null,RESUME_SECTION_DEFS:v,assembleSections:S,defaultResumeConfig:_,resumeToWordHtml:X},Symbol.toStringTag,{value:"Module"}));function te(){var z,T;const x=F(),a=C({queryKey:["profile"],queryFn:q}),c=C({queryKey:["resume-records"],queryFn:()=>H({page:1,page_size:500})}),r=(z=a.data)==null?void 0:z.content,t={...(r==null?void 0:r.info)??{}},[n,f]=k.useState(()=>(r==null?void 0:r.resume)??_()),[s,y]=k.useState(t.selfIntro??""),g=s!==(t.selfIntro??""),l={...t,selfIntro:s},m=((T=c.data)==null?void 0:T.items)??[],u=k.useMemo(()=>S(m,l,n),[m,l,n]),j=(i,d)=>f(p=>{const o=[...p.sections],h=i+d;return h<0||h>=o.length?p:([o[i],o[h]]=[o[h],o[i]],{...p,sections:o})}),I=i=>f(d=>{const p=[...d.sections];return p[i]={...p[i],enabled:!p[i].enabled},{...d,sections:p}}),U=(i,d)=>f(p=>{const o=[...p.sections];return o[i]={...o[i],title:d},{...p,sections:o}}),E=()=>{L(async()=>{const{resumeToWordHtml:i}=await Promise.resolve().then(()=>Y);return{resumeToWordHtml:i}},void 0).then(({resumeToWordHtml:i})=>{const d=i(u,l,l.photoUrl),p=new Blob(["\uFEFF"+d],{type:"application/msword"}),o=URL.createObjectURL(p),h=document.createElement("a");h.href=o,h.download=(t.name||"个人简历")+".doc",h.click(),setTimeout(()=>URL.revokeObjectURL(o),6e4),x("success","Word 文档已导出")})};return e.jsxs("div",{className:"mx-auto max-w-[1080px] px-3 py-4 sm:px-6 sm:py-5",children:[e.jsxs("div",{className:"no-print mb-4 flex flex-wrap items-center justify-between gap-2",children:[e.jsx("h2",{className:"text-[15px] font-semibold text-ink-1",children:"我的简历"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(w,{variant:"secondary",onClick:E,children:[e.jsx(R,{size:13})," 导出 Word"]}),e.jsxs(w,{variant:"primary",onClick:()=>window.print(),children:[e.jsx(J,{size:13})," 打印 / 导出 PDF"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-[300px_1fr]",children:[e.jsxs(O,{className:"no-print",children:[e.jsx(A,{title:"板块布局"}),e.jsx(W,{className:"p-0",children:e.jsx("div",{className:"flex flex-col divide-y divide-line",children:n.sections.map((i,d)=>{var o,h;const p=u.find(b=>b.key===i.key);return e.jsxs("div",{className:"p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{type:"checkbox",checked:i.enabled,onChange:()=>I(d),"aria-label":"启用板块",className:"size-3.5"}),e.jsx("input",{className:"min-w-0 flex-1 rounded-sm border border-transparent bg-transparent px-1 py-0.5 text-[12.5px] font-medium text-ink-1 transition-colors hover:border-line focus:border-brand focus:outline-none",value:i.title,onChange:b=>U(d,b.target.value)}),e.jsx("button",{className:"rounded p-1 text-ink-3 transition-colors hover:bg-surface-3 hover:text-ink-1 disabled:opacity-30","aria-label":"上移",disabled:d===0,onClick:()=>j(d,-1),children:e.jsx($,{size:13})}),e.jsx("button",{className:"rounded p-1 text-ink-3 transition-colors hover:bg-surface-3 hover:text-ink-1 disabled:opacity-30","aria-label":"下移",disabled:d===n.sections.length-1,onClick:()=>j(d,1),children:e.jsx(Q,{size:13})})]}),e.jsxs("div",{className:"mt-0.5 pl-5 text-[11px] text-ink-3",children:[((h=(o=v.find(b=>b.key===i.key))==null?void 0:o.types)==null?void 0:h.join(" / "))??"固定板块",i.enabled&&!p&&e.jsx("span",{className:"text-warning",children:" · 暂无内容"})]})]},i.key)})})}),e.jsxs("div",{className:"border-t border-line p-3",children:[e.jsx(B,{label:"自我评价",children:e.jsx(D,{rows:4,value:s,onChange:i=>y(i.target.value),placeholder:"简述性格、能力、研究方向…"})}),e.jsx(w,{size:"sm",variant:"primary",className:"mt-2 w-full",disabled:!g,onClick:()=>{(async()=>{try{await M({info:{...t,selfIntro:s},resume:n}),await a.refetch(),x("success","自我评价已保存")}catch(i){x("error",i.message)}})()},children:"保存自我评价"}),e.jsx("p",{className:"mt-1 text-[11px] text-ink-3",children:"板块顺序与标题自动保存 · 内容来自「个人信息」与各类型记录"})]})]}),e.jsx("div",{children:e.jsx("div",{className:"print-sheet mx-auto w-full max-w-[794px] rounded-lg border border-line bg-white p-8 text-[13px] leading-relaxed text-neutral-900 shadow-card sm:p-10",children:e.jsx(Z,{sections:u,profile:l})})})]})]})}function Z({sections:x,profile:a}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6 flex items-start justify-between gap-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-[26px] font-bold leading-tight tracking-tight text-neutral-900",children:a.name||"姓名"}),e.jsx("div",{className:"mt-1.5 text-[12.5px] text-neutral-500",children:[a.school,a.college,a.major,a.degree].filter(Boolean).join(" · ")}),e.jsx("div",{className:"mt-1 text-[12px] text-neutral-500",children:[a.phone,a.email,a.homepage].filter(Boolean).join(" · ")})]}),a.photoUrl&&e.jsx("img",{src:a.photoUrl,alt:"证件照",className:"h-[120px] w-[90px] rounded border border-neutral-200 object-cover"})]}),x.map(c=>{var r;return e.jsxs("div",{className:"mb-5",children:[e.jsx("div",{className:"mb-2.5 border-b-2 border-neutral-800 pb-1 text-[14px] font-bold tracking-wide text-neutral-900",children:c.title}),c.key==="info"?e.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-1 text-[12.5px]",children:[["姓名",a.name],["性别",a.gender],["出生年月",a.birth],["民族",a.nation],["籍贯",a.native],["政治面貌",a.political],["班级",a.className],["学号",a.studentId],["手机",a.phone],["邮箱",a.email]].filter(t=>t[1]).map(([t,n])=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"w-16 shrink-0 text-neutral-500",children:t}),e.jsx("span",{children:n})]},t))}):c.text!==void 0?e.jsx("p",{className:"whitespace-pre-wrap text-[12.5px] leading-relaxed",children:c.text||"(在「个人信息」中填写自我评价)"}):e.jsx("div",{className:"flex flex-col gap-2.5",children:(r=c.items)==null?void 0:r.map(t=>{const n=t.row,f=(n.start_date??n.created_at).slice(0,10);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("span",{className:"text-[13px] font-semibold text-neutral-900",children:n.title}),e.jsxs("span",{className:"num shrink-0 text-[11.5px] text-neutral-500",children:[f,n.end_date?" ~ "+n.end_date.slice(5,10):""]})]}),e.jsxs("div",{className:"text-[12px] text-neutral-600",children:[[n.organizer,n.level,n.award_grade].filter(Boolean).join(" · "),n.result&&e.jsxs("span",{className:"text-emerald-700",children:[" — ",n.result]})]}),n.description&&e.jsx("p",{className:"mt-0.5 line-clamp-2 text-[12px] text-neutral-500",children:n.description})]},n.id)})})]},c.key)})]})}export{te as ResumePage};