import{$ as O,E as m}from"./index.CL7yl-Wb.js";import{U as $}from"./api.HqQpaxQG.js";import{a as z,r as f,_ as F,w as V,aj as s,J as b,o as _,K as o,S as a,c as J,u as N,P as y}from"./vue.D1BjjNmv.js";import{_ as R}from"./_plugin-vue_export-helper.DlAUqK2U.js";const T=["src"],W=z({__name:"EditDialog",props:{modelValue:Boolean,rowData:{type:Object,default:()=>({})}},emits:["update:modelValue","success"],setup(w,{emit:k}){const p=w,c=k,n=f(p.modelValue),u=f(),x=f("编辑数字人"),t=F({id:void 0,name:"",description:"",avatar_url:"",status:1}),C={name:[{required:!0,message:"请输入数字人名称",trigger:"blur"}],avatar_url:[{required:!0,message:"请上传头像",trigger:"change"}],status:[{required:!0,message:"请选择状态",trigger:"change"}]},U={Authorization:`JWT ${localStorage.getItem("token")||""}`},h=l=>{const e=l.type.startsWith("image/"),d=l.size/1024/1024<2;return e?d?!0:(m.error("图片大小不能超过 2MB!"),!1):(m.error("只能上传图片文件!"),!1)},B=l=>{t.avatar_url=l.data.url},E=()=>{Object.assign(t,p.rowData)},j=async()=>{u.value&&await u.value.validate(async l=>{if(l)try{await $(t),m.success("更新成功"),c("success"),n.value=!1}catch(e){console.error("更新失败:",e),m.error("更新失败")}})},D=()=>{u.value&&u.value.resetFields(),c("update:modelValue",!1)};return V(()=>p.modelValue,l=>{n.value=l,l&&E()}),V(()=>n.value,l=>{c("update:modelValue",l)}),(l,e)=>{const d=s("el-input"),i=s("el-form-item"),S=s("el-icon"),q=s("el-upload"),v=s("el-option"),A=s("el-select"),I=s("el-form"),g=s("el-button"),M=s("el-dialog");return _(),b(M,{modelValue:n.value,"onUpdate:modelValue":e[4]||(e[4]=r=>n.value=r),title:x.value,width:"600px","close-on-click-modal":!1,onClosed:D},{footer:o(()=>[a(g,{onClick:e[3]||(e[3]=r=>n.value=!1)},{default:o(()=>e[5]||(e[5]=[y("取 消")])),_:1}),a(g,{type:"primary",onClick:j},{default:o(()=>e[6]||(e[6]=[y("确 定")])),_:1})]),default:o(()=>[a(I,{ref_key:"formRef",ref:u,model:t,rules:C,"label-width":"100px"},{default:o(()=>[a(i,{label:"数字人名称",prop:"name"},{default:o(()=>[a(d,{modelValue:t.name,"onUpdate:modelValue":e[0]||(e[0]=r=>t.name=r),placeholder:"请输入数字人名称"},null,8,["modelValue"])]),_:1}),a(i,{label:"描述",prop:"description"},{default:o(()=>[a(d,{modelValue:t.description,"onUpdate:modelValue":e[1]||(e[1]=r=>t.description=r),type:"textarea",rows:3,placeholder:"请输入描述"},null,8,["modelValue"])]),_:1}),a(i,{label:"头像",prop:"avatar_url"},{default:o(()=>[a(q,{class:"avatar-uploader",action:"/api/system/admin_upload/",headers:U,"show-file-list":!1,"before-upload":h,"on-success":B},{default:o(()=>[t.avatar_url?(_(),J("img",{key:0,src:t.avatar_url,class:"avatar"},null,8,T)):(_(),b(S,{key:1,class:"avatar-uploader-icon"},{default:o(()=>[a(N(O))]),_:1}))]),_:1})]),_:1}),a(i,{label:"状态",prop:"status"},{default:o(()=>[a(A,{modelValue:t.status,"onUpdate:modelValue":e[2]||(e[2]=r=>t.status=r),placeholder:"请选择状态"},{default:o(()=>[a(v,{label:"启用",value:1}),a(v,{label:"禁用",value:0})]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue","title"])}}}),G=R(W,[["__scopeId","data-v-58df170d"]]);export{G as default};
