2 lines
29 KiB
JavaScript
2 lines
29 KiB
JavaScript
|
import{u as ye,r as u,B as Ae,b as h,c as i,k as b,f as l,w as a,g as f,F as X,l as ue,d as L,E as P,_ as he,o as ge,m as E,a as be,h as ve,e,i as Fe,j as ce,z as le,t as k,p as Q,q as ke,s as $e,G as Ge,n as fe,D as He,J as Qe}from"./index-QWlmoZOY.js";import{a as Ve,b as Xe,c as Ye,u as Ze,d as Le,e as De,f as el,g as ll,h as tl,i as al,j as sl}from"./user-67Kj74w6.js";import"./moment-Cl4UOzQZ.js";import{r as _e}from"./axiosAPI-CcLrXseV.js";import{f as ol,u as il,j as nl}from"./store-ChtKbj0U.js";import{_ as ul}from"./authCode-DA-pJ64X.js";import{p as dl}from"./padding-CEkSWg1M.js";function Ie(V){return _e.get("/city",{params:V})}function Pe(V){return _e.get("/area",{params:V})}function Re(V){return _e.get("/street",{params:V})}function Oe(V){return _e.get("/village",{params:V})}function je(V){return _e.get("/brigade",{params:V})}const rl={class:"add-user"},cl={__name:"add",emits:["close"],setup(V,{expose:t,emit:_}){const w=ye(),F=u(null),c=Ae({mobile:"",code:"",real_name:"",user_ship:"",selectedValues:[]}),U=Ae({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"}]}),N=u([]),B=async(R,d)=>{const y=R.level;let s;if(y!==0&&!R.data.code)return d([]);y===0?(s=await Ie({province_code:51e4}),s=s.data.map(x=>({code:x.city_code,name:x.city_name}))):y===1?(s=await Pe({city_code:R.data.code}),s=s.data.map(x=>({code:x.area_code,name:x.area_name}))):y===2?(s=await Re({area_code:R.data.code}),s=s.data.map(x=>({code:x.street_code,name:x.street_name}))):y===3?(s=await Oe({street_code:R.data.code}),s=s.data.map(x=>({code:x.village_code,name:x.village_name}))):y===4&&(s=await je({village_code:R.data.code}),s=s.data.map(x=>({code:x.id,name:x.brigade_name,leaf:!0}))),d(s)},K={value:"code",label:"name",children:"children",multiple:!1,lazy:!0,lazyLoad:B},C=u([]);(()=>{Ve().then(R=>{C.value=R.data.lists})})();const H=_,de=()=>{F.value.validate(async R=>{if(R){let d={};d.mobile=c.mobile,d.code=c.code,d.user_ship=c.user_ship,d.real_name=c.real_name,d.province="510000",d.city=c.selectedValues[0],d.area=c.selectedValues[1],d.street=c.selectedValues[2],d.village=c.selectedValues[3],d.brigade=c.selectedValues[4],d.store_id=w.userInfo.store_id,Xe(d).then(y=>{H("close")})}})},ae=()=>{F.value.validateField("mobile",R=>{R&&Ye({mobile:c.mobile}).then(d=>{P.success("发送成功")}).catch(d=>{P.error("发送失败")})})};return t({addUser:de}),(R,d)=>{const y=h("el-input"),s=h("el-form-item"),x=h("el-button"),ie=h("el-option"),M=h("el-select"),se=h("el-cascader"),j=h("el-form");return i(),b("div",rl,[l(j,{model:c,rules:U,ref_key:"formDataRef",ref:F,"label-width":"80px"},{default:a(()=>[l(s,{label:"用户电话",prop:"mobile"},{default:a(()=>[l(y,{modelValue:c.mobile,"onUpdate:modelValue":d[0]||(d[0]=$=>c.mobile=$),placeholder:"请输入用户电话"},null,8,["modelValue"])]),_:1}),l(s,{label:"验证码",prop:"code"},{default:a(()=>[l(y,{modelValue:c.code,"onUpdate:modelValue":d[1]||(d[1]=$=>c.code=$),placeholder:"请输入验证码",style:{flex:"1"}},null,8,["modelValue"]),l(x,{type:"primary",style:{"margin-left":"1rem"},onClick:ae},{default:a(()=>[f("获取验证码")]),_:1})]),_:1}),l(s,{label:"用户姓名",prop:"real_name"},{default:a(()=>[l(y,{modelValue:c.real_name,"onUpdate:modelValue":d[2]||(d[2]=$=>c.real_name=$),placeholder:"请输入用户姓名"},null,8,["modelValue"])]),_:1}),l(s,{label:"用户类型",prop:"user_ship"},{default:a(()=>[l(M,{modelValue:c.user_ship,"onUpdate:modelValue":d[3]||(d[3]=$=>c.user_ship=$),placeholder:"请选择用户类型",style:{width:"100%"}},{default:a(()=>[(i(!0),b(X,null,ue(C.value,$=>(i(),L(ie,{key:$.id,label:$.title,value:$.id,disabled:$.id==1},null,8,["label","value","disabled"]))),128))]),_:1},8,["modelValue"])]),_:1}),l(
|