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-DvHhBloa.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-DTCZY3pu.js";import"./moment-Cl4UOzQZ.js";import{r as ye}from"./axiosAPI-BqSqmNsM.js";import{_ as je}from"./authCode-CBqz1lgm.js";import{i as sl,m as ol,n as il}from"./store-CN9suVdR.js";import{p as nl}from"./padding-DoCkqYhX.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"},vl=Re(()=>e("div",{class:"nav-item"},h("用户列表"),-1)),_l={class:"header-row"},ml=Re(()=>e("div",{class:"label"},"用户类型",-1)),pl={class:"header-row"},fl=Re(()=>e("div",{class:"label"},"用户地区",-1)),yl={class:"header-input"},hl={class:"order-lists","infinite-scroll-distance":300,"infinite-scroll-delay":500,style:{overflow:"auto"}},gl=["onClick"],bl={style:{display:"flex","flex-direction":"column","justify-content":"space-around",flex:"1"}},kl={class:"top flex"},$l={class:"r-1"},Vl={class:"bold"},wl={class:"bottom flex",style:{"justify-content":"space-between"}},Cl={class:"red"},Sl={class:"red"},Ul={class:"red"},xl={class:"red"},zl={key:0,class:"load-end"},Al={key:1,class:"load-end"},Rl={class:"dialog-footer"},Fl={__name:"order",props:{isSystem:{type:Boolean,default:!1},source:{type:Number,default:1}},setup(C){const r=be();d([]);const $=d({page_no:1,page_size:20,mobile:"",user_ship:"",street:null}),R=d(!1),F=d(0),c=d(0),j=d(!1),Y=d([]),B=(U=!1)=>{if(U)$.value.page_no=1;else if(j.value||R.value)return;R.value=!0,$.value.mobile==""&&$.value.user_ship==""?$.value.store_id=r.userInfo.store_id:$.value.store_id=null,Ze($.value).then(u=>{U?Y.value=u.data.lists:Y.value=[...Y.value,...u.data.lists],$.value.page_no==1&&Y.value.length>0&&K.emit("set-user-detail",Y.value[0]),u.data.lists.length<$.value.page_size?j.value=!0:$.value.page_no++,c.value=0,F.value=u.data.count,R.value=!1}).catch(u=>{j.value=!0,R.value=!1})},H=(U,u)=>{c.value=u,K.emit("set-user-detail",U)},V=d(!1),w=d(null),z=()=>{var U;(U=w.value)==null||U.addUser()},P=()=>{V.value=!1,B(!0)},q=d([]);(()=>{Ee({type_id:4}).then(U=>{q.value=U.data.lists})})();const N=()=>{$.value.mobile="",$.value.user_ship="",$.value.street=null,b.value=[],B(!0)},b=d([]),A=d([]),ae=async(U,u)=>{const x=U.level;let _;if(x!==0&&!U.data.code)return u([]);x===0?(_=await Se({province_code:51e4}),_=_.data.map(p=>({code:p.city_code,name:p.city_name}))):x===1?(_=await Ue({city_code:U.data.code}),_=_.data.map(p=>({code:p.area_code,name:p.area_name}))):x===2?(_=await xe({area_code:U.data.code}),_=_.data.map(p=>({code:p.street_code,name:p.street_name,leaf:!0}))):x===3?(_=await ze({street_code:U.data.code}),_=_.data.map(p=>({code:p.village_code,name:p.village_name}))):x===4&&(_=await Ae({village_code:U.data.code}),_=_.data.map(p=>({code:p.id,name:p.brigade_name,leaf:!0}))),u(_)},E={value:"code",label:"name",children:"children",multiple:!1,lazy:!0,lazyLoad:ae},Z=()=>{b.value.length?$.value.street=b.value[b.value.length-1]:$.value.street="",B(!0)};return $e(()=>{K.on("re-load-user-list",U=>{U&&B(!0)})}),Ve(()=>{K.off("re-load-user-list")}),(U,u)=>{const x=y("Plus"),_=y("el-icon"),p=y("el-button"),ee=y("el-option"),W=y("el-select"),le=y("el-cascader"),J=y("CircleClose"),ve=y("el-input"),ue=y("el-avatar"),ie=y("el-tag"),te=y("el-dialog"),o=fe("loading"),m=fe("infinite-scroll");return n(),g("div",rl,[e("div",cl,[vl,a(p,{type:"primary",onClick:u[0]||(u[0]=l=>V.value=!0)},{default:t(()=>[a(_,null,{default:t(()=>[a(x)]),_:1}),f(" 添加用户")]),_:1})]),e("div",_l,[ml,a(W,{modelValue:$.value.user_ship,"onUpdate:modelValue":u[1]||(u[1]=l=>$.value.user_ship=l),onChange:u[2]||(u[2]=l=>B(!0)),placeholder:"请选择用户类型",style:{flex:"1"}},{default:t(()=>[(n(!0),g(ne,null,re(q.value,l=>(n(),O(ee,{key:l.id,label:l.title,value:l.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"]),a(p,{onClick:N,style:{"margin-left":"1rem"}},{default:t(()=>[f("重置")]),_:1})]),e("div",pl,[fl,a(le,{style:{flex:"1"},options:A.value,modelValue:b.value,"onUpdate:modelValue":u[3]||(u[3]=l=>b.value=l),props:E,load:ae,class:"w-full",onChange:Z},null,8,["options","modelValue"])]),e("div",yl,[a(ve,{modelValue:$.value.mobile,"onUpdate:modelValue":u[6]||(u[6]=l=>$.value.mobile=l),placeholder:"搜索手机号",onKeydown:u[7]||(u[7]=Ne(l=>B(!0),["enter"])),onClear:u[8]||(u[8]=l=>B(!0))},{suffix:t(()=>[$.value.mobile!=""?(n(),O(_,{key:0,size:"18",onClick:u[4]||(u[4]=l=>{$.value.mobile="",B(!0)}),style:{cursor:"pointer","margin-right":"0.5rem"}},{default:t(()=>[a(J)]),_:1})):oe("",!0)]),append:t(()=>[a(p,{type:"primary",style:{"background-color":"#1890ff",color:"#fff","border-radius":"0 0.315rem 0.315rem 0"},onClick:u[5]||(u[5]=l=>B(!0))},{default:t(()=>[f("搜索")]),_:1})]),_:1},8,["modelValue"])]),ge((n(),g("div",hl,[(n(!0),g(ne,null,re(Y.value,(l,S)=>{var Q;return n(),g("div",{class:ce(["item",{"item-active":c.value==S}]),key:S,onClick:v=>H(l,S)},[a(ue,{class:"avatar",src:l.avatar},null,8,["src"]),e("div",bl,[e("div",kl,[e("div",$l,[e("span",Vl,h(l.real_name||l.nickname),1),e("span",null,h(" (ID:"+l.id+")"),1)]),e("div",null,"手机号: "+h(l.mobile),1)]),e("div",wl,[e("div",null,[f("余额: "),e("span",Cl,h(l.now_money),1)]),e("div",null,[f("采购款: "),e("span",Sl,h(l.purchase_funds),1)]),e("div",null,[f("返还金: "),e("span",Ul,h((Q=l.return_money)==null?void 0:Q.toFixed(2)),1)]),e("div",null,[f("礼品券: "),e("span",xl,h(l.integral),1)]),e("div",null,[l.user_ship==0?(n(),O(ie,{key:0,type:"primary"},{default:t(()=>[f(h(l.user_ship_name),1)]),_:2},1024)):(n(),O(ie,{key:1,type:"success"},{default:t(()=>[f(h(l.user_ship_name),1)]),_:2},1024))])])])],10,gl)}),128)),j.value?(n(),g("div",zl,"没有更多了")):oe("",!0),R.value?(n(),g("div",Al,"加载中...")):oe("",!0)])),[[o,R.value],[m,B]]),a(te,{modelValue:V.value,"onUpdate:modelValue":u[10]||(u[10]=l=>V.value=l),title:"添加用户",width:"600"},{footer:t(()=>[e("div",Rl,[a(p,{onClick:u[9]||(u[9]=l=>V.value=!1)},{default:t(()=>[f("取消")]),_:1}),a(p,{type:"primary",onClick:z},{default:t(()=>[f(" 添加 ")]),_:1})])]),default:t(()=>[a(dl,{ref_key:"addRef",ref:w,onClose:P},null,512)]),_:1},8,["modelValue"])])}}},Ll=ke(Fl,[["__scopeId","data-v-df06e4b9"]]),_e=C=>(we("data-v-5ad4b8f5"),C=C(),Ce(),C),Ol=_e(()=>e("h4",null,"选择支付方式",-1)),Dl={class:"dra-body"},Il={class:"header"},Pl={style:{display:"inline-block"}},Nl=_e(()=>e("div",{style:{color:"#999",padding:"2rem 0 0.3rem 0"}},"应收金额(元):",-1)),El={style:{color:"#f5222d","padding-bottom":"2rem"}},jl={style:{"font-size":"1.6rem"}},ql={key:0,"element-loading-text":"支付中",class:"card1"},Bl=_e(()=>e("div",{class:"tips"},null,-1)),Jl={key:1,class:"card2"},Tl={class:"drawer-body"},Kl={class:"counter"},Ml={class:"received"},Wl={key:0},Gl={key:1,style:{"font-size":"1rem",color:"#999"}},Hl={key:0,class:"balance"},Ql={class:"money"},Xl=_e(()=>e("div",{class:"tips"},"按回车(Enter)确认支付",-1)),Yl={key:1,class:"balance"},Zl=_e(()=>e("div",null,"不够找零, 请支付更多金额",-1)),ea=_e(()=>e("div",{class:"tips"},"按下小键盘输入金额",-1)),la=[Zl,ea],aa={class:"keypad"},ta={class:"left"},sa={class:"right"},oa={style:{width:"100%",display:"flex","justify-content":"center"}},ia={__name:"payUser",emits:["paySuccess"],setup(C,{expose:r,emit:$}){const R=d(!1),F=d(1),c=d(""),j=d("");be();const Y=()=>{u()},B=()=>{pe(()=>{setTimeout(()=>{var m;x.value=!1,c.value="",N.value=!0,(m=j.value)==null||m.focus(),H(F.value)},300)})},H=m=>{m!=1&&j.value.blur(),F.value=m,console.log(F.value),F.value==2?window.addEventListener("keydown",ue):(window.removeEventListener("keydown",ue),pe(()=>{var l;c.value="",(l=j.value)==null||l.focus()}))},V=d({price:0,uid:"",user_ship:"",village:null,brigade:null}),w=d([]),z=d(!1),P=m=>{V.value=m.data,V.value.total=m.data.price,w.value=m.cart_id,z.value=m.isRePay||!1},q=m=>{V.value.total=m.price,E.value=m.order_id},k=$,N=d(!1),b=d(["1","2","3","4","5","6","7","8","9","0","00","."]),A=/^(10|11|12|13|14|15)\d{16}$/,ae=/^(25|26|27|28|29|30)\d{14,22}$/,E=d(""),Z=()=>{if(x.value=!0,j.value.blur(),z.value)U();else{let m;if(A.test(c.value))m="9";else if(ae.test(c.value))m="13";else return x.value=!1,c.value="",j.value.focus(),D.error("请输入正确的支付码");Ie({uid:V.value.uid,user_ship:V.value.user_ship,village:V.value.village,brigade:V.value.brigade,price:V.value.price,pay_type:m,auth_code:c.value}).then(l=>{l.data.out_trade_no&&l.msg=="支付成功"?(R.value=!1,D({message:"支付成功",type:"success"}),u(l.data)):l.msg=="用户支付中"&&l.code==1&&(D.warning(l.msg),K.on("pay_user_success",S=>{D({message:"支付成功",type:"success"}),setTimeout(()=>{K.off("pay_user_success")},200),R.value=!1,u(S)}))}).catch(l=>{x.value=!1,pe(()=>{var S;(S=j.value)==null||S.focus()})})}},U=()=>{let m=17;if(F.value==1)if(A.test(c.value))m="9";else if(ae.test(c.value))m="13";else return x.value=!1,c.value="",j.value.focus(),D.error("请输入正确的支付码");sl({order_id:V.value.order_id,pay_type:m,auth_code:c.value}).then(l=>{var S;(S=l.msg)!=null&&S.includes("成功")?(R.value=!1,D({message:"支付成功",type:"success"}),u({msg:"支付成功"})):l.msg=="用户支付中"&&l.code==1&&(D.warning(l.msg),K.on("pay_user_success",Q=>{D({message:"支付成功",type:"success"}),setTimeout(()=>{K.off("pay_user_success")},200),R.value=!1,u(Q)}))}).catch(l=>{c.value="",x.value=!1,pe(()=>{var S;(S=j.value)==null||S.focus()})})};d(0);const u=(m=null)=>{var l;window.removeEventListener("keydown",ue),N.value=!1,x.value=!1,c.value="",p.value="",_.value=[],(l=j.value)==null||l.blur(),typeof m=="function"&&(m=null),k("paySuccess",m),R.value=!1},x=d(!1);r({drawer:R,setForm:P,setRePay:q,beforeClose:u});const _=d([]),p=d(""),ee=He(()=>+p.value>0?(p.value-V.value.total).toFixed(2):-1),W=d(!1),le=m=>{m===-1?_.value=[]:_.value.pop(),p.value=_.value.length?_.value.join(""):0},J=m=>{W.value===!1&&(p.value="",W.value=!0);let l=String(p.value).indexOf(".")+1,S=String(p.value).length-l;console.log(l,S),(l===0||S<2)&&(_.value.join("")<=9999999&&_.value.push(m),p.value=_.value.join("")>99999999?99999999:_.value.join(""))},ve=()=>{if(ee.value===""||ee.value===null||ee.value===void 0||+p.value<+V.value.total)return D.error("收款金额应该大于等于应收金额");z.value?U():Ie({uid:V.value.uid,user_ship:V.value.user_ship,village:V.value.village,brigade:V.value.brigade,price:V.value.price,pay_type:17}).then(m=>{console.log("========"),R.value=!1,D({message:m.msg,type:"success"}),F.value=1,u({msg:"收款成功"})}).catch(m=>{x.value=!1})},ue=m=>{let S=(m||window.event).keyCode;if(S==37)return H(2);if(S==120)return K.emit("F9");if(S==27)return u();switch(m.stopPropagation(),m.preventDefault(),S){case 96:case 48:J(0);break;case 97:case 49:J(1);break;case 98:case 50:J(2);break;case 99:case 51:J(3);break;case 100:case 52:J(4);break;case 101:case 53:J(5);break;case 102:case 54:J(6);break;case 103:case 55:J(7);break;case 104:case 56:J(8);break;case 105:case 57:J(9);break;case 110:J(".");break;case 190:J(".");break;case 8:le();break;case 13:ve();break}},ie=d(!1),te=()=>{if(!(!R.value||ie.value&&c.value.length>0)&&F.value==2)return H(1)},o=()=>{if(!(!R.value||ie.value&&c.value.length>0)&&F.value==1)return H(2)};return $e(()=>{K.on("left",te),K.on("right",o)}),Ve(()=>{K.off("left",te),K.off("right",o)}),(m,l)=>{const S=y("el-input"),Q=y("el-button"),v=y("Delete"),s=y("el-icon"),G=y("el-drawer"),I=fe("loading");return n(),O(G,{size:"60rem",modelValue:R.value,"onUpdate:modelValue":l[6]||(l[6]=L=>R.value=L),direction:"rtl",onOpen:B,"before-close":u},{header:t(()=>[Ol]),default:t(()=>{var L;return[e("div",Dl,[e("div",Il,[e("div",{class:ce(["left",{active:F.value==1}]),onClick:l[0]||(l[0]=X=>H(1))}," 微信/支付宝 ",2),e("div",{class:ce(["right",{active:F.value==2}]),onClick:l[1]||(l[1]=X=>H(2))}," 现金收款 ",2)]),e("div",null,[e("div",Pl,[Nl,e("div",El,[f(" ¥"),e("span",jl,h((L=V.value)==null?void 0:L.price),1)])])]),F.value==1?ge((n(),g("div",ql,[a(S,{ref_key:"codeRef",ref:j,modelValue:c.value,"onUpdate:modelValue":l[2]||(l[2]=X=>c.value=X),autofocus:"",class:"code-input",placeholder:"请点击输入框聚焦扫码或输入编码号",onKeyup:Ne(Z,["enter"]),onFocus:l[3]||(l[3]=X=>ie.value=!0),onBlur:l[4]||(l[4]=X=>ie.value=!1)},null,8,["modelValue"]),Bl])),[[I,x.value]]):(n(),g("div",Jl,[e("div",Tl,[e("div",Kl,[e("div",Ml,[p.value?(n(),g("span",Wl,h(p.value),1)):(n(),g("span",Gl,"按下键盘输入客户支付金额"))]),ee.value>=0?(n(),g("div",Hl,[e("div",null,[f(" 需找零(元):"),e("span",Ql,"¥"+h(ee.value),1)]),Xl])):(n(),g("div",Yl,la)),e("div",aa,[e("div",ta,[(n(!0),g(ne,null,re(b.value,X=>(n(),O(Q,{key:X,onClick:T=>J(X)},{default:t(()=>[f(h(X),1)]),_:2},1032,["onClick"]))),128))]),e("div",sa,[a(Q,{onClick:le},{default:t(()=>[a(s,null,{default:t(()=>[a(v)]),_:1})]),_:1}),a(Q,{onClick:l[5]||(l[5]=X=>le(-1))},{default:t(()=>[f("C")]),_:1}),a(Q,{class:ce(["enter",{"enter-disable":+p.value<+V.value.total}]),disabled:+p.value<+V.value.total,onClick:ve},{default:t(()=>[f(" 确认 ")]),_:1},8,["class","disabled"])])])])])]))])]}),footer:t(()=>[e("div",oa,[a(Q,{class:"cancel-btn",onClick:Y},{default:t(()=>[f("取消收款")]),_:1})])]),_:1},8,["modelValue"])}}},na=ke(ia,[["__scopeId","data-v-5ad4b8f5"]]),M=C=>(we("data-v-d356fe09"),C=C(),Ce(),C),ua={class:"my-order"},da={class:"header-nav"},ra=["onClick"],ca={key:0,class:"detail"},va={class:"table"},_a=M(()=>e("div",{class:"table-title"},"用户信息",-1)),ma={class:"table-info"},pa={class:"info-item"},fa=M(()=>e("div",{class:"info-item-title"},"用户余额:",-1)),ya={class:"info-item-info red"},ha={class:"info-item"},ga=M(()=>e("div",{class:"info-item-title"},"采购款:",-1)),ba={class:"info-item-info red"},ka={class:"info-item"},$a=M(()=>e("div",{class:"info-item-title"},"返还金:",-1)),Va={class:"info-item-info red"},wa={class:"info-item"},Ca=M(()=>e("div",{class:"info-item-title"},"头像:",-1)),Sa={class:"info-item-info"},Ua={class:"info-item"},xa=M(()=>e("div",{class:"info-item-title"},"礼品券:",-1)),za={class:"info-item-info red"},Aa={class:"info-item"},Ra=M(()=>e("div",{class:"info-item-title"},"冻结礼品券:",-1)),Fa={class:"info-item-info red"},La={class:"info-item"},Oa=M(()=>e("div",{class:"info-item-title"},"ID:",-1)),Da={class:"info-item-info"},Ia={class:"info-item"},Pa=M(()=>e("div",{class:"info-item-title"},"用户昵称:",-1)),Na={class:"info-item-info"},Ea={class:"info-item"},ja=M(()=>e("div",{class:"info-item-title"},"用户电话:",-1)),qa={class:"info-item-info"},Ba={class:"info-item"},Ja=M(()=>e("div",{class:"info-item-title"},"用户账号:",-1)),Ta={class:"info-item-info"},Ka={class:"info-item"},Ma=M(()=>e("div",{class:"info-item-title"},"真实姓名:",-1)),Wa={class:"info-item-info"},Ga={class:"info-item"},Ha=M(()=>e("div",{class:"info-item-title"},"创建时间:",-1)),Qa={class:"info-item-info"},Xa={class:"info-item",style:{width:"100%","flex-shrink":"0","align-items":"center"}},Ya=M(()=>e("div",{class:"info-item-title"},"用户类型:",-1)),Za={class:"info-item-info"},et={class:"info-item",style:{width:"100%","flex-shrink":"0","align-items":"center"}},lt=M(()=>e("div",{class:"info-item-title"},"用户地址:",-1)),at={key:1,class:"detail"},tt={class:"table","infinite-scroll-distance":300,"infinite-scroll-delay":300,style:{overflow:"auto"},"infinite-scroll-immediate":!1},st={style:{display:"flex","align-items":"center"}},ot={style:{"margin-left":"0.5rem"}},it={key:0,style:{display:"flex","align-items":"center"}},nt={class:"footer"},ut={key:0},dt={key:1},rt={key:2},ct={class:"dialog-footer"},vt={key:0},_t={class:"ship-money-list"},mt=["onClick"],pt={class:"item1"},ft={class:"item2"},yt={class:"dialog-footer"},ht={__name:"detail",setup(C){be(),Qe();const r=d({id:""});d({price:"",type:1});const $=d(null),R=(v=null)=>{ie()},F=d(!1),c=d([]);(()=>{Ee({type_id:4}).then(v=>{c.value=v.data.lists})})();const Y=()=>{el({id:r.value.id,user_ship:r.value.user_ship}).then(v=>{var s;D.success("修改成功"),r.value.user_ship_name=(s=c.value.find(G=>G.id==r.value.user_ship))==null?void 0:s.title,F.value=!1})},B=()=>{F.value=!1},H=d([]);(()=>{ll().then(v=>{H.value=v.data,console.log(v)})})();const w=d({id:"",province:"",city:"",area:"",street:"",brigade:""}),z=d([]),P=d([]),q=()=>{al({uid:r.value.id}).then(v=>{var s;(s=v.data)!=null&&s.village?(z.value=[v.data.city,v.data.area,v.data.street,v.data.village,+v.data.brigade],P.value=JSON.parse(JSON.stringify(z.value)),w.value=v.data):(z.value=[],P.value=[],w.value={id:"",province:"",city:"",area:"",street:"",brigade:""})}).catch(v=>{z.value=[],P.value=[],w.value={id:"",province:"",city:"",area:"",street:"",brigade:""}})},k=d([]),N=async(v,s)=>{const G=v.level;let I;if(G!==0&&!v.data.code)return s([]);G===0?(I=await Se({province_code:51e4}),I=I.data.map(L=>({code:L.city_code,name:L.city_name}))):G===1?(I=await Ue({city_code:v.data.code}),I=I.data.map(L=>({code:L.area_code,name:L.area_name}))):G===2?(I=await xe({area_code:v.data.code}),I=I.data.map(L=>({code:L.street_code,name:L.street_name}))):G===3?(I=await ze({street_code:v.data.code}),I=I.data.map(L=>({code:L.village_code,name:L.village_name}))):G===4&&(I=await Ae({village_code:v.data.code}),I=I.data.map(L=>({code:L.id,name:L.brigade_name,leaf:!0}))),s(I)},b={value:"code",label:"name",children:"children",multiple:!1,lazy:!0,lazyLoad:N},A=async()=>{w.value.city=z.value[0],w.value.area=z.value[1],w.value.street=z.value[2],w.value.village=z.value[3],w.value.brigade=z.value[4],w.value.phone||(w.value.phone=r.value.account),w.value.real_name||(w.value.real_name=r.value.real_name||r.value.nickname),tl({...w.value,uid:r.value.id}).then(v=>{P.value=JSON.parse(JSON.stringify(z.value)),D.success("编辑成功"),E.value=!0}).catch(v=>{ae()})},ae=()=>{z.value=JSON.parse(JSON.stringify(P.value)),P.value.length>0&&(w.value.city=P.value[0],w.value.area=P.value[1],w.value.street=P.value[2],w.value.village=P.value[3],w.value.brigade=P.value[4]),E.value=!0},E=d(!0),Z=d(0),U=d(["基本信息","用户资产"]),u=d(!1),x=d([]),_=d({page_no:1,page_size:10,loading:!1,loadend:!1});let p=[];const ee=(v=!1)=>{v&&(x.value=[],_.value.page_no=1,_.value.loadend=!1),!(_.value.loadend||_.value.loading)&&(_.value.loading=!0,ol({uid:r.value.id,page_no:_.value.page_no,page_size:_.value.page_size}).then(s=>{x.value=[...x.value,...s.data.lists],_.value.loading=!1,_.value.page_no++,s.data.lists.length<_.value.page_size&&(_.value.loadend=!0)}))},W=d({mobile:"",code:""}),le=d(!1),J=()=>{if(W.value.mobile=r.value.phone,W.value.code="",p=x.value.filter(v=>v.n_num).map(v=>({product_id:v.product_id,nums:v.n_num})),p.length==0)return D.error("请选择商品");le.value=!0},ve=()=>{console.log("发送短信验证码"),D.success("验证码已发送")},ue=()=>{if(W.value.code=="")return D.error("请输入验证码");il({uid:r.value.id,info:p}).then(v=>{u.value=!1,D.success("出库成功"),le.value=!1,ee(!0)})},ie=()=>{Pe({id:r.value.id}).then(({data:v})=>{v.phone=v.mobile+"",delete v.mobile,r.value=Object.assign(r.value,v)})},te=d(!1),o=d({user_ship:"",user_ship_name:"",limit:"",money:"",type:""}),m=()=>{o.value.money=Number(o.value.money).toFixed(2),(+o.value.money<+o.value.limit||+o.value.money>1e4)&&(+o.value.limit>0?o.value.money=o.value.limit:o.value.money="")},l=v=>{if(o.value.type=="add"){let s=c.value.find(G=>G.id==v);s&&(o.value.limit=s.limit,o.value.user_ship_name=s.title,o.value.money=s.limit)}},S=()=>{if(o.value.user_ship===""||o.value.user_ship===null||o.value.user_ship===void 0||o.value.user_ship===0)return D.error("请选择会员类型");if(o.value.money==0||o.value.money=="")return D.error(o.value.type=="add"?"请输入充值金额":"请选择金额");if(o.value.type=="add"&&(+o.value.money<+o.value.limit||+o.value.money>1e4))return+o.value.limit>0?o.value.money=o.value.limit:o.value.money="",D.error(`该类型至少需要充值${o.value.limit}元`);$.value.setForm({data:{uid:r.value.id,price:o.value.money,user_ship:o.value.user_ship,village:w.value.village,brigade:w.value.brigade}}),$.value.drawer=!0,pe(()=>{te.value=!1})},Q=v=>{if(P.value.length==0)return D.error("请先选择用户地址");o.value.type=v,v=="add"&&(o.value.user_ship=r.value.user_ship,o.value.user_ship_name=r.value.user_ship_name,l(o.value.user_ship)),te.value=!0};return $e(()=>{K.on("set-user-detail",v=>{r.value=v,u.value=!1,Pe({id:r.value.id}).then(({data:s})=>{s.phone=s.mobile+"",delete s.mobile,r.value=Object.assign(v,s)}),z.value=[],P.value=[],q(),ee(!0),o.value={user_ship:"",user_ship_name:"",limit:"",money:"",type:""}})}),Ve(()=>{K.off("set-user-detail")}),(v,s)=>{var Oe;const G=y("el-avatar"),I=y("el-tag"),L=y("el-option"),X=y("el-select"),T=y("el-button"),qe=y("el-cascader"),Be=y("el-image"),he=y("el-table-column"),Je=y("el-input-number"),Te=y("el-table"),Ke=y("el-empty"),me=y("el-input"),de=y("el-form-item"),Fe=y("el-form"),Le=y("el-dialog"),Me=fe("infinite-scroll"),We=fe("loading");return n(),g("div",ua,[e("div",da,[(n(!0),g(ne,null,re(U.value,(i,se)=>(n(),g("div",{key:se,class:ce(["nav-item",{"nav-item-active":Z.value==se,"nav-item-radius1":Z.value==se+1,"nav-item-radius2":Z.value==se-1}]),onClick:Ge=>Z.value=se},h(i),11,ra))),128)),e("div",{class:ce(["nav-item",{"nav-item-radius2":Z.value==U.value.length-1}]),style:{flex:"1"}},null,2)]),r.value.id&&Z.value==0?(n(),g("div",ca,[e("div",va,[_a,e("div",ma,[e("div",pa,[fa,e("div",ya,"¥"+h(r.value.now_money),1)]),e("div",ha,[ga,e("div",ba,"¥"+h(r.value.purchase_funds),1)]),e("div",ka,[$a,e("div",Va,"¥"+h((Oe=r.value.return_money)==null?void 0:Oe.toFixed(2)),1)]),e("div",wa,[Ca,e("div",Sa,[a(G,{style:{width:"4rem",height:"4rem"},src:r.value.avatar},null,8,["src"])])]),e("div",Ua,[xa,e("div",za,"¥"+h(r.value.integral),1)]),e("div",Aa,[Ra,e("div",Fa,"¥"+h(r.value.get_frozen),1)]),e("div",La,[Oa,e("div",Da,h(r.value.id),1)]),e("div",Ia,[Pa,e("div",Na,h(r.value.nickname),1)]),e("div",Ea,[ja,e("div",qa,h(r.value.phone),1)]),e("div",Ba,[Ja,e("div",Ta,h(r.value.account),1)]),e("div",Ka,[Ma,e("div",Wa,h(r.value.real_name),1)]),e("div",Ga,[Ha,e("div",Qa,h(r.value.create_time),1)]),e("div",Xa,[Ya,e("div",Za,[F.value==!1?(n(),g(ne,{key:0},[r.value.user_ship==0?(n(),O(I,{key:0,type:"primary",size:"large"},{default:t(()=>[f(h(r.value.user_ship_name),1)]),_:1})):(n(),O(I,{key:1,type:"success",size:"large"},{default:t(()=>[f(h(r.value.user_ship_name),1)]),_:1}))],64)):(n(),g(ne,{key:1},[a(X,{modelValue:r.value.user_ship,"onUpdate:modelValue":s[0]||(s[0]=i=>r.value.user_ship=i),placeholder:"请选择用户类型",style:{width:"10rem"}},{default:t(()=>[(n(!0),g(ne,null,re(c.value,i=>(n(),O(L,{key:i.id,label:i.title,value:i.id,disabled:i.id!=0&&i.id!=4},null,8,["label","value","disabled"]))),128))]),_:1},8,["modelValue"]),a(T,{type:"primary",style:{"margin-left":"1rem"},onClick:Y},{default:t(()=>[f("确认")]),_:1}),a(T,{style:{"margin-left":"1rem"},onClick:B},{default:t(()=>[f("取消")]),_:1})],64))])]),e("div",et,[lt,(n(),O(qe,{key:r.value.id,style:{flex:"1"},modelValue:z.value,"onUpdate:modelValue":s[1]||(s[1]=i=>z.value=i),options:k.value,props:b,load:N,class:"w-full",disabled:E.value},null,8,["modelValue","options","disabled"])),E.value&&!P.value.length?(n(),O(T,{key:0,type:"primary",style:{"margin-left":"1rem"},onClick:s[2]||(s[2]=i=>E.value=!1)},{default:t(()=>[f("修改")]),_:1})):oe("",!0),E.value?oe("",!0):(n(),O(T,{key:1,type:"primary",style:{"margin-left":"1rem"},onClick:A},{default:t(()=>[f("确认")]),_:1})),E.value?oe("",!0):(n(),O(T,{key:2,style:{"margin-left":"1rem"},onClick:ae},{default:t(()=>[f("取消")]),_:1}))]),r.value.user_ship!=0?(n(),O(T,{key:0,type:"success",class:"big-btn",size:"large",onClick:s[3]||(s[3]=i=>Q("add"))},{default:t(()=>[f("增加经营资金")]),_:1})):(n(),O(T,{key:1,type:"primary",class:"big-btn",size:"large",onClick:s[4]||(s[4]=i=>Q("recharge"))},{default:t(()=>[f("成为会员")]),_:1}))])])])):oe("",!0),r.value.id&&Z.value==1?ge((n(),g("div",at,[ge((n(),g("div",tt,[a(Te,{data:x.value},{default:t(()=>[a(he,{label:"商品信息"},{default:t(({row:i})=>[e("div",st,[a(Be,{style:{height:"3rem",width:"3rem","flex-shrink":"0"},src:i.image},null,8,["src"]),e("span",ot,h(i.store_name),1)])]),_:1}),a(he,{prop:"price",label:"单价",width:u.value?130:200},null,8,["width"]),a(he,{prop:"nums",label:"存量",width:u.value?100:200},null,8,["width"]),u.value?(n(),O(he,{key:0,prop:"nums",label:"出库量",width:"250"},{default:t(({row:i})=>[i.nums?(n(),g("div",it,[a(Je,{modelValue:i.n_num,"onUpdate:modelValue":se=>i.n_num=se,"step-strictly":"",min:0,max:i.nums},null,8,["modelValue","onUpdate:modelValue","max"]),a(T,{type:"primary",style:{"margin-left":"1rem"},onClick:se=>i.n_num=i.nums},{default:t(()=>[f("全部")]),_:2},1032,["onClick"])])):oe("",!0)]),_:1})):oe("",!0)]),_:1},8,["data"])])),[[Me,ee]]),e("div",nt,[u.value?(n(),g("div",dt,[a(T,{type:"primary",size:"large",onClick:J},{default:t(()=>[f("确认出库")]),_:1}),a(T,{size:"large",onClick:s[6]||(s[6]=i=>u.value=!1)},{default:t(()=>[f("取消")]),_:1})])):(n(),g("div",ut,[a(T,{type:"warning",size:"large",onClick:s[5]||(s[5]=i=>u.value=!0),disabled:x.value.length==0},{default:t(()=>[f("商品出库")]),_:1},8,["disabled"])]))])])),[[We,_.value.loading]]):(n(),g("div",rt,[a(Ke)])),a(na,{ref_key:"payRef",ref:$,onPaySuccess:R},null,512),a(Le,{modelValue:le.value,"onUpdate:modelValue":s[10]||(s[10]=i=>le.value=i),title:"出库验证",width:"500"},{footer:t(()=>[e("div",ct,[a(T,{onClick:s[9]||(s[9]=i=>le.value=!1)},{default:t(()=>[f("取消")]),_:1}),a(T,{type:"primary",onClick:ue},{default:t(()=>[f(" 确认 ")]),_:1})])]),default:t(()=>[a(Fe,{model:W.value},{default:t(()=>[a(de,{label:"手机号:"},{default:t(()=>[a(me,{modelValue:W.value.mobile,"onUpdate:modelValue":s[7]||(s[7]=i=>W.value.mobile=i),autocomplete:"off",readonly:""},null,8,["modelValue"])]),_:1}),a(de,{label:"验证码:"},{default:t(()=>[a(me,{modelValue:W.value.code,"onUpdate:modelValue":s[8]||(s[8]=i=>W.value.code=i),autocomplete:"off",placeholder:"请输入验证码",style:{flex:"1"}},null,8,["modelValue"]),(n(),O(je,{style:{"margin-left":"1rem"},onSendCode:ve,key:W.value.mobile}))]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue"]),a(Le,{modelValue:te.value,"onUpdate:modelValue":s[17]||(s[17]=i=>te.value=i),title:o.value.type=="add"?"增加经营资金":"成为会员",width:"500"},{footer:t(()=>[e("div",yt,[a(T,{onClick:s[16]||(s[16]=i=>te.value=!1)},{default:t(()=>[f("取消")]),_:1}),a(T,{type:"primary",onClick:S},{default:t(()=>[f(" 确认 ")]),_:1})])]),default:t(()=>[a(Fe,{model:o.value,"label-width":"100px"},{default:t(()=>[a(de,{label:"手机号:"},{default:t(()=>[a(me,{modelValue:r.value.phone,"onUpdate:modelValue":s[11]||(s[11]=i=>r.value.phone=i),autocomplete:"off",readonly:""},null,8,["modelValue"])]),_:1}),o.value.type=="add"?(n(),O(de,{key:0,label:"会员类型:"},{default:t(()=>[a(me,{modelValue:o.value.user_ship_name,"onUpdate:modelValue":s[12]||(s[12]=i=>o.value.user_ship_name=i),autocomplete:"off",readonly:""},null,8,["modelValue"])]),_:1})):(n(),O(de,{key:1,label:"会员类型:",required:""},{default:t(()=>[a(X,{modelValue:o.value.user_ship,"onUpdate:modelValue":s[13]||(s[13]=i=>o.value.user_ship=i),placeholder:"请选择用户类型",style:{flex:"1"},onChange:l},{default:t(()=>[(n(!0),g(ne,null,re(c.value,i=>(n(),O(L,{key:i.id,label:i.title,value:i.id,disabled:i.id==0},null,8,["label","value","disabled"]))),128))]),_:1},8,["modelValue"])]),_:1})),o.value.type=="add"?(n(),O(de,{key:2,label:"充值金额:",required:""},{default:t(()=>[a(me,{modelValue:o.value.money,"onUpdate:modelValue":s[14]||(s[14]=i=>o.value.money=i),type:"number",onBlur:m,onFocus:s[15]||(s[15]=i=>o.value.money=""),autocomplete:"off"},{prepend:t(()=>[f("¥")]),append:t(()=>[f("元")]),_:1},8,["modelValue"]),o.value.limit?(n(),g("div",vt,h(`${o.value.user_ship_name}角色至少要充值${o.value.limit}元, 最大不超过10000元`),1)):oe("",!0)]),_:1})):(n(),O(de,{key:3,label:"充值金额:",required:""},{default:t(()=>[e("div",_t,[(n(!0),g(ne,null,re(H.value,(i,se)=>(n(),g("div",{class:ce(["ship-money-item",{"ship-money-item-active":i.money==o.value.money}]),onClick:Ge=>o.value.money=i.money,key:se},[e("div",pt,h(i.money)+h(i.money_string),1),e("div",ft,"送"+h(i.send)+h(i.send_string),1)],10,mt))),128))])]),_:1}))]),_:1},8,["model"])]),_:1},8,["modelValue","title"])])}}},gt=ke(ht,[["__scopeId","data-v-d356fe09"]]),bt={class:"my-card"},xt={__name:"index",setup(C){return(r,$)=>(n(),g("div",bt,[a(Ll,{style:{"flex-shrink":"0"},ref:"orderRef"},null,512),a(nl),a(gt,{ref:"detailRef"},null,512)]))}};export{xt as default};