| 1 |
- import{k as Q,E as p,h as X,t as I,y as Y,z as P}from"./index.DxJKo3PQ.js";import{G as Z,c as ee}from"./crud.DtMEdP7_.js";import{G as ae}from"./api.DxStTdv-.js";import{h as le}from"./columnPermission.CXxtPz_m.js";import{a as L,r as k,f as oe,q as re,aj as c,J as _,o as i,K as t,S as u,H as te,u as ne,c as h,R as V,a9 as C,P as g}from"./vue.D1BjjNmv.js";const ie={key:0,style:{display:"flex",gap:"8px",width:"100%"}},de=L({name:"allusers"}),ge=L({...de,setup(ue,{expose:S}){const b=k(!1),w=k([]),f=k([]),A=k(!1),x=k(!1),z=oe(()=>{const e=Array.isArray(f.value)?f.value:[],a=[];return e.forEach(r=>{Array.isArray(r==null?void 0:r.children)&&a.push(...r.children)}),a.map(r=>({id:r.id,name:r.name}))});function R(e){if(!e)return;const a=[...f.value||[]];for(;a.length;){const r=a.shift();if((r==null?void 0:r.id)===e)return r;Array.isArray(r==null?void 0:r.children)&&r.children.length&&a.push(...r.children)}}function B(e){const a=R(e);return Array.isArray(a==null?void 0:a.children)?a.children:[]}function F(e){const a=R(e);return Array.isArray(a==null?void 0:a.children)?a.children:[]}function j(e){e.form._major_id=void 0,e.form._grade_id=void 0,e.form.user_type===0?e.form.organization_ref=void 0:e.form.organization_ref=e.form._college_id}function D(e){e.form._grade_id=void 0,e.form.user_type===0&&(e.form.organization_ref=void 0)}function G(e){e.form.user_type===0&&(e.form.organization_ref=e.form._grade_id)}const T=()=>{ae().then(e=>{if(console.log("组织架构API响应:",e),e&&(e.code===200||e.code===2e3||!e.code)){const a=e.data||e.results||e;Array.isArray(a)?(f.value=a,console.log("成功赋值组织架构数据:",f.value)):(console.warn("返回的数据不是数组格式:",a),f.value=[])}else console.error("获取组织架构数据失败:",e),f.value=[]}).catch(e=>{console.error("请求组织架构数据失败:",e),f.value=[]})},{crudBinding:M,crudRef:N,crudExpose:s,crudOptions:O,resetCrudOptions:q,selectedRows:se}=Q({createCrudOptions:ee}),E=()=>{b.value=!0},J=e=>{w.value=[e.raw]},$=async()=>{if(w.value.length===0){p.warning("请先选择文件");return}const e=w.value[0];if(!e){p.error("文件无效,请重新选择");return}const a=new FormData;a.append("file",e);const r=X.get("token");try{A.value=!0,await I({url:"/api/system/app_user/batch_import/",method:"post",data:a,headers:{"Content-Type":"multipart/form-data",Authorization:r?`JWT ${r}`:""}}).then(d=>{console.log("导入resssss:::",d),p.success("导入成功"),b.value=!1,w.value=[],s.doRefresh()})}catch(d){p.error("导入失败,请检查文件格式或内容"),console.error(d)}finally{A.value=!1}},H=()=>{Y({url:"/api/system/app_user/download_template/",method:"get",filename:"用户导入模板"})},K=()=>{var a;const e=((a=s.selectedIds)==null?void 0:a.value)||[];if(console.log("selectedRows::",e),e.length===0){p.warning("请先选择要导出的用户");return}P({url:"/api/system/app_user/export_selected/",method:"post",data:{user_ids:e},filename:"用户导出"})},W=async()=>{var e,a,r;x.value=!0;try{const d=s!=null&&s.getSearchFormData?s.getSearchFormData():{},m=((r=(a=(e=s==null?void 0:s.crudBinding)==null?void 0:e.value)==null?void 0:a.pagination)==null?void 0:r.pageSize)||50;let U=1;const y=[];for(;;){const n=await I({url:"/api/system/app_user/",method:"get",params:{...d,page:U,limit:m},timeout:0}),v=Array.isArray(n==null?void 0:n.data)?n.data:Array.isArray(n==null?void 0:n.results)?n.results:[];if(!Array.isArray(v)||v.length===0)break;for(const l of v)(l==null?void 0:l.id)!=null&&y.push(l.id);const o=(n==null?void 0:n.total)??(n==null?void 0:n.count)??void 0;if(o!==void 0&&y.length>=Number(o)||v.length<m)break;U+=1}if(y.length===0){p.warning("当前筛选结果为空,无法导出");return}await P({url:"/api/system/app_user/export_selected/",method:"post",data:{user_ids:y},filename:"用户导出-全部",timeout:0})}catch(d){p.error("全部导出失败"),console.error(d)}finally{x.value=!1}};return re(async()=>{T();const e=await le(Z,O);q(e),s.doRefresh()}),S({getMajors:B,getGrades:F,onCollegeChange:j,onMajorChange:D,onGradeChange:G,colleges:z}),(e,a)=>{const r=c("el-button"),d=c("el-option"),m=c("el-select"),U=c("fs-crud"),y=c("el-upload"),n=c("el-dialog"),v=c("fs-page");return i(),_(v,null,{default:t(()=>[u(U,te({ref_key:"crudRef",ref:N},ne(M)),{"actionbar-right":t(()=>[u(r,{type:"primary",style:{"margin-left":"12px"},onClick:E},{default:t(()=>a[2]||(a[2]=[g("批量导入")])),_:1}),u(r,{type:"primary",onClick:H},{default:t(()=>a[3]||(a[3]=[g("下载模板")])),_:1}),u(r,{type:"primary",loading:x.value,disabled:x.value,onClick:W},{default:t(()=>a[4]||(a[4]=[g("全部导出")])),_:1},8,["loading","disabled"]),u(r,{type:"primary",onClick:K},{default:t(()=>a[5]||(a[5]=[g("批量导出")])),_:1})]),form_organization_ref:t(o=>[o.form.user_type===0?(i(),h("div",ie,[u(m,{style:{flex:"1"},disabled:o.mode=="view",modelValue:o.form._college_id,"onUpdate:modelValue":l=>o.form._college_id=l,placeholder:"请选择学院",filterable:"","allow-create":"","default-first-option":"",clearable:"",onChange:()=>j(o)},{default:t(()=>[(i(!0),h(V,null,C(z.value,l=>(i(),_(d,{key:l.id,label:l.name,value:l.id},null,8,["label","value"]))),128))]),_:2},1032,["disabled","modelValue","onUpdate:modelValue","onChange"])])):o.form.user_type===1||o.form.user_type===3?(i(),_(m,{key:1,disabled:o.mode=="view",modelValue:o.form.organization_ref,"onUpdate:modelValue":l=>o.form.organization_ref=l,placeholder:"请选择学院",filterable:"","allow-create":"","default-first-option":"",clearable:""},{default:t(()=>[(i(!0),h(V,null,C(z.value,l=>(i(),_(d,{key:l.id,label:l.name,value:l.id},null,8,["label","value"]))),128))]),_:2},1032,["disabled","modelValue","onUpdate:modelValue"])):(i(),_(m,{key:2,disabled:o.mode=="view",modelValue:o.form.organization_ref,"onUpdate:modelValue":l=>o.form.organization_ref=l,placeholder:"请选择学院",filterable:"","allow-create":"","default-first-option":"",clearable:""},{default:t(()=>[(i(!0),h(V,null,C(z.value,l=>(i(),_(d,{key:l.id,label:l.name,value:l.id},null,8,["label","value"]))),128))]),_:2},1032,["disabled","modelValue","onUpdate:modelValue"]))]),form_sub_organization:t(o=>[u(m,{style:{flex:"1"},disabled:o.mode=="view"||!o.form._college_id,modelValue:o.form._major_id,"onUpdate:modelValue":l=>o.form._major_id=l,placeholder:"请选择专业",filterable:"",clearable:"",onChange:()=>D(o)},{default:t(()=>[(i(!0),h(V,null,C(B(o.form._college_id),l=>(i(),_(d,{key:l.id,label:l.name,value:l.id},null,8,["label","value"]))),128))]),_:2},1032,["disabled","modelValue","onUpdate:modelValue","onChange"])]),form_grade_or_level:t(o=>[u(m,{style:{flex:"1"},disabled:o.mode=="view"||!o.form._major_id,modelValue:o.form._grade_id,"onUpdate:modelValue":l=>o.form._grade_id=l,placeholder:"请选择班级",filterable:"",clearable:"",onChange:()=>G(o)},{default:t(()=>[(i(!0),h(V,null,C(F(o.form._major_id),l=>(i(),_(d,{key:l.id,label:l.name,value:l.id},null,8,["label","value"]))),128))]),_:2},1032,["disabled","modelValue","onUpdate:modelValue","onChange"])]),_:1},16),u(n,{modelValue:b.value,"onUpdate:modelValue":a[1]||(a[1]=o=>b.value=o),title:"导入用户信息",width:"30%"},{footer:t(()=>[u(r,{onClick:a[0]||(a[0]=o=>b.value=!1)},{default:t(()=>a[7]||(a[7]=[g("取消")])),_:1}),u(r,{type:"primary",loading:A.value,disabled:A.value,onClick:$},{default:t(()=>a[8]||(a[8]=[g("确认导入")])),_:1},8,["loading","disabled"])]),default:t(()=>[u(y,{ref:"uploadRef","auto-upload":!1,"file-list":w.value,limit:1,"on-change":J,"before-upload":()=>!1,accept:".xls,.xlsx"},{default:t(()=>[u(r,{type:"primary"},{default:t(()=>a[6]||(a[6]=[g("选择文件")])),_:1})]),_:1},8,["file-list"])]),_:1},8,["modelValue"])]),_:1})}}});export{ge as default};
|