83 lines
36 KiB
Java
83 lines
36 KiB
Java
|
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/vue-plugin-hiprint-f7b0vEHA.js","js/emoji-mart-vue-fast-R0uJEDq-.js","js/JsBarcode-9Xoda2fA.js","js/index-X7Y8jykP.js","js/vue-vendor-DNhG1Cve.js","assets/index-GuhSw_Yp.css","js/browser-CC9DCAWJ.js","js/stackblur-es-DK4L4ctA.js"])))=>i.map(i=>d[i]);
|
|||
|
|
var ve=Object.defineProperty,ye=Object.defineProperties;var we=Object.getOwnPropertyDescriptors;var Tt=Object.getOwnPropertySymbols;var be=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable;var xt=(O,P,A)=>P in O?ve(O,P,{enumerable:!0,configurable:!0,writable:!0,value:A}):O[P]=A,ft=(O,P)=>{for(var A in P||(P={}))be.call(P,A)&&xt(O,A,P[A]);if(Tt)for(var A of Tt(P))Se.call(P,A)&&xt(O,A,P[A]);return O},ct=(O,P)=>ye(O,we(P));var L=(O,P,A)=>new Promise((F,b)=>{var et=T=>{try{_(A.next(T))}catch(M){b(M)}},j=T=>{try{_(A.throw(T))}catch(M){b(M)}},_=T=>T.done?F(T.value):Promise.resolve(T.value).then(et,j);_((A=A.apply(O,P)).next())});import{M as ke,_ as _e,s as Ne,aE as Pe,av as Ae,aG as Te,cx as xe,x as Ct,aR as Ce,aS as Le,bR as $e,aH as Ee,bL as Oe,au as He}from"./index-X7Y8jykP.js";import{r as Je}from"./qhmesProvider-MWkGjy8y.js";import Me from"./BasicTable-C6eG0bgK.js";import Be from"./TableAction-BiXnWkvt.js";import"./TableImg.vue_vue_type_style_index_0_lang-65ZOQtFn.js";import"./index-BDvqZ5j4.js";import{u as We}from"./useListPage-CK9oQ-1O.js";import{e as Et,r as N,h as De,o as Fe,C as ht,z as B,f as g,A as S,u as W,c as z,p as Re,K as qe,X as ze,O as gt,y as I,H as Lt,E as $,Q as J,G as Ie}from"./vue-vendor-DNhG1Cve.js";import{_ as je,s as Ue,c as Ve}from"./PrintTemplateModal.vue_vue_type_script_setup_true_lang-Bg6SMY-d.js";import{q as Ke,l as $t,b as tt,c as Qe,d as Xe,f as Ge,a as Ye,g as Ze}from"./printTemplate.api-Dfuyi-ab.js";import tn from"./NativeTemplateListPreviewModal-CsdnFNwg.js";import{g as en,P as vt,f as nn,s as rn,b as an}from"./printNativeViaPrintDot-hFBchMti.js";import{u as on}from"./useModal-DaJ3Bflg.js";import"./index-DSsDi_fL.js";import{C as sn}from"./Group-UHkub2tu.js";import"./index-CfNJyBRj.js";import{D as ln}from"./dropdown-jkliuVyN.js";import{b as un}from"./index-CeNCCWzL.js";import{O as pn}from"./index-CuWaQdlK.js";import{A as dn}from"./index-DO7ZhK45.js";import"./emoji-mart-vue-fast-R0uJEDq-.js";import"./BasicTable.vue_vue_type_style_index_0_lang-B9DxrWas.js";import"./BasicForm-ClUSoD_-.js";import"./helper-DcLcf4v6.js";import"./index-BzChaRPg.js";import"./useAppInject-DPZGPcR3.js";import"./BasicForm.vue_vue_type_style_index_0_lang-B29PWQy0.js";import"./index-ByCwbQDV.js";import"./index-Upeu4GGa.js";import"./index-C4wWpZeQ.js";import"./useTimeout-D5AmIBZw.js";import"./index-M9QP6cvf.js";import"./Skeleton-CimgOdM7.js";import"./useScrollTo-0FPEw5-K.js";import"./useIntersectionObserver-BGOgyKyu.js";import"./index-saD4h7VJ.js";import"./useBreakpoint-DXhPW7nV.js";import"./useEventListener-BRXjwk7A.js";import"./breakpointEnum-BhAg6bcX.js";import"./uniqBy--vsL0WVB.js";import"./BasicModal-xH56XuRZ.js";import"./ModalHeader-Sr8KwhJJ.js";import"./useWindowSizeFn-C-0M9_Ul.js";import"./useForm-D61zovon.js";import"./injectionKey-DPVn4AgL.js";import"./FormOutlined-Y84itqS0.js";import"./useTableContext-CncNVXgp.js";import"./index-DTjkSGYl.js";import"./eagerComputed-BTlOruLW.js";import"./fromPairs-Dx9PT-t0.js";import"./useMaxLevel-DE205ncc.js";import"./index-DfHu-LAS.js";import"./Group-DBzJABA_.js";import"./Checkbox-Dbxs4we4.js";import"./RadioButton-DRBix2Fq.js";import"./index-C7ckZv9Z.js";import"./DirectoryTree-nk_YTTIy.js";import"./FolderOpenOutlined-SzIPA7z0.js";import"./index-Cl-8Hzo4.js";import"./index-BuONesFs.js";import"./scrollTo-D49dA-9c.js";import"./operationUnit-vCu2co3e.js";import"./index-C69VKHba.js";import"./index-DklMb9Qc.js";import"./UpOutlined-B1UMbtrP.js";import"./index-DsixALRt.js";import"./dayjs-jnKD3YGS.js";import"./index-aCD42OrZ.js";import"./quarterOfYear-BU2sPnff.js";import"./index-J2mOtM3w.js";import"./dayjs-ALi1pEeb.js";import"./clickOutside-DHfwTU6R.js";import"./onMountedOrActivated-DhSdLlqP.js";import"./throttle-De_jAmBh.js";import"./uuid-CODpppBC.js";import"./sortable.esm-DJNoJSdJ.js";import"./RedoOutlined-Cq2g4Slp.js";import"./TableAction.vue_vue_type_style_index_0_lang-BIWZ0bGo.js";import"./index-fAAIzD3j.js";import"./index-DfX9t4DO.js";import"./isNumeric-DjvBa-1E.js";import"./useTable-DbHE4FHE.js";import"./useMethods-D3efiSSd.js";import"./useApprovalSelection-
|
|||
|
|
"docNo": "MO-001",
|
|||
|
|
"mainTable": [
|
|||
|
|
{ "materialCode": "M01", "materialName": "示例物料", "qty": 10 }
|
|||
|
|
]
|
|||
|
|
}`,Mt=`请填写对象或数组形式的打印数据,例如:
|
|||
|
|
${it}`,ot=N(!1),x=N({templateCode:"",printerName:"__system_default__",dataJson:it}),K=N(""),Q=N(""),X=N(!1),st=N(!1),H=N(""),G=N("convert"),Bt=z(()=>G.value==="guide"?"技能指南打印(hiprint-export-print)":"技能转换打印(hiprint → PDF → 后端队列)"),Wt=z(()=>G.value==="guide"?"与项目 Cursor 技能「hiprint-export-print」约定一致:hiprint 模板 JSON + 打印数据 JSON → 校验 → 生成预览(Lodop 同源 HTML 包装)→ html2canvas + jsPDF 生成 PDF → 调用后端 directPrintPdf。开发人员可查阅仓库 .cursor/skills/hiprint-export-print/SKILL.md 中的文件路径、自检项与常见问题。":"选择模板并填写打印数据 JSON → 校验 → 生成预览确认版式 → 提交为 PDF 由后端发送到所选打印机。"),Dt=z(()=>G.value==="guide"?"技能指南打印预览":"技能转换预览"),Ft=z(()=>{const t=K.value.trim().toLowerCase(),e=V.value;return t?e.filter(n=>String(n.value||"").toLowerCase().includes(t)||String(n.label||"").toLowerCase().includes(t)):e});let q=null;function Rt(t){const e=(t==null?void 0:t.default)||{};return q=(t==null?void 0:t.hiprint)||(e==null?void 0:e.hiprint)||(window==null?void 0:window.hiprint),q}function lt(){return L(this,null,function*(){if(q)return;const t=yield _e(()=>import("./vue-plugin-hiprint-f7b0vEHA.js").then(n=>n.v),__vite__mapDeps([0,1,2,3,4,5,6,7])),e=Rt(t);if(!e)throw new Error("未获取到 hiprint 实例");e.init({providers:Je(t)})})}const{tableContext:qt}=We({tableProps:{title:"打印模板",api:$t,columns:Ve,rowKey:"id",formConfig:{schemas:Ue},actionColumn:{width:300}}}),[zt,{reload:Y},{rowSelection:It,selectedRowKeys:St}]=qt;function Z(t=!0){return L(this,null,function*(){var l;const e=new Map;if(e.set("__system_default__",{label:"系统默认打印机",value:"__system_default__"}),D.value){try{const p=yield nn();p.forEach(y=>{const r=String(y.name||"").trim();if(!r)return;const d=y.isDefault?"(默认)":"";e.set(r,{label:`${r}${d}`,value:r})}),_.value&&!e.has(_.value)&&e.set(_.value,{label:`${_.value}(手动)`,value:_.value}),T.value=Array.from(e.values()),t&&(p.length?b.success(`已从 PrintDot 桥接识别 ${p.length} 台打印机`):b.warning("PrintDot 已连接但未返回打印机列表"))}catch(p){_.value&&!e.has(_.value)&&e.set(_.value,{label:`${_.value}(手动)`,value:_.value}),T.value=Array.from(e.values()),t&&b.warning(`PrintDot:${(p==null?void 0:p.message)||"无法连接本地桥接器"}`)}return}const n=yield Ke(),i=[...Array.isArray(n==null?void 0:n.serverPrinters)?n.serverPrinters:[],...Array.isArray(n==null?void 0:n.networkPrinters)?n.networkPrinters:[]].map(p=>String(p||"").trim()).filter(Boolean).filter((p,y,r)=>r.indexOf(p)===y);if(i.forEach(p=>{e.set(p,{label:p,value:p})}),_.value&&!e.has(_.value)&&e.set(_.value,{label:`${_.value}(手动)`,value:_.value}),T.value=Array.from(e.values()),t)if(i.length)b.success(`已从服务端识别到 ${i.length} 台打印机`);else{const p=String(((l=n==null?void 0:n.capability)==null?void 0:l.localReason)||"").trim();b.warning(`服务端未返回可用打印机。${p||"请在后端配置网络打印机后重试。"}`)}})}function kt(){const t=String(M.value||"").trim();if(!t)return;T.value.some(n=>n.value===t)||(T.value=[...T.value,{label:`${t}(手动)`,value:t}]),_.value=t,M.value="",b.success("已添加手动打印机名称")}function jt(){return L(this,null,function*(){var n;const t=yield $t({pageNo:1,pageSize:500}),e=(t==null?void 0:t.records)||((n=t==null?void 0:t.result)==null?void 0:n.records)||[];V.value=e.map(i=>({value:String((i==null?void 0:i.templateCode)||"").trim(),label:`${String((i==null?void 0:i.templateCode)||"").trim()} ${i!=null&&i.templateName?`- ${i.templateName}`:""}`.trim()})).filter(i=>!!i.value)})}function Ut(){return L(this,null,function*(){U.value="",V.value.length||(yield jt()),R.value=!0})}function Vt(){return L(this,null,function*(){var e,n,i,l,p,y;const t=String(U.value||"").trim();if(!t){b.warning("请先选择模板编号");return}nt.value=!0;try{const r=yield tt(t),d=(e=r==null?void 0:r.result)
|
|||
|
|
`),p=e&&n?`@page { size: ${e}mm ${n}mm; margin: 0; }`:"@page { margin: 0; }",r=`
|
|||
|
|
html, body { margin: 0; padding: 0; background: #fff; }
|
|||
|
|
${e&&n?`.lodop-print-root { width: ${e}mm; margin: 0; padding: 0; overflow: visible; }`:".lodop-print-root { margin: 0; padding: 0; overflow: visible; }"}
|
|||
|
|
.hiprint-printTemplate {
|
|||
|
|
transform: none !important;
|
|||
|
|
transform-origin: top left !important;
|
|||
|
|
zoom: 1 !important;
|
|||
|
|
-webkit-print-color-adjust: exact !important;
|
|||
|
|
print-color-adjust: exact !important;
|
|||
|
|
}
|
|||
|
|
/* 打印态去掉设计器预览缩放,避免整体变小与合并表头被裁切 */
|
|||
|
|
.hiprint-printTemplate [style*="transform: scale"] {
|
|||
|
|
transform: none !important;
|
|||
|
|
}
|
|||
|
|
.hiprint-printTemplate table {
|
|||
|
|
border-collapse: collapse !important;
|
|||
|
|
border-spacing: 0 !important;
|
|||
|
|
}
|
|||
|
|
.hiprint-printTemplate th,
|
|||
|
|
.hiprint-printTemplate td {
|
|||
|
|
border-color: #333 !important;
|
|||
|
|
border-style: solid !important;
|
|||
|
|
border-width: 1px !important;
|
|||
|
|
overflow: visible !important;
|
|||
|
|
text-overflow: clip !important;
|
|||
|
|
white-space: normal !important;
|
|||
|
|
vertical-align: middle !important;
|
|||
|
|
word-break: normal !important;
|
|||
|
|
line-height: 1.35 !important;
|
|||
|
|
}
|
|||
|
|
.hiprint-printTemplate thead th {
|
|||
|
|
line-height: 1.45 !important;
|
|||
|
|
padding-top: 2px !important;
|
|||
|
|
padding-bottom: 2px !important;
|
|||
|
|
}
|
|||
|
|
.hiprint-printTemplate .qh-merged-header-cell {
|
|||
|
|
border-bottom: none !important;
|
|||
|
|
}
|
|||
|
|
.hiprint-printTemplate .hiprint-printElement,
|
|||
|
|
.hiprint-printTemplate .hiprint-printElement > div,
|
|||
|
|
.hiprint-printTemplate .hiprint-printElement span,
|
|||
|
|
.hiprint-printTemplate .hiprint-printElement p {
|
|||
|
|
overflow: visible !important;
|
|||
|
|
text-overflow: clip !important;
|
|||
|
|
}
|
|||
|
|
/* 合并单元格专门处理:避免跨列跨行时边框与文字被裁切 */
|
|||
|
|
.hiprint-printTemplate th[colspan], .hiprint-printTemplate td[colspan],
|
|||
|
|
.hiprint-printTemplate th[rowspan], .hiprint-printTemplate td[rowspan] {
|
|||
|
|
overflow: visible !important;
|
|||
|
|
white-space: normal !important;
|
|||
|
|
text-align: center !important;
|
|||
|
|
vertical-align: middle !important;
|
|||
|
|
position: relative;
|
|||
|
|
z-index: 1;
|
|||
|
|
background-clip: padding-box !important;
|
|||
|
|
}
|
|||
|
|
.hiprint-printTemplate tr {
|
|||
|
|
page-break-inside: avoid !important;
|
|||
|
|
}
|
|||
|
|
.hiprint-printTemplate img, .hiprint-printTemplate canvas {
|
|||
|
|
max-width: none !important;
|
|||
|
|
max-height: none !important;
|
|||
|
|
}
|
|||
|
|
`;return`<!doctype html>
|
|||
|
|
<html>
|
|||
|
|
<head>
|
|||
|
|
<meta charset="UTF-8" />
|
|||
|
|
${l}
|
|||
|
|
<style></style>
|
|||
|
|
<style>${p}
|
|||
|
|
${r}</style>
|
|||
|
|
</head>
|
|||
|
|
<body><div class="lodop-print-root">${t}</div></body>
|
|||
|
|
</html>`}function le(){j(!0,{isUpdate:!1,isNative:!0})}function ue(t){j(!0,{isUpdate:!0,record:t})}function At(t){const e=t==null?void 0:t.templateJson;if(!e)return!1;if(typeof e=="object")return(e==null?void 0:e.engine)==="native";if(typeof e!="string")return!1;try{const n=JSON.parse(e);return(n==null?void 0:n.engine)==="native"}catch(n){return!1}}function pe(t){const e=At(t)?"/print/native-designer":"/print/designer";F.push({path:e,query:{id:t.id}})}function de(t){A.value=String(t.id||""),P.value=!0}function me(t){return L(this,null,function*(){yield Ze({id:t.id},Y)})}function fe(t){return L(this,null,function*(){var n,i,l,p,y,r,d,m,o,f,u,w;const e=String((t==null?void 0:t.id)||"").trim();if(!e){b.warning("无法复制:缺少模板主键");return}try{const a=yield Ge(e),c=String((i=(n=a==null?void 0:a.templateCode)!=null?n:t==null?void 0:t.templateCode)!=null?i:"TPL").trim()||"TPL",s=Date.now();let v=`${c}_CP_${s}`;v.length>64&&(v=`CP_${s}`);const h=`${String((p=(l=a==null?void 0:a.templateName)!=null?l:t==null?void 0:t.templateName)!=null?p:c).trim()||"模板"}_副本`;yield Ye({templateCode:v,templateName:h,category:String((r=(y=a==null?void 0:a.category)!=null?y:t==null?void 0:t.category)!=null?r:"form"),paperWidthMm:(d=a==null?void 0:a.paperWidthMm)!=null?d:t==null?void 0:t.paperWidthMm,paperHeightMm:(m=a==null?void 0:a.paperHeightMm)!=null?m:t==null?void 0:t.paperHeightMm,paperOrientation:String((f=(o=a==null?void 0:a.paperOrientation)!=null?o:t==null?void 0:t.paperOrientation)!=null?f:"portrait"),templateJson:String((w=(u=a==null?void 0:a.templateJson)!=null?u:t==null?void 0:t.templateJson)!=null?w:"{}"),remark:(a==null?void 0:a.remark)!=null?String(a.remark):(t==null?void 0:t.remark)!=null?String(t.remark):""}),b.success("已复制为新模板"),yield Y()}catch(a){b.error((a==null?void 0:a.message)||"复制失败")}})}function ce(){return L(this,null,function*(){yield Qe({ids:St.value.join(",")},Y)})}function he(t){return L(this,null,function*(){var i,l,p,y,r;if(Y(),(t==null?void 0:t.isNative)!==!0||(t==null?void 0:t.isUpdate)===!0)return;const e=((i=t==null?void 0:t.savedResult)==null?void 0:i.id)||((p=(l=t==null?void 0:t.savedResult)==null?void 0:l.result)==null?void 0:p.id)||((y=t==null?void 0:t.values)==null?void 0:y.id);if(e){F.push({path:"/print/native-designer",query:{id:String(e)}});return}const n=String(((r=t==null?void 0:t.values)==null?void 0:r.templateCode)||"").trim();if(n)try{const d=yield tt(n);d!=null&&d.id&&F.push({path:"/print/native-designer",query:{id:String(d.id)}})}catch(d){}})}function ge(t){const e=At(t),n=[{label:e?"原生设计":"Hiprint设计",onClick:pe.bind(null,t),auth:"print:template:edit"}];return e&&n.push({label:"预览",onClick:de.bind(null,t),auth:"print:template:list"}),n.push({label:"编辑",onClick:ue.bind(null,t),auth:"print:template:edit"},{label:"复制",onClick:fe.bind(null,t),auth:"print:template:add"},{label:"删除",color:"error",popConfirm:{title:"确认删除?",confirm:me.bind(null,t)},auth:"print:template:delete"}),n}return De(_,t=>{if(!t){localStorage.removeItem(vt);return}localStorage.setItem(vt,t)},{immediate:!1}),Fe(()=>L(null,null,function*(){try{yield lt()}catch(t){}_.value=localStorage.getItem(vt)||"__system_default__",yield Z(!1),_.value||(_.value="__system_default__")})),(t,e)=>{const n=Ae,i=Te,l=qe("a-button"),p=sn,y=xe,r=Pe,d=Le,m=Ce,o=ln,f=un,u=ke,w=dn,a=pn,c=$e,s=Oe,v=Ee,k=ze("auth");return B(),ht("div",null,[g(W(Me),{onRegister:W(zt),rowSelection:W(It)},{tableTitle:S(()=>[g(r,null,{default:S(()=>[g(n,{value:_.value,"onUpdate:value":e[0]||(e[0]=h=>_.value=h),options:T.value,style:{width:"260px"},"allow-clear":"","show-search":"","option-filter-prop":"label",placeholder:Ot.value},null,8,["value","options","placeholder"]),g(i,{value:M.value,"onUpdate:value":e[1]||(e[1]=h=>M.value=h),style:{width:"180px"},placeholder:"手动输入打印机名称",onPressEnter:kt},null,8,["value"]),g(l,{onClick:kt},{default:S(()=>[...e[14]||(e[14]=[$("添加打印机",-1)])]),_:1}),g(l,{onClick:Z},{default:S(()=>[...e[15]||(e[15]=[$("刷新打印机",-1)])]),_:1}),g(
|