import{d as J,a6 as Q,r as p,b as z,p as W,c as i,e as f,f as b,h as t,i as o,u as n,aU as X,g as d,aT as Y,F as Z,j as ee,k as te,dF as B,t as E,a1 as le,as as oe,m as x,y as m,_ as ae}from"./index.0308b213.js";import{g as se}from"./merchant.1b322e07.js";import{g as ne}from"./merchant.9d35eb14.js";const ie={class:"optimization-config"},ue={class:"select-stores"},ce=x("\u9009\u62E9\u5546\u6237 "),re={key:0,class:"selected-stores"},de={class:"store-name"},pe={key:1,class:"empty-tip"},_e={class:"dialog-content"},fe={class:"search-bar"},me={class:"store-cell"},ge={class:"pagination"},ve={class:"dialog-footer"},he=x("\u53D6\u6D88"),ye=x(" \u786E\u8BA4\u9009\u62E9 "),be=J({props:{config:null,agentid:null},emits:["update:config"],setup(U,{emit:S}){const A=U,{OpPlatform:L}=Q(),_=p(!1),V=p(0),s=p([]),w=p([]),c=p({title:"\u9650\u65F6\u79D2\u6740",stores:[]}),C=z({list:[]}),u=z({page:1,limit:10,areaid:"",sid:"",keyword:""}),g=p(),v=async()=>{const l=L.value=="agent"?se:ne;try{const e=await l(u);C.list=e.list,V.value=e.count}catch(e){console.error(e)}},T=()=>{u.page=1,v().then(()=>{m(()=>{h()})})},K=l=>{u.limit=l,v().then(()=>{m(()=>{h()})})},N=l=>{u.page=l,v().then(()=>{m(()=>{h()})})},R=l=>{w.value=l.map(e=>({id:e.id,title:e.title}))},I=()=>{_.value=!0,w.value=[],v().then(()=>{m(()=>{h()})})},M=()=>{const l=w.value.filter(e=>!s.value.some(r=>r.id===e.id));s.value=[...s.value,...l],c.value={title:c.value.title,stores:s.value},S("update:config",c.value),_.value=!1},P=l=>{const e=s.value.findIndex(r=>r.id===l.id);e>-1&&(s.value.splice(e,1),c.value={title:c.value.title,stores:s.value},S("update:config",c.value))},h=()=>{!g.value||(g.value.clearSelection(),C.list.forEach(l=>{s.value.some(e=>e.id===l.id)&&g.value.toggleRowSelection(l,!0)}))};return W(()=>A.config,l=>{l&&m(()=>{var e;c.value={title:l.title||"\u9650\u65F6\u79D2\u6740",stores:l.stores||[]},(e=l.stores)!=null&&e.length?s.value=[...l.stores]:s.value=[]})},{immediate:!0,deep:!0}),(l,e)=>{const r=i("el-icon"),F=i("el-input"),D=i("el-form-item"),k=i("el-button"),$=i("el-tag"),j=i("el-empty"),q=i("el-form"),y=i("el-table-column"),O=i("el-table"),G=i("el-pagination"),H=i("el-dialog");return f(),b("div",ie,[t(q,{"label-width":"80px"},{default:o(()=>[t(D,{label:"\u6807\u9898",class:"title-item"},{default:o(()=>[t(F,{modelValue:c.value.title,"onUpdate:modelValue":e[0]||(e[0]=a=>c.value.title=a),placeholder:"\u8BF7\u8F93\u5165\u6807\u9898",clearable:"",maxlength:20,"show-word-limit":""},{prefix:o(()=>[t(r,null,{default:o(()=>[t(n(X))]),_:1})]),_:1},8,["modelValue"])]),_:1}),t(D,{label:"\u9009\u62E9\u5546\u6237",class:"store-select-item"},{default:o(()=>[d("div",ue,[t(k,{type:"primary",size:"default",onClick:I},{default:o(()=>[t(r,null,{default:o(()=>[t(n(Y))]),_:1}),ce]),_:1}),s.value.length?(f(),b("div",re,[(f(!0),b(Z,null,ee(s.value,a=>(f(),te($,{key:a.id,closable:"",onClose:we=>P(a),class:"store-tag",type:"success",effect:"light"},{default:o(()=>[t(r,null,{default:o(()=>[t(n(B))]),_:1}),d("span",de,E(a.title),1)]),_:2},1032,["onClose"]))),128))])):(f(),b("div",pe,[t(j,{description:"\u6682\u672A\u9009\u62E9\u5546\u6237","image-size":60})]))])]),_:1})]),_:1}),t(H,{modelValue:_.value,"onUpdate:modelValue":e[5]||(e[5]=a=>_.value=a),title:"\u9009\u62E9\u5546\u6237",width:"800px","destroy-on-close":""},{footer:o(()=>[d("span",ve,[t(k,{onClick:e[4]||(e[4]=a=>_.value=!1)},{default:o(()=>[he]),_:1}),t(k,{type:"primary",onClick:M},{default:o(()=>[ye]),_:1})])]),default:o(()=>[d("div",_e,[d("div",fe,[t(F,{modelValue:n(u).keyword,"onUpdate:modelValue":e[1]||(e[1]=a=>n(u).keyword=a),placeholder:"\u8BF7\u8F93\u5165\u5546\u6237\u540D\u79F0\u641C\u7D22",style:{width:"300px"},clearable:"",onKeyup:le(T,["enter"])},{prefix:o(()=>[t(r,null,{default:o(()=>[t(n(oe))]),_:1})]),_:1},8,["modelValue","onKeyup"])]),t(O,{data:n(C).list,style:{width:"100%"},onSelectionChange:R,"row-key":"id",ref_key:"tableRef",ref:g,border:"","highlight-current-row":""},{default:o(()=>[t(y,{type:"selection",width:"55",align:"center"}),t(y,{prop:"title",label:"\u5546\u6237\u540D\u79F0","min-width":"200"},{default:o(({row:a})=>[d("div",me,[t(r,null,{default:o(()=>[t(n(B))]),_:1}),d("span",null,E(a.title),1)])]),_:1}),t(y,{prop:"address",label:"\u5730\u5740","show-overflow-tooltip":""}),t(y,{prop:"telephone",label:"\u8054\u7CFB\u7535\u8BDD",width:"120"})]),_:1},8,["data"]),d("div",ge,[t(G,{"current-page":n(u).page,"onUpdate:current-page":e[2]||(e[2]=a=>n(u).page=a),"page-size":n(u).limit,"onUpdate:page-size":e[3]||(e[3]=a=>n(u).limit=a),total:V.value,"page-sizes":[10,20,30,50],layout:"total, sizes, prev, pager, next",onSizeChange:K,onCurrentChange:N},null,8,["current-page","page-size","total"])])])]),_:1},8,["modelValue"])])}}});const Se=ae(be,[["__scopeId","data-v-8b2a3492"]]);export{Se as default};
