2024-07-22 17:53:44 +08:00
|
|
|
import{u as be,r as d,G as De,b as y,c as n,k as g,f as a,w as t,E as D,_ as ke,o as $e,m as K,a as Ve,h as fe,e,g as f,F as ne,l as re,d as O,p as oe,i as Ne,j as ge,z as ce,t as h,q as we,s as Ce,J as He,n as pe,I as Qe}from"./index-Clx5m4fn.js";import{a as Xe,b as Ye,u as Ze,c as Ee,d as Ie,e as Pe,f as el,g as ll,h as al,i as tl}from"./user-zt7KI_9C.js";import"./moment-Cl4UOzQZ.js";import{r as ye}from"./axiosAPI-6XQnSuyJ.js";import{_ as je}from"./authCode-DvinZ9_P.js";import{g as sl,k as ol,l as il}from"./store-Df-n1qLs.js";import{p as nl}from"./padding-BQSXCca3.js";function Se(C){return ye.get("/city",{params:C})}function Ue(C){return ye.get("/area",{params:C})}function xe(C){return ye.get("/street",{params:C})}function ze(C){return ye.get("/village",{params:C})}function Ae(C){return ye.get("/brigade",{params:C})}const ul={class:"add-user"},dl={__name:"add",emits:["close"],setup(C,{expose:r,emit:$}){const R=be(),F=d(null),c=De({mobile:"",code:"",real_name:"",user_ship:0,selectedValues:[]}),j=De({mobile:[{required:!0,message:"请输入手机号",trigger:"blur"},{pattern:/^1[3456789]\d{9}$/,message:"请输入正确的手机号",trigger:"blur"}],code:[{required:!0,message:"请输入验证码",trigger:"blur"}],real_name:[{required:!0,message:"请输入用户姓名",trigger:"blur"}],user_ship:[{required:!0,message:"请选择用户类型",trigger:"change"}],selectedValues:[{required:!0,message:"请选择用户地址",trigger:"change"}]}),Y=d([]),B=async(q,k)=>{const N=q.level;let b;if(N!==0&&!q.data.code)return k([]);N===0?(b=await Se({province_code:51e4}),b=b.data.map(A=>({code:A.city_code,name:A.city_name}))):N===1?(b=await Ue({city_code:q.data.code}),b=b.data.map(A=>({code:A.area_code,name:A.area_name}))):N===2?(b=await xe({area_code:q.data.code}),b=b.data.map(A=>({code:A.street_code,name:A.street_name}))):N===3?(b=await ze({street_code:q.data.code}),b=b.data.map(A=>({code:A.village_code,name:A.village_name}))):N===4&&(b=await Ae({village_code:q.data.code}),b=b.data.map(A=>({code:A.id,name:A.brigade_name,leaf:!0}))),k(b)},H={value:"code",label:"name",children:"children",multiple:!1,lazy:!0,lazyLoad:B};d([]);const V=$,w=()=>{F.value.validate(async q=>{if(q){let k={};k.mobile=c.mobile,k.code=c.code,k.user_ship=c.user_ship,k.real_name=c.real_name,k.province="510000",k.city=c.selectedValues[0],k.area=c.selectedValues[1],k.street=c.selectedValues[2],k.village=c.selectedValues[3],k.brigade=c.selectedValues[4],k.store_id=R.userInfo.store_id,Xe(k).then(N=>{c.mobile="",c.code="",c.user_ship=0,c.real_name="",c.selectedValues=[],F.value.resetFields(),V("close")})}})},z=d(null),P=()=>{F.value.validateField("mobile",q=>{q&&Ye({mobile:c.mobile}).then(k=>{D.success("发送成功"),z.value.startCountDown()}).catch(k=>{D.error("发送失败")})})};return r({addUser:w}),(q,k)=>{const N=y("el-input"),b=y("el-form-item"),A=y("el-cascader"),ae=y("el-form");return n(),g("div",ul,[a(ae,{model:c,rules:j,ref_key:"formDataRef",ref:F,"label-width":"80px"},{default:t(()=>[a(b,{label:"用户电话",prop:"mobile"},{default:t(()=>[a(N,{modelValue:c.mobile,"onUpdate:modelValue":k[0]||(k[0]=E=>c.mobile=E),placeholder:"请输入用户电话"},null,8,["modelValue"])]),_:1}),a(b,{label:"验证码",prop:"code"},{default:t(()=>[a(N,{modelValue:c.code,"onUpdate:modelValue":k[1]||(k[1]=E=>c.code=E),placeholder:"请输入验证码",style:{flex:"1"}},null,8,["modelValue"]),a(je,{ref_key:"authCodeRef",ref:z,style:{"margin-left":"1rem"},onSendCode:P,start:!1},null,512)]),_:1}),a(b,{label:"用户姓名",prop:"real_name"},{default:t(()=>[a(N,{modelValue:c.real_name,"onUpdate:modelValue":k[2]||(k[2]=E=>c.real_name=E),placeholder:"请输入用户姓名"},null,8,["modelValue"])]),_:1}),a(b,{label:"用户地址",prop:"selectedValues"},{default:t(()=>[a(A,{style:{width:"100%"},modelValue:c.selectedValues,"onUpdate:modelValue":k[3]||(k[3]=E=>c.selectedValues=E),options:Y.value,props:H,load:B,class:"w-full"},null,8,["modelValue","options"])]),_:1})]),_:1},8,["model","rules"])])}}},Re=C=>(we("data-v-df06e4b9"),C=C(),Ce(),C),rl={class:"my-order"},cl={class:"header-nav"},v
|