import{F as T,G as z,h as D}from"./elementPlus.CSBdF9Zt.js";import{u as I}from"./api.CLbmRPvq.js";import{u as L}from"./useResponse.DqThFJSa.js";import{h as S}from"./hasPermission.BaNF3kc2.js";import{d as Z,aJ as x,r as y,aK as $,aI as A,Z as k,w as G,ai as m,o as _,c as b,U as t,O as r,n as J,u as l,F as K,a8 as P,R as H,a as Q,S as F}from"./vue.1RczIYhx.js";import{_ as W}from"./_plugin-vue_export-helper.DlAUqK2U.js";import"./index.K_MFulpu.js";const X={class:"drawer-container"},Y={key:0},ee={class:"flex flex-1 justify-end gap-3"},ae=Z({__name:"EditDrawer",props:x({rowData:{}},{modelValue:{default:!1},modelModifiers:{}}),emits:x(["refresh"],["update:modelValue"]),setup(g,{emit:h}){const i=g,C=h,d=y(!1),c=$(g,"modelValue"),v=A("editDrawer"),f=y(),p=()=>{var a,e,n;return{platform_number:((a=i.rowData)==null?void 0:a.platform_number)??"",name:((e=i.rowData)==null?void 0:e.name)??"",status:((n=i.rowData)==null?void 0:n.status)??""}},s=k(p()),O=k({name:[{required:!0,message:"请输入店铺名称",trigger:"blur"},{min:2,max:50,message:"店铺名称长度在 2 到 50 个字符",trigger:"blur"}],platform_number:[{required:!0,message:"请输入平台编号",trigger:"blur"},{pattern:/^[A-Za-z0-9_-]+$/,message:"平台编号只能包含字母、数字、下划线和短横线",trigger:"blur"}],status:[{required:!0,message:"请选择店铺状态",trigger:"change"}]}),R=[{label:"启用",value:"open"},{label:"关闭",value:"closed"}],U=async a=>{var e;if(!(!a||!((e=i.rowData)!=null&&e.id)))try{if(!await a.validate())return;d.value=!0;const u=await L(I,{id:i.rowData.id,...s},d);(u==null?void 0:u.code)===2e3&&(c.value=!1,D.success({message:"编辑成功",plain:!0,icon:"Operation"}),C("refresh"),w())}catch(n){console.error("编辑失败:",n),D.error("编辑失败，请重试")}finally{d.value=!1}},w=()=>{var a;(a=f.value)==null||a.clearValidate(),Object.assign(s,p())},E=()=>{var a;(a=v.value)==null||a.handleClose(),w()};return G(c,a=>{a&&i.rowData&&(Object.assign(s,p()),J(()=>{var e;(e=f.value)==null||e.clearValidate()}))}),(a,e)=>{const n=m("el-input"),u=m("el-form-item"),M=m("el-option"),N=m("el-select"),j=m("el-divider"),V=m("el-button"),q=m("el-form"),B=m("el-drawer");return _(),b("div",X,[t(B,{ref_key:"editDrawer",ref:v,modelValue:c.value,"onUpdate:modelValue":e[4]||(e[4]=o=>c.value=o),"close-on-click-modal":!1,"close-on-press-escape":!1,size:"30%",title:"市场店铺 - 编辑","destroy-on-close":""},{default:r(()=>[t(q,{ref_key:"ruleFormRef",ref:f,model:l(s),rules:l(O),class:"mx-2.5 mt-7","label-position":"top","label-width":"auto","status-icon":""},{default:r(()=>[t(u,{class:"font-medium",label:"店铺名称：",prop:"name"},{default:r(()=>[t(n,{modelValue:l(s).name,"onUpdate:modelValue":e[0]||(e[0]=o=>l(s).name=o),placeholder:"请输入店铺名称",maxlength:"50","show-word-limit":"",clearable:""},null,8,["modelValue"])]),_:1}),t(u,{class:"font-medium",label:"平台编号：",prop:"platform_number"},{default:r(()=>[t(n,{modelValue:l(s).platform_number,"onUpdate:modelValue":e[1]||(e[1]=o=>l(s).platform_number=o),placeholder:"请输入平台编号",clearable:""},null,8,["modelValue"])]),_:1}),l(S)("shopStatusEdit")?(_(),b("div",Y,[t(u,{class:"font-medium",label:"店铺状态：",prop:"status"},{default:r(()=>[t(N,{modelValue:l(s).status,"onUpdate:modelValue":e[2]||(e[2]=o=>l(s).status=o),placeholder:"请选择店铺状态",clearable:"",class:"w-full"},{default:r(()=>[(_(),b(K,null,P(R,o=>t(M,{key:o.value,label:o.label,value:o.value},null,8,["label","value"])),64))]),_:1},8,["modelValue"])]),_:1})])):H("",!0),t(u,null,{default:r(()=>[t(j),Q("div",ee,[t(V,{icon:l(T),onClick:E},{default:r(()=>e[5]||(e[5]=[F(" 取 消 ")])),_:1},8,["icon"]),t(V,{icon:l(z),loading:l(d),type:"primary",onClick:e[3]||(e[3]=o=>U(l(f)))},{default:r(()=>e[6]||(e[6]=[F(" 确 定 ")])),_:1},8,["icon","loading"])])]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["modelValue"])])}}}),me=W(ae,[["__scopeId","data-v-555b7f7a"]]);export{me as default};
