Merge remote-tracking branch 'origin/master'

This commit is contained in:
zhangzq
2025-12-01 11:23:50 +08:00
18 changed files with 991 additions and 265 deletions

View File

@@ -23,15 +23,8 @@ public class FlwInstanceController {
@Lazy
private FlwInstanceService instanceService;
/**
* 发起流程
*/
@RequestMapping("/startFlowInstance")
public R startFlowInstance(@RequestParam Map<String, Object> params){
instanceService.startFlowInstance(params);
return R.ok();
}
/**
* 我的待办
@@ -65,16 +58,29 @@ public class FlwInstanceController {
}
/**
* 审批通过
* 提交审批
*/
@PostMapping("/completeFlow")
public R completeFlow(@RequestBody Map<String, Object> params){
R r = instanceService.completeTaskById(params);
return r;
}
/**
* 终结流程
*/
@PostMapping("/deleteFlow")
public R deleteFlow(@RequestBody Map<String, Object> params){
R r = instanceService.deleteFlow(params);
return r;
}
@RequestMapping("/claimTask/{id}")
public R claimTask(@PathVariable("id") String id){
if(StringUtils.isBlank(id)){

View File

@@ -9,10 +9,12 @@ import java.util.Map;
public interface FlwInstanceService {
void startFlowInstance(Map<String, Object> params);
R getTodoTaskList(Map<String, Object> params);
R completeTaskById(Map<String, Object> id);
void unclaimTask(String id);
void claimTask(String id);
@@ -26,4 +28,7 @@ public interface FlwInstanceService {
R getMyCompleteTaskList(Map<String, Object> params);
List<FlwHiTaskEntity> getCompleteHiTaskInstance(String id);
R deleteFlow(Map<String, Object> params);
}

View File

@@ -215,26 +215,7 @@ public class FlwDeployServiceImpl extends FlowServiceNoFactory implements FlwDep
map.put("value", "");
map.put("key", findFlowDefUserOrGroup(assignee));
list.add(map);
} else if (candidateUsers != null && candidateUsers.size() > 0) {
// 指定的候选人
String join = String.join(",", candidateUsers);
Map<String, Object> map = new HashMap<>();
map.put("name", flowElement.getName());
map.put("type", "candidateUsers");
// ${user1} ${user2},${user3} ${group1}
map.put("value", "");
map.put("key", findFlowDefUserOrGroup(join));
list.add(map);
} else if (candidateGroups != null && candidateGroups.size() > 0) {
String join = String.join(",", candidateGroups);
Map<String, Object> map = new HashMap<>();
map.put("name", flowElement.getName());
map.put("type", "candidateGroups");
// ${user1} ${user2},${user3} ${group1}
map.put("value", "");
map.put("key", findFlowDefUserOrGroup(join));
list.add(map);
break;
}
}

View File

@@ -18,13 +18,16 @@ import com.boge.modules.sys.entity.SysUserEntity;
import com.boge.modules.sys.service.SysRoleService;
import com.boge.modules.sys.service.SysUserService;
import com.boge.modules.sys.service.impl.SysUserServiceImpl;
import com.boge.modules.tickets.dao.TicketsDao;
import com.boge.modules.tickets.entity.TicketsEntity;
import com.boge.modules.tickets.enums.TicketUserEnums;
import com.boge.modules.tickets.enums.TicketsStatusEnums;
import com.boge.modules.tickets.service.TicketsService;
import org.flowable.bpmn.model.BpmnModel;
import org.flowable.bpmn.model.FlowElement;
import org.flowable.bpmn.model.Process;
import org.flowable.bpmn.model.UserTask;
import org.flowable.common.engine.api.FlowableException;
import org.flowable.engine.ProcessEngineConfiguration;
import org.flowable.engine.history.HistoricActivityInstance;
import org.flowable.engine.history.HistoricProcessInstance;
@@ -68,7 +71,8 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
@Value("${ProcessInstance.defId}")
private String defId;
@Autowired
private TicketsDao ticketsDao;
//发送消息的类型
private final static String MSGTYPE = "text";
//将消息发送给所有成员
@@ -83,12 +87,11 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
private final static String CREATE_SESSION_URL = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=";
@Override
public void startFlowInstance(Map<String, Object> params) {
SysUserEntity loginUser = ShiroUtils.getUserEntity();
// 获取需要发起的流程信息
String ticketsId = (String) params.get("ticketsId");
// String ticketsId = (String) params.get("ticketsId");
Long userId = Long.valueOf((String) params.get("user1"));
Map<String, Object> variable = new HashMap<>();
// 结合传递过来的数据动态的绑定流程变量
@@ -98,27 +101,33 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
// 记录流程的发起人
identityService.setAuthenticatedUserId(ShiroUtils.getUserId().toString());
// 启动流程
ProcessInstance processInstance = runtimeService.startProcessInstanceById(defId, variable);
try {
ProcessInstance processInstance = runtimeService.startProcessInstanceById(defId, variable);
} catch (FlowableException e) {
e.printStackTrace();
}
SysUserEntity user = sysUserService.getById(userId);
//更新工单审批id
TicketsEntity ticketsEntity = new TicketsEntity();
ticketsEntity.setTicketsId(Long.valueOf(ticketsId));
ticketsEntity.setStatus(TicketsStatusEnums.CHECKED.getCode());
ticketsEntity.setProcessInstance(processInstance.getProcessInstanceId());
ticketsEntity.setDeptPeople(user.getNickname());
ticketsEntity.setAssignUserId(userId);
ticketsService.updateById(ticketsEntity);
// TicketsEntity ticketsEntity = new TicketsEntity();
// ticketsEntity.setTicketsId(Long.valueOf(ticketsId));
// ticketsEntity.setStatus(TicketsStatusEnums.CHECKED.getCode());
// ticketsEntity.setProcessInstance(processInstance.getProcessInstanceId());
// ticketsEntity.setDeptPeople(user.getNickname());
// ticketsEntity.setAssignUserId(userId);
// ticketsService.updateById(ticketsEntity);
if (StrUtil.isEmpty(user.getWexinId())){
throw new RRException("企业id为空企业微信消息无法推送");
if (StrUtil.isEmpty(user.getWexinId())) {
throw new RRException("企业id为空企业微信消息无法推送");
}
String accessToken = getAccessToken();
sendWeChatMessage(user.getWexinId(),"工单已推送,请登入售后管理系统处理",accessToken,ticketsId);
// sendWeChatMessage(user.getWexinId(),"工单已推送,请登入售后管理系统处理",accessToken,ticketsId);
}
/**
* 获取access_token
*/
@@ -162,7 +171,6 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
}
public static void sendWeChatMessage(String toUser, String content, String ACCESS_TOKEN, String ticketsId) {
//请求串
String url = CREATE_SESSION_URL + ACCESS_TOKEN;
@@ -173,7 +181,7 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
JSONObject contentJSon = new JSONObject();
contentJSon.put("title", "[协同提醒] - 工单审批待处理");
contentJSon.put("description", "点击查看详情");
contentJSon.put("url", "http://localhost:8001/#/tickets-detail?id="+ticketsId);
contentJSon.put("url", "http://localhost:8001/#/tickets-detail?id=" + ticketsId);
contentJSon.put("btntxt", "处理");
jsonObject.put("textcard", contentJSon);
@@ -202,7 +210,7 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
JSONObject jsonObject1 = JSONObject.parseObject(result);
int errcode = jsonObject1.getInteger("errcode");
if (Objects.equals(42001, errcode)) {
throw new RRException("发送企业微信 token 失效");
throw new RRException("发送企业微信 token 失效");
}
if (Objects.equals(0, errcode)) {
System.out.println("消息发送成功");
@@ -225,33 +233,31 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
}
private static void packageData(Map<String, Object> params, Set<String> keys, Map<String, Object> variable) {
if(keys != null){
if (keys != null) {
for (String key : keys) {
if("id".equals(key) || "t".equals(key)){
if ("id".equals(key) || "t".equals(key)) {
continue;
}
String value = (String) params.get(key);
if(key.contains(",")){
if (key.contains(",")) {
String[] split = key.split(",");
int i = 0;
for (String s : split) {
if(value.contains(",")){
if (value.contains(",")) {
String[] split1 = value.split(",");
if(split1.length >= i){
variable.put(s,split1[i]);
}else{
variable.put(s,split1[0]);
if (split1.length >= i) {
variable.put(s, split1[i]);
} else {
variable.put(s, split1[0]);
}
}else{
variable.put(s,value);
} else {
variable.put(s, value);
}
i++;
}
}else{
variable.put(key,value);
} else {
variable.put(key, value);
}
}
}
@@ -259,9 +265,9 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
/**
* 查询我的待办任务
* 审批人
* 候选人
* 候选人组
* 审批人
* 候选人
* 候选人组
*
* @param params
* @return
@@ -269,8 +275,8 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
@Override
public R getTodoTaskList(Map<String, Object> params) {
// 获取到分页的信息
Integer page = Integer.parseInt((String)params.getOrDefault(Constant.PAGE,1));
Integer limit = Integer.parseInt((String) params.getOrDefault(Constant.LIMIT,5));
Integer page = Integer.parseInt((String) params.getOrDefault(Constant.PAGE, 1));
Integer limit = Integer.parseInt((String) params.getOrDefault(Constant.LIMIT, 5));
// 获取当前的登录用户
SysUserEntity loginUser = ShiroUtils.getUserEntity();
TaskQuery taskQuery = taskService.createTaskQuery()
@@ -286,13 +292,13 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
List<Task> tasks = taskQuery.listPage((page - 1) * limit, page * limit);
long count = taskQuery.count();
List<FlwTaskEntity> list = new ArrayList<>();
if(tasks != null && tasks.size() > 0){
if (tasks != null && tasks.size() > 0) {
for (Task task : tasks) {
FlwTaskEntity entity = new FlwTaskEntity();
entity.setTaskId(task.getId());
entity.setCategory(task.getCategory());
entity.setAssigneeId(task.getAssignee());
if(task.getAssignee() != null){
if (task.getAssignee() != null) {
SysUserEntity assigneeUser = userService.getById(task.getAssignee());
entity.setAssigneeName(assigneeUser.getNickname());
}
@@ -310,46 +316,113 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
// 任务的发起人
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
.processInstanceId(entity.getProcInsId()).singleResult();
if(historicProcessInstance != null){
if (historicProcessInstance != null) {
String startUserId = historicProcessInstance.getStartUserId();
entity.setStartTime(historicProcessInstance.getStartTime());
entity.setStartUserId(startUserId);
if(StringUtils.isNotBlank(startUserId)){
if (StringUtils.isNotBlank(startUserId)) {
SysUserEntity startUser = userService.getById(startUserId);
entity.setStartUserName(startUser.getNickname());
}
}
// 通过 BpmnModel 对象来检查当前的节点的 定义信息
entity.setStatus(getUserTaskStatus(task.getProcessDefinitionId(),task.getTaskDefinitionKey()));
entity.setStatus(getUserTaskStatus(task.getProcessDefinitionId(), task.getTaskDefinitionKey()));
list.add(entity);
}
}
PageUtils pageUtils = new PageUtils(list,(int)count,limit,page);
return R.ok("操作成功").put("page",pageUtils);
PageUtils pageUtils = new PageUtils(list, (int) count, limit, page);
return R.ok("操作成功").put("page", pageUtils);
}
@Override
public R completeTaskById(Map<String, Object> params) {
String processInstance = (String) params.get("processInstance");
Integer ticketsId = (Integer) params.get("ticketsId");
if(StringUtils.isBlank(processInstance)){
Integer ticketsId = (Integer) params.get("ticketsId");
String result = (String) params.get("result");
String opinion = (String) params.get("opinion");
if (StringUtils.isBlank(processInstance)) {
return R.error("流程Id不能为空");
}
TaskQuery taskQuery = taskService.createTaskQuery().active().processInstanceId(processInstance);
List<Task> tasks = taskQuery.list();
if (!tasks.isEmpty()){
taskService.complete(tasks.get(0).getId());
if (StringUtils.isBlank(processInstance)) {
return R.error("流程Id不能为空");
}
//更新工单审批id
Task secondTask = taskService.createTaskQuery()
.processInstanceId(processInstance)
.singleResult();
Map<String, Object> secondApprovalVars = new HashMap<>();
TicketsEntity ticketsEntity = new TicketsEntity();
// 完结流程
if (Objects.nonNull(secondTask) && StrUtil.isNotEmpty(result) && result.equals("完结")) {
secondApprovalVars.put("approvalResult", true);
ticketsEntity.setStatus(TicketsStatusEnums.FINISH.getCode());
ticketsEntity.setFinishTime(new Date());
ticketsEntity.setAssignUserId(TicketUserEnums.SPECIALIST.getCode());
taskService.complete(secondTask.getId(), secondApprovalVars);
}
// 继续流程
if (Objects.nonNull(secondTask) && StrUtil.isNotEmpty(result) && result.equals("同意")) {
secondApprovalVars.put("approvalResult", false);
ticketsEntity.setAssignUserId(TicketUserEnums.MANAGER.getCode());
taskService.complete(secondTask.getId(), secondApprovalVars);
}
// 指派处理人
if (Objects.nonNull(secondTask) && StrUtil.isNotEmpty(result) && result.equals("指派")) {
String userId = String.valueOf(params.get("userId"));
Map<String, Object> startVars = new HashMap<>();
startVars.put("user1",userId);
ticketsEntity.setAssignUserId(Long.valueOf(userId));
taskService.complete(secondTask.getId(), startVars);
}
// 继续流程
if (Objects.nonNull(secondTask) && StrUtil.isNotEmpty(result) && result.equals("提交")) {
ticketsEntity.setAssignUserId(TicketUserEnums.SPECIALIST.getCode());
taskService.complete(secondTask.getId(), secondApprovalVars);
}
String processName = ticketsDao.selectByProcessInstance(processInstance);
if (StringUtils.isNotBlank(processName)&& processName.contains("完结")){
ticketsEntity.setStatus(TicketsStatusEnums.FINISH.getCode());
}
//更新工单审批id
ticketsEntity.setTicketsId(Long.valueOf(ticketsId));
ticketsEntity.setStatus(TicketsStatusEnums.CANCEL.getCode());
ticketsEntity.setUpdateTime(new Date());
ticketsService.updateById(ticketsEntity);
return R.ok("操作成功");
}
@Override
public R deleteFlow(Map<String, Object> params) {
String processInstance = (String) params.get("processInstance");
// Integer ticketsId = (Integer) params.get("ticketsId");
if (StringUtils.isBlank(processInstance)) {
return R.error("流程Id不能为空");
}
//查询活跃任务
TaskQuery taskQuery = taskService.createTaskQuery().active().processInstanceId(processInstance);
List<Task> tasks = taskQuery.list();
if (tasks.isEmpty()) {
return R.error("没有可终结的任务");
}
runtimeService.deleteProcessInstance(processInstance, "测试终结流程");
//更新工单审批id
// TicketsEntity ticketsEntity = new TicketsEntity();
// ticketsEntity.setTicketsId(Long.valueOf(ticketsId));
// ticketsEntity.setStatus(TicketsStatusEnums.CANCEL.getCode());
// ticketsEntity.setUpdateTime(new Date());
// ticketsService.updateById(ticketsEntity);
return R.ok("操作成功");
}
@Override
public void unclaimTask(String id) {
taskService.unclaim(id);
@@ -357,7 +430,7 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
@Override
public void claimTask(String id) {
taskService.claim(id,ShiroUtils.getUserId().toString());
taskService.claim(id, ShiroUtils.getUserId().toString());
}
@Override
@@ -399,7 +472,6 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
}
//获取流程图
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
ProcessEngineConfiguration configuration = processEngine.getProcessEngineConfiguration();
@@ -412,7 +484,7 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
byte[] b = new byte[in.available()];
in.read(b);
return b;
}catch (IOException e){
} catch (IOException e) {
}
return null;
@@ -422,8 +494,8 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
@Override
public R getMyStartTaskList(Map<String, Object> params) {
// 获取到分页的信息
Integer page = Integer.parseInt((String)params.getOrDefault(Constant.PAGE,1));
Integer limit = Integer.parseInt((String) params.getOrDefault(Constant.LIMIT,5));
Integer page = Integer.parseInt((String) params.getOrDefault(Constant.PAGE, 1));
Integer limit = Integer.parseInt((String) params.getOrDefault(Constant.LIMIT, 5));
// 获取当前的登录用户
SysUserEntity loginUser = ShiroUtils.getUserEntity();
// 我们需要根据当前登录用户查询所有发起的流程
@@ -436,7 +508,7 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
List<HistoricProcessInstance> tasks = historicProcessInstanceQuery.listPage((page - 1) * limit, page * limit);
long count = historicProcessInstanceQuery.count();
List<FlwMyFlowEntity> list = new ArrayList<>();
if(tasks != null && tasks.size() > 0){
if (tasks != null && tasks.size() > 0) {
for (HistoricProcessInstance historicProcessInstance : tasks) {
HistoricProcessInstanceEntityImpl impl = (HistoricProcessInstanceEntityImpl) historicProcessInstance;
FlwMyFlowEntity entity = new FlwMyFlowEntity();
@@ -449,7 +521,7 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
entity.setFlowProceId(impl.getProcessInstanceId());
// 任务的发起人
if(historicProcessInstance != null){
if (historicProcessInstance != null) {
String startUserId = historicProcessInstance.getStartUserId();
entity.setStartDate(historicProcessInstance.getStartTime());
entity.setEndDate(historicProcessInstance.getEndTime());
@@ -459,12 +531,13 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
list.add(entity);
}
}
PageUtils pageUtils = new PageUtils(list,(int)count,limit,page);
return R.ok("操作成功").put("page",pageUtils);
PageUtils pageUtils = new PageUtils(list, (int) count, limit, page);
return R.ok("操作成功").put("page", pageUtils);
}
/**
* 根据流程实例ID获取对应的流转记录
*
* @param id
* @return
*/
@@ -474,7 +547,7 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
.processInstanceId(id).orderByTaskCreateTime().asc().list();
List<FlwHiTaskEntity> ress = new ArrayList<>();
if(list != null){
if (list != null) {
for (HistoricTaskInstance entity : list) {
FlwHiTaskEntity task = new FlwHiTaskEntity();
task.setId(entity.getId());
@@ -483,26 +556,26 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
task.setAssignee(entity.getAssignee());
task.setStartTime(entity.getCreateTime());
Long durationInMillis = entity.getDurationInMillis();
if(durationInMillis != null){
if (durationInMillis != null) {
task.setDuration(durationInMillis);
}
if(StringUtils.isNotBlank(entity.getAssignee())){
if (StringUtils.isNotBlank(entity.getAssignee())) {
// 需要查询到用户的名称
SysUserEntity userEntity = userService.getById(entity.getAssignee());
String username = userEntity.getUsername();
String nickname = userEntity.getNickname();
if(StringUtils.isNotBlank(nickname)){
if (StringUtils.isNotBlank(nickname)) {
task.setAssigneeName(nickname);
}else{
} else {
task.setAssigneeName(username);
}
}
// 查询当前的节点的状态
if(entity.getEndTime() != null){
if (entity.getEndTime() != null) {
// 这个节点已经审批完成了
task.setStatus("finish");
}else{
} else {
task.setStatus("wait");
}
ress.add(task);
@@ -515,16 +588,16 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
@Override
public R getMyCompleteTaskList(Map<String, Object> params) {
// 获取到分页的信息
Integer page = Integer.parseInt((String)params.getOrDefault(Constant.PAGE,1));
Integer limit = Integer.parseInt((String) params.getOrDefault(Constant.LIMIT,5));
Integer page = Integer.parseInt((String) params.getOrDefault(Constant.PAGE, 1));
Integer limit = Integer.parseInt((String) params.getOrDefault(Constant.LIMIT, 5));
// 获取当前的登录用户
SysUserEntity loginUser = ShiroUtils.getUserEntity();
// 我的已办 可以通过当前登录用户 匹配 act_hi_taskinst 中的审批人来找到对应的流程实例id
List<HistoricTaskInstance> taskInstances = historyService.createHistoricTaskInstanceQuery()
.taskAssignee(loginUser.getUserId().toString()).list();
if(taskInstances == null || taskInstances.size() == 0){
PageUtils pageUtils = new PageUtils(null,0,limit,page);
return R.ok("操作成功").put("page",pageUtils);
if (taskInstances == null || taskInstances.size() == 0) {
PageUtils pageUtils = new PageUtils(null, 0, limit, page);
return R.ok("操作成功").put("page", pageUtils);
}
Set<String> processInsIds = taskInstances.stream().map(item -> {
return item.getProcessInstanceId();
@@ -539,7 +612,7 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
List<HistoricProcessInstance> tasks = historicProcessInstanceQuery.listPage((page - 1) * limit, page * limit);
long count = historicProcessInstanceQuery.count();
List<FlwMyFlowEntity> list = new ArrayList<>();
if(tasks != null && tasks.size() > 0){
if (tasks != null && tasks.size() > 0) {
for (HistoricProcessInstance historicProcessInstance : tasks) {
HistoricProcessInstanceEntityImpl impl = (HistoricProcessInstanceEntityImpl) historicProcessInstance;
FlwMyFlowEntity entity = new FlwMyFlowEntity();
@@ -552,10 +625,10 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
entity.setFlowProceId(impl.getProcessInstanceId());
// 任务的发起人
if(historicProcessInstance != null){
if (historicProcessInstance != null) {
String startUserId = historicProcessInstance.getStartUserId();
SysUserEntity userEntity = userService.getById(startUserId);
if(userEntity != null){
if (userEntity != null) {
entity.setUserName(userEntity.getNickname());
}
entity.setStartDate(historicProcessInstance.getStartTime());
@@ -566,8 +639,8 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
list.add(entity);
}
}
PageUtils pageUtils = new PageUtils(list,(int)count,limit,page);
return R.ok("操作成功").put("page",pageUtils);
PageUtils pageUtils = new PageUtils(list, (int) count, limit, page);
return R.ok("操作成功").put("page", pageUtils);
}
@Override
@@ -577,7 +650,7 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
List<FlwHiTaskEntity> ress = new ArrayList<>();
SysUserEntity loginUser = ShiroUtils.getUserEntity();
if(list != null){
if (list != null) {
for (HistoricTaskInstance entity : list) {
FlwHiTaskEntity task = new FlwHiTaskEntity();
task.setId(entity.getId());
@@ -586,30 +659,30 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
task.setAssignee(entity.getAssignee());
task.setStartTime(entity.getCreateTime());
Long durationInMillis = entity.getDurationInMillis();
if(durationInMillis != null){
if (durationInMillis != null) {
task.setDuration(durationInMillis);
}
if(StringUtils.isNotBlank(entity.getAssignee())){
if (StringUtils.isNotBlank(entity.getAssignee())) {
// 需要查询到用户的名称
SysUserEntity userEntity = userService.getById(entity.getAssignee());
String username = userEntity.getUsername();
String nickname = userEntity.getNickname();
if(StringUtils.isNotBlank(nickname)){
if (StringUtils.isNotBlank(nickname)) {
task.setAssigneeName(nickname);
}else{
} else {
task.setAssigneeName(username);
}
}
// 查询当前的节点的状态
if(entity.getEndTime() != null){
if (entity.getEndTime() != null) {
// 这个节点已经审批完成了
task.setStatus("finish");
}else{
} else {
task.setStatus("wait");
}
if(entity.getAssignee() != null && entity.getAssignee().equals(loginUser.getUserId().toString())){
if (entity.getAssignee() != null && entity.getAssignee().equals(loginUser.getUserId().toString())) {
task.setStatus("success");
}
ress.add(task);
@@ -619,21 +692,21 @@ public class FlwInstanceServiceImpl extends FlowServiceNoFactory implements FlwI
return ress;
}
private Integer getUserTaskStatus(String processDef,String taskDefKey){
private Integer getUserTaskStatus(String processDef, String taskDefKey) {
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDef);
Process mainProcess = bpmnModel.getMainProcess();
Collection<FlowElement> flowElements = mainProcess.getFlowElements();
Integer status = 0;
if(flowElements != null && flowElements.size() > 0){
if (flowElements != null && flowElements.size() > 0) {
for (FlowElement flowElement : flowElements) {
if(flowElement instanceof UserTask){
if (flowElement instanceof UserTask) {
UserTask userTask = (UserTask) flowElement;
if(userTask.getId().equals(taskDefKey)){
if (userTask.getId().equals(taskDefKey)) {
String assignee = userTask.getAssignee();
if(StringUtils.isNotBlank(assignee)){
if (StringUtils.isNotBlank(assignee)) {
// 说明是制定的审批人
status = 0;
}else{
} else {
status = 1;
}
break;

View File

@@ -88,7 +88,6 @@ public class FileController {
if(StringUtils.isBlank(procId)|| "null".equals(procId) || "undefined".equals(procId)){
return ;
}
byte[] bytes = instanceService.diagram(procId);
response.setContentType("image/png");
ServletOutputStream outputStream = response.getOutputStream();

View File

@@ -75,11 +75,7 @@ public class TicketsController {
@RequestMapping("/save")
//@RequiresPermissions("tickets:tickets:save")
public R save(@RequestBody TicketsEntity tickets){
SysUserEntity loginUser = ShiroUtils.getUserEntity();
tickets.setCreateTime(new Date());
tickets.setCreateUser(loginUser.getNickname());
ticketsService.save(tickets);
ticketsService.saveTicket(tickets);
return R.ok();
}

View File

@@ -17,4 +17,6 @@ public interface TicketsDao extends BaseMapper<TicketsEntity> {
TicketsDTO getTicketsDTOById(String ticketsId);
String selectByProcessInstance(String processInstance);
}

View File

@@ -1,5 +1,6 @@
package com.boge.modules.tickets.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import java.util.Date;
@@ -28,7 +29,7 @@ public class TicketsDTO {
/**
* 合同编号
*/
private String contractNumber;
private String contractCode;
/**
* 客户id
*/
@@ -51,9 +52,9 @@ public class TicketsDTO {
*/
private String deptPhone;
/**
* 创建者ID
* 创建者
*/
private Long createUserId;
private String createUser;
/**
* 创建时间
*/
@@ -65,14 +66,21 @@ public class TicketsDTO {
/**
* 工单状态
*/
private Integer status;
/**
* 工单关闭时间
*/
private Date updateTime;
/**
* 审批流id
*/
private String processInstance;
/**
* 审批结点
*/
private String processInstanceUser;
}

View File

@@ -1,5 +1,6 @@
package com.boge.modules.tickets.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
@@ -75,10 +76,15 @@ public class TicketsEntity implements Serializable {
*/
private Integer status;
/**
* 工单关闭时间
* 更新时间
*/
private Date updateTime;
/**
* 完结时间
*/
private Date finishTime;
/**
* 审批流id
*/

View File

@@ -0,0 +1,25 @@
package com.boge.modules.tickets.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum TicketUserEnums {
SPECIALIST(2L, "专员"),
MANAGER(3L, "经理");
private Long code;
private String msg;
public static String getStatus(String code) {
for (TicketUserEnums value : values()) {
if (value.code.equals(code)) {
return value.msg;
}
}
return null;
}
}

View File

@@ -10,7 +10,7 @@ import lombok.Getter;
UNCHECK(0, "未开始"),
CHECKED(1, "已指派"),
REJECT(2, "处理中"),
CANCEL(3, "已完成");
FINISH(3, "已完成");
private Integer code;
private String msg;

View File

@@ -21,5 +21,7 @@ public interface TicketsService extends IService<TicketsEntity> {
TicketsDTO getTicketsById(String ticketsId);
PageUtils queryPageByType(Map<String, Object> params);
void saveTicket(TicketsEntity tickets);
}

View File

@@ -12,11 +12,19 @@ import com.boge.modules.sys.entity.SysUserEntity;
import com.boge.modules.sys.service.SysUserRoleService;
import com.boge.modules.sys.service.impl.SysUserServiceImpl;
import com.boge.modules.tickets.dto.TicketsDTO;
import com.boge.modules.tickets.enums.TicketUserEnums;
import org.flowable.common.engine.api.FlowableException;
import org.flowable.engine.IdentityService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.runtime.ProcessInstance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.boge.modules.tickets.enums.TicketsTypeEnums;
import com.boge.modules.tickets.enums.TicketsStatusEnums;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -45,18 +53,28 @@ public class TicketsServiceImpl extends ServiceImpl<TicketsDao, TicketsEntity> i
@Autowired
private SysUserRoleService sysUserRoleService;
@Autowired
protected RuntimeService runtimeService;
@Autowired
protected IdentityService identityService;
@Value("${ProcessInstance.defId}")
private String defId;
@Override
public PageUtils queryPage(Map<String, Object> params) {
SysUserEntity loginUser = ShiroUtils.getUserEntity();
QueryWrapper<TicketsEntity> ticketsEntityQueryWrapper = new QueryWrapper<>();
if (ObjectUtil.isNotEmpty(loginUser)){
if (ObjectUtil.isNotEmpty(loginUser)) {
List<Long> longs = sysUserRoleService.queryRoleIdList(loginUser.getUserId());
//判断是否是超级管理员
if (longs.contains(2L)){
ticketsEntityQueryWrapper.orderBy(true, false,"create_time");
}else {
if (longs.contains(2L)) {
ticketsEntityQueryWrapper.orderBy(true, false, "create_time");
} else {
ticketsEntityQueryWrapper.eq("assign_user_id", loginUser.getUserId())
.orderBy(true, false,"create_time");;
.orderBy(true, false, "create_time");
;
}
}
@@ -71,18 +89,18 @@ public class TicketsServiceImpl extends ServiceImpl<TicketsDao, TicketsEntity> i
public PageUtils queryPageByType(Map<String, Object> params) {
SysUserEntity loginUser = ShiroUtils.getUserEntity();
QueryWrapper<TicketsEntity> ticketsEntityQueryWrapper = new QueryWrapper<>();
if (ObjectUtil.isNotEmpty(loginUser)){
if (ObjectUtil.isNotEmpty(loginUser)) {
//判断是否是超级管理员
ticketsEntityQueryWrapper.orderBy(true, false,"create_time");
if (TicketsTypeEnums.ASSIGN.getCode().equals(params.get("type"))){
ticketsEntityQueryWrapper.orderBy(true, false, "create_time");
if (TicketsTypeEnums.ASSIGN.getCode().equals(params.get("type"))) {
ticketsEntityQueryWrapper.eq("create_user", loginUser.getUsername());
}
if (TicketsTypeEnums.TO_BE_DONE.getCode().equals(params.get("type"))){
ticketsEntityQueryWrapper.eq("assign_user_id", loginUser.getUserId()).eq("status",TicketsStatusEnums.CHECKED.getCode());
if (TicketsTypeEnums.TO_BE_DONE.getCode().equals(params.get("type"))) {
ticketsEntityQueryWrapper.eq("assign_user_id", loginUser.getUserId()).eq("status", TicketsStatusEnums.REJECT.getCode());
}
if (TicketsTypeEnums.FINISH.getCode().equals(params.get("type"))){
ticketsEntityQueryWrapper.eq("assign_user_id", loginUser.getUserId()).eq("status",TicketsStatusEnums.CANCEL.getCode());
if (TicketsTypeEnums.FINISH.getCode().equals(params.get("type"))) {
ticketsEntityQueryWrapper.eq("assign_user_id", loginUser.getUserId()).eq("status", TicketsStatusEnums.FINISH.getCode());
}
@@ -95,9 +113,32 @@ public class TicketsServiceImpl extends ServiceImpl<TicketsDao, TicketsEntity> i
return new PageUtils(page);
}
@Override
public void saveTicket(TicketsEntity tickets) {
// 启动流程
try {
// 记录流程的发起人
identityService.setAuthenticatedUserId(ShiroUtils.getUserId().toString());
Map<String, Object> startVars = new HashMap<>();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(defId, startVars);
SysUserEntity loginUser = ShiroUtils.getUserEntity();
tickets.setCreateTime(new Date());
tickets.setCreateUser(loginUser.getNickname());
tickets.setStatus(TicketsStatusEnums.REJECT.getCode());
tickets.setAssignUserId(TicketUserEnums.SPECIALIST.getCode());
tickets.setProcessInstance(processInstance.getProcessInstanceId());
ticketsDao.insert(tickets);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public TicketsDTO getTicketsById(String ticketsId) {
TicketsDTO tickets = ticketsDao.getTicketsDTOById(ticketsId);
String processName = ticketsDao.selectByProcessInstance(tickets.getProcessInstance());
tickets.setProcessInstanceUser(processName);
return tickets;
}

View File

@@ -3,7 +3,7 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/basefast?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
url: jdbc:mysql://localhost:3306/flowable?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
username: root
password: 123456
initial-size: 10

View File

@@ -4,6 +4,7 @@ server:
uri-encoding: UTF-8
max-threads: 1000
min-spare-threads: 30
port: 8070
connection-timeout: 5000ms
servlet:
@@ -87,5 +88,8 @@ file:
avatarMaxSize: 5
ProcessInstance:
defId: Process_1:2:05cb9af4-03a2-11f0-8846-e40d36456f42
defId: Process_1:9:70cda2de-bb83-11f0-a10e-e60d36456f41

View File

@@ -8,12 +8,11 @@
<result property="ticketsId" column="tickets_id"/>
<result property="carType" column="car_type"/>
<result property="errorType" column="error_type"/>
<result property="contractId" column="contract_number"/>
<result property="clientId" column="client_id"/>
<result property="description" column="description"/>
<result property="deptPeople" column="dept_people"/>
<result property="deptPhone" column="dept_phone"/>
<result property="createUserId" column="create_user_id"/>
<result property="createUser" column="create_user"/>
<result property="createTime" column="create_time"/>
<result property="isCheck" column="is_check"/>
<result property="status" column="status"/>
@@ -23,10 +22,12 @@
select * from sys_tickets as a
left join sys_client as b on a.client_id = b.client_id
left join sys_car as c on a.car_type = c.car_id
left join sys_contract as d on a.contract_id = d.contract_id
where a.tickets_id = #{ticketsId}
</select>
<select id="selectByProcessInstance" resultType="java.lang.String" parameterType="java.lang.String">
select NAME_ from act_ru_task where PROC_INST_ID_ = #{processInstance}
</select>
</mapper>

View File

@@ -1,123 +1,670 @@
<template>
<div class="mod-config">
<el-descriptions title="工单详情" direction="vertical" :column="column" size="mini" border>
<template slot="extra">
<el-button v-if="String(ticketsData.status) === '1'" type="primary" size="small" @click="doOperate">审批</el-button>
<!-- 页面标题栏 -->
<div class="page-header">
<div class="title">工单详情</div>
<div class="meta-info">
<span class="creator">{{ ticketsData.createUser }} </span>
<span class="create-time">{{ ticketsData.createTime }}</span>
</div>
</div>
<!-- 主内容区左侧表单 + 右侧审批栏 -->
<div class="main-container">
<!-- 左侧表单区域 -->
<div class="form-container">
<!-- 公司标识 -->
<div class="company-logo">NOBLELIFT 诺力</div>
<!-- 工单表单标题 -->
<div class="form-title">工单信息</div>
<!-- 基本信息区块 -->
<div class="form-block">
<div class="block-title">基本信息</div>
<table class="info-table">
<tbody>
<tr>
<td class="label">工单ID</td>
<td class="value">
<el-tag size="small">{{ ticketsData.ticketsId }}</el-tag>
</td>
<td class="label">小车类型</td>
<td class="value">{{ ticketsData.carName || '-' }}</td>
</tr>
<tr>
<td class="label">异常类型</td>
<td class="value">{{ ticketsData.errorType || '-' }}</td>
<td class="label">合同编号</td>
<td class="value">{{ ticketsData.contractCode || '-' }}</td>
</tr>
<tr>
<td class="label">客户</td>
<td class="value">{{ ticketsData.clientName || '-' }}</td>
<td class="label">工单对接人</td>
<td class="value">{{ ticketsData.deptPeople || '-' }}</td>
</tr>
<tr>
<td class="label">客户联系电话</td>
<td class="value">{{ ticketsData.deptPhone || '-' }}</td>
<td class="label">创建者</td>
<td class="value">{{ ticketsData.createUser || '-' }}</td>
</tr>
<tr>
<td class="label">创建时间</td>
<td class="value">{{ ticketsData.createTime || '-' }}</td>
<td class="label">是否验收</td>
<td class="value">{{ ['否', '是'][Number(ticketsData.isCheck)] || '-' }}</td>
</tr>
<tr>
<td class="label">工单状态</td>
<td class="value">{{ statusOpt | findByValue(ticketsData.status) || '-' }}</td>
<td class="label">审批完成时间</td>
<td class="value">{{ ticketsData.updateTime || '-' }}</td>
</tr>
</tbody>
</table>
</div>
<!-- 故障描述区块 -->
<div class="form-block">
<div class="block-title">故障描述</div>
<div class="description-content">
{{ ticketsData.description || '无故障描述信息' }}
</div>
</div>
</div>
<!-- 右侧审批栏 -->
<div class="approval-sidebar">
<div class="sidebar-content">
<div class="sidebar-header">审批</div>
<!-- 审批操作按钮组 -->
<div class="approval-tools">
<el-upload
ref="upload"
:action="$baseUrl + '/api/localStorage' + '?name=' + dataForm.filename"
:limit="1"
:headers="headers"
:before-upload="beforeUpload"
:on-success="handleSuccess"
:on-error="handleError"
:on-remove="handleRemove"
:auto-upload="false"
>
<el-button slot="trigger" size="mini" type="primary">上传附件</el-button>
<div slot="tip" class="el-upload__tip">可上传任意格式文件且不超过100M</div>
</el-upload>
</div>
<!-- 处理意见输入 -->
<div class="opinion-input">
<el-input
type="textarea"
v-model="approvalForm.opinion"
placeholder="请输入处理意见"
rows="6"
>
<template slot="prepend">
<el-button type="text" icon="el-icon-edit" size="mini"></el-button>
<el-button type="text" icon="el-icon-at" size="mini"></el-button>
<el-button type="text" size="mini">常用语</el-button>
</template>
</el-input>
</div>
<!-- 外层容器控制对齐方式 -->
<div v-if= "ticketsData.processInstanceUser === '销售经理'" style="text-align: left; margin: 8px 0;"> <!-- 左对齐 + 上下间距 -->
<el-button type="text" size="small"
class="custom-assign-btn"
@click="startFlowUser()"
>
指派
</el-button>
</div>
<div v-if="assignedUsername" class="assigned-username">
指派{{ assignedUsername }}
</div>
<el-radio-group v-if= "ticketsData.processInstanceUser === '销售专员'" v-model="approvalForm.result">
<el-radio label="同意" border size="small">同意</el-radio>
<el-radio label="完结" border size="small">完结</el-radio>
</el-radio-group>
<!-- 附加选项 -->
<div class="approval-options">
<el-checkbox v-model="approvalForm.hideOpinion">意见隐藏</el-checkbox>
<div class="option-item">
<el-checkbox v-model="approvalForm.track">跟踪</el-checkbox>
</div>
</div>
<!-- 底部操作按钮固定在底部 -->
<div class="approval-actions">
<el-button size="small" @click="saveAsDraft">存为草稿</el-button>
<el-button size="small" @click="saveForLater">暂存待办</el-button>
<el-button type="primary" size="small" @click="submitApproval">提交</el-button>
</div>
</div>
</div>
</div>
<!-- 弹窗, 新增 / 修改 -->
<el-dialog
title="指派"
:visible.sync="dialogFormVisible"
width="30%"
:close-on-click-modal="false"
>
<el-form
:model="flowForm"
label-width="100px"
class="demo-dynamic"
ref="flowFormRef"
>
<!-- 循环渲染动态表单时增加v-if判断避免空数据报错 -->
<el-form-item
v-for="(form, index) in dynamiForm"
:label="form.name || '未命名'"
:key="`${form.key}-${index}`"
:prop="form.key"
:rules="[{ required: true, message: `请选择${form.name}`, trigger: 'change' }]"
>
<!-- 只在users有数据时渲染选择器避免循环空数组 -->
<el-select
v-if="form.type === 'assignee' && users.length > 0"
v-model="flowForm[form.key]"
placeholder="请选择"
clearable
>
<el-option
v-for="user in users"
:key="user.userId"
:label="`${user.nickname || user.username}[${user.username}]`"
:value="user.userId"
/>
</el-select>
<!-- 当users为空时显示提示 -->
<div v-else-if="form.type === 'assignee' && users.length === 0">
暂无可选用户
</div>
</el-form-item>
</el-form>
<!-- 弹窗底部按钮区之前可能缺少导致无法提交/关闭 -->
<template #footer>
<el-button @click="dialogFormVisible = false">取消</el-button>
<el-button type="primary" @click="handleAssign">确认指派</el-button>
</template>
<el-descriptions-item label="工单ID">
<el-tag size="small">{{ ticketsData.ticketsId }}</el-tag>
</el-descriptions-item>
<el-descriptions-item label="小车类型">
{{ ticketsData.carName }}
</el-descriptions-item>
<el-descriptions-item label="异常类型">
{{ ticketsData.errorType }}
</el-descriptions-item>
<el-descriptions-item label="合同编号">{{ ticketsData.contractCode }}</el-descriptions-item>
<el-descriptions-item label="客户">{{ ticketsData.clientName }}</el-descriptions-item>
<el-descriptions-item label="工单对接人">{{ ticketsData.deptPeople }}</el-descriptions-item>
<el-descriptions-item label="客户联系电话">{{ ticketsData.deptPhone }}</el-descriptions-item>
<el-descriptions-item label="创建者">{{ ticketsData.createUser }}</el-descriptions-item>
<el-descriptions-item label="创建时间">{{ ticketsData.createTime }}</el-descriptions-item>
<el-descriptions-item label="是否验收">{{ ['否', '是'][Number(ticketsData.isCheck)] }}</el-descriptions-item>
<el-descriptions-item label="工单状态">{{ statusOpt | findByValue(ticketsData.status) }}</el-descriptions-item>
<el-descriptions-item label="工单审批完成时间">{{ ticketsData.updateTime }}</el-descriptions-item>
<el-descriptions-item label="故障描述">{{ ticketsData.description }}</el-descriptions-item>
</el-descriptions>
</el-dialog>
</div>
</template>
<script>
export default {
data () {
return {
column: 0,
ticketsData: {},
statusOpt: [{value: '0', label: '未开始'}, {value: '1', label: '已指派'}, {value: '2', label: '处理中'}, {value: '3', label: '已完成'}]
}
},
created () {
if (this.isMobile() || window.innerWidth < 768) {
this.column = 2
} else {
this.column = 4
}
this.getDataList()
},
methods: {
isMobile() {
const userAgentInfo = navigator.userAgent;
const mobileAgents = [
"Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"
];
let isMobile = false;
for (let i = 0; i < mobileAgents.length; i++) {
if (userAgentInfo.indexOf(mobileAgents[i]) > -1) {
isMobile = true;
break;
}
}
return isMobile;
import AddOrUpdate from "./tickets-add-or-update.vue";
export default {
components: {AddOrUpdate},
data() {
return {
column: 0,
ticketsData: {},
statusOpt: [
{value: '0', label: '未开始'},
{value: '1', label: '已指派'},
{value: '2', label: '处理中'},
{value: '3', label: '已完成'}
],
assignedUsername: '',
// 审批表单数据
approvalForm: {
result: '指派', // 默认为同意
opinion: '', // 处理意见
hideOpinion: false, // 意见隐藏
track: false, // 跟踪
trackType: '全部', // 跟踪类型
archiveAfterHandle: false, // 处理后归档
assignUserId: 0 // 指派人id
},
// 获取数据列表
getDataList () {
dictData: [],
// 上传文件
dataForm: {
contractId: 0,
contractType: '',
isMaster: 0,
contractNumber: '',
clientId: '',
isAcceptance: 0,
remarks: '',
fileNo: '',
totalSum: 0,
filename: null,
storageId: null
},
dialogFormVisible: false, // 必须初始化
flowForm: {},
users: [],
}
},
created() {
// 初始化布局
this.column = this.isMobile() || window.innerWidth < 768 ? 2 : 4;
this.getDataList();
// this.checkAndSetAgree();
},
methods: {
// 移动端判断
isMobile() {
const userAgentInfo = navigator.userAgent;
const mobileAgents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
return mobileAgents.some(agent => userAgentInfo.indexOf(agent) > -1);
},
handleAssign() {
// 先验证表单必填项
this.$refs.flowFormRef.validate(valid => {
if (valid) {
// 1. 获取选中的userId假设dynamiForm中只有一个assignee类型的表单项取第一个
const formItem = this.dynamiForm[0]; // 若有多个,需根据实际场景调整
const selectedUserId = this.flowForm[formItem.key];
// 2. 从users数组中找到对应的user获取username
const selectedUser = this.users.find(user => user.userId === selectedUserId);
if (selectedUser) {
this.assignedUsername = selectedUser.nickname;// 保存username
this.approvalForm.assignUserId = selectedUser.userId;
} else {
this.assignedUsername = '未知用户'; // 未找到时的兜底
}
// 3. 关闭对话框
this.dialogFormVisible = false;
// (可选)这里可以添加实际的指派逻辑,如调用接口等
}
});
},
// 上传文件
beforeUpload(file) {
let isLt2M = true
isLt2M = file.size / 1024 / 1024 < 100
if (!isLt2M) {
this.$message.error('上传文件大小不能超过 100MB!')
return
}
this.dataForm.filename = file.name
return isLt2M
},
startFlowUser() {
this.$http({
url: this.$http.adornUrl('/flow/deploy/flowDef'),
method: 'get',
params: this.$http.adornParams()
}).then(({data}) => {
if (data && data.code === 0) {
this.dynamiForm = [...data.data]
this.users = [...data.users]
this.roles = [...data.roles]
this.dialogFormVisible = true
}
})
},
handleSuccess(response, file, fileList) {
this.$notify({title: '上传成功', type: 'success'})
this.dataForm.storageId = response.storageId
},
handleError(e, file, fileList) {
const msg = JSON.parse(e.message)
this.$notify({
title: msg.message,
type: 'error',
duration: 2500
})
},
handleRemove(file, fileList) {
this.dataForm.storageId = null
},
// 获取工单数据
getDataList() {
this.$http({
url: this.$http.adornUrl(`/tickets/tickets/info/${this.$route.query.id}`),
method: 'get',
params: this.$http.adornParams({})
}).then(({data}) => {
if (data && data.code === 0) {
this.ticketsData = data.tickets;
}
const user = this.ticketsData.processInstanceUser;
if (user && (user.includes('指派') || user.includes('完结'))) {
this.approvalForm.result = '提交'; // 自动选中“同意”
}
});
},
// 提交审批
submitApproval() {
if (!this.approvalForm.opinion && this.approvalForm.result === '不同意') {
this.$message.warning('不同意时请填写处理意见');
return;
}
this.$confirm(`确定${this.approvalForm.result}该工单?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$http({
url: this.$http.adornUrl(`/tickets/tickets/info/${this.$route.query.id}`),
method: 'get',
params: this.$http.adornParams({})
url: this.$http.adornUrl('/flw/instance/completeFlow'),
method: 'post',
data: this.$http.adornData({
ticketsId: this.ticketsData.ticketsId,
processInstance: this.ticketsData.processInstance,
result: this.approvalForm.result,
opinion: this.approvalForm.opinion,
userId: this.approvalForm.assignUserId
})
}).then(({data}) => {
if (data && data.code === 0) {
this.ticketsData = data.tickets
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.$router.push('/tickets-tickets');
}
});
} else {
this.$message.error(data.msg || '操作失败');
}
})
},
// 每页数
sizeChangeHandle (val) {
this.pageSize = val
this.pageIndex = 1
this.getDataList()
},
// 当前页
currentChangeHandle (val) {
this.pageIndex = val
this.getDataList()
},
doOperate () {
this.$confirm(`确定进行审批操作?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$http({
url: this.$http.adornUrl('/flw/instance/completeFlow'),
method: 'post',
data: this.$http.adornData({ticketsId: this.ticketsData.ticketsId, processInstance: this.ticketsData.processInstance})
}).then(({data}) => {
if (data && data.code === 0) {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.$router.push('/tickets-tickets')
}
})
} else {
this.$message.error(data.msg)
}
})
}).catch(() => {})
}
});
}).catch(() => {
});
},
// 存为草稿
saveAsDraft() {
this.$message.success('已保存为草稿');
},
// 暂存待办
saveForLater() {
this.$message.success('已暂存待办');
},
// 分页相关方法(未使用可删除)
sizeChangeHandle(val) {
this.pageSize = val;
this.pageIndex = 1;
this.getDataList();
},
currentChangeHandle(val) {
this.pageIndex = val;
this.getDataList();
}
}
};
</script>
<style scoped>
.mod-config {
padding: 30px 30px;
padding: 20px;
background-color: #f5f5f5;
min-height: 100vh;
}
.el-pagination {
margin-top: 15px;
/* 页面标题栏 */
.page-header {
margin-bottom: 20px;
padding-bottom: 10px;
border-bottom: 1px solid #e5e5e5;
}
.title {
font-size: 18px;
font-weight: bold;
color: #333;
margin-bottom: 5px;
}
.meta-info {
color: #666;
font-size: 14px;
}
.meta-info .creator {
margin-right: 15px;
}
/* 主内容区布局:强制两侧高度一致 */
.main-container {
display: flex;
gap: 20px;
align-items: stretch; /* 核心:左右两侧高度强制对齐 */
}
/* 左侧表单容器:高度随内容撑开,作为右侧高度基准 */
.form-container {
flex: 1;
background-color: #fff;
padding: 30px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
border: 1px solid #eee; /* 新增边框,与右侧视觉统一 */
}
/* 公司标识 */
.company-logo {
font-size: 24px;
font-weight: bold;
color: #f37b1d; /* 诺力橙色 */
text-align: center;
margin-bottom: 20px;
}
/* 表单标题 */
.form-title {
text-align: center;
font-size: 20px;
font-weight: bold;
margin-bottom: 30px;
color: #333;
}
.custom-assign-btn {
color: #606266; /* 与表单文字色统一 */
border: 1px solid #e4e7ed;
border-radius: 4px;
padding: 4px 8px;
margin: 8px 0;
font-size: 16px;
}
.custom-assign-btn:hover {
color: #409EFF;
border-color: #c6e2ff;
background-color: #f0f9ff;
}
/* 表单区块样式 */
.form-block {
margin-bottom: 25px;
border: 1px solid #ddd;
}
.block-title {
background-color: #f8f0e3; /* 浅橙色背景 */
color: #333;
padding: 8px 15px;
font-weight: bold;
border-bottom: 1px solid #ddd;
}
/* 表格样式 */
.info-table {
width: 100%;
border-collapse: collapse;
}
.info-table tr {
border-bottom: 1px solid #f0f0f0;
}
.info-table td {
padding: 12px 15px;
vertical-align: middle;
}
.info-table .label {
width: 25%;
background-color: #fafafa;
font-weight: 500;
text-align: right;
padding-right: 20px;
border-right: 1px solid #f0f0f0;
}
.info-table .value {
width: 25%;
padding-left: 20px;
}
/* 故障描述样式 */
.description-content {
padding: 15px;
line-height: 1.6;
min-height: 80px;
}
/* 右侧审批栏:与左侧高度完全一致,优化内容分布 */
.approval-sidebar {
background-color: #fff;
padding: 30px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
border: 1px solid #eee; /* 与左侧统一边框 */
align-self: stretch; /* 强制高度与左侧一致 */
}
/* 审批栏内部容器用flex分布内容底部按钮固定 */
.sidebar-content {
display: flex;
flex-direction: column;
height: 100%; /* 占满审批栏高度 */
gap: 15px; /* 统一内部元素间距 */
}
.sidebar-header {
font-size: 16px;
font-weight: bold;
padding: 10px 0;
border-bottom: 1px solid #e5e5e5;
color: #333;
margin-bottom: 5px; /* 缩减间距,更紧凑 */
}
/* 审批工具栏 */
.approval-tools {
padding-bottom: 10px;
border-bottom: 1px solid #eee;
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-bottom: 5px; /* 缩减间距 */
}
/* 审批结果选择 */
.approval-result {
display: flex;
gap: 10px;
margin-bottom: 5px;
}
.approval-result .el-radio {
flex: 1;
}
/* 意见输入框:占满中间空间 */
.opinion-input {
flex: 1; /* 让输入框自适应填充中间高度 */
min-height: 120px; /* 确保输入框有足够高度 */
}
/* 审批选项 */
.approval-options {
margin-bottom: 10px;
}
.option-item {
display: flex;
align-items: center;
gap: 10px;
margin: 8px 0; /* 缩减选项间距 */
}
.option-item .el-radio-group {
display: flex;
gap: 10px;
}
.approval-options .el-checkbox {
display: block;
margin: 8px 0; /* 缩减复选框间距 */
}
/* 底部操作按钮:固定在审批栏底部 */
.approval-actions {
display: flex;
gap: 10px;
justify-content: flex-end;
margin-top: auto; /* 推到最底部 */
padding-top: 15px;
border-top: 1px solid #eee; /* 分隔线,参考图片样式 */
}
/* 响应式适配 */
@media (max-width: 992px) {
.main-container {
flex-direction: column;
}
.approval-sidebar {
width: 100%;
margin-top: 20px; /* 垂直排列时增加间距 */
}
.info-table .label, .info-table .value {
width: 50%;
}
}
@media (max-width: 576px) {
.form-container, .approval-sidebar {
padding: 15px;
}
.info-table td {
display: block;
width: 100% !important;
text-align: left !important;
}
.info-table .label {
border-right: none;
padding-right: 0;
background-color: transparent;
font-weight: bold;
}
.info-table .value {
padding-left: 0;
margin-bottom: 10px;
padding-bottom: 10px;
border-bottom: 1px dashed #eee;
}
}
</style>

View File

@@ -137,8 +137,16 @@
header-align="center"
align="center"
min-width="100px"
label="工单更新时间">
</el-table-column>
<el-table-column
prop="finishTime"
header-align="center"
align="center"
min-width="100px"
label="工单审批完成时间">
</el-table-column>
<el-table-column
fixed="right"
header-align="center"
@@ -148,7 +156,7 @@
<template slot-scope="scope">
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.ticketsId)">修改</el-button>
<el-button type="text" size="small" @click="deleteHandle(scope.row.ticketsId)">删除</el-button>
<el-button v-if="!scope.row.status" type="text" size="small" @click="startFlowHandle(scope.row.ticketsId)">指派</el-button>
<el-button type="text" size="small" @click="startFlowHandle(scope.row.processInstance)">流程进度</el-button>
<el-button type="text" size="small" @click="$router.push(`/tickets-detail?id=${scope.row.ticketsId}`)">详情</el-button>
</template>
</el-table-column>
@@ -162,6 +170,16 @@
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
<!-- 流程图弹框 -->
<el-dialog
title="流程进度图"
:visible.sync="dialogVisible"
width="80%"
style="max-height: 80vh; overflow: auto;"
>
<img :src="flowImgUrl" alt="流程进度图" style="width:100%;" />
</el-dialog>
<!-- 弹窗, 新增 / 修改 -->
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" :dictData="dictData" @refreshDataList="getDataList"></add-or-update>
<el-dialog
@@ -215,6 +233,8 @@
export default {
data () {
return {
dialogVisible: false, // 弹框显隐控制
flowImgUrl: '', // 流程图图片URL
dataForm: {
deptPeople: '',
errorType: '',
@@ -227,10 +247,11 @@
dataListLoading: false,
dataListSelections: [],
addOrUpdateVisible: false,
dictConfigs: [{url: '/car/car/list', type: 'list', value: 'carId', label: 'carName'}, {type: 'dict', code: 'error_type'}, {url: '/flow/contract/list', type: 'list', value: 'contractId', label: 'contractNumber'}, {url: '/client/client/list', type: 'list', value: 'clientId', label: 'clientName'}],
dictConfigs: [{url: '/car/car/list', type: 'list', value: 'carId', label: 'carName'}, {type: 'dict', code: 'error_type'}, {url: '/flow/projectContract/list', type: 'list', value: 'contractId', label: 'contractNumber'}, {url: '/client/client/list', type: 'list', value: 'clientId', label: 'clientName'}],
dictData: [],
dialogFormVisible: false,
flowForm:{ticketsId: null},
flowFormInsId:{processInstance: null},
dynamiForm:[],
users: [],
roles: [],
@@ -321,21 +342,30 @@
})
}).catch(() => {})
},
startFlowHandle(id){
this.flowForm = {}
this.flowForm.ticketsId = id
startFlowHandle(processInstance) {
// 传递流程实例ID作为参数假设后端需要的参数名为procid
this.$http({
url: this.$http.adornUrl('/flow/deploy/flowDef'),
url: this.$http.adornUrl('/file/fileController/downloadFlowActiveImg'),
method: 'get',
params: this.$http.adornParams()
}).then(({data}) => {
if (data && data.code === 0) {
this.dynamiForm = [...data.data]
this.users = [...data.users]
this.roles = [...data.roles]
this.dialogFormVisible = true
params: this.$http.adornParams({
procId: processInstance // 关键传递流程实例ID
}),
responseType: 'blob' // 关键声明响应类型为二进制blob
}).then((response) => {
// 成功获取二进制图片数据
this.flowImgUrl = URL.createObjectURL(response.data); // 转换为可展示的URL
this.dialogVisible = true; // 显示弹框
}).catch((error) => {
// 错误处理可能返回JSON格式的错误信息
console.error('获取流程图失败', error);
// 尝试解析错误信息若后端返回JSON错误
if (error.response && error.response.data) {
const errorData = error.response.data;
this.$message.error(errorData.msg || '获取流程图失败,请稍后重试');
} else {
this.$message.error('获取流程图失败,请稍后重试');
}
})
});
},
submitStartFlow(){
// 提交表单数据