import{d as B,r as n,p as g,c as r,e as D,k,i as d,g as F,h as u,m as h,_ as I}from"./index.0308b213.js";const x={class:"dialog-footer"},L=h("\u53D6\u6D88"),R=h("\u786E\u8BA4\u9009\u62E9"),A=B({props:{modelValue:Boolean,supplierList:Array,defaultSelected:String},emits:["update:modelValue","selectSupplier"],setup(S,{emit:p}){const s=S,c=n(!1),o=n([]),a=n([]),i=n([]),_=e=>{if(typeof e=="string"){const l=e.split(",").map(t=>parseInt(t.trim(),10));return console.log("Converted defaultSelectedIds:",l),l}return[]};g(()=>s.modelValue,e=>{c.value=e,e&&(i.value=_(s.defaultSelected),a.value=o.value.filter(l=>i.value.includes(l.id)))}),g(()=>s.supplierList,e=>{o.value=e,console.log("supplierList updated:",o.value),c.value&&w()});const v=n(null),w=()=>{s.defaultSelected&&(i.value=_(s.defaultSelected),i.value.forEach(e=>{const l=o.value.find(t=>t.id===e);l?(v.value.toggleRowSelection(l,!0),console.log(`Selected row with id: ${e}`)):console.log(`Row with id: ${e} not found`)}))},b=e=>{a.value=e,console.log("selectedRows.value",a.value)},C=()=>{if(a.value.length>0){const e=a.value.map(l=>l.id);p("update:modelValue",!1),p("selectSupplier",e),console.log("Selected IDs:",e)}else alert("\u8BF7\u9009\u62E9\u81F3\u5C11\u4E00\u4E2A\u4F9B\u5E94\u5546");f()},f=()=>{o.value=[],p("update:modelValue",!1),a.value=[]};return(e,l)=>{const t=r("el-table-column"),E=r("el-table"),m=r("el-button"),V=r("el-dialog");return D(),k(V,{modelValue:c.value,"onUpdate:modelValue":l[0]||(l[0]=y=>c.value=y),title:"\u9009\u62E9\u4F9B\u5E94\u5546",width:"500","before-close":f},{footer:d(()=>[F("div",x,[u(m,{onClick:f},{default:d(()=>[L]),_:1}),u(m,{type:"primary",onClick:C},{default:d(()=>[R]),_:1})])]),default:d(()=>[u(E,{ref_key:"table",ref:v,data:o.value,"row-key":"id",style:{width:"100%"},onSelectionChange:b},{default:d(()=>[u(t,{type:"selection",width:"55","reserve-selection":!0}),u(t,{prop:"id",label:"\u4F9B\u5E94\u5546ID",align:"center"}),u(t,{prop:"supplier_name",label:"\u4F9B\u5E94\u5546\u540D\u79F0",align:"center"})]),_:1},8,["data"])]),_:1},8,["modelValue"])}}});const $=I(A,[["__scopeId","data-v-0f830d7f"]]);export{$ as default};
