import{r as i,bv as _,P as r,o as s,e as c,w as f,c as h,ac as b,aU as x,af as y,a as N,t as w,__tla as k}from"./index.91e2b97e.js";import{__tla as S}from"./el-tag.b6486cea.js";import{a as j,b as $,__tla as O}from"./el-select.1f459249.js";let p,P=Promise.all([(()=>{try{return k}catch{}})(),(()=>{try{return S}catch{}})(),(()=>{try{return O}catch{}})()]).then(async()=>{p={__name:"index",props:{url:String,to:String,modelValue:String,modelName:String,change:Function,fields:Array,d:Object},emits:["update:modelValue","update:modelName"],setup(g,{emit:v}){const e=g,n=i(!1),m=i(e.modelValue),o=i(e.modelValue&&e.modelName?[{name:e.modelName,value:e.modelValue}]:[]);V().then(()=>{e.modelValue&&e.modelName&&!o.value.find(({value:a})=>a===e.modelValue)&&o.value.unshift({name:e.modelName,value:e.modelValue})});function V(a){return n.value=!0,_({url:e.to?`/jcxx/${e.to}/index`:e.url,data:{...e.d,keyword:a,limit:100}}).then(({data:l})=>{o.value=l.page_data.map(t=>({value:t[e.fields?e.fields[0]:e.to+"_id"],name:t[e.fields?e.fields[1]:e.to+"_name"],origin:t})),n.value=!1})}return r(()=>m.value,a=>{var t;const l=o.value.find(({value:u})=>u===a);v("update:modelValue",a),v("update:modelName",l==null?void 0:l.name),(t=e.change)==null||t.call(e,l==null?void 0:l.origin)}),r(()=>e.modelValue,a=>{a===void 0?m.value=void 0:m.value=a}),r(()=>e.d,(a,l)=>{Object.keys(a).some(t=>a[t]!==l[t])&&(console.log("watch request :>> "),_({url:e.to?`/jcxx/${e.to}/index`:e.url,data:{...e.d,limit:100}}).then(({data:t})=>{o.value=t.page_data.map(u=>({value:u[e.fields?e.fields[0]:e.to+"_id"],name:u[e.fields?e.fields[1]:e.to+"_name"],origin:u}))}))},{immediate:!1}),(a,l)=>{const t=j,u=$;return s(),c(u,{class:"w-full",modelValue:m.value,"onUpdate:modelValue":l[0]||(l[0]=d=>m.value=d),filterable:"","reserve-keyword":"",clearable:"",loading:n.value},{default:f(()=>[(s(!0),h(b,null,x(o.value,d=>(s(),c(t,{key:d.value,label:d.name,value:d.value},{default:f(()=>[y(a.$slots,"default",{item:d.origin},()=>[N("span",null,w(d.name),1)])]),_:2},1032,["label","value"]))),128))]),_:3},8,["modelValue","loading"])}}}});export{p as _,P as __tla};
