import x from"./basic-purchase.5bb63e11.js";import A from"./add-order-modal.36ad9e8f.js";import{u as g}from"./use-response-handle.23bba72b.js";import{q as O,x as S,a2 as y,B as i,a4 as L,b0 as P,r as U,o as N,n as h,t as n,H as u,v as r,P as w,bi as H,I}from"./index.10c3f8e5.js";import{c as $,d as q}from"./index.44c8546a.js";import{R as _}from"./remote-select.1801f2db.js";import{h as M}from"./index.cefa9fb5.js";import{h as V}from"./index.88eb7924.js";import{r as j}from"./configs.051126a9.js";import"./status.7319085b.js";const z={key:0,flex:"","gap-10":""},oe=O({__name:"index",props:{payNo:null,statementDetail:null},setup(c){const p=c,{push:C}=S(),B=y(()=>!!p.payNo),b=g(),d=i(null),D=y(()=>Number(p.statementDetail&&p.statementDetail.status)>=0),t=i([]),m=i(null),e=L({cids:"",supplierNo:"",companyNo:""});function E(){d.value.onDisplay(r(t))}function f(a){t.value=a,v()}function F({id:a}){const o=t.value.findIndex(s=>String(s.id)===String(a));o<0||(t.value.splice(o,1),v())}function k(){m.value.validate(async a=>{if(!a)return;const o=B.value?$:q,{cids:s}=e,{code:l,message:R}=await o({cids:s,...p.payNo?{payNo:p.payNo}:{}});b({code:l,message:R,handler:()=>C("/purchase/orderRecord")})})}const v=()=>{e.cids=t.value.map(a=>a.id).join(",")};return P(()=>{const{supplierNo:a,companyNo:o}=e;(!a||!o)&&(t.value=[])}),(a,o)=>{const s=U("el-form-item");return N(),h(I,null,[n(r(H),{ref_key:"formRef",ref:m,model:e,rules:r(j),disabled:r(D)},{default:u(()=>[c.payNo?w("",!0):(N(),h("div",z,[n(s,{label:"\u4E1A\u52A1\u516C\u53F8",prop:"companyNo"},{default:u(()=>[n(r(_),{value:e.companyNo,"onUpdate:value":o[0]||(o[0]=l=>e.companyNo=l),api:r(V),placeholder:"\u8BF7\u9009\u62E9\u4E1A\u52A1\u516C\u53F8","request-prop":"companyName","response-label-prop":"company_name","response-val-prop":"companyNo"},null,8,["value","api"])]),_:1}),n(s,{label:"\u4F9B\u5E94\u5546",prop:"supplierNo"},{default:u(()=>[n(r(_),{value:e.supplierNo,"onUpdate:value":o[1]||(o[1]=l=>e.supplierNo=l),api:r(M),placeholder:"\u8BF7\u9009\u62E9\u4F9B\u5E94\u5546","response-label-prop":"name","response-val-prop":"code"},null,8,["value","api"])]),_:1})])),n(s,{label:"\u91C7\u8D2D\u5355\u4FE1\u606F",prop:"cids"},{default:u(()=>[n(x,{"purchase-order-list":t.value,"supplier-no":e.supplierNo,"company-no":e.companyNo,onAddBtnClick:E,onDelBtnClick:F,onCrateBtnClick:k,onChangeSupplieList:f},null,8,["purchase-order-list","supplier-no","company-no"])]),_:1})]),_:1},8,["model","rules","disabled"]),n(A,{ref_key:"addOrderModalRef",ref:d,"supplier-no":e.supplierNo,"company-no":e.companyNo,onSaveBtnClick:f},null,8,["supplier-no","company-no"])],64)}}});export{oe as default};
