import{k as T,E as S}from"./index.BKEMpsLA.js";import{createCrudOptions as j}from"./crud.BKJ3Z8m3.js";import{_ as q}from"./index.vue_vue_type_script_setup_true_lang.Ll1utYSV.js";import{_ as A}from"./index.vue_vue_type_script_setup_true_lang.Bv6i0bWJ.js";import{_ as N}from"./index.vue_vue_type_script_setup_true_lang.BZnHs63z.js";import{_ as H}from"./index.vue_vue_type_script_setup_true_lang.BHa7VSjx.js";import{_ as J}from"./index.vue_vue_type_script_setup_true_lang.CXZlov1z.js";import K from"./SettlementDialog.D5XsafBe.js";import{U as P,A as Z}from"./api.DPMoyOcC.js";import{a as F,r as i,q as z,Z as G,aj as $,J as b,o as y,K as I,S as g,M as h,H as Q,u as x,t as a}from"./vue.YrNK8sx4.js";import"./index.vue_vue_type_script_setup_true_lang.DPcMoT8a.js";import"./api.DDmks2Xr.js";import"./api.Dv806c7F.js";import"./api.DBbkK7jc.js";import"./index.vue_vue_type_script_setup_true_lang.BEnB_T-q.js";import"./index.BLhOp19b.js";import"./api.DMIi2eFH.js";import"./crud.CbTQXB9v.js";import"./columnPermission.BZw343bd.js";import"./index.vue_vue_type_script_setup_true_lang.mNXE7Mpb.js";import"./_plugin-vue_export-helper.DlAUqK2U.js";import"./index.vue_vue_type_script_setup_true_lang.C0NDDu1F.js";import"./api.BT1AK3Px.js";import"./index.CqgzMLTt.js";import"./index.CEXDsK6x.js";const W=F({name:"borrow"}),Le=F({...W,setup(X){const{crudBinding:M,crudRef:u,crudExpose:d}=T({createCrudOptions:j}),m=i(!1),v=i(!1),w=i(!1),c=i(!1),n=i(!1),r=i({}),f=i(!1),L=i({});function p(o,e,l){m.value=!1,a(()=>{r.value={...l||{},borrow_type:o,mode:e}}),o===1?(console.log("mode:::",e),e==="view"?n.value=!0:w.value=!0):o===2?(console.log("mode:::",e),e==="view"?n.value=!0:c.value=!0):o===0&&(e==="view"?n.value=!0:v.value=!0)}async function _(o){try{o.mode==="edit"?(await P(o),S.success("编辑成功")):(await Z(o),S.success("添加成功")),u.value&&u.value.doRefresh&&u.value.doRefresh(),d.doRefresh()}catch(e){console.error(o.mode==="edit"?"编辑失败":"提交失败",e),S.error(o.mode==="edit"?"编辑失败":"提交失败")}}async function O(o){try{d.doRefresh()}catch(e){console.error("提交失败",e)}}async function R(o){const e=o.detail;console.log("row:::",e),n.value=!0,console.log("showCollectDialog:::",n.value),a(()=>{r.value={...e,mode:"collect"}})}async function V(o){const e=o.detail;console.log("row:::",e),n.value=!0,a(()=>{r.value={...e,mode:"return"}}),console.log("showReturnDialog:::",n.value)}async function B(o){const e=o.detail;p(e.borrow_type,"view",e)}async function C(o){const e=o.detail;p(e.borrow_type,"edit",e)}async function k(o){const e=o.detail;p(e.borrow_type)}async function U(o){const e=o.detail;f.value=!0,a(()=>{r.value={...e,mode:"settlement"}})}async function D(o){const e=o.detail;f.value=!0,a(()=>{r.value={...e,mode:"renew"}})}let s=null;return z(()=>{d.doRefresh(),window.addEventListener("borrow-view",B),window.addEventListener("borrow-edit",C),window.addEventListener("borrow-remove",k),window.addEventListener("borrow-collect",R),window.addEventListener("borrow-return",V),window.addEventListener("borrow-settlement",U),window.addEventListener("renew-device",D);const o=document.querySelector(".borrow-page .fs-actionbar");if(!o)return;function e(){if(o&&!o.querySelector(".my-create-btn")){const l=document.createElement("button");l.className="el-button el-button--primary el-button--default my-create-btn",l.innerHTML="创建借用单",l.onclick=()=>{m.value=!0},o.append(l)}}e(),s=new MutationObserver((l,E)=>{e(),E.disconnect()}),s.observe(o,{childList:!0})}),G(()=>{s&&(s.disconnect(),s=null),window.removeEventListener("borrow-view",B),window.removeEventListener("borrow-edit",C),window.removeEventListener("borrow-remove",k),window.removeEventListener("borrow-collect",R),window.removeEventListener("borrow-return",V),window.removeEventListener("borrow-settlement",U),window.removeEventListener("renew-device",D)}),(o,e)=>{const l=$("fs-crud"),E=$("fs-page");return y(),b(E,{class:"borrow-page"},{default:I(()=>[g(l,Q({ref_key:"crudRef",ref:u},x(M)),null,16),g(q,{visible:m.value,"onUpdate:visible":e[0]||(e[0]=t=>m.value=t),onSelect:p},null,8,["visible"]),v.value?(y(),b(A,{key:0,visible:v.value,"onUpdate:visible":e[1]||(e[1]=t=>v.value=t),modelValue:r.value,onSubmit:_,onRefresh:e[2]||(e[2]=t=>x(d).doRefresh())},null,8,["visible","modelValue"])):h("",!0),w.value?(y(),b(N,{key:1,visible:w.value,"onUpdate:visible":e[3]||(e[3]=t=>w.value=t),modelValue:r.value,lastFormSnapshot:L.value,"onUpdate:lastFormSnapshot":e[4]||(e[4]=t=>L.value=t),onSubmit:_},null,8,["visible","modelValue","lastFormSnapshot"])):h("",!0),c.value?(y(),b(H,{key:2,visible:c.value,"onUpdate:visible":e[5]||(e[5]=t=>c.value=t),modelValue:r.value,onSubmit:_},null,8,["visible","modelValue"])):h("",!0),g(J,{visible:n.value,"onUpdate:visible":e[6]||(e[6]=t=>n.value=t),modelValue:r.value,onSubmit:O},null,8,["visible","modelValue"]),g(K,{visible:f.value,"onUpdate:visible":e[7]||(e[7]=t=>f.value=t),modelValue:r.value},null,8,["visible","modelValue"])]),_:1})}}});export{Le as default};
