import A from"./basic-purchase.ba1d31fb.js";import k from"./add-order-modal.468df5a2.js";import{u as R}from"./use-response-handle.e6cae34f.js";import{_ as S,q as O,x as I,a2 as _,B as l,a4 as w,aC as L,r as P,o as h,n as y,t as u,H as c,v as s,P as U,aD as H,I as $}from"./index.d8ce26ef.js";import{b as M,c as V}from"./index.79955875.js";import{R as g}from"./remote-select.0c28bf23.js";import{h as j}from"./index.b57c1791.js";import{h as z}from"./index.8916d48f.js";import"./status.fad06285.js";import"./global.9ad647c8.js";const G={cids:{required:!0,trigger:"change",message:"\u8BF7\u6DFB\u52A0\u91C7\u8D2D\u5355\u4FE1\u606F"},companyNo:{required:!0,trigger:"change",message:"\u8BF7\u9009\u62E9\u4E1A\u52A1\u516C\u53F8"},supplierNo:{required:!0,trigger:"change",message:"\u8BF7\u9009\u62E9\u4F9B\u5E94\u5546"}};const J={key:0,flex:"","gap-10":""},K=O({__name:"index",props:{payNo:null,statementDetail:null},setup(d){const p=d,{push:C}=I(),F=_(()=>!!p.payNo),B=R(),m=l(null),i=l({}),E=_(()=>Number(p.statementDetail&&p.statementDetail.status)>=0),t=l([]),f=l(null),o=w({cids:"",supplierNo:"",companyNo:""});function D(){m.value.onDisplay()}function v(a){a.forEach(e=>{i.value[e.sequenceNo]||(i.value[e.sequenceNo]=e.sequenceNo,t.value.push(e))}),N()}function x({id:a}){const e=t.value.findIndex(n=>String(n.id)===String(a));if(e<0)return;const[r]=t.value.splice(e,1);delete i.value[r.sequenceNo],N()}function b(){f.value.validate(async a=>{if(!a)return;const e=F.value?M:V,{cids:r}=o,{code:n,message:q}=await e({cids:r,...p.payNo?{payNo:p.payNo}:{}});B({code:n,message:q,handler:()=>C("/purchase/orderRecord")})})}const N=()=>{o.cids=t.value.map(a=>a.id).join(",")};return L(()=>{const{supplierNo:a,companyNo:e}=o;(!a||!e)&&(t.value=[])}),(a,e)=>{const r=P("el-form-item");return h(),y($,null,[u(s(H),{ref_key:"formRef",ref:f,model:o,rules:s(G),disabled:s(E)},{default:c(()=>[d.payNo?U("",!0):(h(),y("div",J,[u(r,{label:"\u4E1A\u52A1\u516C\u53F8",prop:"companyNo"},{default:c(()=>[u(s(g),{value:o.companyNo,"onUpdate:value":e[0]||(e[0]=n=>o.companyNo=n),api:s(z),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}),u(r,{label:"\u4F9B\u5E94\u5546",prop:"supplierNo"},{default:c(()=>[u(s(g),{value:o.supplierNo,"onUpdate:value":e[1]||(e[1]=n=>o.supplierNo=n),api:s(j),width:"300px",placeholder:"\u8BF7\u9009\u62E9\u4F9B\u5E94\u5546","response-label-prop":"name","response-val-prop":"code"},null,8,["value","api"])]),_:1})])),u(r,{label:"\u91C7\u8D2D\u5355\u4FE1\u606F",prop:"cids"},{default:c(()=>[u(A,{"purchase-order-list":t.value,"supplier-no":o.supplierNo,"company-no":o.companyNo,onAddBtnClick:D,onDelBtnClick:x,onCrateBtnClick:b,onChangeSupplieList:v},null,8,["purchase-order-list","supplier-no","company-no"])]),_:1})]),_:1},8,["model","rules","disabled"]),u(k,{ref_key:"addOrderModalRef",ref:m,"supplier-no":o.supplierNo,"company-no":o.companyNo,onSaveBtnClick:v},null,8,["supplier-no","company-no"])],64)}}});var re=S(K,[["__scopeId","data-v-29020e8f"]]);export{re as default};
