import{k as F,E as M}from"./index.CN1lNsL-.js";import{createCrudOptions as T}from"./crud.gAFxRZ58.js";import{_ as $}from"./index.vue_vue_type_script_setup_true_lang.EAJsqNb7.js";import{_ as q}from"./index.vue_vue_type_script_setup_true_lang.DhU0Mv7c.js";import{_ as x}from"./index.vue_vue_type_script_setup_true_lang.Dct-16Lw.js";import{_ as A}from"./index.vue_vue_type_script_setup_true_lang.CijaK08F.js";import N from"./SettlementDialog.Dv1BWzOA.js";import{A as O}from"./api.o0pCW0KB.js";import{a as B,r as a,q as j,Z as H,aj as L,J as p,o as y,K as J,S as v,M as V,H as K,u as P,t as w}from"./vue.YrNK8sx4.js";import"./index.vue_vue_type_script_setup_true_lang.BxK00RXb.js";import"./api.BlfGKqFh.js";import"./api.EJ6EzJuI.js";import"./index.DGhZWrxe.js";import"./api.Cpwr_LRz.js";import"./crud.BXEgOpmV.js";import"./columnPermission.Cb6zaPuX.js";import"./index.vue_vue_type_script_setup_true_lang.x-VeFpYo.js";import"./_plugin-vue_export-helper.DlAUqK2U.js";import"./index.vue_vue_type_script_setup_true_lang.D-g3gj9W.js";const Z=B({name:"borrow"}),ve=B({...Z,setup(z){const{crudBinding:C,crudRef:i,crudExpose:f}=F({createCrudOptions:T}),u=a(!1),d=a(!1),m=a(!1),l=a(!1),r=a({}),b=a(!1);function c(o,e,n){u.value=!1,w(()=>{r.value={...n||{},borrow_type:o,mode:e}}),o===1?d.value=!0:o===2?m.value=!0:o===0&&(l.value=!0)}async function _(o){try{await O(o),M.success("保存成功"),i.value&&i.value.doRefresh&&i.value.doRefresh(),f.doRefresh()}catch(e){console.error("提交失败",e)}}async function R(o){try{f.doRefresh()}catch(e){console.error("提交失败",e)}}async function g(o){const e=o.detail;console.log("row:::",e),l.value=!0,console.log("showCollectDialog:::",l.value),w(()=>{r.value={...e,mode:"collect"}})}async function S(o){const e=o.detail;console.log("row:::",e),l.value=!0,w(()=>{r.value={...e,mode:"return"}}),console.log("showReturnDialog:::",l.value)}async function h(o){const e=o.detail;c(e.borrow_type,"view",e)}async function k(o){const e=o.detail;c(e.borrow_type,"edit",e)}async function D(o){const e=o.detail;c(e.borrow_type)}async function E(o){const e=o.detail;b.value=!0,w(()=>{r.value={...e,mode:"settlement"}})}let s=null;return j(()=>{f.doRefresh(),window.addEventListener("borrow-view",h),window.addEventListener("borrow-edit",k),window.addEventListener("borrow-remove",D),window.addEventListener("borrow-collect",g),window.addEventListener("borrow-return",S),window.addEventListener("borrow-settlement",E);function o(){const e=document.querySelector(".borrow-page .fs-actionbar");if(e&&!e.querySelector(".my-create-btn")){const n=document.createElement("button");n.className="el-button el-button--primary el-button--default my-create-btn",n.innerHTML="创建借用单",n.onclick=()=>{u.value=!0},e.append(n)}}o(),s=new MutationObserver(()=>{o()}),s.observe(document.body,{childList:!0,subtree:!0})}),H(()=>{s&&(s.disconnect(),s=null),window.removeEventListener("borrow-view",h),window.removeEventListener("borrow-collect",g),window.removeEventListener("borrow-return",S),window.removeEventListener("borrow-settlement",E)}),(o,e)=>{const n=L("fs-crud"),U=L("fs-page");return y(),p(U,{class:"borrow-page"},{default:J(()=>[v(n,K({ref_key:"crudRef",ref:i},P(C)),null,16),v($,{visible:u.value,"onUpdate:visible":e[0]||(e[0]=t=>u.value=t),onSelect:c},null,8,["visible"]),d.value?(y(),p(q,{key:0,visible:d.value,"onUpdate:visible":e[1]||(e[1]=t=>d.value=t),modelValue:r.value,lastFormSnapshot:o.lastFormSnapshot,"onUpdate:lastFormSnapshot":e[2]||(e[2]=t=>o.lastFormSnapshot=t),onSubmit:_},null,8,["visible","modelValue","lastFormSnapshot"])):V("",!0),m.value?(y(),p(x,{key:1,visible:m.value,"onUpdate:visible":e[3]||(e[3]=t=>m.value=t),modelValue:r.value,onSubmit:_},null,8,["visible","modelValue"])):V("",!0),v(A,{visible:l.value,"onUpdate:visible":e[4]||(e[4]=t=>l.value=t),modelValue:r.value,onSubmit:R},null,8,["visible","modelValue"]),v(N,{visible:b.value,"onUpdate:visible":e[5]||(e[5]=t=>b.value=t),modelValue:r.value},null,8,["visible","modelValue"])]),_:1})}}});export{ve as default};
