| 1 |
- import{x as u,W as x}from"./index.TaRuePjT.js";import{M as b}from"./md5.DLPczxzP.js";import{r as q,f as W}from"./vue.D1BjjNmv.js";const c="/api/platform-admin/users/";function v(r){return u({url:c,method:"get",params:r})}function R(r){return u({url:c,method:"post",data:r})}function z(r){return u({url:c+r.id+"/",method:"put",data:r})}function M(r){return u({url:c+r+"/",method:"delete",data:{id:r}})}const O=function({crudExpose:r}){const m=q(!1);return{crudOptions:{toolbar:{buttons:{search:{show:!1},refresh:{show:!1},compact:{show:!1},export:{text:"导出",type:"primary",size:"small",icon:"upload",circle:!1,display:!0,show:!1},columns:{show:!1}}},search:{col:{span:3},show:!0,autoSearch:!0,buttons:{search:{size:"small"},reset:{size:"small"}}},request:{pageRequest:async t=>{var i,d,h,f;console.log(t);const e=await v(t);console.log("API返回的完整响应:",e);let a=[];if((i=e==null?void 0:e.data)!=null&&i.results&&Array.isArray(e.data.results)?a=e.data.results:(d=e==null?void 0:e.data)!=null&&d.items&&Array.isArray(e.data.items)?a=e.data.items:Array.isArray(e==null?void 0:e.data)?a=e.data:Array.isArray(e==null?void 0:e.records)&&(a=e.records),a.length>0){const l=a.length;console.log("过滤前数据:",a.map(s=>({username:s.username,name:s.name})));const o=a.filter(s=>{var y;const A=s.username==="platform_admin"||s.username==="platform2_admin",_=s.name==="平台管理员";let p=!1;if(t.tenant_id){const g=s.tenant_id??((y=s.tenant)==null?void 0:y.id);g&&String(g)!==String(t.tenant_id)&&(p=!0)}const w=A||_||p;return w&&console.log("过滤掉账号:",{username:s.username,name:s.name}),!w}),n=o.length;console.log("过滤后数据数量:",n,"原始数量:",l),(h=e==null?void 0:e.data)!=null&&h.results?(e.data.results=o,e.data.count!==void 0&&(e.data.count=Math.max(0,e.data.count-(l-n)))):(f=e==null?void 0:e.data)!=null&&f.items?(e.data.items=o,e.data.total!==void 0&&(e.data.total=Math.max(0,e.data.total-(l-n)))):Array.isArray(e==null?void 0:e.data)?(e.data=o,e.total!==void 0&&(e.total=Math.max(0,e.total-(l-n)))):Array.isArray(e==null?void 0:e.records)&&(e.records=o,e.total!==void 0&&(e.total=Math.max(0,e.total-(l-n)))),m.value=o.length>0}else m.value=!1;return e},addRequest:async({form:t})=>await R(t),editRequest:async({form:t,row:e})=>(t.id=e.id,await z(t)),delRequest:async({row:t})=>await M(t.id)},actionbar:{buttons:{add:{show:W(()=>!m.value)}}},rowHandle:{fixed:"right",width:230,buttons:{view:{show:!0,size:"small"},edit:{type:"primary",show:!0,size:"small"},remove:{type:"danger",show:!0,size:"small"}}},columns:{_index:{title:"序号",form:{show:!1},column:{type:"index",align:"center",width:"70px",columnSetDisabled:!0}},username:{title:"用户名",type:"text",search:{show:!0},form:{component:{placeholder:"请输入用户名"},rules:[{required:!0,message:"请输入用户名"}]},column:{minWidth:120}},password:{title:"密码",type:"password",search:{show:!1},column:{show:!1},addForm:{component:{placeholder:"请输入密码"},rules:[{required:!0,message:"请输入密码"},{validator:(t,e,a)=>{if(!e){a();return}if(e.length<8){a(new Error("密码长度不能少于8位"));return}const i=/[a-zA-Z]/.test(e),d=/[0-9]/.test(e);if(!i||!d){a(new Error("密码必须包含字母和数字"));return}a()},trigger:"blur"}],show:!0,column:{show:!1}},valueResolve({form:t}){t.password&&(t.password=b.hashStr(t.password))}},name:{title:"姓名",type:"text",search:{show:!1},form:{component:{placeholder:"请输入姓名"},rules:[{required:!0,message:"请输入姓名"}]},column:{minWidth:120}},mobile:{title:"手机号",type:"text",search:{show:!0},form:{component:{placeholder:"请输入手机号"},rules:[{required:!0,message:"请输入手机号"}]},column:{minWidth:120}},email:{title:"邮箱",type:"text",search:{show:!0},form:{component:{placeholder:"请输入邮箱"},rules:[{required:!0,message:"请输入邮箱"}]},column:{minWidth:180}},tenant_id:{title:"商户",search:{show:!0},type:"dict-select",dict:x({url:"/api/platform-admin/tenants/",value:"id",label:"name"})},is_active:{title:"账号状态",search:{show:!0},type:"dict-select",form:{show:!0,component:{placeholder:"请选择账号状态"}},column:{minWidth:120},dict:x({data:[{value:!0,label:"启用"},{value:!1,label:"禁用"}]})},create_datetime:{title:"开通时间",type:"datetime",search:{show:!1},form:{component:{placeholder:"请选择开通时间"},show:!1},column:{minWidth:150}},account_expiry_days:{title:"截至天数",type:"number",search:{show:!1},form:{component:{placeholder:"请输入截至天数",min:1,max:365},show:!0},column:{minWidth:150,show:!1}},account_expiry:{title:"账号到期时间",type:"datetime",search:{show:!1},form:{component:{placeholder:"请选择账号到期时间"},show:!1},column:{minWidth:150}},last_login:{title:"最后登录时间",type:"datetime",search:{show:!1},form:{component:{placeholder:"请选择最后登录时间"},show:!1},column:{minWidth:150}}}}}},F=Object.freeze(Object.defineProperty({__proto__:null,createCrudOptions:O},Symbol.toStringTag,{value:"Module"}));export{v as G,F as a,O as c};
|