import{t as s,r as y,W as j}from"./index.C8350zAH.js";import{a as S}from"./authFunction.CMm04RsS.js";import{r as C}from"./vue.D1BjjNmv.js";const c="/api/system/app_user/";function P(i){return s({url:c,method:"get",params:i})}function V(i){return s({url:c+i+"/",method:"get"})}function D(i){return s({url:c,method:"post",data:i})}function G(i){return s({url:c+i.id+"/",method:"put",data:i})}function L(i){return s({url:c+i+"/",method:"delete",data:{id:i}})}function M(){return s({url:c,method:"get"})}function R(){return s({url:"/api/system/organization/tree/",method:"get"})}let h=[];const A=async()=>{try{const i=await R();if(i&&(i.code===200||i.code===2e3||!i.code)){const o=i.data||i.results||i;Array.isArray(o)&&(h=o)}}catch(i){console.error("获取组织架构数据失败:",i),h=[]}};function T(i,o){if(!(!i||!o)){for(const _ of o)if(Array.isArray(_.children)){for(const m of _.children)if(m.name===i)return m}}}const I=function({crudExpose:i}){A();const o=async e=>await P(e),_=async({row:e})=>await V(e.id),m=async({form:e,row:r})=>(e.id=r.id,await G(e)),F=async({row:e})=>await L(e.id),O=async({form:e})=>await D(e),z=C([]),E=e=>{console.log("selection",e),z.value=e.map(r=>r.id)};return i.selectedIds=z,{crudOptions:{request:{pageRequest:o,editRequest:m,delRequest:F,addRequest:O,getDetail:_},toolbar:{show:!1},actionbar:{buttons:{add:{show:S("area:Create")}}},form:{wrapper:{buttons:{ok:{text:"提交",show:y(e=>e.mode!=="view")}}}},pagination:{show:!0},table:{rowSelection:{show:!0,multiple:!0},onSelectionChange:E},columns:{$checked:{title:"选择",form:{show:!1},column:{type:"selection",align:"center",width:"55px",columnSetDisabled:!0,selectable(e,r){return e.id}}},_index:{title:"序号",form:{show:!1},column:{type:"index",align:"center",width:"70px",columnSetDisabled:!0}},search:{title:"关键字搜索",search:{show:!0,type:"input"},type:"input",form:{component:{placeholder:"请输入"},show:!1},column:{show:!1}},user_code:{title:"学号/工号",type:"input",column:{minWidth:120},form:{component:{placeholder:"请填写学号/工号"},rules:[{required:!0,message:"请填写学号/工号"}]},viewForm:{component:{placeholder:""}}},username:{title:"用户名",type:"input",column:{show:!1,minWidth:120},form:{component:{placeholder:"请填写用户名"},rules:[{required:!0,message:"请填写用户名"}]},viewForm:{component:{placeholder:""}}},name:{title:"姓名",search:{show:!1},treeNode:!0,type:"input",column:{minWidth:120},form:{rules:[{required:!0,message:"姓名必填项"}],component:{placeholder:"请输入姓名"}}},password:{title:"密码",type:"input",column:{minWidth:120,show:!1},form:{component:{placeholder:"请填写密码",type:"password",showPassword:!0}},addForm:{component:{placeholder:"请填写密码",type:"password",showPassword:!0},rules:[{required:!0,message:"请填写密码"},{validator:(e,r,t)=>{if(!r||r.trim()===""){t(new Error("请填写密码"));return}const n=8,l=/[a-zA-Z]/.test(r),d=/\d/.test(r),u=/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(r);if(r.length{if(!r||r.trim()===""){t();return}const n=8,l=/[a-zA-Z]/.test(r),d=/\d/.test(r),u=/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(r);if(r.length=4?(e._college_id=(n=a[1])==null?void 0:n.id,e._major_id=(l=a[2])==null?void 0:l.id,e._grade_id=t==null?void 0:t.id):a.length===3?(e._college_id=(d=a[1])==null?void 0:d.id,e._major_id=(u=a[2])==null?void 0:u.id,e._grade_id=t==null?void 0:t.id):a.length===2?(e._college_id=(w=a[0])==null?void 0:w.id,e._major_id=(b=a[1])==null?void 0:b.id,e._grade_id=t==null?void 0:t.id):a.length===1?(e._college_id=(q=a[0])==null?void 0:q.id,e._major_id=void 0,e._grade_id=t==null?void 0:t.id):(e._college_id=void 0,e._major_id=void 0,e._grade_id=t==null?void 0:t.id)}else if(e.user_type===1||e.user_type===3)t&&t.id&&(e.organization_ref=t.id);else if(e.user_type===0&&!t&&h.length>0){const a=e.organization,N=e.sub_organization,W=e.grade_or_level||e.class_or_group;if(a){const g=T(a,h);if(g&&(e._college_id=g.id,N&&Array.isArray(g.children))){const f=g.children.find(p=>p.name===N);if(f&&(e._major_id=f.id,W&&Array.isArray(f.children))){const p=f.children.find(x=>x.name===W);p&&(e._grade_id=p.id,e.organization_ref=p.id)}}}}},valueResolve({form:e,value:r}){if(e.user_type!==0){e.organization_ref=r??e.organization_ref;return}if(e._grade_id){e.organization_ref=e._grade_id;return}}},organization_detail:{title:"组织架构",type:"dict-cascader",column:{show:!1,minWidth:200,formatter:({row:e,value:r})=>e.organization_detail&&e.organization_detail.full_path?e.organization_detail.full_path:r||""},form:{show:!1,component:{placeholder:"请填写组织架构"},rules:[{required:!1,message:"请填写组织架构"}]},viewForm:{component:{placeholder:""}}},organization:{title:"学院",type:"input",search:{show:!1},column:{show:!0,minWidth:200,formatter:({row:e,value:r})=>{const t=n=>n!=null&&n!==""&&n!=="nan"&&!Number.isNaN(n);if(e.user_type!==0)return e.organization_detail&&e.organization_detail.name?e.organization_detail.name:t(r)?r:t(e.class_or_group)?e.class_or_group:"";if(e.organization_detail&&e.organization_detail.parent_chain&&e.organization_detail.parent_chain.length>=2){if(!e.organization_detail.parent_chain[1])return;const n=e.organization_detail.parent_chain[1];return n.name||n.code||""}return t(r)?r:t(e.sub_organization)?e.sub_organization:""}},form:{show:y(e=>e.user_type===0||e.user_type===1||e.user_type===3),component:{placeholder:"请选择学院"},rules:[{required:!1,message:"请选择学院"}]},viewForm:{component:{placeholder:""}}},sub_organization:{title:"专业",type:"input",search:{show:!1},column:{show:!0,minWidth:120,formatter:({row:e,value:r})=>{const t=n=>n!=null&&n!==""&&n!=="nan"&&!Number.isNaN(n);if(e.organization_detail&&e.organization_detail.parent_chain&&e.organization_detail.parent_chain.length>=2){if(!e.organization_detail.parent_chain[2])return;const n=e.organization_detail.parent_chain[2];return n.name||n.code||""}return t(r)?r:t(e.sub_organization)?e.sub_organization:""}},form:{show:y(({form:e})=>e&&e.user_type==0),component:{placeholder:"请填写专业"},rules:[{required:!1,message:"请填写专业"}]}},grade_or_level:{title:"班级",type:"input",search:{show:!1},column:{show:!0,minWidth:120,formatter:({row:e,value:r})=>{const t=n=>n!=null&&n!==""&&n!=="nan"&&!Number.isNaN(n);if(e.user_type===0)return e.organization_detail&&e.organization_detail.name?e.organization_detail.name:t(r)?r:t(e.class_or_group)?e.class_or_group:""}},form:{show:y(({form:e})=>e&&e.user_type==0),component:{placeholder:"请选择年级"},rules:[{required:!1,message:"请选择年级"}]},viewForm:{component:{placeholder:""}}},class_or_group:{title:"班级",type:"input",search:{show:!1},column:{show:!1,minWidth:120,formatter:({row:e,value:r})=>e.organization_detail&&e.organization_detail.name?e.organization_detail.name:r||e.class_or_group},form:{show:!1,component:{placeholder:"请填写班级"},rules:[{required:!1,message:"请填写班级"}]},viewForm:{component:{placeholder:""}}}}}}},U=Object.freeze(Object.defineProperty({__proto__:null,createCrudOptions:I},Symbol.toStringTag,{value:"Module"}));export{M as G,U as a,I as c};