import{a as N}from"./context.6c9ae94a.js";import{_ as A,t as z}from"./index.b35f53c6.js";import"./vue.db505ee4.js";import{u as w}from"./use-http.ec808253.js";import{d as E,r as m,w as j,aW as u,aR as c,at as g,au as U,c as o,bd as i,S as y,ai as p,ar as H,as as B,aM as R,af as D,H as F}from"./@vue.cb43a243.js";import"./js-md5.5179c6be.js";import"./@babel.6cd0804c.js";import"./regenerator-runtime.8e24db72.js";import"./vue-router.a08742b9.js";import"./js-cookie.31874410.js";import"./ant-design-vue.6b10f349.js";import"./@ant-design.bcfb08ae.js";import"./@ctrl.fa7cbd46.js";import"./resize-observer-polyfill.8deb1e21.js";import"./vue-types.6e6d84ba.js";import"./dom-align.f1b5d360.js";import"./lodash-es.0ea26897.js";import"./dayjs.38e390ea.js";import"./async-validator.5d25c98b.js";import"./scroll-into-view-if-needed.5191fdbf.js";import"./compute-scroll-into-view.6058b3be.js";import"./lodash.c9cf1bdb.js";import"./spark-md5.2cc5764b.js";import"./@vueuse.952f4739.js";import"./vue-demi.5fb18120.js";import"./axios.e3200588.js";/* empty css                     */import"./sortablejs.412b554c.js";import"./clipboard.099d05c9.js";import"./markdown-it.80c3a67b.js";import"./entities.0d2c0164.js";import"./uc.micro.981ceb7b.js";import"./mdurl.ef76b4dc.js";import"./linkify-it.92c30060.js";import"./markdown-it-emoji.e3e91710.js";import"./escape-html.e5dfadb9.js";import"./prismjs.c97a8414.js";import"./diacritics.6be19c75.js";import"./markdown-it-container.512a5043.js";import"./markdown-it-anchor.c88e5394.js";import"./markdown-it-attrs.3af5ab50.js";import"./markdown-it-table-of-contents.8a4ce16f.js";import"./@kangc.86f7507c.js";const I=E({name:"ExSelectTable",props:{value:[String,Array,Number],params:Object,gridUrl:String,submitUrl:String,remoteParams:{type:Object,default:{}},submitParams:{type:Object,default:{}},custom:Boolean,multiple:Boolean},inheritAttrs:!1,emits:["update:value"],setup(e,a){const _=N(),h=m(!0),s=m(e.value),f=m(!1),v=m([]),r=m(null),t=m(e.value||[]),d=m("");Array.isArray(t.value)||(t.value=[t.value]);const{loading:k,http:C}=w(),S={x:"max-content",y:window.innerHeight/2};e.submitUrl&&O(),j(()=>e.value,l=>{s.value=l}),j(s,l=>{e.multiple?t.value=l:l?t.value=[l]:t.value=[],a.emit("update:value",l)});function n(){e.gridUrl&&(d.value=null,f.value=!0,C({url:e.gridUrl,method:"POST",data:e.params}).then(l=>{Object.assign(l.attribute.params,e.params),d.value=l}))}function O(){const{http:l}=w();let V=Object.assign(e.submitParams,{ex_eadmin_select_id:t.value});_&&(V.data=_.submitData()),l({url:e.submitUrl,method:"POST",data:V}).then($=>{e.custom?r.value=$.data:v.value=$.data,f.value=!1;const T=[];if(t.value.forEach(b=>{T.push(b)}),e.multiple)s.value=T;else{let b=T.pop();typeof b!="undefined"&&(s.value=b)}}).finally(()=>{h.value=!1})}function P(){e.multiple?s.value=[]:s.value=null}return{clear:P,trans:z,selectLoading:h,loading:k,submit:O,open:n,content:d,options:v,selectValue:s,selection:t,visible:f,height:S,customRender:r}}}),L={key:0},M={class:"action"},W={key:1},q={key:0};function G(e,a,_,h,s,f){const v=u("plus-outlined"),r=u("a-button"),t=u("delete-outlined"),d=u("render"),k=u("a-select"),C=u("a-form-item-rest"),S=u("a-modal");return c(),g(F,null,[e.custom?(c(),g("div",L,[U("div",M,[o(r,{size:"small",onClick:e.open,disabled:e.$attrs.disabled},{icon:i(()=>[o(v)]),default:i(()=>[y(" "+p(e.trans("SelectTable.select")),1)]),_:1},8,["onClick","disabled"]),e.selectValue?(c(),H(r,{key:0,size:"small",onClick:e.clear,disabled:e.$attrs.disabled},{icon:i(()=>[o(t)]),default:i(()=>[y(" "+p(e.trans("SelectTable.clear")),1)]),_:1},8,["onClick","disabled"])):B("",!0)]),o(d,{data:e.customRender},null,8,["data"])])):(c(),g("div",W,[o(k,R(e.$attrs,{value:e.selectValue,"onUpdate:value":a[0]||(a[0]=n=>e.selectValue=n),options:e.options,"allow-clear":"",open:!1,onClick:e.open}),null,16,["value","options","onClick"])])),o(S,{visible:e.visible,"onUpdate:visible":a[3]||(a[3]=n=>e.visible=n),width:"80%",destroyOnClose:""},{footer:i(()=>[U("div",{class:D(e.multiple&&e.selection.length>0?"footer":"")},[e.multiple&&e.selection.length>0?(c(),g("div",q,p(e.trans("SelectTable.selected"))+": "+p(e.selection.length),1)):B("",!0),U("div",null,[o(r,{type:"primary",onClick:e.submit},{default:i(()=>[y(p(e.trans("SelectTable.confirm")),1)]),_:1},8,["onClick"]),o(r,{onClick:a[2]||(a[2]=n=>e.visible=!1)},{default:i(()=>[y(p(e.trans("SelectTable.cancel")),1)]),_:1})])],2)]),default:i(()=>[o(C,null,{default:i(()=>[o(d,{data:e.content,selection:e.selection,"onUpdate:selection":a[1]||(a[1]=n=>e.selection=n),scroll:e.height,"selection-type":e.multiple?"checkbox":"radio"},null,8,["data","selection","scroll","selection-type"])]),_:1})]),_:1},8,["visible"])],64)}var Ee=A(I,[["render",G],["__scopeId","data-v-29cc7068"]]);export{Ee as default};
