import{t as u,r as z,W as F,X as s}from"./index.DxJKo3PQ.js";import{r as R,t as x}from"./vue.D1BjjNmv.js";const h="/api/system/app_user/";function C(i){return u({url:h,method:"get",params:i})}function P(i){return u({url:h+i+"/",method:"get"})}function V(i){return u({url:h,method:"post",data:i})}function G(i){return u({url:h+i.id+"/",method:"put",data:i})}function L(i){return u({url:h+i+"/",method:"delete",data:{id:i}})}function Z(){return u({url:h,method:"get"})}function I(){return u({url:"/api/system/organization/tree/",method:"get"})}let g=[];const D=async()=>{try{const i=await I();if(i&&(i.code===200||i.code===2e3||!i.code)){const l=i.data||i.results||i;Array.isArray(l)&&(g=l)}}catch(i){console.error("获取组织架构数据失败:",i),g=[]}};function $(i,l){if(!(!i||!l)){for(const m of l)if(Array.isArray(m.children)){for(const f of m.children)if(f.name===i)return f}}}const B=function({crudExpose:i}){D();const l=async e=>await C(e),m=async({row:e})=>await P(e.id),f=async({form:e,row:n})=>(e.id=n.id,await G(e)),E=async({row:e})=>await L(e.id),O=async({form:e})=>await V(e),d=R([]),b=R([]),S=e=>{const t=i.getTableData().filter(r=>!e.includes(r));s.arrayEach(e,r=>{s.pluck(d.value,"id").includes(r.id)||(d.value=s.union(d.value,[r]))}),s.arrayEach(t,r=>{d.value=s.remove(d.value,o=>o.id!==r.id)}),b.value=s.pluck(d.value,"id")},T=()=>{const e=i.getBaseTableRef(),n=i.getTableData(),t=s.filter(n,r=>s.pluck(d.value,"id").includes(r.id));x(()=>{s.arrayEach(t,r=>{e.toggleRowSelection(r,!0)})})};return i.selectedIds=b,{crudOptions:{request:{pageRequest:l,editRequest:f,delRequest:E,addRequest:O,getDetail:m},toolbar:{show:!1},actionbar:{buttons:{add:{show:!0}}},form:{wrapper:{buttons:{ok:{text:"提交",show:z(e=>e.mode!=="view")}}}},pagination:{show:!0},table:{rowKey:"id",rowSelection:{show:!0,multiple:!0},onSelectionChange:S,onRefreshed:()=>T()},columns:{$checked:{title:"选择",form:{show:!1},column:{type:"selection",align:"center",width:"55px",columnSetDisabled:!0,selectable(e,n){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,n,t)=>{if(!n||n.trim()===""){t(new Error("请填写密码"));return}const r=8,o=/[a-zA-Z]/.test(n),c=/\d/.test(n),p=/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(n);if(n.length{if(!n||n.trim()===""){t();return}const r=8,o=/[a-zA-Z]/.test(n),c=/\d/.test(n),p=/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(n);if(n.length=4?(e._college_id=(r=a[1])==null?void 0:r.id,e._major_id=(o=a[2])==null?void 0:o.id,e._grade_id=t==null?void 0:t.id):a.length===3?(e._college_id=(c=a[1])==null?void 0:c.id,e._major_id=(p=a[2])==null?void 0:p.id,e._grade_id=t==null?void 0:t.id):a.length===2?(e._college_id=(q=a[0])==null?void 0:q.id,e._major_id=(N=a[1])==null?void 0:N.id,e._grade_id=t==null?void 0:t.id):a.length===1?(e._college_id=(W=a[0])==null?void 0:W.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&&g.length>0){const a=e.organization,j=e.sub_organization,A=e.grade_or_level||e.class_or_group;if(a){const y=$(a,g);if(y&&(e._college_id=y.id,j&&Array.isArray(y.children))){const w=y.children.find(_=>_.name===j);if(w&&(e._major_id=w.id,A&&Array.isArray(w.children))){const _=w.children.find(v=>v.name===A);_&&(e._grade_id=_.id,e.organization_ref=_.id)}}}}},valueResolve({form:e,value:n}){if(e.user_type!==0){e.organization_ref=n??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:n})=>e.organization_detail&&e.organization_detail.full_path?e.organization_detail.full_path:n||""},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:n})=>{const t=r=>r!=null&&r!==""&&r!=="nan"&&!Number.isNaN(r);if(e.user_type!==0)return e.organization_detail&&e.organization_detail.name?e.organization_detail.name:t(n)?n: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 r=e.organization_detail.parent_chain[1];return r.name||r.code||""}return t(n)?n:t(e.sub_organization)?e.sub_organization:""}},form:{show:z(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:n})=>{if(e&&e.user_type!==0)return"";const t=r=>r!=null&&r!==""&&r!=="nan"&&!Number.isNaN(r);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 r=e.organization_detail.parent_chain[2];return r.name||r.code||""}return t(n)?n:t(e.sub_organization)?e.sub_organization:""}},form:{show:z(({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:n})=>{const t=r=>r!=null&&r!==""&&r!=="nan"&&!Number.isNaN(r);if(e.user_type===0)return e.organization_detail&&e.organization_detail.name?e.organization_detail.name:t(n)?n:t(e.class_or_group)?e.class_or_group:""}},form:{show:z(({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:n})=>e.organization_detail&&e.organization_detail.name?e.organization_detail.name:n||e.class_or_group},form:{show:!1,component:{placeholder:"请填写班级"},rules:[{required:!1,message:"请填写班级"}]},viewForm:{component:{placeholder:""}}}}}}},K=Object.freeze(Object.defineProperty({__proto__:null,createCrudOptions:B},Symbol.toStringTag,{value:"Module"}));export{Z as G,K as a,B as c};