SettlementDialog.C9fVOzum.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import{E as f}from"./index.DXluV3p1.js";import{a as P,r as h,w as C,f as _,ao as p,K as I,o as g,L as n,b as t,T as r,R as i,c as E,S as L,a9 as q,Q as V}from"./vue.fY72QXCX.js";import{_ as A}from"./_plugin-vue_export-helper.DlAUqK2U.js";const K={class:"form-content"},M={class:"form-content"},O={class:"form-content"},Q={class:"form-content"},R={class:"form-content"},U={class:"form-content"},Y={class:"table-container"},j={class:"detail-table"},G={class:"accessories-info"},H={class:"form-content"},J={class:"remark-info"},X={class:"form-content"},Z=P({__name:"SettlementDialog",props:{visible:{type:Boolean},settlementData:{},modelValue:{}},emits:["update:visible","update:modelValue"],setup(D,{emit:W}){const m=D,w=W,b=h(!1),a=h({});C(()=>m.visible,o=>{b.value=o,o&&(a.value=m.modelValue||m.settlementData||{})}),C(()=>m.modelValue,o=>{console.log("val:::",o),o&&(a.value=o,console.log("formData.value:::",a.value))},{immediate:!0});const B=_(()=>{var o,e,l,s;return((e=(o=a.value)==null?void 0:o.app_user_borrower)==null?void 0:e.name)||((s=(l=a.value)==null?void 0:l.borrower_info)==null?void 0:s.name)||""}),T=_(()=>{var o,e,l,s;return((e=(o=a.value)==null?void 0:o.app_user_borrower)==null?void 0:e.user_code)||((s=(l=a.value)==null?void 0:l.borrower_info)==null?void 0:s.user_code)||""}),N=_(()=>{var o,e;return((o=a.value)==null?void 0:o.borrow_type_label)||((e=a.value)==null?void 0:e.borrow_type)||""}),S=_(()=>{var o,e;return((e=(o=a.value)==null?void 0:o.items)==null?void 0:e.filter(l=>(l==null?void 0:l.device)!==null))||[]}),x=()=>{w("update:visible",!1),w("update:modelValue",a.value)},v=h(null),z=()=>{try{if(!v.value){f.error("打印区域未找到");return}const o=v.value.cloneNode(!0),e=document.createElement("iframe");if(e.style.position="absolute",e.style.width="0px",e.style.height="0px",e.style.left="-9999px",document.body.appendChild(e),!e.contentWindow||!e.contentWindow.document)throw new Error("iframe初始化失败");const l=e.contentWindow.document;l.write(`
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <meta charset="utf-8">
  6. <title>设备借用单打印</title>
  7. <style>
  8. /* 打印样式 */
  9. @media print {
  10. body {
  11. font-family: Arial, sans-serif;
  12. padding: 20px;
  13. margin: 0;
  14. }
  15. .no-print {
  16. display: none !important;
  17. }
  18. /* 表单布局优化 */
  19. .el-form {
  20. width: 100%;
  21. }
  22. .el-row {
  23. display: flex !important;
  24. flex-wrap: nowrap !important;
  25. margin: 0 -8px;
  26. }
  27. .el-col {
  28. padding: 0 8px;
  29. flex: 1;
  30. }
  31. /* 表单项样式 */
  32. .el-form-item {
  33. margin-bottom: 12px;
  34. page-break-inside: avoid;
  35. }
  36. .el-form-item__label {
  37. font-weight: bold;
  38. margin-bottom: 4px;
  39. display: block;
  40. }
  41. .el-form-item__content {
  42. line-height: 1.5;
  43. }
  44. /* 表格样式优化 */
  45. table {
  46. page-break-inside: auto;
  47. width: 100% !important;
  48. border-collapse: collapse;
  49. margin: 20px 0;
  50. table-layout: fixed;
  51. }
  52. tr {
  53. page-break-inside: avoid;
  54. page-break-after: auto;
  55. }
  56. th, td {
  57. border: 1px solid #000;
  58. padding: 8px;
  59. text-align: center;
  60. word-break: break-all;
  61. }
  62. /* 隐藏Element Plus的默认样式 */
  63. .el-input__inner {
  64. border: none !important;
  65. padding: 0 !important;
  66. }
  67. .el-form--label-top .el-form-item__label {
  68. padding: 0;
  69. }
  70. /* 标题样式 */
  71. h2 {
  72. text-align: center;
  73. margin-bottom: 30px;
  74. font-size: 24px;
  75. }
  76. /* 明细表标题 */
  77. .detail-title {
  78. font-weight: bold;
  79. margin: 20px 0 10px;
  80. font-size: 16px;
  81. }
  82. /* 配件信息和备注 */
  83. .accessories-info,
  84. .remark-info {
  85. margin-top: 20px;
  86. }
  87. .accessories-info .el-input,
  88. .remark-info .el-input {
  89. width: 100%;
  90. }
  91. }
  92. /* 屏幕预览样式 */
  93. @media screen {
  94. body {
  95. background-color: #fff;
  96. padding: 20px;
  97. }
  98. }
  99. </style>
  100. </head>
  101. <body>
  102. <h2 style="text-align: center; margin-bottom: 30px;">设备借用单</h2>
  103. </body>
  104. </html>
  105. `);const s=l.body;s.appendChild(o);const c=l.createElement("button");if(c.className="no-print",c.textContent="打印",c.style.cssText=`
  106. position: fixed;
  107. top: 20px;
  108. right: 20px;
  109. padding: 10px 20px;
  110. background: #409EFF;
  111. color: white;
  112. border: none;
  113. border-radius: 4px;
  114. cursor: pointer;
  115. z-index: 9999;
  116. `,c.onclick=()=>{try{if(e.contentWindow)e.contentWindow.print();else throw new Error("打印窗口未准备好")}catch(u){console.error("打印过程出错:",u),f.error("打印失败,请重试")}},s.appendChild(c),e.contentWindow)e.contentWindow.focus(),setTimeout(()=>{try{if(e.contentWindow)e.contentWindow.print();else throw new Error("打印窗口未准备好")}catch(u){console.error("打印过程出错:",u),f.error("打印失败,请重试")}finally{document.body.removeChild(e)}},500);else throw new Error("打印窗口未准备好")}catch(o){console.error("打印准备过程出错:",o),f.error("打印准备失败,请重试")}};return(o,e)=>{const l=p("el-form-item"),s=p("el-col"),c=p("el-row"),u=p("el-form"),y=p("el-button"),F=p("el-dialog");return g(),I(F,{modelValue:b.value,"onUpdate:modelValue":e[0]||(e[0]=d=>b.value=d),title:"领取设备结算单",width:"75%","close-on-click-modal":!1,onClose:x},{footer:n(()=>[r(y,{onClick:x},{default:n(()=>e[5]||(e[5]=[V("关闭",-1)])),_:1,__:[5]}),r(y,{type:"primary",onClick:z},{default:n(()=>e[6]||(e[6]=[V("打印",-1)])),_:1,__:[6]})]),default:n(()=>[t("div",{ref_key:"printContent",ref:v,class:"print-container"},[r(u,{model:a.value,"label-width":"110px","label-position":"top",class:"print-form"},{default:n(()=>[r(c,{gutter:16},{default:n(()=>[r(s,{span:8},{default:n(()=>[r(l,{label:"借用单编号"},{default:n(()=>[t("div",K,i(a.value.application_no),1)]),_:1})]),_:1}),r(s,{span:8},{default:n(()=>[r(l,{label:"借用人"},{default:n(()=>[t("div",M,i(B.value),1)]),_:1})]),_:1}),r(s,{span:8},{default:n(()=>[r(l,{label:"学号/工号"},{default:n(()=>[t("div",O,i(T.value),1)]),_:1})]),_:1})]),_:1}),r(c,{gutter:16},{default:n(()=>[r(s,{span:8},{default:n(()=>[r(l,{label:"借用性质"},{default:n(()=>[t("div",Q,i(N.value),1)]),_:1})]),_:1}),r(s,{span:8},{default:n(()=>[r(l,{label:"借出时间"},{default:n(()=>[t("div",R,i(a.value.expected_start_time),1)]),_:1})]),_:1}),r(s,{span:8},{default:n(()=>[r(l,{label:"预计归还时间"},{default:n(()=>[t("div",U,i(a.value.expected_end_time),1)]),_:1})]),_:1})]),_:1}),e[4]||(e[4]=t("div",{class:"detail-title"},"借用明细表",-1)),t("div",Y,[t("table",j,[e[1]||(e[1]=t("thead",null,[t("tr",null,[t("th",{width:"60"},"序号"),t("th",null,"设备编号"),t("th",null,"设备分类"),t("th",null,"设备名称"),t("th",null,"借用数量"),t("th",null,"规格型号"),t("th",null,"存放位置"),t("th",null,"备注")])],-1)),t("tbody",null,[(g(!0),E(L,null,q(S.value,(d,k)=>(g(),E("tr",{key:k},[t("td",null,i(k+1),1),t("td",null,i(d.device_code),1),t("td",null,i(d.device_category_name),1),t("td",null,i(d.device_name),1),t("td",null,i(d.quantity),1),t("td",null,i(d.device_specification),1),t("td",null,i(d.device_storage_location||"-"),1),t("td",null,i(d.remark||"-"),1)]))),128))])])]),t("div",G,[e[2]||(e[2]=t("div",{class:"detail-title"},"配件信息",-1)),t("div",H,i(a.value.accessories||"-"),1)]),t("div",J,[e[3]||(e[3]=t("div",{class:"detail-title"},"备注",-1)),t("div",X,i(a.value.remark||"-"),1)])]),_:1,__:[4]},8,["model"])],512)]),_:1},8,["modelValue"])}}}),oe=A(Z,[["__scopeId","data-v-1dd018fc"]]);export{oe as default};