项目实训—flowable开发(一)

目录

任课老师提交申请

获取任课教师课程

ExcApplyMapper.xml:

ExcApplyMapper:

IExcApplyService:

ExcApplyServiceImpl:

controller文件编写

ExcApplyForm.vue:

健壮性

关联流程

IExcApplyService:

ExcApplyServiceImpl:

健壮性:

提交申请:

ActApplyBtn:

撤回流程:

 健壮性

审批历史

任课老师提交申请

获取任课教师课程

首先要获取任课教师所教课程,让教师申请时更方便地选择

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.courseclass;
            this.model.teaName = itemN.teaName;
            this.model.term = itemN.lesSem;
            this.model.testweek = itemN.exWeek;
            this.model.weektime = itemN.exWeektime;
            this.model.courseid = itemN.lesId;
            this.model.courseord = itemN.lesOrd;
            this.model.isapply = "否";
        },

结果如下:

前端点击新增,填完表格点击确定后调用add()连接后端将数据插入数据库中

add () {

          this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },

健壮性

对此add()方法进行修改,增强系统健壮性

1.已申请过的课程不可重复申请

首先从后端select查看此课程申请是否已经在数据库中 :

ExcApplyMapper.xml:

<select id="getThisCourse" resultType="org.jeecg.modules.demo.ExcApply.entity.ExcApply">
        select *
        from exc_apply
        where courseid = #{courseid} and courseord = #{courseord}
    </select>

 ExcApplyMapper:

 List<ExcApply> getThisCourse(@Param("courseid") String courseid,@Param("courseord") String courseord);

IExcApplyService:

List<ExcApply> getThisCourse(String courseid,String courseord);

 ExcApplyService:
 

@Override
    public List<ExcApply> getThisCourse(String courseid, String courseord) {
            return this.baseMapper.getThisCourse(courseid,courseord);

    }

修改ExcApplyController中add方法:

/**
	 *   添加
	 *
	 * @param excApply
	 * @return
	 */
	@AutoLog(value = "任课老师申请-添加")
	@ApiOperation(value="任课老师申请-添加", notes="任课老师申请-添加")
	@PostMapping(value = "/add")
	public Result<String> add(@RequestBody ExcApply excApply) {
		List<ExcApply> list = excApplyService.getThisCourse(excApply.getCourseid(),excApply.getCourseord());
		//若数据库中没有此条数据
		if(list.size() == 0){
			//若此条数据有冲突
			if((excApply.getNeedextea().equals("是")  && excApply.getType().equals("任课教师") )||(excApply.getNeedextea().equals("是")  && excApply.getType().equals("任课教师、助教"))||(excApply.getNeedextea().equals("否") && excApply.getType().equals("实验教师"))||(excApply.getNeedextea().equals("否") && excApply.getType().equals("任课教师、实验教师"))){
				return Result.error("'授课方式'和'是否需要实验老师'有冲突!");
			}else if((excApply.getType().equals("任课教师、助教")  && excApply.getZhujiao() == null)||(!excApply.getType().equals("任课教师、助教")  && excApply.getZhujiao() != null)){
				return Result.error("'授课方式'和'助教id'有冲突!");
			}else{
				excApplyService.save(excApply);
				return Result.OK("添加成功!");
			}
		}else{
			//若数据库中有此条数据,返回错误信息
			return  Result.error("此课程已申请,不可重复申请!");
		}

	}

2.前端表格信息不能有冲突: 

 

关联流程

 新增申请时,要往flow_my_business表中插入申请数据,首先得关联流程

IExcApplyService:

void relationAct(String dataId);

ExcApplyServiceImpl:

调用initActBusiness(title,serviceImpl,processDefinitionKey,processDefinitionId)将申请与流程关联起来

@Override
    public void relationAct(String dataId) {
        flowCommonService.initActBusiness("实验授课申请:dataId"+dataId,dataId,"excApplyService","ExcApply","process_tpho5a4q:16:fb1d2869-d8f2-11ec-8d04-927841cf098b");
    }

修改save()方法,保存申请时关联流程

@Override
    public boolean save(ExcApply excApply){
        /**新增数据,初始化流程关联信息**/
        excApply.setId(IdUtil.fastSimpleUUID());
        this.relationAct(excApply.getId());
        return super.save(excApply);
    }

健壮性:

 提交申请后,不能再编辑申请,所以需要修改JeecgListMixin.js中的HandleEdit()方法:

handleEdit: function (record) {
      if(record.isvisiable == "是"){
        this.$message.error("此任务已发布,不可编辑!")
        return
      }
      //excApply提交申请后,isapply值为"是"
      if(record.isapply == "是"){
        this.$message.error("此任务已申请,不可编辑!")
        return
      }
      this.$refs.modalForm.edit(record);
      this.$refs.modalForm.title = "编辑";
      this.$refs.modalForm.disableSubmit = false;
    },

提交申请:

用封装好的ActApplyBtn,此组件借鉴网上资料,点击按钮提交申请

ActApplyBtn:

<act-apply-btn @success="loadData" :data-id="record.id" :variables="{isNeeded:record.needextea}" :service-type="0"></act-apply-btn>

ActApplyBtn设置了必要属性data-id传入申请的dataid,variables为流程下一步需要的变量

ActApplyBtn需要在props中添加serviceType属性,方便点击事件后判断处理,在调用此按钮时需要用:service-type传入

此处传入是否需要实验教师needextea的值,排他网关会根据needextea的值来查看下一步如何走,候选人是谁

此申请需要实验教师,因此排他网关选择上一条路,可查看到申请候选人为"实验排课员"。 

applySubmit() {
            if (this.dataId && this.dataId.length < 1) {
                this.error = '必须传入参数dataId';
                this.$message.error(this.error);
                return;
            } else {
                this.error = '';
            }
            this.submitLoading = true;
            var params = Object.assign({
                dataId: this.dataId
            }, this.variables);
            console.log(params);
            //调用此方法设置taskid,开启流程
          definitionStartByDataId(this.dataId, params)
                .then(res => {
                    if (res.success) {
                        this.$message.success('操作成功');
                        this.$emit('success');
                    } else {
                        this.$message.error(res.message);
                    }
                })
                .finally(() => (this.submitLoading = false));
          if(this.serviceType == this.applySerType.extApply){
              getAction("ExtApply/extApply/setChoose",{id:this.dataId}).then(res=>{
                  if(res.success){
                      this.loadData()
                  }else{
                      this.$message.error("操作失败")
                  }
              })
              //excApply提交申请将isapply设为"是",将servicekey设为"excApply"
          }else if(this.serviceType == this.applySerType.excApply){
              getAction("ExcApply/excApply/setService",{id:this.dataId}).then(res=>{
                  if(res.success){
                      this.loadData()
                  }else{
                      this.$message.error("操作失败")
                  }
              })
          }
        }

调用definitionStartByDataId()方法创建实例,开启流程。

撤回流程:

ActCancelBtn:

<act-cancel-btn @success="loadData" :data-id="record.id" :service-type="0"></act-cancel-btn>

serviceType与ActApplyBtn相同

点击确定撤回时触发handelSubmitCancel()方法,调用deleteByDataId来取消申请

handelSubmitCancel() {
            this.submitLoading = true;
          deleteByDataId(this.dataId, this.cancelForm.reason)
                .then(res => {
                    if (res.success) {
                        this.$message.success('操作成功');
                        this.modalCancelVisible = false;
                        this.$emit('success');
                    } else {
                        this.$message.error(res.message);
                    }
                })
                .finally(() => (this.submitLoading = false));
          //如果服务类型为excApply
            if(this.serviceType == this.applySerType.excApply){
                getAction("/ExcApply/excApply/cancelApply",{id:this.dataId}).then(res=>{
                    if(res.success){
                        this.loadData()
                    }else{
                        this.$message.error("操作失败")
                    }
                })
            }

        }

如果服务类型为excApply,取消时要将exc_apply中isapply这一列设为"否“(流程文件与上文相同

 <update id="cancelApply">
        update exc_apply set isapply = "否"
        where id = #{id}
    </update>
 @RequestMapping(value = "/cancelApply",method = RequestMethod.GET)
	 public Result<Object> cancelApply(@RequestParam(name = "id",required = true) String id){
		 excApplyService.cancelApply(id);
		 return Result.OK();
	 }

撤回后,流程结束(也可以看成未开启,可以点"编辑"修改申请,也可以点"提交申请"重新提交

 健壮性

 

审批历史

调用封装好的ActHistoricDetailBtn,点击后调用history()方法

history() {
            if (!this.dataId) {
                this.$message.error('流程实例ID不存在');
                return;
            }
            this.modalLsVisible = true;
        }

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值