Files
qhmes/deploy-qhmes/frontend/js/PrintTemplateModal-Cq9ZPa_M.js
2026-05-15 11:34:12 +08:00

2 lines
6.8 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
var R=Object.defineProperty,J=Object.defineProperties;var k=Object.getOwnPropertyDescriptors;var M=Object.getOwnPropertySymbols;var B=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable;var N=(t,a,i)=>a in t?R(t,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[a]=i,T=(t,a)=>{for(var i in a||(a={}))B.call(a,i)&&N(t,i,a[i]);if(M)for(var i of M(a))E.call(a,i)&&N(t,i,a[i]);return t},S=(t,a)=>J(t,k(a));var _=(t,a,i)=>new Promise((r,s)=>{var c=p=>{try{d(i.next(p))}catch(m){s(m)}},u=p=>{try{d(i.throw(p))}catch(m){s(m)}},d=p=>p.done?r(p.value):Promise.resolve(p.value).then(c,u);d((i=i.apply(t,a)).next())});import{d as W,aC as V,as as F,aF as H,k as D,u as l,aG as G,e as U,f as y}from"./vue-vendor-C7Zq48Yl.js";import{B as j}from"./index-Du0A3ksf.js";import"./index-Di-j2gt4.js";import{e as q,a as z}from"./printTemplate.api-CHChWHTu.js";import{ak as Y}from"./index-BI6CMai0.js";import{B as $}from"./BasicForm-BJnSRkIE.js";import{u as K}from"./useForm-BZtHZyx2.js";const C="print_template_category",Q="print_paper_preset",X=[{label:"条码",value:"barcode"},{label:"标签",value:"label"},{label:"快递面单",value:"waybill"},{label:"吊牌",value:"hangtag"},{label:"物料卡",value:"materialCard"},{label:"箱唛",value:"cartonMark"},{label:"质检单",value:"qc"},{label:"入库单",value:"inbound"},{label:"出库单",value:"outbound"},{label:"工单",value:"workOrder"},{label:"表单套打",value:"form"},{label:"报表",value:"report"}],Z=X.reduce((t,a)=>(t[a.value]=a.label,t),{}),w={A4:{width:210,height:297,orientation:"portrait"},A5:{width:148,height:210,orientation:"portrait"},A6:{width:105,height:148,orientation:"portrait"},B5:{width:176,height:250,orientation:"portrait"},B6:{width:125,height:176,orientation:"portrait"},L_10_12:{width:10,height:12,orientation:"portrait"},L_20_10:{width:20,height:10,orientation:"landscape"},L_25_15:{width:25,height:15,orientation:"landscape"},L_30_20:{width:30,height:20,orientation:"landscape"},L_40_30:{width:40,height:30,orientation:"landscape"},L_50_30:{width:50,height:30,orientation:"landscape"},L_60_40:{width:60,height:40,orientation:"landscape"},L_70_50:{width:70,height:50,orientation:"landscape"},L_80_50:{width:80,height:50,orientation:"landscape"},L_90_60:{width:90,height:60,orientation:"landscape"},L_100_70:{width:100,height:70,orientation:"landscape"},L_100_150:{width:100,height:150,orientation:"portrait"},L_100_180:{width:100,height:180,orientation:"portrait"}},me=[{title:"模板编码",dataIndex:"templateCode",width:140},{title:"模板名称",dataIndex:"templateName",width:180},{title:"分类",dataIndex:"category",width:100,customRender:({text:t})=>Z[t]||t},{title:"纸张(mm)",dataIndex:"paperWidthMm",width:130,customRender:({record:t})=>(t==null?void 0:t.paperWidthMm)!=null&&(t==null?void 0:t.paperHeightMm)!=null?`${t.paperWidthMm}×${t.paperHeightMm}`:"-"},{title:"备注",dataIndex:"remark",ellipsis:!0},{title:"创建时间",dataIndex:"createTime",width:165}],he=[{label:"模板编码",field:"templateCode",component:"Input",colProps:{span:6}},{label:"模板名称",field:"templateName",component:"Input",colProps:{span:6}},{label:"分类",field:"category",component:"JDictSelectTag",componentProps:{dictCode:C,allowClear:!0},colProps:{span:6}}],ee=[{label:"模板编码",field:"templateCode",component:"Input",required:!0,componentProps:{maxlength:64},dynamicDisabled:({values:t})=>!!(t!=null&&t.id)},{label:"模板名称",field:"templateName",component:"Input",required:!0},{label:"分类",field:"category",component:"JDictSelectTag",defaultValue:"form",componentProps:{dictCode:C},required:!0},{label:"纸张规格",field:"paperPreset",component:"JDictSelectTag",defaultValue:"A4",componentProps:({formModel:t})=>({dictCode:Q,allowClear:!0,placeholder:"选择预设规格或自定义",onChange:a=>{const i=w[String(a||"")];i&&(t.paperWidthMm=i.width,t.paperHeightMm=i.height,t.paperOrientation=i.orientation)}})},{label:"纸宽(mm)",field:"paperWidthMm",component:"InputNumber",defaultValue:210,componentProps:{min:10,max:2e3,style:{width:"100%"}}},{label:"纸高(mm)",field:"paperHeightMm",component:"InputNumber",defaultValue:297,componentProps:{min:10,max:2e3,style:{width:"100%"}}},{label:"方向",field:"paperOrientation",component:"Select",defaultValue:"portrait",componentProps:{options:[{label:"纵向",value:"portrait"},{label:"横向",value:"landscape"}]}},{label:"备注",field:"remark",component:"InputTextArea",componentProps:{rows:2}},{label:"",field:"id",component:"Input",show:!1},{label:"",field:"templateJson",component:"Input",show:!1,defaultValue:"{}"}],te=W({__name:"PrintTemplateModal",emits:["success","register"],setup(t,{emit:a}){const i=a,r=y(!1),s=y(!1),c=U(()=>l(r)?"编辑打印模板":"新增打印模板");function u(e){const n=Number((e==null?void 0:e.paperWidthMm)||0),h=Number((e==null?void 0:e.paperHeightMm)||0),f=String((e==null?void 0:e.paperOrientation)||"portrait");return!n||!h?void 0:Object.keys(w).find(o=>{const b=w[o];return b.width===n&&b.height===h&&b.orientation===f})||"CUSTOM"}const[d,{resetFields:p,setFieldsValue:m,validate:I}]=K({labelWidth:110,schemas:ee,showActionButtonGroup:!1,baseColProps:{span:24}}),[v,{setModalProps:g,closeModal:L}]=Y(e=>_(null,null,function*(){if(p(),g({confirmLoading:!1}),r.value=!!(e!=null&&e.isUpdate),s.value=(e==null?void 0:e.isNative)===!0,l(r)&&(e!=null&&e.record)){const n=u(e.record);m(S(T({},e.record),{paperPreset:n||"CUSTOM"}));return}m({paperPreset:"A4"})}));function O(e,n,h){const f=Math.max(10,Number(n)||210),P=Math.max(10,Number(h)||297);try{const o=JSON.parse(e||"{}");if((o==null?void 0:o.engine)==="native")return(!o.page||typeof o.page!="object")&&(o.page={unit:"mm",margin:[10,10,10,10],gridSize:2}),o.page.width=f,o.page.height=P,JSON.stringify(o)}catch(o){}return e}function x(e){const n=Math.max(10,Number((e==null?void 0:e.paperWidthMm)||210)),h=Math.max(10,Number((e==null?void 0:e.paperHeightMm)||297));return JSON.stringify({engine:"native",version:"1.0.0",page:{width:n,height:h,unit:"mm",margin:[10,10,10,10],gridSize:2},elements:[],dataBinding:{fieldMap:{},tableSources:["mainTable","detailList"]}})}function A(){return _(this,null,function*(){try{const e=yield I();delete e.paperPreset,l(r)&&e.templateJson&&(e.templateJson=O(String(e.templateJson),Number(e.paperWidthMm),Number(e.paperHeightMm))),l(r)||(delete e.id,s.value?e.templateJson=x(e):e.templateJson||(e.templateJson="{}")),g({confirmLoading:!0});let n=null;l(r)?n=yield q(e):n=yield z(e),L(),i("success",{isNative:s.value,isUpdate:l(r),values:e,savedResult:n})}finally{g({confirmLoading:!1})}})}return(e,n)=>(F(),V(l(j),G(e.$attrs,{onRegister:l(v),title:c.value,width:"640px",onOk:A,destroyOnClose:""}),{default:H(()=>[D(l($),{onRegister:l(d)},null,8,["onRegister"])]),_:1},16,["onRegister","title"]))}}),de=Object.freeze(Object.defineProperty({__proto__:null,default:te},Symbol.toStringTag,{value:"Module"}));export{de as P,te as _,me as c,he as s};