实现 OA 请假的取消申请

This commit is contained in:
YunaiV 2022-01-23 00:10:06 +08:00
parent 5437775172
commit e6142b5308
18 changed files with 74 additions and 196 deletions

View File

@ -1,10 +1,10 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.oa;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.BpmOALeaveCreateReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeavePageReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeaveRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.convert.oa.OALeaveConvert;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.BpmOALeavePageReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.BpmOALeaveRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.convert.oa.BpmOALeaveConvert;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.BpmOALeaveDO;
import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.BpmOALeaveService;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
@ -43,27 +43,19 @@ public class BpmOALeaveController {
return success(leaveService.createLeave(getLoginUserId(), createReqVO));
}
@DeleteMapping("/cancel")
@ApiOperation("取消请假申请")
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
public CommonResult<Boolean> cancelLeave(@RequestParam("id") Long id) {
leaveService.cancelLeave(id);
return success(true);
}
@GetMapping("/get")
@ApiOperation("获得请假申请")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
public CommonResult<OALeaveRespVO> getLeave(@RequestParam("id") Long id) {
OALeaveDO leave = leaveService.getLeave(id);
return success(OALeaveConvert.INSTANCE.convert(leave));
public CommonResult<BpmOALeaveRespVO> getLeave(@RequestParam("id") Long id) {
BpmOALeaveDO leave = leaveService.getLeave(id);
return success(BpmOALeaveConvert.INSTANCE.convert(leave));
}
@GetMapping("/page")
@ApiOperation("获得请假申请分页")
public CommonResult<PageResult<OALeaveRespVO>> getLeavePage(@Valid OALeavePageReqVO pageVO) {
PageResult<OALeaveDO> pageResult = leaveService.getLeavePage(getLoginUserId(), pageVO);
return success(OALeaveConvert.INSTANCE.convertPage(pageResult));
public CommonResult<PageResult<BpmOALeaveRespVO>> getLeavePage(@Valid BpmOALeavePageReqVO pageVO) {
PageResult<BpmOALeaveDO> pageResult = leaveService.getLeavePage(getLoginUserId(), pageVO);
return success(BpmOALeaveConvert.INSTANCE.convertPage(pageResult));
}
}

View File

@ -12,7 +12,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class OALeavePageReqVO extends PageParam {
public class BpmOALeavePageReqVO extends PageParam {
@ApiModelProperty(value = "状态", example = "1", notes = "参见 bpm_process_instance_result 枚举")
private Integer result;

View File

@ -13,7 +13,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class OALeaveRespVO extends BpmOALeaveBaseVO {
public class BpmOALeaveRespVO extends BpmOALeaveBaseVO {
@ApiModelProperty(value = "请假表单主键", required = true, example = "1024")
private Long id;

View File

@ -1,8 +1,8 @@
package cn.iocoder.yudao.adminserver.modules.bpm.convert.oa;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.BpmOALeaveCreateReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeaveRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.BpmOALeaveRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.BpmOALeaveDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@ -15,16 +15,16 @@ import java.util.List;
* @author 芋艿
*/
@Mapper
public interface OALeaveConvert {
public interface BpmOALeaveConvert {
OALeaveConvert INSTANCE = Mappers.getMapper(OALeaveConvert.class);
BpmOALeaveConvert INSTANCE = Mappers.getMapper(BpmOALeaveConvert.class);
OALeaveDO convert(BpmOALeaveCreateReqVO bean);
BpmOALeaveDO convert(BpmOALeaveCreateReqVO bean);
OALeaveRespVO convert(OALeaveDO bean);
BpmOALeaveRespVO convert(BpmOALeaveDO bean);
List<OALeaveRespVO> convertList(List<OALeaveDO> list);
List<BpmOALeaveRespVO> convertList(List<BpmOALeaveDO> list);
PageResult<OALeaveRespVO> convertPage(PageResult<OALeaveDO> page);
PageResult<BpmOALeaveRespVO> convertPage(PageResult<BpmOALeaveDO> page);
}

View File

@ -22,7 +22,7 @@ import org.activiti.engine.runtime.ProcessInstance;
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class OALeaveDO extends BaseDO {
public class BpmOALeaveDO extends BaseDO {
/**
* 请假表单主键

View File

@ -1,4 +0,0 @@
/**
* TODO 芋艿实现请假流程接入工作流
*/
package cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave;

View File

@ -1,7 +1,7 @@
package cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.oa;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeavePageReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.BpmOALeavePageReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.BpmOALeaveDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
@ -14,16 +14,16 @@ import org.apache.ibatis.annotations.Mapper;
* @author 芋道源码
*/
@Mapper
public interface BpmOALeaveMapper extends BaseMapperX<OALeaveDO> {
public interface BpmOALeaveMapper extends BaseMapperX<BpmOALeaveDO> {
default PageResult<OALeaveDO> selectPage(Long userId, OALeavePageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<OALeaveDO>()
.eqIfPresent(OALeaveDO::getUserId, userId)
.eqIfPresent(OALeaveDO::getResult, reqVO.getResult())
.eqIfPresent(OALeaveDO::getType, reqVO.getType())
.likeIfPresent(OALeaveDO::getReason, reqVO.getReason())
.betweenIfPresent(OALeaveDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.orderByDesc(OALeaveDO::getId));
default PageResult<BpmOALeaveDO> selectPage(Long userId, BpmOALeavePageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<BpmOALeaveDO>()
.eqIfPresent(BpmOALeaveDO::getUserId, userId)
.eqIfPresent(BpmOALeaveDO::getResult, reqVO.getResult())
.eqIfPresent(BpmOALeaveDO::getType, reqVO.getType())
.likeIfPresent(BpmOALeaveDO::getReason, reqVO.getReason())
.betweenIfPresent(BpmOALeaveDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.orderByDesc(BpmOALeaveDO::getId));
}
}

View File

@ -2,7 +2,7 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.oa;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.*;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.BpmOALeaveDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import javax.validation.Valid;
@ -32,20 +32,13 @@ public interface BpmOALeaveService {
*/
void updateLeaveResult(Long id, Integer result);
/**
* 删除请假申请
*
* @param id 编号
*/
void cancelLeave(Long id);
/**
* 获得请假申请
*
* @param id 编号
* @return 请假申请
*/
OALeaveDO getLeave(Long id);
BpmOALeaveDO getLeave(Long id);
/**
* 获得请假申请分页
@ -54,6 +47,6 @@ public interface BpmOALeaveService {
* @param pageReqVO 分页查询
* @return 请假申请分页
*/
PageResult<OALeaveDO> getLeavePage(Long userId, OALeavePageReqVO pageReqVO);
PageResult<BpmOALeaveDO> getLeavePage(Long userId, BpmOALeavePageReqVO pageReqVO);
}

View File

@ -2,14 +2,13 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.oa.impl;
import cn.hutool.core.date.DateUtil;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.*;
import cn.iocoder.yudao.adminserver.modules.bpm.convert.oa.OALeaveConvert;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO;
import cn.iocoder.yudao.adminserver.modules.bpm.convert.oa.BpmOALeaveConvert;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.BpmOALeaveDO;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.oa.BpmOALeaveMapper;
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceResultEnum;
import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.BpmOALeaveService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmProcessInstanceService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.dto.BpmProcessInstanceCreateReqDTO;
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -29,7 +28,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
*/
@Service
@Validated
public class OALeaveServiceImpl implements BpmOALeaveService {
public class BpmOALeaveServiceImpl implements BpmOALeaveService {
/**
* OA 请假对应的流程定义 KEY
@ -47,7 +46,7 @@ public class OALeaveServiceImpl implements BpmOALeaveService {
public Long createLeave(Long userId, BpmOALeaveCreateReqVO createReqVO) {
// 插入 OA 请假单
long day = DateUtil.betweenDay(createReqVO.getStartTime(), createReqVO.getEndTime(), false);
OALeaveDO leave = OALeaveConvert.INSTANCE.convert(createReqVO).setUserId(userId).setDay(day)
BpmOALeaveDO leave = BpmOALeaveConvert.INSTANCE.convert(createReqVO).setUserId(userId).setDay(day)
.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
leaveMapper.insert(leave);
@ -59,22 +58,13 @@ public class OALeaveServiceImpl implements BpmOALeaveService {
.setVariables(processInstanceVariables).setBusinessKey(String.valueOf(leave.getId())));
// 将工作流的编号更新到 OA 请假单中
leaveMapper.updateById(new OALeaveDO().setId(leave.getId()).setProcessInstanceId(processInstanceId));
leaveMapper.updateById(new BpmOALeaveDO().setId(leave.getId()).setProcessInstanceId(processInstanceId));
return leave.getId();
}
@Override
public void updateLeaveResult(Long id, Integer result) {
leaveMapper.updateById(new OALeaveDO().setId(id).setResult(result));
}
@Override
public void cancelLeave(Long id) {
// TODO 需要重新实现
// 校验存在
this.validateLeaveExists(id);
// 删除
leaveMapper.deleteById(id);
leaveMapper.updateById(new BpmOALeaveDO().setId(id).setResult(result));
}
private void validateLeaveExists(Long id) {
@ -84,12 +74,12 @@ public class OALeaveServiceImpl implements BpmOALeaveService {
}
@Override
public OALeaveDO getLeave(Long id) {
public BpmOALeaveDO getLeave(Long id) {
return leaveMapper.selectById(id);
}
@Override
public PageResult<OALeaveDO> getLeavePage(Long userId, OALeavePageReqVO pageReqVO) {
public PageResult<BpmOALeaveDO> getLeavePage(Long userId, BpmOALeavePageReqVO pageReqVO) {
return leaveMapper.selectPage(userId, pageReqVO);
}

View File

@ -3,7 +3,7 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.oa.listener;
import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event.BpmProcessInstanceResultEvent;
import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event.BpmProcessInstanceResultEventListener;
import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.BpmOALeaveService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.impl.OALeaveServiceImpl;
import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.impl.BpmOALeaveServiceImpl;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@ -21,7 +21,7 @@ public class BpmOALeaveResultListener extends BpmProcessInstanceResultEventListe
@Override
protected String getProcessDefinitionKey() {
return OALeaveServiceImpl.PROCESS_KEY;
return BpmOALeaveServiceImpl.PROCESS_KEY;
}
@Override

View File

@ -255,7 +255,8 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
}
// 需要主动查询因为 instance 只有 id 属性
ProcessInstance processInstance = getProcessInstance(instance.getId());
// 另外此时如果去查询 ProcessInstance 的话字段是不全的所以去查询了 HistoricProcessInstance
HistoricProcessInstance processInstance = getHistoricProcessInstance(instance.getId());
// 更新拓展表
BpmProcessInstanceExtDO instanceExtDO = BpmProcessInstanceConvert.INSTANCE.convert(instance)
.setEndTime(new Date()) // 由于 ProcessInstance 里没有办法拿到 endTime所以这里设置

View File

@ -9,14 +9,6 @@ export function createLeave(data) {
})
}
// 删除请假申请
export function deleteLeave(id) {
return request({
url: '/oa/leave/delete?id=' + id,
method: 'delete'
})
}
// 获得请假申请
export function getLeave(id) {
return request({

View File

@ -1,9 +0,0 @@
import request from '@/utils/request'
export function getStartForm(processKey) {
return request({
url: '/workflow/process/definition/getStartForm?processKey='+processKey,
method: 'get'
})
}

View File

@ -1,91 +0,0 @@
import request from '@/utils/request'
// 创建请假申请
export function createLeave(data) {
return request({
url: '/oa/leave/create',
method: 'post',
data: data
})
}
// 更新请假申请
export function updateLeave(data) {
return request({
url: '/oa/leave/update',
method: 'put',
data: data
})
}
// 删除请假申请
export function deleteLeave(id) {
return request({
url: '/oa/leave/delete?id=' + id,
method: 'delete'
})
}
// 获得请假申请
export function getLeave(id) {
return request({
url: '/oa/leave/get?id=' + id,
method: 'get'
})
}
// 获得待办任务分页
export function getTodoTaskPage(query) {
return request({
url: '/workflow/task/todo/page',
method: 'get',
params: query
})
}
// 签收任务
export function claimTask(id) {
return request({
url: '/workflow/task/claim?id=' + id,
method: 'get'
})
}
export function completeTask(data) {
return request({
url: '/workflow/task/complete',
method: 'post',
data: data
})
}
export function taskSteps(data) {
return request({
url: '/workflow/task/task-steps',
method: 'post',
data: data
})
}
export function getTaskFormKey(data) {
return request({
url: '/workflow/task/formKey',
method: 'post',
data: data
})
}
export function processHistorySteps(id) {
return request({
url: '/workflow/task/process/history-steps?id='+id,
method: 'get'
})
}
export function getHighlightImg(id) {
return request({
url: '/workflow/task/process/highlight-img?processInstanceId='+id,
method: 'get'
})
}

View File

@ -26,8 +26,9 @@
</template>
<script>
import { createLeave} from "@/api/oa/leave"
import { createLeave} from "@/api/bpm/leave"
import { getDictDatas, DICT_TYPE } from '@/utils/dict'
export default {
name: "LeaveCreate",
components: {

View File

@ -11,7 +11,7 @@
</template>
<script>
import { getLeave} from "@/api/oa/leave"
import { getLeave} from "@/api/bpm/leave"
import {getDictDatas, DICT_TYPE, getDictDataLabel} from '@/utils/dict'
export default {
name: "LeaveDetail",

View File

@ -56,8 +56,10 @@
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleCancel(scope.row)"
v-if="scope.row.result === 1">取消请假</el-button>
<el-button size="mini" type="text" icon="el-icon-view" @click="handleDetail(scope.row)">详情</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleProcessDetail(scope.row)">审批进度</el-button>
</template>
@ -71,8 +73,9 @@
</template>
<script>
import { createLeave, getLeaveApplyMembers, getLeave, getLeavePage} from "@/api/oa/leave"
import { getLeavePage } from "@/api/bpm/leave"
import { getDictDataLabel, getDictDatas, DICT_TYPE } from '@/utils/dict'
import {cancelProcessInstance} from "@/api/bpm/processInstance";
export default {
name: "Leave",
@ -88,20 +91,14 @@ export default {
total: 0,
//
list: [],
//
title: "",
//
open: false,
//
dateRangeCreateTime: [],
//
queryParams: {
pageNo: 1,
pageSize: 10,
processInstanceId: null,
status: null,
userId: null,
leaveType: null,
result: null,
type: null,
reason: null,
},
@ -149,6 +146,22 @@ export default {
handleProcessDetail(row) {
this.$router.push({ path: "/bpm/process-instance/detail", query: { id: row.processInstanceId}});
},
/** 取消请假 */
handleCancel(row) {
const id = row.processInstanceId;
this.$prompt('请输入取消原因?', "取消流程", {
type: 'warning',
confirmButtonText: "确定",
cancelButtonText: "取消",
inputPattern: /^[\s\S]*.*[^\s][\s\S]*$/, //
inputErrorMessage: "取消原因不能为空",
}).then(({ value }) => {
return cancelProcessInstance(id, value);
}).then(() => {
this.getList();
this.msgSuccess("取消成功");
})
},
resultFormat(row, column) {
return getDictDataLabel(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT, row.result)
},

View File

@ -192,7 +192,7 @@ export default {
/** 取消按钮操作 */
handleCancel(row) {
const id = row.id;
this.$prompt('请输取消原因?', "取消流程", {
this.$prompt('请输取消原因?', "取消流程", {
type: 'warning',
confirmButtonText: "确定",
cancelButtonText: "取消",