add : 工单流程交互开发

This commit is contained in:
ls
2025-11-08 15:46:45 +08:00
parent 712aefd8d3
commit edc28808fa
13 changed files with 382 additions and 237 deletions

View File

@@ -23,26 +23,7 @@ public class FlwInstanceController {
@Lazy @Lazy
private FlwInstanceService instanceService; private FlwInstanceService instanceService;
/**
* 发起流程
*/
@RequestMapping("/startFlowInstance")
public R startFlowInstance(@RequestParam Map<String, Object> params){
instanceService.startFlowInstance(params);
return R.ok();
}
/**
* 发起流程
*/
@RequestMapping("/startFlowInstance1")
public R startFlowInstance1(@RequestParam Map<String, Object> params){
instanceService.startFlowInstance1(params);
return R.ok();
}
/** /**
@@ -77,7 +58,7 @@ public class FlwInstanceController {
} }
/** /**
* 审批通过 * 提交审批
*/ */
@PostMapping("/completeFlow") @PostMapping("/completeFlow")
public R completeFlow(@RequestBody Map<String, Object> params){ public R completeFlow(@RequestBody Map<String, Object> params){
@@ -86,30 +67,6 @@ public class FlwInstanceController {
} }
/**
* 任务节点1审批通过工单完结
*/
@PostMapping("/completeFlow1")
public R completeFlow1(@RequestBody Map<String, Object> params){
R r = instanceService.completeTaskById1(params);
return r;
}
/**
* 任务节点1无法解决进入下一个节点
*/
@PostMapping("/deleteFlow1")
public R deleteFlow1(@RequestBody Map<String, Object> params){
R r = instanceService.deleteFlow1(params);
return r;
}
/** /**
* 终结流程 * 终结流程

View File

@@ -9,13 +9,11 @@ import java.util.Map;
public interface FlwInstanceService { public interface FlwInstanceService {
void startFlowInstance(Map<String, Object> params); void startFlowInstance(Map<String, Object> params);
void startFlowInstance1(Map<String, Object> params);
R getTodoTaskList(Map<String, Object> params); R getTodoTaskList(Map<String, Object> params);
R completeTaskById(Map<String, Object> id); R completeTaskById(Map<String, Object> id);
R completeTaskById1(Map<String, Object> id);
void unclaimTask(String id); void unclaimTask(String id);
@@ -33,5 +31,4 @@ public interface FlwInstanceService {
R deleteFlow(Map<String, Object> params); R deleteFlow(Map<String, Object> params);
R deleteFlow1(Map<String, Object> params);
} }

View File

@@ -215,26 +215,7 @@ public class FlwDeployServiceImpl extends FlowServiceNoFactory implements FlwDep
map.put("value", ""); map.put("value", "");
map.put("key", findFlowDefUserOrGroup(assignee)); map.put("key", findFlowDefUserOrGroup(assignee));
list.add(map); list.add(map);
} else if (candidateUsers != null && candidateUsers.size() > 0) { break;
// 指定的候选人
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);
} }
} }

View File

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

View File

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

View File

@@ -78,4 +78,9 @@ public class TicketsDTO {
* 审批流id * 审批流id
*/ */
private String processInstance; private String processInstance;
/**
* 审批结点
*/
private String processInstanceUser;
} }

View File

@@ -76,11 +76,14 @@ public class TicketsEntity implements Serializable {
*/ */
private Integer status; private Integer status;
/** /**
* 工单关闭时间 * 更新时间
*/ */
private Date updateTime; private Date updateTime;
/**
* 完结时间
*/
private Date finishTime;
/** /**
* 审批流id * 审批流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, "未开始"), UNCHECK(0, "未开始"),
CHECKED(1, "已指派"), CHECKED(1, "已指派"),
REJECT(2, "处理中"), REJECT(2, "处理中"),
CANCEL(3, "已完成"); FINISH(3, "已完成");
private Integer code; private Integer code;
private String msg; private String msg;

View File

@@ -12,7 +12,9 @@ import com.boge.modules.sys.entity.SysUserEntity;
import com.boge.modules.sys.service.SysUserRoleService; import com.boge.modules.sys.service.SysUserRoleService;
import com.boge.modules.sys.service.impl.SysUserServiceImpl; import com.boge.modules.sys.service.impl.SysUserServiceImpl;
import com.boge.modules.tickets.dto.TicketsDTO; import com.boge.modules.tickets.dto.TicketsDTO;
import com.boge.modules.tickets.enums.TicketUserEnums;
import org.flowable.common.engine.api.FlowableException; import org.flowable.common.engine.api.FlowableException;
import org.flowable.engine.IdentityService;
import org.flowable.engine.RuntimeService; import org.flowable.engine.RuntimeService;
import org.flowable.engine.runtime.ProcessInstance; import org.flowable.engine.runtime.ProcessInstance;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -54,6 +56,9 @@ public class TicketsServiceImpl extends ServiceImpl<TicketsDao, TicketsEntity> i
@Autowired @Autowired
protected RuntimeService runtimeService; protected RuntimeService runtimeService;
@Autowired
protected IdentityService identityService;
@Value("${ProcessInstance.defId}") @Value("${ProcessInstance.defId}")
private String defId; private String defId;
@@ -91,11 +96,11 @@ public class TicketsServiceImpl extends ServiceImpl<TicketsDao, TicketsEntity> i
ticketsEntityQueryWrapper.eq("create_user", loginUser.getUsername()); ticketsEntityQueryWrapper.eq("create_user", loginUser.getUsername());
} }
if (TicketsTypeEnums.TO_BE_DONE.getCode().equals(params.get("type"))) { if (TicketsTypeEnums.TO_BE_DONE.getCode().equals(params.get("type"))) {
ticketsEntityQueryWrapper.eq("assign_user_id", loginUser.getUserId()).eq("status", TicketsStatusEnums.CHECKED.getCode()); ticketsEntityQueryWrapper.eq("assign_user_id", loginUser.getUserId()).eq("status", TicketsStatusEnums.REJECT.getCode());
} }
if (TicketsTypeEnums.FINISH.getCode().equals(params.get("type"))) { if (TicketsTypeEnums.FINISH.getCode().equals(params.get("type"))) {
ticketsEntityQueryWrapper.eq("assign_user_id", loginUser.getUserId()).eq("status", TicketsStatusEnums.CANCEL.getCode()); ticketsEntityQueryWrapper.eq("assign_user_id", loginUser.getUserId()).eq("status", TicketsStatusEnums.FINISH.getCode());
} }
@@ -112,11 +117,15 @@ public class TicketsServiceImpl extends ServiceImpl<TicketsDao, TicketsEntity> i
public void saveTicket(TicketsEntity tickets) { public void saveTicket(TicketsEntity tickets) {
// 启动流程 // 启动流程
try { try {
// 记录流程的发起人
identityService.setAuthenticatedUserId(ShiroUtils.getUserId().toString());
Map<String, Object> startVars = new HashMap<>(); Map<String, Object> startVars = new HashMap<>();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(defId, startVars); ProcessInstance processInstance = runtimeService.startProcessInstanceById(defId, startVars);
SysUserEntity loginUser = ShiroUtils.getUserEntity(); SysUserEntity loginUser = ShiroUtils.getUserEntity();
tickets.setCreateTime(new Date()); tickets.setCreateTime(new Date());
tickets.setCreateUser(loginUser.getNickname()); tickets.setCreateUser(loginUser.getNickname());
tickets.setStatus(TicketsStatusEnums.REJECT.getCode());
tickets.setAssignUserId(TicketUserEnums.SPECIALIST.getCode());
tickets.setProcessInstance(processInstance.getProcessInstanceId()); tickets.setProcessInstance(processInstance.getProcessInstanceId());
ticketsDao.insert(tickets); ticketsDao.insert(tickets);
} catch (Exception e) { } catch (Exception e) {
@@ -127,6 +136,9 @@ public class TicketsServiceImpl extends ServiceImpl<TicketsDao, TicketsEntity> i
@Override @Override
public TicketsDTO getTicketsById(String ticketsId) { public TicketsDTO getTicketsById(String ticketsId) {
TicketsDTO tickets = ticketsDao.getTicketsDTOById(ticketsId); TicketsDTO tickets = ticketsDao.getTicketsDTOById(ticketsId);
String processName = ticketsDao.selectByProcessInstance(tickets.getProcessInstance());
tickets.setProcessInstanceUser(processName);
return tickets; return tickets;
} }

View File

@@ -24,6 +24,10 @@
left join sys_car as c on a.car_type = c.car_id left join sys_car as c on a.car_type = c.car_id
where a.tickets_id = #{ticketsId} where a.tickets_id = #{ticketsId}
</select> </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> </mapper>

View File

@@ -26,7 +26,9 @@
<tbody> <tbody>
<tr> <tr>
<td class="label">工单ID</td> <td class="label">工单ID</td>
<td class="value"><el-tag size="small">{{ ticketsData.ticketsId }}</el-tag></td> <td class="value">
<el-tag size="small">{{ ticketsData.ticketsId }}</el-tag>
</td>
<td class="label">小车类型</td> <td class="label">小车类型</td>
<td class="value">{{ ticketsData.carName || '-' }}</td> <td class="value">{{ ticketsData.carName || '-' }}</td>
</tr> </tr>
@@ -80,26 +82,25 @@
<!-- 审批操作按钮组 --> <!-- 审批操作按钮组 -->
<div class="approval-tools"> <div class="approval-tools">
<el-upload <el-upload
ref="upload" ref="upload"
:action="$baseUrl + '/api/localStorage' + '?name=' + dataForm.filename" :action="$baseUrl + '/api/localStorage' + '?name=' + dataForm.filename"
:limit="1" :limit="1"
:headers="headers" :headers="headers"
:before-upload="beforeUpload" :before-upload="beforeUpload"
:on-success="handleSuccess" :on-success="handleSuccess"
:on-error="handleError" :on-error="handleError"
:on-remove="handleRemove" :on-remove="handleRemove"
:auto-upload="false" :auto-upload="false"
> >
<el-button slot="trigger" size="mini" type="primary">上传附件</el-button> <el-button slot="trigger" size="mini" type="primary">上传附件</el-button>
<div slot="tip" class="el-upload__tip">可上传任意格式文件且不超过100M</div> <div slot="tip" class="el-upload__tip">可上传任意格式文件且不超过100M</div>
</el-upload> </el-upload>
</div> </div>
<!-- 处理意见输入 --> <!-- 处理意见输入 -->
<div class="opinion-input"> <div class="opinion-input">
<el-input <el-input
@@ -116,19 +117,33 @@
</el-input> </el-input>
</div> </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"> <div class="approval-options">
<el-checkbox v-model="approvalForm.hideOpinion">意见隐藏</el-checkbox> <el-checkbox v-model="approvalForm.hideOpinion">意见隐藏</el-checkbox>
<div class="option-item"> <div class="option-item">
<el-checkbox v-model="approvalForm.track">跟踪</el-checkbox> <el-checkbox v-model="approvalForm.track">跟踪</el-checkbox>
<el-radio-group v-model="approvalForm.trackType" v-if="approvalForm.track">
<el-radio label="全部" border size="small">全部</el-radio>
<el-radio label="指定人" border size="small">指定人</el-radio>
</el-radio-group>
</div>
<el-checkbox v-model="approvalForm.archiveAfterHandle">处理后归档</el-checkbox> </div>
</div> </div>
<!-- 底部操作按钮固定在底部 --> <!-- 底部操作按钮固定在底部 -->
@@ -140,30 +155,86 @@
</div> </div>
</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-dialog>
</div> </div>
</template> </template>
<script> <script>
import AddOrUpdate from "./tickets-add-or-update.vue";
export default { export default {
components: {AddOrUpdate},
data() { data() {
return { return {
column: 0, column: 0,
ticketsData: {}, ticketsData: {},
statusOpt: [ statusOpt: [
{ value: '0', label: '未开始' }, {value: '0', label: '未开始'},
{ value: '1', label: '已指派' }, {value: '1', label: '已指派'},
{ value: '2', label: '处理中' }, {value: '2', label: '处理中'},
{ value: '3', label: '已完成' } {value: '3', label: '已完成'}
], ],
assignedUsername: '',
// 审批表单数据 // 审批表单数据
approvalForm: { approvalForm: {
result: '同意', // 默认为同意 result: '指派', // 默认为同意
opinion: '', // 处理意见 opinion: '', // 处理意见
hideOpinion: false, // 意见隐藏 hideOpinion: false, // 意见隐藏
track: false, // 跟踪 track: false, // 跟踪
trackType: '全部', // 跟踪类型 trackType: '全部', // 跟踪类型
archiveAfterHandle: false // 处理后归档 archiveAfterHandle: false, // 处理后归档
assignUserId: 0 // 指派人id
}, },
dictData: [],
// 上传文件 // 上传文件
dataForm: { dataForm: {
contractId: 0, contractId: 0,
@@ -177,13 +248,19 @@ export default {
totalSum: 0, totalSum: 0,
filename: null, filename: null,
storageId: null storageId: null
} },
dialogFormVisible: false, // 必须初始化
flowForm: {},
users: [],
} }
}, },
created() { created() {
// 初始化布局 // 初始化布局
this.column = this.isMobile() || window.innerWidth < 768 ? 2 : 4; this.column = this.isMobile() || window.innerWidth < 768 ? 2 : 4;
this.getDataList(); this.getDataList();
// this.checkAndSetAgree();
}, },
methods: { methods: {
// 移动端判断 // 移动端判断
@@ -192,6 +269,31 @@ export default {
const mobileAgents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; const mobileAgents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
return mobileAgents.some(agent => userAgentInfo.indexOf(agent) > -1); 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) { beforeUpload(file) {
let isLt2M = true let isLt2M = true
@@ -203,8 +305,22 @@ export default {
this.dataForm.filename = file.name this.dataForm.filename = file.name
return isLt2M 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) { handleSuccess(response, file, fileList) {
this.$notify({title: '上传成功',type: 'success'}) this.$notify({title: '上传成功', type: 'success'})
this.dataForm.storageId = response.storageId this.dataForm.storageId = response.storageId
}, },
handleError(e, file, fileList) { handleError(e, file, fileList) {
@@ -215,7 +331,7 @@ export default {
duration: 2500 duration: 2500
}) })
}, },
handleRemove (file, fileList) { handleRemove(file, fileList) {
this.dataForm.storageId = null this.dataForm.storageId = null
}, },
// 获取工单数据 // 获取工单数据
@@ -224,10 +340,14 @@ export default {
url: this.$http.adornUrl(`/tickets/tickets/info/${this.$route.query.id}`), url: this.$http.adornUrl(`/tickets/tickets/info/${this.$route.query.id}`),
method: 'get', method: 'get',
params: this.$http.adornParams({}) params: this.$http.adornParams({})
}).then(({ data }) => { }).then(({data}) => {
if (data && data.code === 0) { if (data && data.code === 0) {
this.ticketsData = data.tickets; this.ticketsData = data.tickets;
} }
const user = this.ticketsData.processInstanceUser;
if (user && (user.includes('指派') || user.includes('完结'))) {
this.approvalForm.result = '提交'; // 自动选中“同意”
}
}); });
}, },
// 提交审批 // 提交审批
@@ -249,9 +369,10 @@ export default {
ticketsId: this.ticketsData.ticketsId, ticketsId: this.ticketsData.ticketsId,
processInstance: this.ticketsData.processInstance, processInstance: this.ticketsData.processInstance,
result: this.approvalForm.result, result: this.approvalForm.result,
opinion: this.approvalForm.opinion opinion: this.approvalForm.opinion,
userId: this.approvalForm.assignUserId
}) })
}).then(({ data }) => { }).then(({data}) => {
if (data && data.code === 0) { if (data && data.code === 0) {
this.$message({ this.$message({
message: '操作成功', message: '操作成功',
@@ -265,7 +386,8 @@ export default {
this.$message.error(data.msg || '操作失败'); this.$message.error(data.msg || '操作失败');
} }
}); });
}).catch(() => {}); }).catch(() => {
});
}, },
// 存为草稿 // 存为草稿
saveAsDraft() { saveAsDraft() {
@@ -302,16 +424,19 @@ export default {
padding-bottom: 10px; padding-bottom: 10px;
border-bottom: 1px solid #e5e5e5; border-bottom: 1px solid #e5e5e5;
} }
.title { .title {
font-size: 18px; font-size: 18px;
font-weight: bold; font-weight: bold;
color: #333; color: #333;
margin-bottom: 5px; margin-bottom: 5px;
} }
.meta-info { .meta-info {
color: #666; color: #666;
font-size: 14px; font-size: 14px;
} }
.meta-info .creator { .meta-info .creator {
margin-right: 15px; margin-right: 15px;
} }
@@ -328,7 +453,7 @@ export default {
flex: 1; flex: 1;
background-color: #fff; background-color: #fff;
padding: 30px; padding: 30px;
box-shadow: 0 1px 3px rgba(0,0,0,0.1); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
border: 1px solid #eee; /* 新增边框,与右侧视觉统一 */ border: 1px solid #eee; /* 新增边框,与右侧视觉统一 */
} }
@@ -350,11 +475,27 @@ export default {
color: #333; 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 { .form-block {
margin-bottom: 25px; margin-bottom: 25px;
border: 1px solid #ddd; border: 1px solid #ddd;
} }
.block-title { .block-title {
background-color: #f8f0e3; /* 浅橙色背景 */ background-color: #f8f0e3; /* 浅橙色背景 */
color: #333; color: #333;
@@ -368,13 +509,16 @@ export default {
width: 100%; width: 100%;
border-collapse: collapse; border-collapse: collapse;
} }
.info-table tr { .info-table tr {
border-bottom: 1px solid #f0f0f0; border-bottom: 1px solid #f0f0f0;
} }
.info-table td { .info-table td {
padding: 12px 15px; padding: 12px 15px;
vertical-align: middle; vertical-align: middle;
} }
.info-table .label { .info-table .label {
width: 25%; width: 25%;
background-color: #fafafa; background-color: #fafafa;
@@ -383,6 +527,7 @@ export default {
padding-right: 20px; padding-right: 20px;
border-right: 1px solid #f0f0f0; border-right: 1px solid #f0f0f0;
} }
.info-table .value { .info-table .value {
width: 25%; width: 25%;
padding-left: 20px; padding-left: 20px;
@@ -400,7 +545,7 @@ export default {
background-color: #fff; background-color: #fff;
padding: 30px; padding: 30px;
box-shadow: 0 1px 3px rgba(0,0,0,0.1); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
border: 1px solid #eee; /* 与左侧统一边框 */ border: 1px solid #eee; /* 与左侧统一边框 */
align-self: stretch; /* 强制高度与左侧一致 */ align-self: stretch; /* 强制高度与左侧一致 */
} }
@@ -438,6 +583,7 @@ export default {
gap: 10px; gap: 10px;
margin-bottom: 5px; margin-bottom: 5px;
} }
.approval-result .el-radio { .approval-result .el-radio {
flex: 1; flex: 1;
} }
@@ -452,16 +598,19 @@ export default {
.approval-options { .approval-options {
margin-bottom: 10px; margin-bottom: 10px;
} }
.option-item { .option-item {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 10px; gap: 10px;
margin: 8px 0; /* 缩减选项间距 */ margin: 8px 0; /* 缩减选项间距 */
} }
.option-item .el-radio-group { .option-item .el-radio-group {
display: flex; display: flex;
gap: 10px; gap: 10px;
} }
.approval-options .el-checkbox { .approval-options .el-checkbox {
display: block; display: block;
margin: 8px 0; /* 缩减复选框间距 */ margin: 8px 0; /* 缩减复选框间距 */
@@ -482,10 +631,12 @@ export default {
.main-container { .main-container {
flex-direction: column; flex-direction: column;
} }
.approval-sidebar { .approval-sidebar {
width: 100%; width: 100%;
margin-top: 20px; /* 垂直排列时增加间距 */ margin-top: 20px; /* 垂直排列时增加间距 */
} }
.info-table .label, .info-table .value { .info-table .label, .info-table .value {
width: 50%; width: 50%;
} }
@@ -495,17 +646,20 @@ export default {
.form-container, .approval-sidebar { .form-container, .approval-sidebar {
padding: 15px; padding: 15px;
} }
.info-table td { .info-table td {
display: block; display: block;
width: 100% !important; width: 100% !important;
text-align: left !important; text-align: left !important;
} }
.info-table .label { .info-table .label {
border-right: none; border-right: none;
padding-right: 0; padding-right: 0;
background-color: transparent; background-color: transparent;
font-weight: bold; font-weight: bold;
} }
.info-table .value { .info-table .value {
padding-left: 0; padding-left: 0;
margin-bottom: 10px; margin-bottom: 10px;

View File

@@ -137,8 +137,16 @@
header-align="center" header-align="center"
align="center" align="center"
min-width="100px" min-width="100px"
label="工单更新时间">
</el-table-column>
<el-table-column
prop="finishTime"
header-align="center"
align="center"
min-width="100px"
label="工单审批完成时间"> label="工单审批完成时间">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
fixed="right" fixed="right"
header-align="center" header-align="center"