import{a as D}from"./apiAdmin-D4J8O5cP.js";import{U as k}from"./Upload-DinpFMlS.js";import{_ as y,x as C,Z as h,$ as O,a as U,e as g,o as w,f as E,w as o,c as l,i as c,t as b,a0 as I,a1 as T,n as B,v as M,a8 as q,B as A,al as F,b as N}from"./app-DGDivIsO.js";import{S as V}from"./SaveOutlined-saF8VQQc.js";const W=C({props:["formData","data","visible","url","addEditType","pageTitle","successMessage"],components:{PlusOutlined:h,LoadingOutlined:O,SaveOutlined:V,Upload:k},setup(e,{emit:a}){const{addEditRequestAdmin:u,loading:d,rules:t}=D(),{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 K(e,a,u,d,t,p){const m=I,r=T,s=B,i=M,_=g("Upload"),v=q,S=g("SaveOutlined"),f=A,$=F;return w(),E($,{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 j=y(W,[["render",K]]),z=()=>{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{j as A,z as f};
