| 1 |
- import{t as s,r as y,W as j}from"./index.BDe1Jdfj.js";import{r as S}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 C(i){return s({url:c,method:"post",data:i})}function D(i){return s({url:c+i.id+"/",method:"put",data:i})}function G(i){return s({url:c+i+"/",method:"delete",data:{id:i}})}function Z(){return s({url:c,method:"get"})}function L(){return s({url:"/api/system/organization/tree/",method:"get"})}let h=[];const A=async()=>{try{const i=await L();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 R(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 T=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 D(e)),F=async({row:e})=>await G(e.id),O=async({form:e})=>await C(e),z=S([]),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:!0}}},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<n){t(new Error("密码长度不能少于8位"));return}if(!l){t(new Error("密码必须包含字母"));return}if(!d){t(new Error("密码必须包含数字"));return}if(!u){t(new Error("密码必须包含特殊符号"));return}t()},trigger:"blur"}]},editForm:{show:!0,component:{placeholder:"留空则不修改密码",type:"password",showPassword:!0},rules:[{validator:(e,r,t)=>{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<n){t(new Error("密码长度不能少于8位"));return}if(!l){t(new Error("密码必须包含字母"));return}if(!d){t(new Error("密码必须包含数字"));return}if(!u){t(new Error("密码必须包含特殊符号"));return}t()},trigger:"blur"}]},viewForm:{show:!1}},email:{title:"邮箱",type:"input",column:{show:!1,minWidth:120},form:{component:{placeholder:"请填写邮箱"},rules:[{required:!1,message:"请填写邮箱"}]},viewForm:{component:{placeholder:""}}},mobile:{title:"手机号",type:"input",column:{show:!1,minWidth:120},form:{component:{placeholder:"请填写手机号"},rules:[{required:!0,message:"请填写手机号"}]},viewForm:{component:{placeholder:""}}},gender:{title:"性别",type:"dict-select",column:{show:!0,minWidth:120},dict:j({data:[{label:"男",value:1},{label:"女",value:2}]}),form:{component:{placeholder:"请选择性别"},rules:[{required:!0,message:"请选择性别"}]}},user_type:{title:"用户类型",type:"dict-select",search:{show:!1},column:{minWidth:120},dict:j({data:[{label:"学生",value:0},{label:"教师",value:1},{label:"外部用户",value:2},{label:"学院领导",value:3}]}),form:{component:{placeholder:"请选择用户类型"},rules:[{required:!1,message:"请选择用户类型"}]}},organization_ref:{title:"学院",type:"dict-cascader",column:{show:!1},valueBuilder({form:e,value:r}){var n,l,d,u,w,b,q;e.organization_ref=r;const t=e.organization_detail;if(h.length===0&&A(),e.user_type===0&&t&&Array.isArray(t.parent_chain)){const a=t.parent_chain;a.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=R(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:""}}}}}}},B=Object.freeze(Object.defineProperty({__proto__:null,createCrudOptions:T},Symbol.toStringTag,{value:"Module"}));export{Z as G,B as a,T as c};
|