import{a as A,f as p,r as b,w as P,aj as m,J as V,o as f,K as a,b as t,S as r,c as E,M as D,Q as i,R as J,a9 as K,L as S,an as F,P as W}from"./vue.D1BjjNmv.js";import{R as O}from"./api.BGRTtbog.js";import{E as _}from"./index.Df8UJ10K.js";import{_ as Q}from"./_plugin-vue_export-helper.DlAUqK2U.js";const Y={class:"form-content"},G={class:"form-content"},H={class:"form-content"},X={class:"form-content"},Z={class:"form-content"},ee={class:"form-content"},te={class:"table-container"},oe={class:"detail-table"},le={class:"accessories-info"},ne={class:"form-content"},ae={class:"remark-info"},re={class:"form-content"},ie={key:0},se=A({__name:"SettlementDialog",props:{visible:{type:Boolean},settlementData:{},modelValue:{}},emits:["update:visible","update:modelValue"],setup(I,{emit:M}){const c=I,w=M,z=p(()=>{var o;return((o=c.modelValue)==null?void 0:o.mode)==="settlement"}),B=p(()=>{var o;return((o=c.modelValue)==null?void 0:o.mode)==="renew"}),x=b(!1),n=b({}),y=b(""),h=b(1);P(()=>c.visible,o=>{x.value=o,o&&(n.value=c.modelValue||c.settlementData||{})}),P(()=>c.modelValue,o=>{console.log("val:::",o),o&&(n.value=o,console.log("formData.value:::",n.value))},{immediate:!0});const R=p(()=>{var o,e,l,s;return((e=(o=n.value)==null?void 0:o.app_user_borrower)==null?void 0:e.name)||((s=(l=n.value)==null?void 0:l.borrower_info)==null?void 0:s.name)||""}),U=p(()=>{var o,e,l,s;return((e=(o=n.value)==null?void 0:o.app_user_borrower)==null?void 0:e.user_code)||((s=(l=n.value)==null?void 0:l.borrower_info)==null?void 0:s.user_code)||""}),L=p(()=>{var o,e;return((o=n.value)==null?void 0:o.borrow_type_label)||((e=n.value)==null?void 0:e.borrow_type)||""}),g=p(()=>{var o,e;return((e=(o=n.value)==null?void 0:o.items)==null?void 0:e.filter(l=>(l==null?void 0:l.device)!==null))||[]}),N=()=>{w("update:visible",!1),w("update:modelValue",n.value)};async function $(){console.log("filteredItems::",g.value.length),console.log("formData.value::",n.value);for(let o=0;o<g.value.length;o++){g.value[o];const e={renewal_days:h.value,return_remark:y.value,id:n.value.id};try{const l=await O(e);l.code===2e3&&(console.log(`设备 ${e.device} 续借申请提交成功`,l),w("update:visible",!1),w("update:modelValue",n.value),_.success("续借申请提交成功"))}catch(l){console.error(`设备 ${e.device} 续借申请提交失败`,l),_.success("续借申请提交失败")}}}const k=b(null),j=()=>{try{if(!k.value){_.error("打印区域未找到");return}const o=k.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(`
      <!DOCTYPE html>
      <html>
        <head>
          <meta charset="utf-8">
          <title>设备借用单打印</title>
          <style>
                          /* 打印样式 */
              @media print {
                body {
                  font-family: Arial, sans-serif;
                  padding: 20px;
                  margin: 0;
                }
                .no-print {
                  display: none !important;
                }
                /* 表单布局优化 */
                .el-form {
                  width: 100%;
                }
                .el-row {
                  display: flex !important;
                  flex-wrap: nowrap !important;
                  margin: 0 -8px;
                }
                .el-col {
                  padding: 0 8px;
                  flex: 1;
                }
                /* 表单项样式 */
                .el-form-item {
                  margin-bottom: 12px;
                  page-break-inside: avoid;
                }
                .el-form-item__label {
                  font-weight: bold;
                  margin-bottom: 4px;
                  display: block;
                }
                .el-form-item__content {
                  line-height: 1.5;
                }
                /* 表格样式优化 */
                table {
                  page-break-inside: auto;
                  width: 100% !important;
                  border-collapse: collapse;
                  margin: 20px 0;
                  table-layout: fixed;
                }
                tr {
                  page-break-inside: avoid;
                  page-break-after: auto;
                }
                th, td {
                  border: 1px solid #000;
                  padding: 8px;
                  text-align: center;
                  word-break: break-all;
                }
                /* 隐藏Element Plus的默认样式 */
                .el-input__inner {
                  border: none !important;
                  padding: 0 !important;
                }
                .el-form--label-top .el-form-item__label {
                  padding: 0;
                }
                /* 标题样式 */
                h2 {
                  text-align: center;
                  margin-bottom: 30px;
                  font-size: 24px;
                }
                /* 明细表标题 */
                .detail-title {
                  font-weight: bold;
                  margin: 20px 0 10px;
                  font-size: 16px;
                }
                /* 配件信息和备注 */
                .accessories-info,
                .remark-info {
                  margin-top: 20px;
                }
                .accessories-info .el-input,
                .remark-info .el-input {
                  width: 100%;
                }
            }
            /* 屏幕预览样式 */
            @media screen {
              body {
                background-color: #fff;
                padding: 20px;
              }
            }
          </style>
        </head>
        <body>
          <h2 style="text-align: center; margin-bottom: 30px;">设备借用单</h2>
        </body>
      </html>
    `);const s=l.body;s.appendChild(o);const u=l.createElement("button");if(u.className="no-print",u.textContent="打印",u.style.cssText=`
      position: fixed;
      top: 20px;
      right: 20px;
      padding: 10px 20px;
      background: #409EFF;
      color: white;
      border: none;
      border-radius: 4px;
      cursor: pointer;
      z-index: 9999;
    `,u.onclick=()=>{try{if(e.contentWindow)e.contentWindow.print();else throw new Error("打印窗口未准备好")}catch(v){console.error("打印过程出错:",v),_.error("打印失败，请重试")}},s.appendChild(u),e.contentWindow)e.contentWindow.focus(),setTimeout(()=>{try{if(e.contentWindow)e.contentWindow.print();else throw new Error("打印窗口未准备好")}catch(v){console.error("打印过程出错:",v),_.error("打印失败，请重试")}finally{document.body.removeChild(e)}},500);else throw new Error("打印窗口未准备好")}catch(o){console.error("打印准备过程出错:",o),_.error("打印准备失败，请重试")}};return(o,e)=>{const l=m("el-form-item"),s=m("el-col"),u=m("el-row"),v=m("el-form"),C=m("el-button"),q=m("el-dialog");return f(),V(q,{modelValue:x.value,"onUpdate:modelValue":e[2]||(e[2]=d=>x.value=d),title:z.value?"领取设备结算单":"续借",width:"75%","close-on-click-modal":!1,onClose:N},{footer:a(()=>[r(C,{onClick:N},{default:a(()=>e[9]||(e[9]=[W("关闭")])),_:1}),z.value?(f(),V(C,{key:0,type:"primary",onClick:j},{default:a(()=>e[10]||(e[10]=[W("打印")])),_:1})):D("",!0),B.value?(f(),V(C,{key:1,type:"primary",onClick:$},{default:a(()=>e[11]||(e[11]=[W("提交")])),_:1})):D("",!0)]),default:a(()=>[t("div",{ref_key:"printContent",ref:k,class:"print-container"},[r(v,{model:n.value,"label-width":"110px","label-position":"top",class:"print-form"},{default:a(()=>[r(u,{gutter:16},{default:a(()=>[r(s,{span:8},{default:a(()=>[r(l,{label:"借用单编号"},{default:a(()=>[t("div",Y,i(n.value.application_no),1)]),_:1})]),_:1}),r(s,{span:8},{default:a(()=>[r(l,{label:"借用人"},{default:a(()=>[t("div",G,i(R.value),1)]),_:1})]),_:1}),r(s,{span:8},{default:a(()=>[r(l,{label:"学号/工号"},{default:a(()=>[t("div",H,i(U.value),1)]),_:1})]),_:1})]),_:1}),r(u,{gutter:16},{default:a(()=>[r(s,{span:8},{default:a(()=>[r(l,{label:"借用性质"},{default:a(()=>[t("div",X,i(L.value),1)]),_:1})]),_:1}),r(s,{span:8},{default:a(()=>[r(l,{label:"借出时间"},{default:a(()=>[t("div",Z,i(n.value.expected_start_time),1)]),_:1})]),_:1}),r(s,{span:8},{default:a(()=>[r(l,{label:"预计归还时间"},{default:a(()=>[t("div",ee,i(n.value.expected_end_time),1)]),_:1})]),_:1})]),_:1}),e[8]||(e[8]=t("div",{class:"detail-title"},"借用明细表",-1)),t("div",te,[t("table",oe,[e[3]||(e[3]=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,[(f(!0),E(J,null,K(g.value,(d,T)=>(f(),E("tr",{key:T},[t("td",null,i(T+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",le,[e[4]||(e[4]=t("div",{class:"detail-title"},"配件信息",-1)),t("div",ne,i(n.value.pre_borrow_accessories||"-"),1)]),t("div",ae,[e[5]||(e[5]=t("div",{class:"detail-title"},"备注",-1)),t("div",re,i(n.value.remark||"-"),1)]),B.value?(f(),E("div",ie,[e[6]||(e[6]=t("div",{style:{"margin-bottom":"8px","font-weight":"bold"}},"续借时间（天）",-1)),S(t("input",{"onUpdate:modelValue":e[0]||(e[0]=d=>h.value=d),type:"number",min:"1",placeholder:"请输入续借天数",style:{width:"100%",border:"1px solid #dcdfe6",padding:"8px","box-sizing":"border-box"}},null,512),[[F,h.value,void 0,{number:!0}]]),e[7]||(e[7]=t("div",{style:{"margin-bottom":"8px","font-weight":"bold"}},"续借理由",-1)),S(t("textarea",{"onUpdate:modelValue":e[1]||(e[1]=d=>y.value=d),placeholder:"请输入续借理由",rows:"3",style:{width:"100%",border:"1px solid #dcdfe6",padding:"8px",resize:"vertical","box-sizing":"border-box"}},null,512),[[F,y.value]])])):D("",!0)]),_:1},8,["model"])],512)]),_:1},8,["modelValue","title"])}}}),me=Q(se,[["__scopeId","data-v-36aa8ba4"]]);export{me as default};
