crud.lviKhoMK.js 5.7 KB

1
  1. import{t as a,r as p,W as h}from"./index.BI6yz46w.js";const l="/api/system/app_user/";async function w(t){const s=a({url:l+"?user_type=1",method:"get",params:t});return console.log("ressssss",s),s}function y(t){return a({url:l+t+"/",method:"get"})}function _(t){return a({url:l,method:"post",data:t})}function q(t){return a({url:l+t.id+"/",method:"put",data:t})}function z(t){return a({url:l+t+"/",method:"delete",data:{id:t}})}function v(){return a({url:l,method:"get"})}function b(){return a({url:"/api/system/organization/tree/",method:"get"})}let u=[];const f=async()=>{try{const t=await b();if(t&&(t.code===200||t.code===2e3||!t.code)){const s=t.data||t.results||t;Array.isArray(s)&&(u=s)}}catch(t){console.error("获取组织架构数据失败:",t),u=[]}};function W(t,s){if(!(!t||!s)){for(const d of s)if(Array.isArray(d.children)){for(const c of d.children)if(c.name===t)return c}}}const F=function({crudExpose:t}){return f(),{crudOptions:{request:{pageRequest:async e=>await w(e),editRequest:async({form:e,row:r})=>(e.id=r.id,await q(e)),delRequest:async({row:e})=>await z(e.id),addRequest:async({form:e})=>await _(e),getDetail:async({row:e})=>await y(e.id)},toolbar:{show:!1},form:{wrapper:{buttons:{ok:{text:"提交",show:p(e=>e.mode!=="view")}}}},actionbar:{buttons:{add:{show:!1}}},pagination:{show:!0},columns:{_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:"请填写工号"}]}},username:{title:"用户名",type:"input",column:{show:!1,minWidth:120},form:{component:{placeholder:"请填写用户名"},rules:[{required:!0,message:"请填写用户名"}]},viewForm:{component:{placeholder:""}}},name:{title:"姓名",search:{show:!0},treeNode:!0,type:"input",column:{minWidth:120},form:{rules:[{required:!0,message:"姓名必填项"}],component:{placeholder:"请输入姓名"}}},password:{title:"密码",type:"password",column:{minWidth:120,show:!1},form:{component:{placeholder:"请填写密码"}},addForm:{component:{placeholder:"请填写密码"},rules:[{required:!0,message:"请填写密码"},{validator:(e,r,o)=>{if(!r){o();return}if(r.length<8){o(new Error("密码长度不能少于8位"));return}const n=/[a-zA-Z]/.test(r),i=/[0-9]/.test(r),m=/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?`~]/.test(r);if(!n||!i||!m){o(new Error("密码必须包含字母、数字和特殊符号"));return}o()},trigger:"blur"}]},editForm:{show:!0,component:{placeholder:"留空则不修改密码",type:"password",showPassword:!0},rules:[{validator:(e,r,o)=>{if(!r||r.trim()===""){o();return}const n=8,i=/[a-zA-Z]/.test(r),m=/\d/.test(r),g=/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(r);if(r.length<n){o(new Error("密码长度不能少于8位"));return}if(!i){o(new Error("密码必须包含字母"));return}if(!m){o(new Error("密码必须包含数字"));return}if(!g){o(new Error("密码必须包含特殊符号"));return}o()},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:h({data:[{label:"男",value:1},{label:"女",value:2}]}),form:{component:{placeholder:"请选择性别"},rules:[{required:!0,message:"请选择性别"}]},viewForm:{component:{placeholder:""}}},user_type:{title:"用户类型",type:"dict-select",search:{show:!0},column:{minWidth:120},dict:h({data:[{label:"教师",value:1},{label:"学院领导",value:3}]}),form:{value:1,component:{placeholder:"请选择用户类型"},rules:[{required:!1,message:"请选择用户类型"}]}},organization_ref:{title:"学院",type:"dict-cascader",column:{show:!1},valueBuilder({form:e,value:r}){e.organization_ref=r;const o=e.organization_detail;if(o&&o.id)e.organization_ref=o.id;else if(!o&&u.length>0){const n=e.organization;if(n){const i=W(n,u);i&&i.id&&(e.organization_ref=i.id)}}u.length===0&&f()},valueResolve({form:e,value:r}){e.organization_ref=r??e.organization_ref}},organization:{title:"学院",type:"input",search:{show:!1},column:{show:!0,minWidth:200,formatter:({row:e,value:r})=>{const o=n=>n!=null&&n!==""&&n!=="nan"&&!Number.isNaN(n);return e.organization_detail&&e.organization_detail.name?e.organization_detail.name:o(r)?r:""}},form:{show:p(e=>e.user_type===1||e.user_type===3),component:{placeholder:"请选择学院"},rules:[{required:!1,message:"请选择学院"}]},viewForm:{component:{placeholder:""}}},sub_organization:{title:"专业",type:"input",column:{show:!1,minWidth:120},form:{show:!1,component:{placeholder:"请填写专业"},rules:[{required:!1,message:"请填写专业"}]},viewForm:{component:{placeholder:""}}},grade_or_level:{title:"年级",type:"input",column:{show:!1,minWidth:120},form:{show:!1,component:{placeholder:"请填写年级"},rules:[{required:!1,message:"请填写年级"}]},viewForm:{component:{placeholder:""}}},class_or_group:{title:"班级",type:"input",column:{show:!1,minWidth:120},form:{show:!1,component:{placeholder:"请填写班级"},rules:[{required:!1,message:"请填写班级"}]},viewForm:{component:{placeholder:""}}}}}}},x=Object.freeze(Object.defineProperty({__proto__:null,createCrudOptions:F},Symbol.toStringTag,{value:"Module"}));export{v as G,x as a,F as c};