import{d as J,v as Q,r as _,l as X,ag as q,M as Y,k as l,h as c,c as h,a as f,t as V,u as r,e as o,w as s,F as b,O as v,m as w,i as D,D as Z,G as ee,_ as ae,ac as le,ae as te,bb as oe,aj as re,bh as se,H as de,K as ue,E as ne}from"./index-be67c1b4.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import"./el-form-item-4ed993c7.js";import{u as I}from"./dict-8c55f18d.js";import{g as ie,c as ce,b as j,e as me,f as _e}from"./common-b9363bdc.js";const pe={class:"main-container"},fe={class:"detail-head"},ge=f("span",{class:"iconfont iconxiangzuojiantou !text-xs"},null,-1),he={class:"ml-[1px]"},be=f("span",{class:"adorn"},"|",-1),ve={class:"right"},we={class:"fixed-footer-wrap"},Ve={class:"fixed-footer"},Je=J({__name:"sales_edit",setup(ye){const U=Q(),L=parseInt(U.query.id),y=_(!1),G=U.meta.title,E={id:0,student_phone:"",student_name:"",sex:"",age:"",school_name:"",grade:"",class_name:"",source_channel:"",customer_source:"",add_staff_id:"",get_staff_id:"",contact_name:"",province_id:"",city_id:"",district_id:"",community_name:"",customer_tags:[],full_address:"",full_address_id:[]},t=X({...E}),k=_([]);(async()=>{k.value=await(await ie()).data})();const O=n=>{var p,S;console.log("用户选择的地址值:",n),n.length>=1&&(t.province_id=n[0]),n.length>=2&&(t.city_id=n[1]),n.length>=3&&(t.district_id=n[2]);const e=k.value.find(g=>g.id==n[0]),d=(p=e==null?void 0:e.children)==null?void 0:p.find(g=>g.id==n[1]),u=(S=d==null?void 0:d.children)==null?void 0:S.find(g=>g.id==n[2]);let i=`${(e==null?void 0:e.name)||""}-${(d==null?void 0:d.name)||""}-${(u==null?void 0:u.name)||""}`;t.full_address=i,console.log("更新后的 formData:",t,t.full_address_id)};L&&(async(n=0)=>{Object.assign(t,E);const e=await(await ce(n)).data;Object.keys(t).forEach(d=>{e[d]!=null&&(t[d]=e[d])}),t.full_address_id=[Number(t.province_id),Number(t.city_id),Number(t.district_id)]})(L);const C=_();_([]);let P=_([]);(async()=>{P.value=await(await I("users_sex")).data.dictionary})(),q(()=>P.value,()=>{t.sex=P.value[0].value});let x=_([]);(async()=>{x.value=await(await I("source_channel")).data.dictionary})(),q(()=>x.value,()=>{t.source_channel=x.value[0].value});let N=_([]);(async()=>{N.value=await(await I("customer_source")).data.dictionary})(),q(()=>N.value,()=>{t.customer_source=N.value[0].value});let A=_([]);(async()=>{A.value=await(await I("customer_tags")).data.dictionary})();const T=_([]);(async()=>{T.value=await(await j({})).data})();const F=_([]);(async()=>{F.value=await(await j({})).data})();const R=Y(()=>({student_phone:[{required:!0,message:l("studentPhonePlaceholder"),trigger:"blur"}],student_name:[{required:!0,message:l("studentNamePlaceholder"),trigger:"blur"}],sex:[{required:!0,message:l("sexPlaceholder"),trigger:"blur"}],age:[{required:!0,message:l("agePlaceholder"),trigger:"blur"},{validator:(n,e,d)=>{e&&!/^\d{0,300}$/.test(e)?d(new Error(l("generateBetween"))):d()}}],school_name:[{required:!0,message:l("schoolNamePlaceholder"),trigger:"blur"}],grade:[{required:!0,message:l("gradePlaceholder"),trigger:"blur"}],class_name:[{required:!0,message:l("classNamePlaceholder"),trigger:"blur"}],source_channel:[{required:!0,message:l("sourceChannelPlaceholder"),trigger:"blur"}],customer_source:[{required:!0,message:l("customerSourcePlaceholder"),trigger:"blur"}],add_staff_id:[{required:!0,message:l("addStaffIdPlaceholder"),trigger:"blur"}],get_staff_id:[{required:!0,message:l("getStaffIdPlaceholder"),trigger:"blur"}],contact_name:[{required:!0,message:l("contactNamePlaceholder"),trigger:"blur"}],province_id:[{required:!0,message:l("provinceIdPlaceholder"),trigger:"blur"}],city_id:[{required:!0,message:l("cityIdPlaceholder"),trigger:"blur"}],district_id:[{required:!0,message:l("districtIdPlaceholder"),trigger:"blur"}],community_name:[{required:!0,message:l("communityNamePlaceholder"),trigger:"blur"}],customer_tags:[{required:!0,message:l("customerTagsPlaceholder"),trigger:"blur"}]})),z=async n=>{y.value||!n||await n.validate(async e=>{e&&(y.value=!0,(L?me:_e)(t).then(i=>{y.value=!1,history.back()}).catch(i=>{y.value=!1}))})},$=()=>{history.back()};return(n,e)=>{const d=Z,u=ee,i=ae,p=le,S=te,g=oe,H=re,K=se,M=de,W=ue,B=ne;return c(),h("div",pe,[f("div",fe,[f("div",{class:"left",onClick:e[0]||(e[0]=a=>$())},[ge,f("span",he,V(r(l)("returnToPreviousPage")),1)]),be,f("span",ve,V(r(G)),1)]),o(W,{class:"box-card !border-none",shadow:"never"},{default:s(()=>[o(M,{model:t,"label-width":"240px",ref_key:"formRef",ref:C,rules:r(R),class:"page-form"},{default:s(()=>[o(u,{label:r(l)("studentPhone"),prop:"student_phone"},{default:s(()=>[o(d,{modelValue:t.student_phone,"onUpdate:modelValue":e[1]||(e[1]=a=>t.student_phone=a),clearable:"",placeholder:r(l)("studentPhonePlaceholder"),class:"input-width"},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),o(u,{label:r(l)("studentName"),prop:"student_name"},{default:s(()=>[o(d,{modelValue:t.student_name,"onUpdate:modelValue":e[2]||(e[2]=a=>t.student_name=a),clearable:"",placeholder:r(l)("studentNamePlaceholder"),class:"input-width"},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),o(u,{label:r(l)("sex"),prop:"sex"},{default:s(()=>[o(p,{class:"input-width",modelValue:t.sex,"onUpdate:modelValue":e[3]||(e[3]=a=>t.sex=a),clearable:"",placeholder:r(l)("sexPlaceholder")},{default:s(()=>[o(i,{label:"请选择",value:""}),(c(!0),h(b,null,v(r(P),(a,m)=>(c(),w(i,{key:m,label:a.name,value:a.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),o(u,{label:r(l)("age"),prop:"age"},{default:s(()=>[o(S,{modelValue:t.age,"onUpdate:modelValue":e[4]||(e[4]=a=>t.age=a),clearable:"",placeholder:r(l)("agePlaceholder"),class:"input-width",min:0,max:"300"},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),o(u,{label:r(l)("schoolName"),prop:"school_name"},{default:s(()=>[o(d,{modelValue:t.school_name,"onUpdate:modelValue":e[5]||(e[5]=a=>t.school_name=a),clearable:"",placeholder:r(l)("schoolNamePlaceholder"),class:"input-width"},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),o(u,{label:r(l)("grade")},{default:s(()=>[o(d,{modelValue:t.grade,"onUpdate:modelValue":e[6]||(e[6]=a=>t.grade=a),clearable:"",placeholder:r(l)("gradePlaceholder"),class:"input-width"},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),o(u,{label:r(l)("className")},{default:s(()=>[o(d,{modelValue:t.class_name,"onUpdate:modelValue":e[7]||(e[7]=a=>t.class_name=a),clearable:"",placeholder:r(l)("classNamePlaceholder"),class:"input-width"},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),o(u,{label:r(l)("sourceChannel"),prop:"source_channel"},{default:s(()=>[o(p,{class:"input-width",modelValue:t.source_channel,"onUpdate:modelValue":e[8]||(e[8]=a=>t.source_channel=a),clearable:"",placeholder:r(l)("sourceChannelPlaceholder")},{default:s(()=>[o(i,{label:"请选择",value:""}),(c(!0),h(b,null,v(r(x),(a,m)=>(c(),w(i,{key:m,label:a.name,value:a.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),o(u,{label:r(l)("customerSource"),prop:"customer_source"},{default:s(()=>[o(p,{class:"input-width",modelValue:t.customer_source,"onUpdate:modelValue":e[9]||(e[9]=a=>t.customer_source=a),clearable:"",placeholder:r(l)("customerSourcePlaceholder")},{default:s(()=>[o(i,{label:"请选择",value:""}),(c(!0),h(b,null,v(r(N),(a,m)=>(c(),w(i,{key:m,label:a.name,value:a.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),o(u,{label:r(l)("addStaffId"),prop:"add_staff_id"},{default:s(()=>[o(p,{class:"input-width",modelValue:t.add_staff_id,"onUpdate:modelValue":e[10]||(e[10]=a=>t.add_staff_id=a),clearable:"",placeholder:r(l)("addStaffIdPlaceholder")},{default:s(()=>[o(i,{label:"请选择",value:""}),(c(!0),h(b,null,v(T.value,(a,m)=>(c(),w(i,{key:m,label:a.name,value:a.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),o(u,{label:r(l)("getStaffId")},{default:s(()=>[o(p,{class:"input-width",modelValue:t.get_staff_id,"onUpdate:modelValue":e[11]||(e[11]=a=>t.get_staff_id=a),clearable:"",placeholder:r(l)("getStaffIdPlaceholder")},{default:s(()=>[o(i,{label:"请选择",value:""}),(c(!0),h(b,null,v(F.value,(a,m)=>(c(),w(i,{key:m,label:a.name,value:a.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),o(u,{label:r(l)("contactName"),prop:"contact_name"},{default:s(()=>[o(d,{modelValue:t.contact_name,"onUpdate:modelValue":e[12]||(e[12]=a=>t.contact_name=a),clearable:"",placeholder:r(l)("contactNamePlaceholder"),class:"input-width"},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),o(u,{label:r(l)("所在地区")},{default:s(()=>[o(g,{class:"input-width",modelValue:t.full_address_id,"onUpdate:modelValue":e[13]||(e[13]=a=>t.full_address_id=a),options:k.value,props:{label:"name",value:"id",children:"children"},onChange:O},null,8,["modelValue","options"])]),_:1},8,["label"]),o(u,{label:r(l)("communityName")},{default:s(()=>[o(d,{modelValue:t.community_name,"onUpdate:modelValue":e[14]||(e[14]=a=>t.community_name=a),clearable:"",placeholder:r(l)("communityNamePlaceholder"),class:"input-width"},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),o(u,{label:r(l)("customerTags")},{default:s(()=>[o(K,{modelValue:t.customer_tags,"onUpdate:modelValue":e[15]||(e[15]=a=>t.customer_tags=a),placeholder:r(l)("customerTagsPlaceholder")},{default:s(()=>[(c(!0),h(b,null,v(r(A),(a,m)=>(c(),w(H,{key:m,label:a.value},{default:s(()=>[D(V(a.name),1)]),_:2},1032,["label"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1},8,["model","rules"])]),_:1}),f("div",we,[f("div",Ve,[o(B,{type:"primary",onClick:e[16]||(e[16]=a=>z(C.value))},{default:s(()=>[D(V(r(l)("save")),1)]),_:1}),o(B,{onClick:e[17]||(e[17]=a=>$())},{default:s(()=>[D(V(r(l)("cancel")),1)]),_:1})])])])}}});export{Je as default};