Files
xin-procurement/public/assets/mini-user-BR1wZbCg.js
T
2026-08-15 00:19:00 +08:00

1 line
3.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{i as e}from"./rolldown-runtime-BgaNhQyE.js";import{Dr as t,t as n}from"./jsx-runtime-CRBytmvs.js";import{t as r}from"./request--UCyt0wo.js";import{t as i}from"./typography-DRFhazK9.js";import{t as a}from"./space-Cu4QVMgQ.js";import{t as o}from"./button-BILozH6U.js";import{r as s}from"./DoubleRightOutlined-Blfli1UU.js";import{t as c}from"./modal-g8Q5gNCx.js";import{t as l}from"./form-B3R3kIqp.js";import{r as u}from"./PictureOutlined-CB8Pr7jP.js";import{t as d}from"./popconfirm-DyseZgpU.js";import{t as f}from"./tag-DBV1bHre.js";import{t as p}from"./XinTable-NSSoHqA_.js";import{t as m}from"./AuthButton-DvrpreK4.js";import{t as h}from"./store-JDnJsv44.js";var g=e(t(),1),_={0:{text:`停用`,color:`error`},1:{text:`正常`,color:`success`}};async function v(e,t){return r({url:`/customer/miniUser/${e}/bind`,method:`put`,data:t})}async function y(e,t){return r({url:`/customer/miniUser/${e}/status`,method:`put`,data:{status:t}})}var b=n(),{Title:x,Text:S}=i,C=()=>{let e=(0,g.useRef)(null),[t,n]=(0,g.useState)([]),[r,i]=(0,g.useState)(!1),[C,w]=(0,g.useState)(null),[T,E]=(0,g.useState)(!1),[D]=l.useForm();(0,g.useEffect)(()=>{h().then(e=>n(e.data.data??[]))},[]);let O=e=>{w(e),D.setFieldsValue({store_id:e.store_id||void 0}),i(!0)},k=async t=>{if(C?.id){E(!0);try{await v(C.id,{store_id:t.store_id}),u.success(`绑定成功`),i(!1),await e.current?.reload()}finally{E(!1)}}},A=async t=>{await y(t.id,t.status===1?0:1),u.success(t.status===1?`已停用`:`已启用`),await e.current?.reload()};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`mb-5`,children:[(0,b.jsx)(x,{level:3,children:`小程序用户`}),(0,b.jsx)(S,{type:`secondary`,children:`用户由微信小程序登录自动创建;`})]}),(0,b.jsx)(p,{api:`/customer/miniUser`,columns:[{title:`ID`,dataIndex:`id`,hideInSearch:!0,width:70,align:`center`},{title:`昵称`,dataIndex:`nickname`,valueType:`text`,hideInSearch:!0,render:(e,t)=>(0,b.jsxs)(a,{size:8,children:[t.avatar?(0,b.jsx)(`img`,{src:t.avatar,alt:``,className:`h-6 w-6 rounded-full`}):null,(0,b.jsx)(`span`,{children:t.nickname||`-`})]})},{title:`手机号`,dataIndex:`phone`,valueType:`text`,hideInSearch:!0,render:(e,t)=>t.phone||(0,b.jsx)(S,{type:`secondary`,children:`未绑定`})},{title:`绑定门店`,dataIndex:`store_id`,hideInSearch:!0,render:(e,t)=>(0,b.jsx)(f,{color:`blue`,children:t.store?.name??`门店#${t.store_id}`})},{title:`状态`,dataIndex:`status`,valueType:`select`,fieldProps:{options:[{value:1,label:`正常`},{value:0,label:`停用`}]},render:(e,t)=>{let n=_[t.status??1];return(0,b.jsx)(f,{color:n?.color,children:n?.text})},align:`center`},{title:`最后登录`,dataIndex:`last_login_at`,hideInSearch:!0,align:`center`,render:(e,t)=>t.last_login_at??(0,b.jsx)(S,{type:`secondary`,children:`从未登录`})},{title:`注册时间`,dataIndex:`created_at`,hideInSearch:!0,align:`center`}],rowKey:`id`,accessName:`customer.miniUser`,tableRef:e,operateRender:e=>[(0,b.jsx)(m,{auth:`customer.miniUser.bind`,children:(0,b.jsx)(o,{size:`small`,color:`blue`,variant:`outlined`,onClick:()=>O(e),children:`绑定`})},`bind`),(0,b.jsx)(m,{auth:`customer.miniUser.update`,children:(0,b.jsx)(d,{title:e.status===1?`确定停用该账号?`:`确定启用该账号?`,description:e.status===1?`停用后该用户将无法登录小程序`:void 0,onConfirm:()=>A(e),children:(0,b.jsx)(o,{size:`small`,danger:e.status===1,children:e.status===1?`停用`:`启用`})})},`status`)],formProps:!1}),(0,b.jsx)(c,{title:`绑定主体 · ${C?.nickname||``}`,open:r,onCancel:()=>i(!1),onOk:()=>D.submit(),confirmLoading:T,okText:`确认绑定`,destroyOnHidden:!0,children:(0,b.jsx)(l,{form:D,layout:`vertical`,onFinish:k,className:`mt-4`,children:(0,b.jsx)(l.Item,{label:`绑定门店`,name:`store_id`,rules:[{required:!0,message:`请选择门店`}],children:(0,b.jsx)(s,{showSearch:{optionFilterProp:`label`},placeholder:`选择门店`,options:t.map(e=>({label:`${e.name}${e.code}`,value:e.id}))})})})})]})};export{C as default};