实体类Car中必须要有String userId属性。
设置自定义表单为system/car/deptleadercheck:
然后在CarController中编写system/car/deptleadercheck对应的函数:
@GetMapping("/deptleadercheck")
public String deptleadercheck(String taskid, ModelMap mmap)
{
Task t = taskService.createTaskQuery().taskId(taskid).singleResult();
String processId = t.getProcessInstanceId();
ProcessInstance p = runtimeService.createProcessInstanceQuery().processInstanceId(processId).singleResult();
if (p != null) {
Car apply = carService.selectCarById(Long.parseLong(p.getBusinessKey()));
mmap.put("apply", apply);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
mmap.put("startTime", sdf.format(apply.getStartTime()));
mmap.put("endTime", sdf.format(apply.getEndTime()));
mmap.put("taskid", taskid);
mmap.put("userlist", userService.selectUserList(new SysUser()));
}
return prefix + "/deptleadercheck";
}
将templates/activiti/leaveapply中deptleadercheck.html复制到car目录。
修改deptleadercheck.html中的这些,其它部分不变:
<div class="form-group">
<label class="col-sm-3 control-label">请假人:</label>
<div class="col-sm-8">
<input name="userId" class="form-control" type="text" th:value="${apply.createId}" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">用车地点:</label>
<div class="col-sm-8">
<input name="leaveType" class="form-control" type="text" th:value="${apply.address}" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">起始时间:</label>
<div class="col-sm-8">
<div class="input-group date">
<input name="startTime" class="form-control" placeholder="yyyy-MM-dd HH:mm:ss" type="text" th:value="${startTime}" readonly>
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">结束时间:</label>
<div class="col-sm-8">
<div class="input-group date">
<input name="endTime" class="form-control" placeholder="yyyy-MM-dd HH:mm:ss" type="text" th:value="${endTime}" readonly>
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">用车原因:</label>
<div class="col-sm-8">
<textarea type="text" name="reason" class="form-control" th:text="${apply.reason}" readonly></textarea>
</div>
</div>
<div class="form-group">
<label class="col-xs-3 control-label">人事:</label>
<div class="col-xs-8">
<select class="form-control" id="hr" name="hr">
<option th:each="ul:${userlist}" th:value="${ul.loginName}" th:text="${ul.userName}" th:disabled="${ul.status == '1'}"></option>
</select>
</div>
</div>