import{a as $}from"./apiAdmin-I34Xe3Oj.js";import{U as k}from"./Upload-HTSZWylS.js";import{_ as y,d as C,R as h,aT as O,b as U,r as g,o as w,i as E,w as o,a as l,l as c,t as b,I,n as T,q,h as B,F as M,B as A,X as F,Y as N}from"./app-DyK1k-lL.js";import{S as R}from"./SaveOutlined-BNo3Yq0P.js";const V=C({props:["formData","data","visible","url","addEditType","pageTitle","successMessage"],components:{PlusOutlined:h,LoadingOutlined:O,SaveOutlined:R,Upload:k},setup(e,{emit:a}){const{addEditRequestAdmin:u,loading:d,rules:t}=$(),{slugify:p}=U();return{loading:d,rules:t,onClose:()=>{t.value={},a("closed")},onSubmit:()=>{u({url:e.url,data:e.formData,successMessage:e.successMessage,success:s=>{a("addEditSuccess",s.xid)}})},slugify:p,drawerWidth:window.innerWidth<=991?"90%":"45%"}}});function W(e,a,u,d,t,p){const m=I,r=T,s=q,i=B,_=g("Upload"),v=M,S=g("SaveOutlined"),f=A,D=F;return w(),E(D,{open:e.visible,closable:!1,centered:!0,title:e.pageTitle,onOk:e.onSubmit},{footer:o(()=>[l(f,{key:"submit",type:"primary",loading:e.loading,onClick:e.onSubmit},{icon:o(()=>[l(S)]),default:o(()=>[c(" "+b(e.addEditType=="add"?e.$t("common.create"):e.$t("common.update")),1)]),_:1},8,["loading","onClick"]),l(f,{key:"back",onClick:e.onClose},{default:o(()=>[c(b(e.$t("common.cancel")),1)]),_:1},8,["onClick"])]),default:o(()=>[l(v,{layout:"vertical"},{default:o(()=>[l(i,{gutter:16},{default:o(()=>[l(s,{xs:24,sm:24,md:24,lg:24},{default:o(()=>[l(r,{label:e.$t("brand.name"),name:"name",help:e.rules.name?e.rules.name.message:null,validateStatus:e.rules.name?"error":null,class:"required"},{default:o(()=>[l(m,{value:e.formData.name,"onUpdate:value":a[0]||(a[0]=n=>e.formData.name=n),placeholder:e.$t("common.placeholder_default_text",[e.$t("brand.name")]),onKeyup:a[1]||(a[1]=n=>e.formData.slug=e.slugify(n.target.value))},null,8,["value","placeholder"])]),_:1},8,["label","help","validateStatus"])]),_:1})]),_:1}),l(i,{gutter:16},{default:o(()=>[l(s,{xs:24,sm:24,md:24,lg:24},{default:o(()=>[l(r,{label:e.$t("brand.slug"),name:"slug",help:e.rules.slug?e.rules.slug.message:null,validateStatus:e.rules.slug?"error":null,class:"required"},{default:o(()=>[l(m,{value:e.formData.slug,"onUpdate:value":a[2]||(a[2]=n=>e.formData.slug=n),placeholder:e.$t("common.placeholder_default_text",[e.$t("brand.slug")])},null,8,["value","placeholder"])]),_:1},8,["label","help","validateStatus"])]),_:1})]),_:1}),l(i,{gutter:16},{default:o(()=>[l(s,{xs:24,sm:24,md:24,lg:24},{default:o(()=>[l(r,{label:e.$t("brand.logo"),name:"logo",help:e.rules.logo?e.rules.logo.message:null,validateStatus:e.rules.logo?"error":null},{default:o(()=>[l(_,{formData:e.formData,folder:"brand",onOnFileUploaded:a[3]||(a[3]=n=>{e.formData.image=n.file,e.formData.image_url=n.file_url})},null,8,["formData"])]),_:1},8,["label","help","validateStatus"])]),_:1})]),_:1})]),_:1})]),_:1},8,["open","title","onOk"])}const Y=y(V,[["render",W]]),j=()=>{const e="brands",{t:a}=N(),u={name:"",slug:"",image:void 0,image_url:void 0},d=[{title:a("brand.name"),dataIndex:"name",sorter:!0},{title:a("brand.logo"),dataIndex:"image_url"},{title:a("common.action"),dataIndex:"action"}],t=[{key:"name",value:a("brand.name")}];return{addEditUrl:e,initData:u,columns:d,filterableColumns:t}};export{Y as A,j as f};
