import{k,E as t}from"./index.Df8UJ10K.js";import{createCrudOptions as I}from"./curd.BkPLNyqs.js";import{B as x}from"./api.B6TjG0We.js";import{_ as S}from"./index.vue_vue_type_script_setup_true_lang.BDOPRtT_.js";import j from"./WarehouseSelectDialog.mjWN9TN7.js";import{a as y,r,q as F,Z as D,aj as _,J as h,o as R,K as M,S as g,M as O,H as U,u as W,t as L,C as u}from"./vue.D1BjjNmv.js";import"./index.vue_vue_type_script_setup_true_lang.BUKVPzHI.js";import"./api.CWkru0hL.js";import"./api.DmW_DFI3.js";import"./index.vue_vue_type_script_setup_true_name_RefuseNotification_lang.EsaaaZz7.js";import"./api.BGRTtbog.js";import"./api.CLXii9pQ.js";import"./_plugin-vue_export-helper.DlAUqK2U.js";const N=y({name:"approval"}),oe=y({...N,setup(T){const d=r(!1),m=r(""),p=r(null),n=r(!1),f=r({}),i=r(!1),v=r(null),{crudBinding:B,crudRef:a,crudExpose:l,crudOptions:q}=k({createCrudOptions:e=>I({...e,showRejectDialog:d,rejectReason:m,currentFormId:p,showWarehouseDialog:i,currentApprovalFormId:v})});u("showRejectDialog",d),u("rejectReason",m),u("currentFormId",p),u("crudExpose",l);function C(e,o,s){L(()=>{f.value={...s||{},borrow_type:e,mode:o}}),e!=1&&(n.value=!0)}async function w(e){const s=e.detail;C(s.borrow_type,"view",s)}async function b(e){try{e.mode==="edit"?t.success("编辑成功"):t.success("添加成功"),a.value&&a.value.doRefresh&&a.value.doRefresh(),l.doRefresh()}catch(o){console.error(e.mode==="edit"?"编辑失败":"提交失败",o),t.error(e.mode==="edit"?"编辑失败":"提交失败")}}async function E(e){try{await x(e.formId,"approve","同意借用",e.warehouseId),t.success("审批通过"),l.doRefresh()}catch(o){console.error("审批失败:",o),t.error("审批失败")}}return r(null),F(()=>{l.doRefresh(),window.addEventListener("approve-view",w)}),D(()=>{window.removeEventListener("approve-view",w)}),(e,o)=>{const s=_("fs-crud"),V=_("fs-page");return R(),h(V,null,{default:M(()=>[g(s,U({ref_key:"crudRef",ref:a},W(B)),null,16),n.value?(R(),h(S,{key:0,visible:n.value,"onUpdate:visible":o[0]||(o[0]=c=>n.value=c),modelValue:f.value,onSubmit:b},null,8,["visible","modelValue"])):O("",!0),g(j,{modelValue:i.value,"onUpdate:modelValue":o[1]||(o[1]=c=>i.value=c),formId:v.value,onConfirm:E},null,8,["modelValue","formId"])]),_:1})}}});export{oe as default};
