目录
任课老师提交申请
获取任课教师课程
首先要获取任课教师所教课程,让教师申请时更方便地选择
ExcApplyMapper.xml:
首先要写sql语句(
sql查询语句:
id=“”’,方法名
parameterType =“”,对应查询字段(status)的数据类型
resultType=“”,对应的实体文件名
<select id="getCourse" resultType="org.jeecg.modules.demo.LesInfo.entity.LesInfo">
select *
from les_info
where
tea_id = #{tid} and les_type = "理论课(含实践)" or tea_id = #{tid} and les_type = "集中性实践环节"
</select>
ExcApplyMapper:
List<LesInfo> getCourse(@Param("tid") String tid);
IExcApplyService:
List<LesInfo> getCourse(String tid);
ExcApplyServiceImpl:
@Override
public List<LesInfo> getCourse(String tid) {
return this.baseMapper.getCourse(tid);
}
controller文件编写
defaultValue=“1”,规定默认参数为1,不需要前端传参
如果需要传参,只需要改为如下:required = true
@RequestMapping(value = "/course",method = RequestMethod.GET)
public Result<?> allList(@RequestParam(name="tid",defaultValue="1")String tid){
SysUser sysUser = iFlowThirdService.getLoginUser();
tid = sysUser.getUsername();
List<LesInfo> allList = excApplyService.getCourse(tid);
return Result.ok(allList);
}
ExcApplyForm.vue:
前端需要传来教师工号tid,用getAction()方法从后端获取数据:
getCourse(){
getAction("/ExcApply/excApply/course",{username:""}).then(res=>{
if(res.success){
this.resultList = res.result;
console.log(this.resultList);
}else{
this.$message.error("发送失败")
}
})
},
获取到后端传来的result将其传入自定义的resultList中
用v-for属性将教师所授课程展示出来
<a-col :span="24">
<a-form-model-item label="实验信息" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="course">
<a-select placeholder="请选择" >
<a-select-option v-for="(item,index) in resultList" :value="item.id" v-on:click="result1(item)" >{
{item.lesName+" "+item.courseclass+" 实验周次:"+item.exWeek+" 实验周学时:"+item.exWeektime}}</a-select-option>
</a-select>
</a-form-model-item>
</a-col>
选择后用v-on:click = "result1(item)",将选择的信息传入model中,便于后续添加,通过add方法插入到数据库中
result1(itemN){
this.model.tid = itemN.teaId;
this.model.coursename = itemN.lesName;
this.model.classes = itemN.c