import{r as a,m as i,h as p,w as f,E as h,s as g,I as w,S as x}from"./index.lP_uh0LI.js";import{C as y,g as S}from"./vue.BxlDVA1H.js";const s=`${i.knowledge}course/lecturer/manage/`;function _(r){return a({url:s,method:"get",params:r})}function b(r){return a({url:s,method:"post",data:r})}function R(r){return a({url:s+r.uuid+"/",method:"patch",data:r})}function o(r){return a({url:s+r+"/",method:"delete",data:{uuid:r}})}const j=function({crudExpose:r}){const u=async e=>(e.ordering="-created_time",await _(e)),l=async({form:e,row:t})=>(e.uuid=t.uuid,await R(e)),c=async({row:e})=>await o(e.uuid),d=async({form:e})=>await b(e),m=y();return{crudOptions:{request:{pageRequest:u,addRequest:d,editRequest:l,delRequest:c,transformQuery:({page:e,form:t})=>{const n=(e==null?void 0:e.pageSize)||10;return{offset:(((e==null?void 0:e.currentPage)||1)-1)*n,limit:n,...t}},transformRes:({res:e,query:t})=>{const n=e;return n.success?{records:n.data.results||[],currentPage:t.offset/t.limit+1,pageSize:t.limit,total:n.data.count}:{records:[],currentPage:t.offset/t.limit+1,pageSize:t.limit,total:0}}},actionbar:{buttons:{add:{show:!0,text:"新增讲师"}}},toolbar:{buttons:{export:{show:!1}}},search:{autoSearch:!1},rowHandle:{fixed:"right",width:200,buttons:{view:{show:!1},edit:{show:!0,link:!0,type:"primary"},remove:{show:!0,link:!0,click:async({row:e})=>{if(e.course_count&&e.course_count>0){f("该讲师下有关联课程，请先检查");return}await h.confirm("删除后不可撤销，请谨慎操作！","确认删除数据？",{distinguishCancelAndClose:!0,confirmButtonText:"确定",cancelButtonText:"取消",closeOnClickModal:!1}),(await o(e.uuid)).success?(g("删除成功"),r.doRefresh()):w("删除失败")}}}},table:{rowKey:"uuid"},columns:{_index:{title:"序号",form:{show:!1},column:{align:"center",width:"70px",columnSetDisabled:!0,formatter:e=>{let t=e.index??1,n=r.crudBinding.value.pagination;return((n.currentPage??1)-1)*n.pageSize+t+1}}},photo_url:{title:"讲师照片",type:["cropper-uploader","colspan"],column:{minWidth:120,align:"left"},form:{rules:p([{required:!0,message:"至少上传一张图片",trigger:"change"}]),helper:{text:"限上传png、jpg、jpeg文件，且不超过10M"},component:{limit:1,accept:"png, jpg, jpeg",cropper:{aspectRatio:NaN},maxSize:10,uploader:{action:`${i.knowledge}course/file/manage/`}}}},full_name:{title:"讲师姓名",search:{show:!0,col:{span:6},component:{placeholder:"请输入讲师姓名",minlength:0,maxlength:99999}},type:["text","colspan"],column:{minWidth:120,align:"left"},form:{show:!0,rules:[{required:!0,message:"请输入讲师姓名"}],component:{placeholder:"请输入讲师姓名",minlength:1,maxlength:10}}},introduction:{title:"简介",search:{show:!1},type:["textarea","colspan"],column:{minWidth:300,align:"left"},form:{show:!0,title:"讲师简介",rules:[{required:!0,message:"请输入讲师简介"}],component:{placeholder:"请输入讲师简介",minlength:1,maxlength:200}}},course_count:{title:"关联课程",search:{show:!1},type:["text","colspan"],column:{minWidth:120,align:"left",formatter:({row:e})=>e.course_count?S("div",{style:"color: #409EFF;cursor: pointer;",onClick:()=>{const t=JSON.stringify({label:e.full_name,value:e.uuid});window.localStorage.setItem("lecturer",t);const n=x.get("sessionId");n?window.parent.postMessage({sessionId:n,data:{operation:"curriculumManage"}},"*"):m.push({name:"curriculumManage"})}},[e.course_count]):""},form:{show:!1}},created_time:{title:"创建时间",type:"daterange",search:{show:!1},form:{show:!1},column:{minWidth:120,align:"left",formatter:e=>e.value}}},form:{wrapper:{width:"600px"}},editForm:{wrapper:{title:"编辑讲师"}},addForm:{wrapper:{title:"新建讲师"}}}}};export{j as createCrudOptions};
