import{i as e,t}from"./react-B8IZ02wI.js";import{t as n}from"./button-DqbiydrF.js";import{t as r}from"./PlusOutlined-CP8wKFb7.js";import{t as i}from"./image-Co5qpec0.js";import{t as a}from"./upload-CFPSOK3x.js";import{j as o}from"./authStore-BvQBJ9ky.js";import{ft as s,gt as c,it as l,n as u}from"./index-Bg7bo8aA.js";import{t as d}from"./upload-D9W6AAsY.js";function f(e,t=`单据草稿`){if(!e){window.print();return}let n=document.createElement(`iframe`);n.setAttribute(`title`,t),n.setAttribute(`aria-hidden`,`true`),Object.assign(n.style,{position:`fixed`,right:`0`,bottom:`0`,width:`0`,height:`0`,border:`0`,opacity:`0`,pointerEvents:`none`}),document.body.appendChild(n);let r=n.contentWindow,i=r?.document;if(!r||!i){document.body.removeChild(n),window.print();return}let a=Array.from(document.querySelectorAll(`link[rel="stylesheet"], style`)).map(e=>{if(e instanceof HTMLLinkElement){let t=e.href||e.getAttribute(`href`)||``;return t?`<link rel="stylesheet" href="${t.startsWith(`http`)||t.startsWith(`data:`)?t:new URL(t,window.location.href).href}">`:``}return e.outerHTML}).join(`
`),o=`${window.location.origin}/`,s=e.cloneNode(!0);i.open(),i.write(`<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8"/>
  <base href="${o}">
  <title>${p(t)}</title>
  ${a}
  <style>
    html, body { background: #fff !important; margin: 0; padding: 12px; }
    .doc-draft-watermark { color: rgba(245, 158, 11, 0.35) !important; }
    @media print {
      html, body { padding: 0 !important; }
    }
  </style>
</head>
<body class="print-document-body">
  <div class="print-document-root"></div>
</body>
</html>`),i.close();let c=i.querySelector(`.print-document-root`);c?c.appendChild(s):i.body.appendChild(s);let l=()=>{try{n.parentNode&&n.parentNode.removeChild(n)}catch{}},u=()=>{try{r.focus(),r.print()}catch{}finally{window.setTimeout(l,1500)}},d=Array.from(i.querySelectorAll(`link[rel="stylesheet"]`));Promise.all(d.map(e=>new Promise(t=>{let n=e;if(n.sheet){t();return}n.addEventListener(`load`,()=>t(),{once:!0}),n.addEventListener(`error`,()=>t(),{once:!0}),window.setTimeout(()=>t(),800)}))).then(()=>{window.setTimeout(u,80)})}function p(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}var m=u(),h=[`正面`,`背面`,`盒标`,`瑕疵`,`其他`];function g({deviceId:e,deviceLabel:t,photos:s,onChange:u,max:f=5}){let p=s.filter(t=>t.deviceId===e),g=async(t,n)=>{let r=(await o.resourcePhoto(t)).data;u([...s.filter(t=>t.deviceId!==e||t.filePath!==r.path),{deviceId:e,filePath:r.path,url:r.url,caption:n||`正面`}])},_=t=>{u(s.filter(n=>!(n.deviceId===e&&n.filePath===t)))};return(0,m.jsxs)(`div`,{style:{marginTop:8,padding:12,background:`#f9fafb`,borderRadius:8},children:[(0,m.jsxs)(`div`,{style:{fontSize:13,fontWeight:500,marginBottom:8},children:[`设备影像 · `,t]}),(0,m.jsxs)(c,{wrap:!0,align:`start`,children:[p.map(e=>(0,m.jsxs)(`div`,{style:{textAlign:`center`},children:[(0,m.jsx)(i,{src:d(e.url),width:72,height:72,style:{objectFit:`cover`,borderRadius:6}}),(0,m.jsx)(`div`,{style:{fontSize:11,color:`#6b7280`},children:e.caption}),(0,m.jsx)(n,{type:`link`,size:`small`,danger:!0,icon:(0,m.jsx)(l,{}),onClick:()=>_(e.filePath)})]},e.filePath)),p.length<f&&(0,m.jsx)(a,{showUploadList:!1,accept:`image/jpeg,image/png,image/webp`,beforeUpload:e=>(g(e,h[p.length]||`其他`).catch(()=>{}),!1),children:(0,m.jsx)(`div`,{style:{width:72,height:72,border:`1px dashed #d1d5db`,borderRadius:6,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`,color:`#9ca3af`},children:(0,m.jsx)(r,{})})})]}),(0,m.jsxs)(`div`,{style:{fontSize:11,color:`#9ca3af`,marginTop:4},children:[`建议上传正面照，最多 `,f,` 张（可选）`]})]})}var _=e(t(),1);function v({preview:e,operations:t,previewTitle:r=`单据预览`,previewExtra:i}){let[a,o]=(0,_.useState)(!1);return(0,m.jsxs)(`div`,{className:`flow-doc-split`,children:[(0,m.jsxs)(`aside`,{className:`flow-doc-split-preview${a?` is-open`:``}`,children:[(0,m.jsxs)(`div`,{className:`flow-doc-split-preview-head`,children:[(0,m.jsx)(`strong`,{children:r}),(0,m.jsx)(`div`,{className:`flow-doc-split-preview-extra`,children:i}),(0,m.jsx)(n,{type:`text`,size:`small`,className:`flow-doc-split-mobile-toggle`,onClick:()=>o(!1),children:`收起`})]}),(0,m.jsx)(`div`,{id:`flow-doc-print-root`,className:`flow-doc-split-preview-body`,children:e})]}),(0,m.jsxs)(`section`,{className:`flow-doc-split-ops`,children:[(0,m.jsx)(`div`,{className:`flow-doc-split-mobile-bar no-print`,children:(0,m.jsx)(n,{icon:(0,m.jsx)(s,{}),onClick:()=>o(!0),children:`查看单据草稿`})}),t]})]})}export{g as n,f as r,v as t};