Compare commits

...

18 Commits

Author SHA1 Message Date
f3d5556196 feat:完善出差申请,城市页面优化 2026-04-21 16:32:24 +08:00
f831f29b63 feat: 完善城市管理功能 2026-04-21 10:47:01 +08:00
03b0e20301 feat: 完成城市管理前端增删改查功能 2026-04-20 20:02:35 +08:00
ba5796984c Merge branch 'main' of http://49.232.154.205:10100/liujingchao/fad_oa 2026-04-20 17:52:40 +08:00
a69c1f0cb2 feat:完成城市管理增刪改查功能 2026-04-20 17:51:59 +08:00
e728a98dcc 出差新增检索 2026-04-20 15:55:00 +08:00
54b820cc40 Merge remote-tracking branch 'origin/main' 2026-04-20 15:43:51 +08:00
f73a002f0f 新增城市管理 2026-04-20 14:14:08 +08:00
0400398361 feat(geolocation): 完善工作地点获取功能
- 新增高德地图逆地理编码接口,支持根据浏览器定位自动获取工作地点。
- 在项目报工页面中实现工作地点的自动更新,用户可通过按钮重新获取定位。
- 添加加载状态和错误提示,提升用户体验。
- 优化相关方法以处理地理位置获取的异步操作。
2026-04-17 13:57:27 +08:00
edca68136c feat(geolocation): 添加工作地点自动获取功能
- 在项目报工页面中新增工作地点自动获取功能,用户可通过点击按钮重新获取定位。
- 添加了工作地点加载状态和错误提示,提升用户体验。
- 优化了相关方法以处理地理位置获取的异步操作。
2026-04-17 13:06:39 +08:00
1584d7e06d 提交app同步后端 2026-04-17 12:05:15 +08:00
7c261c3028 feat: 完善高德地图地点搜索功能 2026-04-17 10:36:18 +08:00
5d0c056449 feat: 完成出差目的地高德地图选择功能(2) 2026-04-16 16:22:05 +08:00
fd72c18d48 feat: 完成出差目的地高德地图选择功能 2026-04-16 15:37:08 +08:00
dfd912bf07 feat(security): 新增高德逆地理编码接口并配置RestTemplate超时时间 2026-04-16 11:05:02 +08:00
8b627c000f Merge branch 'main' of http://49.232.154.205:10100/liujingchao/fad_oa 2026-04-15 18:39:01 +08:00
56f7a6abb9 feat:完成出差申请提前结束功能 2026-04-15 18:32:59 +08:00
ebb57f4f26 fix(oa): 修复项目进度步骤查询遗漏删除标记过滤条件
- 在步骤表公共筛选方法中添加删除标记等于0的过滤条件
- 确保查询结果不包含已删除的步骤记录
- 修复因缺少软删除过滤导致的数据查询异常问题
2026-04-15 18:05:23 +08:00
43 changed files with 1801 additions and 60 deletions

View File

@@ -56,6 +56,16 @@ public class HrmFlowTaskController extends BaseController {
}
/**
* 详情页使用:按 bizType + bizId 查询审批概要、当前待办和历史记录
*/
@GetMapping("/detailByBiz")
public R<?> detailByBiz(@RequestParam @NotNull String bizType,
@RequestParam @NotNull Long bizId,
@RequestParam(required = false) Long assigneeUserId) {
return R.ok(service.queryDetailByBiz(bizType, bizId, assigneeUserId));
}
@GetMapping("/{taskId}")
public R<HrmFlowTaskVo> getInfo(@PathVariable @NotNull Long taskId) {
return R.ok(service.queryById(taskId));

View File

@@ -1,6 +1,7 @@
package com.ruoyi.hrm.controller;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.AjaxResult;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
@@ -10,6 +11,7 @@ import com.ruoyi.hrm.domain.bo.HrmTravelReqBo;
import com.ruoyi.hrm.domain.vo.HrmTravelReqVo;
import com.ruoyi.hrm.service.IHrmTravelReqService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -28,6 +30,13 @@ import java.util.List;
public class HrmTravelReqController extends BaseController {
private final IHrmTravelReqService service;
private final IHrmTravelReqService hrmTravelReqService;
@Value("${fad.amap.webkey}")
private String amapKey;
@Value("${fad.amap.securitykey}")
private String amapSecurityKey;
@GetMapping("/list")
public TableDataInfo<HrmTravelReqVo> list(HrmTravelReqBo bo, PageQuery pageQuery) {
@@ -56,6 +65,20 @@ public class HrmTravelReqController extends BaseController {
public R<Void> remove(@PathVariable @NotEmpty Long[] bizIds) {
return toAjax(service.deleteWithValidByIds(Arrays.asList(bizIds), true));
}
@PutMapping("/earlyEnd/{bizId}")
public R<Void> earlyEnd(@PathVariable Long bizId) {
return toAjax(hrmTravelReqService.earlyEnd(bizId));
}
@GetMapping("/amapKey")
public R<String> getAmapKey() {
return R.ok(amapKey);
}
@GetMapping("/amapSecurityKey")
public R<String> getAmapSecurityKey() {
return R.ok(amapSecurityKey);
}
@GetMapping("/all")
public R<List<HrmTravelReqVo>> all(HrmTravelReqBo bo) {

View File

@@ -7,12 +7,11 @@ import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("hrm_flow_action")
public class HrmFlowAction extends BaseEntity implements Serializable {
public class HrmFlowAction extends BaseEntity {
private static final long serialVersionUID = 1L;
@TableId

View File

@@ -32,6 +32,7 @@ public class HrmTravelReq extends BaseEntity {
private String bankName;
private String bankAccount;
private String remark;
private Date actualEndTime;
@TableLogic
private Integer delFlag;
}

View File

@@ -0,0 +1,28 @@
package com.ruoyi.hrm.domain.vo;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class HrmFlowActionTimelineVo implements Serializable {
private static final long serialVersionUID = 1L;
private Long actionId;
private Long taskId;
private Long instId;
private Long actionUserId;
private String actionUserName;
private Long assigneeUserId;
private String assigneeUserName;
private String action;
private String actionText;
private String remark;
private String bizType;
private Long bizId;
private Long nodeId;
private String nodeName;
private String taskStatus;
private Date createTime;
}

View File

@@ -34,6 +34,8 @@ public class HrmFlowInstanceVo implements Serializable {
private Date endTime;
private BigDecimal hours;
private String procStatus;
private Date actualEndTime;
private String statusName;
private String createBy;
private Date createTime;

View File

@@ -0,0 +1,32 @@
package com.ruoyi.hrm.domain.vo;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class HrmFlowTaskDetailVo implements Serializable {
private static final long serialVersionUID = 1L;
/** 当前业务对应的待办任务 */
private HrmFlowTaskVo currentTask;
/** 当前业务对应的全部任务历史 */
private List<HrmFlowTaskVo> taskHistory;
/** 当前流程实例状态 */
private String flowStatus;
/** 当前节点ID */
private Long currentNodeId;
/** 当前节点名称 */
private String currentNodeName;
/** 审批是否通过 */
private Boolean approved;
/** 流程动作历史(更细粒度) */
private List<HrmFlowActionTimelineVo> actionTimeline;
}

View File

@@ -74,6 +74,8 @@ public class HrmTravelReqVo implements Serializable {
private String bankAccount;
@Excel(name = "备注")
private String remark;
private Date actualEndTime;
private String createBy;
private Date createTime;
private String updateBy;

View File

@@ -2,8 +2,8 @@ package com.ruoyi.hrm.service;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.hrm.domain.HrmFlowTask;
import com.ruoyi.hrm.domain.bo.HrmFlowTaskBo;
import com.ruoyi.hrm.domain.vo.HrmFlowTaskDetailVo;
import com.ruoyi.hrm.domain.vo.HrmFlowTaskVo;
import java.util.Collection;
@@ -51,4 +51,9 @@ public interface IHrmFlowTaskService {
* 根据业务类型 + 业务ID 查询当前待办任务pending用于详情页自动带出 currentTaskId
*/
HrmFlowTaskVo queryTodoByBiz(String bizType, Long bizId, Long assigneeUserId);
/**
* 按业务查询详情:当前待办、状态和历史审批记录
*/
HrmFlowTaskDetailVo queryDetailByBiz(String bizType, Long bizId, Long assigneeUserId);
}

View File

@@ -22,5 +22,7 @@ public interface IHrmTravelReqService {
Boolean updateByBo(HrmTravelReqBo bo);
int earlyEnd(Long bizId);
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
}

View File

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.service.UserService;
import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.hrm.domain.HrmFlowInstance;
import com.ruoyi.hrm.domain.HrmFlowNode;
import com.ruoyi.hrm.domain.HrmFlowTask;
@@ -15,6 +16,7 @@ import com.ruoyi.hrm.domain.bo.HrmFlowStartBo;
import com.ruoyi.hrm.domain.bo.HrmFlowInstanceBo;
import com.ruoyi.hrm.domain.vo.HrmFlowInstanceVo;
import com.ruoyi.hrm.domain.vo.HrmFlowTaskVo;
import com.ruoyi.hrm.domain.vo.HrmTravelReqVo;
import com.ruoyi.hrm.mapper.*;
import com.ruoyi.hrm.service.IHrmFlowInstanceService;
import lombok.RequiredArgsConstructor;
@@ -37,6 +39,7 @@ public class HrmFlowInstanceServiceImpl implements IHrmFlowInstanceService {
private final FlowAssigneeHelper assigneeHelper;
private final UserService userService;
private final HrmFlowCcMapper ccMapper;
private final HrmTravelReqMapper travelReqMapper;
@Override
public HrmFlowInstanceVo queryById(Long instId) {
@@ -75,6 +78,7 @@ public class HrmFlowInstanceServiceImpl implements IHrmFlowInstanceService {
task.setNodeId(0L);
task.setAssigneeUserId(bo.getManualAssigneeUserId());
task.setStatus("pending");
task.setRemark("自选审批人一次性审批");
// 关键:写入业务关联字段,便于审批中心联查业务数据
task.setBizType(bo.getBizType());
task.setBizId(bo.getBizId());
@@ -121,6 +125,7 @@ public class HrmFlowInstanceServiceImpl implements IHrmFlowInstanceService {
task.setNodeId(firstNode.getNodeId());
task.setAssigneeUserId(assignees.get(0));
task.setStatus("pending");
task.setRemark(firstNode.getRemark());
// 关键:写入业务关联字段,便于审批中心联查业务数据
task.setBizType(bo.getBizType());
task.setBizId(bo.getBizId());
@@ -140,12 +145,36 @@ public class HrmFlowInstanceServiceImpl implements IHrmFlowInstanceService {
public TableDataInfo<HrmFlowInstanceVo> queryMyInstancePageList(HrmFlowInstanceBo bo, PageQuery pageQuery) {
// “我的申请”= 当前登录用户发起的流程实例
// 这里不信任前端传 startUserId统一以登录态为准
Long userId = com.ruoyi.common.helper.LoginHelper.getUserId();
Long userId = LoginHelper.getUserId();
LambdaQueryWrapper<HrmFlowInstance> lqw = buildQueryWrapper(bo);
lqw.eq(userId != null, HrmFlowInstance::getStartUserId, userId);
// 默认按发起时间倒序如果表里没createTime字段这里可改成instId倒序
lqw.orderByDesc(HrmFlowInstance::getInstId);
Page<HrmFlowInstanceVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
for (HrmFlowInstanceVo record : result.getRecords()) {
// 写入出差相关的时间,用于在页面中可以提前结束
if (record.getBizType().equals("travel")){
HrmTravelReqVo hrmTravelReqVo = travelReqMapper.selectVoById(record.getBizId());
record.setActualEndTime(hrmTravelReqVo.getActualEndTime());
}
}
for (HrmFlowInstanceVo vo : result.getRecords()) {
if ("travel".equals(vo.getBizType())) {
HrmTravelReqVo travel = travelReqMapper.selectVoById(vo.getBizId());
if (travel != null) {
vo.setActualEndTime(travel.getActualEndTime());
// 只有流程已完成,才替换显示文字
if ("complete".equals(vo.getStatus())) {
if (travel.getActualEndTime() == null) {
vo.setStatusName("出差中");
} else {
vo.setStatusName("已结束");
}
}
}
}
}
return TableDataInfo.build(result);
}

View File

@@ -12,11 +12,15 @@ import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.hrm.domain.*;
import com.ruoyi.hrm.domain.bo.HrmFlowTaskBo;
import com.ruoyi.hrm.domain.bo.HrmSealStampBo;
import com.ruoyi.hrm.domain.vo.HrmFlowActionTimelineVo;
import com.ruoyi.hrm.domain.vo.HrmFlowTaskDetailVo;
import com.ruoyi.hrm.domain.vo.HrmFlowTaskVo;
import com.ruoyi.hrm.domain.vo.HrmEmployeeVo;
import com.ruoyi.hrm.mapper.*;
import com.ruoyi.hrm.service.IHrmFlowTaskService;
import com.ruoyi.hrm.service.IHrmSealReqService;
import com.ruoyi.hrm.service.IHrmFlowCcService;
import com.ruoyi.hrm.service.IHrmEmployeeService;
import com.ruoyi.hrm.domain.bo.HrmFlowCcBo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@@ -38,7 +42,6 @@ public class HrmFlowTaskServiceImpl implements IHrmFlowTaskService {
private final FlowAssigneeHelper assigneeHelper;
private final BizStatusSyncHelper bizStatusSyncHelper;
private final HrmFlowTaskMapper hrmFlowTaskMapper;
// 注入五个业务Mapper
private final HrmLeaveReqMapper leaveReqMapper;
private final HrmTravelReqMapper travelReqMapper;
@@ -47,6 +50,7 @@ public class HrmFlowTaskServiceImpl implements IHrmFlowTaskService {
private final HrmAppropriationReqMapper appropriationReqMapper;
private final ObjectMapper objectMapper; // Spring Boot 默认提供
private final UserService userService;
private final IHrmEmployeeService employeeService;
@Override
public HrmFlowTaskVo queryById(Long taskId) {
@@ -74,7 +78,7 @@ public class HrmFlowTaskServiceImpl implements IHrmFlowTaskService {
return tasks;
}
private void fillBizData(List<HrmFlowTaskVo> tasks) {
private void fillBizData(List<HrmFlowTaskVo> tasks) {
// 1. 按 bizType 分组,并收集 bizId
Map<String, List<Long>> bizIdsByType = tasks.stream()
.filter(t -> t.getBizType() != null && t.getBizId() != null)
@@ -90,19 +94,39 @@ public class HrmFlowTaskServiceImpl implements IHrmFlowTaskService {
if (bizIds.isEmpty()) return;
switch (bizType) {
case "leave":
leaveReqMapper.selectBatchIds(bizIds).forEach(d -> bizDataMap.put("leave_" + d.getBizId(), d));
leaveReqMapper.selectBatchIds(bizIds).forEach(d -> {
Map<String, Object> dataMap = objectMapper.convertValue(d, Map.class);
fillEmpName(dataMap, d.getEmpId());
bizDataMap.put("leave_" + d.getBizId(), dataMap);
});
break;
case "travel":
travelReqMapper.selectBatchIds(bizIds).forEach(d -> bizDataMap.put("travel_" + d.getBizId(), d));
travelReqMapper.selectBatchIds(bizIds).forEach(d -> {
Map<String, Object> dataMap = objectMapper.convertValue(d, Map.class);
fillEmpName(dataMap, d.getEmpId());
bizDataMap.put("travel_" + d.getBizId(), dataMap);
});
break;
case "seal":
sealReqMapper.selectBatchIds(bizIds).forEach(d -> bizDataMap.put("seal_" + d.getBizId(), d));
sealReqMapper.selectBatchIds(bizIds).forEach(d -> {
Map<String, Object> dataMap = objectMapper.convertValue(d, Map.class);
fillEmpName(dataMap, d.getEmpId());
bizDataMap.put("seal_" + d.getBizId(), dataMap);
});
break;
case "reimburse":
reimburseReqMapper.selectBatchIds(bizIds).forEach(d -> bizDataMap.put("reimburse_" + d.getBizId(), d));
reimburseReqMapper.selectBatchIds(bizIds).forEach(d -> {
Map<String, Object> dataMap = objectMapper.convertValue(d, Map.class);
fillEmpName(dataMap, d.getEmpId());
bizDataMap.put("reimburse_" + d.getBizId(), dataMap);
});
break;
case "appropriation":
appropriationReqMapper.selectBatchIds(bizIds).forEach(d -> bizDataMap.put("appropriation_" + d.getBizId(), d));
appropriationReqMapper.selectBatchIds(bizIds).forEach(d -> {
Map<String, Object> dataMap = objectMapper.convertValue(d, Map.class);
fillEmpName(dataMap, d.getEmpId());
bizDataMap.put("appropriation_" + d.getBizId(), dataMap);
});
break;
}
});
@@ -112,13 +136,20 @@ public class HrmFlowTaskServiceImpl implements IHrmFlowTaskService {
String key = task.getBizType() + "_" + task.getBizId();
Object data = bizDataMap.get(key);
if (data != null) {
// 将实体对象转换为 Map<String, Object>,方便前端使用
Map<String, Object> dataMap = objectMapper.convertValue(data, Map.class);
task.setBizData(dataMap);
task.setBizData((Map<String, Object>) data);
}
});
}
private void fillEmpName(Map<String, Object> dataMap, Long empId) {
if (empId != null) {
HrmEmployeeVo emp = employeeService.queryById(empId);
if (emp != null && emp.getEmpName() != null) {
dataMap.put("empName", emp.getEmpName());
}
}
}
@Override
@Transactional(rollbackFor = Exception.class)
@@ -155,12 +186,13 @@ public class HrmFlowTaskServiceImpl implements IHrmFlowTaskService {
if (inst == null) {
return false;
}
Long operatorUserId = actionUserId != null ? actionUserId : LoginHelper.getUserId();
// 无模板一次性审批tplId=0 或 nodeId=0直接结束流程
if (inst.getTplId() != null && inst.getTplId() == 0L) {
// 记录动作
saveAction(taskId, inst.getInstId(), "approve", remark, actionUserId,task.getBizType(), task.getBizId());
saveAction(taskId, inst.getInstId(), task.getBizType(), task.getBizId(), task.getAssigneeUserId(), "approve", remark, operatorUserId);
if (stampBo != null) {
saveAction(taskId, inst.getInstId(), "stamp", "盖章", actionUserId,task.getBizType(), task.getBizId());
saveAction(taskId, inst.getInstId(), task.getBizType(), task.getBizId(), task.getAssigneeUserId(), "stamp", "盖章", operatorUserId);
}
task.setStatus("approved");
baseMapper.updateById(task);
@@ -172,7 +204,7 @@ public class HrmFlowTaskServiceImpl implements IHrmFlowTaskService {
sealReqService.updateStatus(inst.getBizId(), "approved");
if (stampBo != null) {
// 盖章动作也写入流转历史
saveAction(taskId, inst.getInstId(), "stamp", "盖章", actionUserId,task.getBizType(), task.getBizId());
saveAction(taskId, inst.getInstId(), task.getBizType(), task.getBizId(), task.getAssigneeUserId(), "stamp", "盖章", operatorUserId);
sealReqService.stampWithJava(inst.getBizId(), stampBo);
}
}
@@ -185,7 +217,7 @@ public class HrmFlowTaskServiceImpl implements IHrmFlowTaskService {
return false;
}
// 记录动作
saveAction(taskId, inst.getInstId(), "approve", remark, actionUserId,task.getBizType(),task.getBizId());
saveAction(taskId, inst.getInstId(), task.getBizType(), task.getBizId(), task.getAssigneeUserId(), "approve", remark, operatorUserId);
// 完成当前任务
task.setStatus("approved");
baseMapper.updateById(task);
@@ -269,7 +301,8 @@ public class HrmFlowTaskServiceImpl implements IHrmFlowTaskService {
if (inst == null) {
return false;
}
saveAction(taskId, inst.getInstId(), "reject", remark, actionUserId,task.getBizType(),task.getBizId());
Long operatorUserId = actionUserId != null ? actionUserId : LoginHelper.getUserId();
saveAction(taskId, inst.getInstId(), task.getBizType(), task.getBizId(), task.getAssigneeUserId(), "reject", remark, operatorUserId);
task.setStatus("rejected");
baseMapper.updateById(task);
inst.setStatus("rejected");
@@ -293,7 +326,8 @@ public class HrmFlowTaskServiceImpl implements IHrmFlowTaskService {
if (inst == null) {
return false;
}
saveAction(taskId, inst.getInstId(), "withdraw", remark, actionUserId, task.getBizType(), task.getBizId());
Long operatorUserId = actionUserId != null ? actionUserId : LoginHelper.getUserId();
saveAction(taskId, inst.getInstId(), task.getBizType(), task.getBizId(), task.getAssigneeUserId(), "withdraw", remark, operatorUserId);
task.setStatus("withdraw");
baseMapper.updateById(task);
// 无模板一次性审批:撤回后业务回到 pending并重新生成一个待办仍然只允许一次审批
@@ -330,13 +364,13 @@ public class HrmFlowTaskServiceImpl implements IHrmFlowTaskService {
return true;
}
private void saveAction(Long taskId, Long instId, String action, String remark, Long userId, String bizType, Long bizId) {
private void saveAction(Long taskId, Long instId, String bizType, Long bizId, Long assigneeUserId, String action, String remark, Long actionUserId) {
HrmFlowAction log = new HrmFlowAction();
log.setTaskId(taskId);
log.setInstId(instId);
log.setAction(action);
log.setRemark(remark);
log.setActionUserId(userId);
log.setActionUserId(actionUserId);
log.setCreateTime(new Date());
log.setBizType(bizType);
log.setBizId(bizId);
@@ -358,7 +392,8 @@ public class HrmFlowTaskServiceImpl implements IHrmFlowTaskService {
return false;
}
// 记录动作
saveAction(taskId, inst.getInstId(), "transfer", remark, actionUserId, task.getBizType(), task.getBizId());
Long operatorUserId = actionUserId != null ? actionUserId : LoginHelper.getUserId();
saveAction(taskId, inst.getInstId(), task.getBizType(), task.getBizId(), newAssigneeUserId, "transfer", remark, operatorUserId);
// 更新办理人
HrmFlowTask u = new HrmFlowTask();
@@ -369,7 +404,6 @@ public class HrmFlowTaskServiceImpl implements IHrmFlowTaskService {
@Override
public HrmFlowTaskVo queryTodoByBiz(String bizType, Long bizId, Long assigneeUserId) {
// 只取"待办 pending"的一条(理论上同一 biz 同一时刻最多一条待办)
LambdaQueryWrapper<HrmFlowTask> lqw = Wrappers.<HrmFlowTask>lambdaQuery()
.eq(bizType != null, HrmFlowTask::getBizType, bizType)
.eq(bizId != null, HrmFlowTask::getBizId, bizId)
@@ -378,12 +412,118 @@ public class HrmFlowTaskServiceImpl implements IHrmFlowTaskService {
.orderByDesc(HrmFlowTask::getTaskId)
.last("limit 1");
HrmFlowTaskVo hrmFlowTaskVo = baseMapper.selectVoOne(lqw);
if (hrmFlowTaskVo != null) {
if (hrmFlowTaskVo != null && hrmFlowTaskVo.getAssigneeUserId() != null) {
hrmFlowTaskVo.setAssigneeNickName(userService.selectNickNameById(hrmFlowTaskVo.getAssigneeUserId()));
}
return hrmFlowTaskVo;
}
@Override
public HrmFlowTaskDetailVo queryDetailByBiz(String bizType, Long bizId, Long assigneeUserId) {
HrmFlowTaskDetailVo result = new HrmFlowTaskDetailVo();
HrmFlowTaskVo currentTask = queryTodoByBiz(bizType, bizId, assigneeUserId);
result.setCurrentTask(currentTask);
LambdaQueryWrapper<HrmFlowTask> historyQ = Wrappers.<HrmFlowTask>lambdaQuery()
.eq(bizType != null, HrmFlowTask::getBizType, bizType)
.eq(bizId != null, HrmFlowTask::getBizId, bizId)
.orderByAsc(HrmFlowTask::getCreateTime);
List<HrmFlowTaskVo> histories = baseMapper.selectVoList(historyQ);
if (histories != null) {
histories.forEach(task -> {
if (task.getAssigneeUserId() != null) {
task.setAssigneeNickName(userService.selectNickNameById(task.getAssigneeUserId()));
}
});
}
result.setTaskHistory(histories == null ? Collections.emptyList() : histories);
HrmFlowInstance inst = instanceMapper.selectOne(Wrappers.<HrmFlowInstance>lambdaQuery()
.eq(bizType != null, HrmFlowInstance::getBizType, bizType)
.eq(bizId != null, HrmFlowInstance::getBizId, bizId)
.orderByDesc(HrmFlowInstance::getInstId)
.last("limit 1"));
if (inst != null) {
result.setFlowStatus(inst.getStatus());
result.setCurrentNodeId(inst.getCurrentNodeId());
HrmFlowNode node = inst.getCurrentNodeId() == null ? null : nodeMapper.selectById(inst.getCurrentNodeId());
if (node != null) {
result.setCurrentNodeName(node.getRemark());
}
result.setApproved(Boolean.valueOf("approved".equalsIgnoreCase(inst.getStatus())));
}
result.setActionTimeline(buildActionTimeline(bizType, bizId));
return result;
}
private List<HrmFlowActionTimelineVo> buildActionTimeline(String bizType, Long bizId) {
LambdaQueryWrapper<HrmFlowAction> actionQ = Wrappers.<HrmFlowAction>lambdaQuery()
.eq(bizType != null, HrmFlowAction::getBizType, bizType)
.eq(bizId != null, HrmFlowAction::getBizId, bizId)
.orderByAsc(HrmFlowAction::getCreateTime);
List<HrmFlowAction> actions = actionMapper.selectList(actionQ);
if (actions == null || actions.isEmpty()) {
return Collections.emptyList();
}
Map<Long, HrmFlowTask> taskMap = new HashMap<>();
List<Long> taskIds = actions.stream().map(HrmFlowAction::getTaskId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
if (!taskIds.isEmpty()) {
baseMapper.selectBatchIds(taskIds).forEach(task -> taskMap.put(task.getTaskId(), task));
}
List<HrmFlowActionTimelineVo> timelines = new ArrayList<HrmFlowActionTimelineVo>();
for (HrmFlowAction action : actions) {
HrmFlowActionTimelineVo vo = new HrmFlowActionTimelineVo();
vo.setActionId(action.getActionId());
vo.setTaskId(action.getTaskId());
vo.setInstId(action.getInstId());
vo.setActionUserId(action.getActionUserId());
vo.setActionUserName(action.getActionUserId() == null ? null : userService.selectNickNameById(action.getActionUserId()));
vo.setAction(action.getAction());
vo.setActionText(actionText(action.getAction()));
vo.setRemark(action.getRemark());
vo.setBizType(action.getBizType());
vo.setBizId(action.getBizId());
HrmFlowTask task = taskMap.get(action.getTaskId());
if (task != null) {
vo.setNodeId(task.getNodeId());
vo.setTaskStatus(task.getStatus());
HrmFlowNode node = task.getNodeId() == null ? null : nodeMapper.selectById(task.getNodeId());
if (node != null) {
vo.setNodeName(node.getRemark());
}
}
vo.setCreateTime(action.getCreateTime());
timelines.add(vo);
}
return timelines;
}
private String actionText(String action) {
if (action == null) {
return "-";
}
String lower = action.toLowerCase();
if ("approve".equals(lower)) {
return "通过";
}
if ("reject".equals(lower)) {
return "驳回";
}
if ("withdraw".equals(lower)) {
return "撤回";
}
if ("transfer".equals(lower)) {
return "转办";
}
if ("stamp".equals(lower)) {
return "盖章";
}
return action;
}
private LambdaQueryWrapper<HrmFlowTask> buildQueryWrapper(HrmFlowTaskBo bo) {
LambdaQueryWrapper<HrmFlowTask> lqw = Wrappers.lambdaQuery();
lqw.eq(bo.getTaskId() != null, HrmFlowTask::getTaskId, bo.getTaskId());
@@ -416,6 +556,11 @@ public class HrmFlowTaskServiceImpl implements IHrmFlowTaskService {
if (result.getRecords() != null && !result.getRecords().isEmpty()) {
fillBizData(result.getRecords());
result.getRecords().forEach(task -> {
if (task.getAssigneeUserId() != null) {
task.setAssigneeNickName(userService.selectNickNameById(task.getAssigneeUserId()));
}
});
}
return TableDataInfo.build(result);

View File

@@ -22,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.Collection;
import java.util.List;
import java.util.Date;
@RequiredArgsConstructor
@Service
@@ -128,4 +129,36 @@ public class HrmTravelReqServiceImpl implements IHrmTravelReqService {
private String defaultStatus(String status) {
return status == null ? "draft" : status;
}
@Override
@Transactional(rollbackFor = Exception.class)
public int earlyEnd(Long bizId) {
HrmTravelReq travelReq = baseMapper.selectById(bizId);
if (travelReq == null) {
throw new RuntimeException("出差申请不存在");
}
String status = travelReq.getStatus();
if (!"approved".equals(status) && !"in_progress".equals(status)) {
throw new RuntimeException("当前状态不能提前结束,只有已通过或进行中的出差才能提前结束");
}
// 3. 检查是否已经提前结束过
if (travelReq.getActualEndTime() != null) {
throw new RuntimeException("该出差已经提前结束过了");
}
// 4. 更新实际结束时间为当前时间
travelReq.setActualEndTime(new Date());
// 5. 可选:更新状态为已完成
travelReq.setStatus("completed");
// 6. 执行更新
int result = baseMapper.updateById(travelReq);
if (result <= 0) {
throw new RuntimeException("提前结束失败");
}
return result;
}
}

View File

@@ -51,12 +51,13 @@
<sql id="selectVo">
SELECT
e.emp_id, e.user_id, e.emp_no, e.emp_name, e.gender, e.mobile, e.email, e.id_no,
e.hire_date, e.employment_type, e.status, e.dept_id, e.post_id, e.remark,
e.hire_date, e.employment_type, e.status, su.dept_id, e.post_id, e.remark,
e.create_by, e.create_time, e.update_by, e.update_time,
d.dept_name,
p.post_name
FROM hrm_employee e
LEFT JOIN sys_dept d ON e.dept_id = d.dept_id AND d.del_flag = '0'
left join sys_user su on su.user_id = e.user_id
LEFT JOIN sys_dept d ON su.dept_id = d.dept_id AND d.del_flag = 0
LEFT JOIN sys_post p ON e.post_id = p.post_id
WHERE e.del_flag = 0
</sql>

View File

@@ -170,6 +170,8 @@ security:
- /oa/attendanceRecord/**
- /oa/oaWarehouse/**
- /oa/oaWarehouseMaster/**
# 高德逆地理(经纬度转城市等,供前端/H5 调用)
- /oa/amap/**
# MyBatisPlus配置
# https://baomidou.com/config/
@@ -317,8 +319,12 @@ flowable:
check-process-definitions: false
# 关闭历史任务定时任务job
async-history-executor-activate: false
fad:
amap:
key: 978ae5bc551f57d172d3e397af5a6f67
# 留作后端接口调用(服务 API的 Key
key: 978ae5bc551f57d172d3e397af5a6f67
# 新增的前端 Web 端使用的 Key 和安全密钥
webKey: 34bf20d1db5b183558b9bb85d6eed783
securityKey: 6f9171724396deb5f8c42ef256b3cbc5

View File

@@ -2,13 +2,20 @@ package com.ruoyi.framework.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
@Configuration
public class RestTemplateConfig {
private static final int CONNECT_TIMEOUT_MS = 5_000;
private static final int READ_TIMEOUT_MS = 15_000;
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
factory.setConnectTimeout(CONNECT_TIMEOUT_MS);
factory.setReadTimeout(READ_TIMEOUT_MS);
return new RestTemplate(factory);
}
}

View File

@@ -0,0 +1,46 @@
package com.ruoyi.oa.controller;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.oa.domain.vo.AmapCityNameVo;
import com.ruoyi.oa.service.IOaAmapGeocodeService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.DecimalMax;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotNull;
/**
* 高德地图:经纬度逆地理编码(城市名等)
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/oa/amap")
public class OaAmapController extends BaseController {
private final IOaAmapGeocodeService oaAmapGeocodeService;
/**
* 根据经纬度获取城市名称(高德逆地理编码)
*/
@GetMapping("/city")
public R<AmapCityNameVo> cityByLocation(
@NotNull(message = "经度不能为空")
@DecimalMin(value = "-180.0", message = "经度范围无效")
@DecimalMax(value = "180.0", message = "经度范围无效")
@RequestParam Double longitude,
@NotNull(message = "纬度不能为空")
@DecimalMin(value = "-90.0", message = "纬度范围无效")
@DecimalMax(value = "90.0", message = "纬度范围无效")
@RequestParam Double latitude
) {
AmapCityNameVo vo = oaAmapGeocodeService.reverseGeocodeCity(longitude, latitude);
return R.ok(vo);
}
}

View File

@@ -0,0 +1,62 @@
package com.ruoyi.oa.controller;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.oa.domain.bo.OaCityBo;
import com.ruoyi.oa.domain.vo.OaCityVo;
import com.ruoyi.oa.service.IOaCityService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;
@RequiredArgsConstructor
@RestController
@RequestMapping("/oa/city")
@Validated
public class OaCityController extends BaseController {
private final IOaCityService cityService;
@GetMapping("/list")
public TableDataInfo<OaCityVo> list(OaCityBo bo, PageQuery pageQuery) {
return cityService.queryPageList(bo, pageQuery);
}
@GetMapping("/{cityId}")
public R<OaCityVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable Long cityId) {
return R.ok(cityService.queryById(cityId));
}
@Log(title = "城市管理", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping
public R<Void> add(@Validated(AddGroup.class) @RequestBody OaCityBo bo) {
return toAjax(cityService.insertByBo(bo));
}
@Log(title = "城市管理", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping
public R<Void> edit(@Validated(EditGroup.class) @RequestBody OaCityBo bo) {
return toAjax(cityService.updateByBo(bo));
}
@Log(title = "城市管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{cityIds}")
public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] cityIds) {
return toAjax(cityService.deleteWithValidByIds(Arrays.asList(cityIds), true));
}
}

View File

@@ -0,0 +1,49 @@
package com.ruoyi.oa.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.common.core.domain.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 城市管理对象 oa_city
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("oa_city")
public class OaCity extends BaseEntity {
private static final long serialVersionUID = 1L;
@TableId(value = "city_id")
private Long cityId;
/** 国家 */
private String countryName;
/** 城市 */
private String cityName;
/**
* 城市编码
*/
private String cityCode;
/**
* 所属省份
*/
private String provinceName;
/** 状态 1正常 0禁用 */
private Long status;
/** 备注 */
private String remark;
@TableLogic
private Integer delFlag;
}

View File

@@ -0,0 +1,29 @@
package com.ruoyi.oa.domain.bo;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* 城市管理业务对象 oa_city
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class OaCityBo extends BaseEntity {
private Long cityId;
@NotBlank(message = "国家不能为空")
private String countryName;
@NotBlank(message = "城市不能为空")
private String cityName;
private Long status;
private String cityCode;
private String provinceName;
private String remark;
}

View File

@@ -0,0 +1,23 @@
package com.ruoyi.oa.domain.vo;
import lombok.Data;
import java.io.Serializable;
/**
* 高德逆地理编码:城市名称(及可选行政区信息,便于展示/调试)
*/
@Data
public class AmapCityNameVo implements Serializable {
private static final long serialVersionUID = 1L;
/** 城市名(直辖市、省直辖等场景可能为省名或区名,与高德 addressComponent 一致) */
private String cityName;
/** 省 */
private String province;
/** 区/县 */
private String district;
}

View File

@@ -0,0 +1,27 @@
package com.ruoyi.oa.domain.vo;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 城市管理视图对象 oa_city
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class OaCityVo extends BaseEntity {
private Long cityId;
private String countryName;
private String cityName;
private Long status;
private String remark;
/** 城市编码 */
private String cityCode;
/** 所属省份 */
private String provinceName;
}

View File

@@ -0,0 +1,11 @@
package com.ruoyi.oa.mapper;
import com.ruoyi.common.core.mapper.BaseMapperPlus;
import com.ruoyi.oa.domain.OaCity;
import com.ruoyi.oa.domain.vo.OaCityVo;
/**
* 城市管理 Mapper
*/
public interface OaCityMapper extends BaseMapperPlus<OaCityMapper, OaCity, OaCityVo> {
}

View File

@@ -0,0 +1,18 @@
package com.ruoyi.oa.service;
import com.ruoyi.oa.domain.vo.AmapCityNameVo;
/**
* 高德地图逆地理编码(经纬度 → 城市等)
*/
public interface IOaAmapGeocodeService {
/**
* 根据经纬度解析城市名称等信息
*
* @param longitude 经度
* @param latitude 纬度
* @return 非 null解析失败时 cityName 等可能为空
*/
AmapCityNameVo reverseGeocodeCity(Double longitude, Double latitude);
}

View File

@@ -0,0 +1,24 @@
package com.ruoyi.oa.service;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.oa.domain.bo.OaCityBo;
import com.ruoyi.oa.domain.vo.OaCityVo;
import java.util.Collection;
import java.util.List;
public interface IOaCityService {
OaCityVo queryById(Long cityId);
TableDataInfo<OaCityVo> queryPageList(OaCityBo bo, PageQuery pageQuery);
List<OaCityVo> queryList(OaCityBo bo);
Boolean insertByBo(OaCityBo bo);
Boolean updateByBo(OaCityBo bo);
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
}

View File

@@ -0,0 +1,118 @@
package com.ruoyi.oa.service.impl;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.oa.domain.vo.AmapCityNameVo;
import com.ruoyi.oa.service.IOaAmapGeocodeService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;
/**
* 高德逆地理编码restapi.amap.com/v3/geocode/regeo
* <p>
* 配置项:{@code fad.amap.key}(与 {@code application.yml} 中一致)
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class OaAmapGeocodeServiceImpl implements IOaAmapGeocodeService {
private static final String AMAP_REGEO_URL = "https://restapi.amap.com/v3/geocode/regeo";
private final RestTemplate restTemplate;
@Value("${fad.amap.key:}")
private String amapKey;
@Override
public AmapCityNameVo reverseGeocodeCity(Double longitude, Double latitude) {
AmapCityNameVo vo = new AmapCityNameVo();
if (longitude == null || latitude == null) {
return vo;
}
if (!StringUtils.hasText(amapKey)) {
log.warn("fad.amap.key 未配置,无法调用高德逆地理编码");
return vo;
}
try {
// 高德要求location = 经度,纬度
String location = longitude + "," + latitude;
String url = UriComponentsBuilder.fromHttpUrl(AMAP_REGEO_URL)
.queryParam("key", amapKey)
.queryParam("location", location)
.queryParam("extensions", "base")
.queryParam("batch", "false")
.queryParam("output", "JSON")
.build(true)
.toUriString();
String body = restTemplate.getForObject(url, String.class);
if (!StringUtils.hasText(body)) {
log.warn("高德逆地理编码响应为空, location={}", location);
return vo;
}
JSONObject response = JSONObject.parseObject(body);
if (response == null) {
log.warn("高德逆地理编码 JSON 解析失败, location={}", location);
return vo;
}
if (!"1".equals(response.getString("status"))) {
String info = response.getString("info");
log.warn("高德逆地理编码失败: status={}, info={}, infocode={}",
response.getString("status"), info, response.getString("infocode"));
return vo;
}
JSONObject regeocode = response.getJSONObject("regeocode");
if (regeocode == null) {
return vo;
}
JSONObject addressComponent = regeocode.getJSONObject("addressComponent");
if (addressComponent == null) {
return vo;
}
String province = nullToEmpty(addressComponent.getString("province"));
String district = nullToEmpty(addressComponent.getString("district"));
vo.setProvince(province);
vo.setDistrict(district);
String cityName = resolveCityName(addressComponent, province);
vo.setCityName(cityName);
return vo;
} catch (Exception e) {
log.warn("高德逆地理编码异常, longitude={}, latitude={}, err={}",
longitude, latitude, e.getMessage(), e);
return vo;
}
}
/**
* 城市字段:普通城市为字符串;部分省直辖为 [];直辖市可能用省名表示
*/
private static String resolveCityName(JSONObject addressComponent, String province) {
Object cityRaw = addressComponent.get("city");
if (cityRaw instanceof JSONArray) {
JSONArray arr = (JSONArray) cityRaw;
if (!arr.isEmpty()) {
return nullToEmpty(arr.getString(0));
}
return province;
}
String city = addressComponent.getString("city");
if (StringUtils.hasText(city) && !"[]".equals(city)) {
return city.trim();
}
return province;
}
private static String nullToEmpty(String s) {
return s == null ? "" : s.trim();
}
}

View File

@@ -0,0 +1,73 @@
package com.ruoyi.oa.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.oa.domain.OaCity;
import com.ruoyi.oa.domain.bo.OaCityBo;
import com.ruoyi.oa.domain.vo.OaCityVo;
import com.ruoyi.oa.mapper.OaCityMapper;
import com.ruoyi.oa.service.IOaCityService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List;
@RequiredArgsConstructor
@Service
public class OaCityServiceImpl implements IOaCityService {
private final OaCityMapper baseMapper;
@Override
public OaCityVo queryById(Long cityId) {
return baseMapper.selectVoById(cityId);
}
@Override
public TableDataInfo<OaCityVo> queryPageList(OaCityBo bo, PageQuery pageQuery) {
IPage<OaCityVo> page = baseMapper.selectVoPage(pageQuery.build(), buildQueryWrapper(bo));
TableDataInfo<OaCityVo> tableDataInfo = new TableDataInfo<>(page.getRecords(), page.getTotal());
return tableDataInfo;
}
@Override
public List<OaCityVo> queryList(OaCityBo bo) {
return baseMapper.selectVoList(buildQueryWrapper(bo));
}
@Override
public Boolean insertByBo(OaCityBo bo) {
OaCity add = BeanUtil.toBean(bo, OaCity.class);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setCityId(add.getCityId());
}
return flag;
}
@Override
public Boolean updateByBo(OaCityBo bo) {
OaCity update = BeanUtil.toBean(bo, OaCity.class);
return baseMapper.updateById(update) > 0;
}
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
return baseMapper.deleteBatchIds(ids) > 0;
}
private LambdaQueryWrapper<OaCity> buildQueryWrapper(OaCityBo bo) {
LambdaQueryWrapper<OaCity> lqw = Wrappers.lambdaQuery();
lqw.like(StringUtils.isNotBlank(bo.getCountryName()), OaCity::getCountryName, bo.getCountryName());
lqw.like(StringUtils.isNotBlank(bo.getCityName()), OaCity::getCityName, bo.getCityName());
lqw.eq(bo.getStatus() != null, OaCity::getStatus, bo.getStatus());
lqw.orderByDesc(OaCity::getCreateTime);
return lqw;
}
}

View File

@@ -154,6 +154,7 @@ public class OaProjectScheduleStepServiceImpl implements IOaProjectScheduleStepS
/** 步骤表公共筛选(与 oa_project_schedule 联表时须使用别名 opss */
private void appendCommonStepFilters (QueryWrapper<OaProjectScheduleStep> lqw, OaProjectScheduleStepBo bo, String alias) {
lqw.eq(stepCol(alias, "del_flag"), 0);
lqw.eq(bo.getScheduleId() != null, stepCol(alias, "schedule_id"), bo.getScheduleId());
lqw.eq(bo.getStepOrder() != null, stepCol(alias, "step_order"), bo.getStepOrder());
lqw.like(StringUtils.isNotBlank(bo.getStepName()), stepCol(alias, "step_name"), bo.getStepName());

View File

@@ -5,7 +5,7 @@ VUE_APP_TITLE = 福安德综合办公系统
ENV = 'development'
# 若依管理系统/开发环境
VUE_APP_BASE_API = '/dev-api'
VUE_APP_BASE_API = '/dev-api'
# VUE_APP_BASE_API = 'http://110.41.139.73:8080'
# 应用访问路径 例如使用前缀 /admin/

View File

@@ -37,6 +37,7 @@
"url": "https://gitee.com/KonBAI-Q/ruoyi-flowable-plus.git"
},
"dependencies": {
"@amap/amap-jsapi-loader": "^1.0.1",
"@babel/parser": "7.7.4",
"@handsontable/vue": "^15.3.0",
"@jiaminghi/data-view": "^2.10.0",

View File

@@ -10,6 +10,7 @@
<title>
<%= webpackConfig.name %>
</title>
<!--[if lt IE 11]><script>window.location.href='/html/ie.html';</script><![endif]-->
<style>
html,
@@ -18,7 +19,7 @@
height: 100%;
margin: 0px;
padding: 0px;
}
.chromeframe {
margin: 0.2em 0;
@@ -216,4 +217,4 @@
</div>
</body>
</html>
</html>

View File

@@ -254,9 +254,4 @@ export function listAssignTask (instId) {
url: `/hrm/flow/instance/tasks/${instId}`,
method: 'get'
})
/**
* 查询当前用户的审批历史
*/
}

View File

@@ -46,3 +46,22 @@ export function allTravelReq(query) {
params: query
})
}
export function earlyEndTravel(bizId) {
return request({
url: `/hrm/travel/earlyEnd/${bizId}`,
method: 'put'
})
}
export function getAmapKey() {
return request({
url: '/hrm/travel/amapKey',
method: 'get'
})
}
export function getAmapSecurityKey() {
return request({
url: '/hrm/travel/amapSecurityKey',
method: 'get'
})
}

View File

@@ -0,0 +1,15 @@
import request from '@/utils/request'
/**
* 根据经纬度逆地理编码获取城市等信息(后端转发高德)
* @param {number} longitude 经度
* @param {number} latitude 纬度
*/
export function getCityByLocation (longitude, latitude) {
return request({
url: '/oa/amap/city',
method: 'get',
params: { longitude, latitude },
timeout: 15000
})
}

View File

@@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询城市列表
export function listCity(query) {
return request({
url: '/oa/city/list',
method: 'get',
params: query
})
}
// 查询城市详细
export function getCity(cityId) {
return request({
url: `/oa/city/${cityId}`,
method: 'get'
})
}
// 新增城市
export function addCity(data) {
return request({
url: '/oa/city',
method: 'post',
data: data
})
}
// 修改城市
export function updateCity(data) {
return request({
url: '/oa/city',
method: 'put',
data: data
})
}
// 删除城市
export function delCity(cityIds) {
return request({
url: `/oa/city/${cityIds}`,
method: 'delete'
})
}

View File

@@ -0,0 +1,371 @@
<template>
<div class="amap-city-select">
<el-input
v-model="cityName"
:placeholder="placeholder"
@focus="openMapDialog"
clearable
readonly
>
<i slot="prefix" class="el-icon-location" style="color: #409eff"></i>
</el-input>
<el-dialog
title="选择出差城市 / 地点"
:visible.sync="dialogVisible"
width="900px"
:append-to-body="true"
@opened="onDialogOpened"
>
<div class="map-selector">
<div class="city-sidebar">
<div class="search-box">
<el-input
v-model="searchKeyword"
placeholder="输入城市或具体地点搜索"
size="small"
prefix-icon="el-icon-search"
@keyup.enter.native="searchLocation"
clearable
@clear="searchKeyword = ''"
>
<el-button slot="append" @click="searchLocation">搜索</el-button>
</el-input>
</div>
<!-- 热门城市模块 -->
<div class="hot-cities" v-if="!searchKeyword || searchResults.length === 0">
<div class="section-title">热门城市</div>
<div class="city-list">
<span
v-for="city in hotCities"
:key="city"
class="city-item"
@click="selectHotCity(city)"
>
{{ city }}
</span>
</div>
</div>
<!-- 搜索结果模块 -->
<div class="search-results" v-if="searchResults.length > 0">
<div class="section-title">搜索结果</div>
<div class="result-list">
<div
v-for="(result, index) in searchResults"
:key="index"
class="result-item"
@click="selectLocation(result)"
>
<i class="el-icon-location-outline"></i>
<div class="result-info">
<div class="poi-name">{{ result.name }}</div>
<div class="poi-address">{{ result.address }}</div>
</div>
</div>
</div>
</div>
</div>
<div class="map-container">
<div id="amapContainer" class="amap-wrapper"></div>
<div class="map-tip">
<i class="el-icon-info"></i> 点击地图上的位置或搜索地点自动识别归属城市
</div>
</div>
</div>
<div slot="footer" class="dialog-footer">
<div class="selected-info" v-if="selectedCity">
识别城市<span class="selected-city">{{ selectedCity }}</span>
<span v-if="selectedPoi" style="margin-left: 10px; color: #909399; font-size: 12px;">
( {{ selectedPoi }} )
</span>
</div>
<div v-else></div>
<div>
<el-button @click="closeDialog">取消</el-button>
<el-button type="primary" @click="confirmCity" :disabled="!selectedCity">确定</el-button>
</div>
</div>
</el-dialog>
</div>
</template>
<script>
import AMapLoader from '@amap/amap-jsapi-loader'
import { getAmapKey, getAmapSecurityKey } from '@/api/hrm/travel'
export default {
name: 'AmapCitySelect',
props: {
value: { type: String, default: '' },
placeholder: { type: String, default: '请选择出差地点' }
},
data() {
return {
cityName: '',
dialogVisible: false,
searchKeyword: '',
searchResults: [],
selectedCity: '', // 最终表单需要的城市名
selectedPoi: '', // 具体的地点名(仅用于展示)
map: null,
geocoder: null,
placeSearch: null, // 新增地点搜索对象
marker: null,
AMap: null,
hotCities: [
'北京市', '上海市', '广州市', '深圳市',
'杭州市', '南京市', '成都市', '武汉市',
'重庆市', '天津市', '苏州市', '西安市'
]
}
},
watch: {
value: {
immediate: true,
handler(val) { this.cityName = val || '' }
}
},
methods: {
async onDialogOpened() {
const AMap = await this.loadAMap()
if (!AMap) return
this.$nextTick(() => {
this.initMap()
})
},
async loadAMap() {
if (this.AMap && window._AMapSecurityConfig) return this.AMap
try {
const [keyRes, securityRes] = await Promise.all([getAmapKey(), getAmapSecurityKey()])
const amapkey = keyRes.data || keyRes.msg
const securityKey = securityRes.data || securityRes.msg
if (!amapkey) throw new Error('未获取到高德地图 Key')
window._AMapSecurityConfig = { securityJsCode: securityKey }
this.AMap = await AMapLoader.load({
key: amapkey,
version: '2.0',
// 加入 PlaceSearch 插件
plugins: ['AMap.Geocoder', 'AMap.PlaceSearch']
})
return this.AMap
} catch (error) {
console.error('地图加载失败:', error)
this.$message.error('地图加载失败,请重试')
return null
}
},
initMap() {
const container = document.getElementById('amapContainer')
if (!container) {
setTimeout(() => this.initMap(), 100)
return
}
if (this.map) {
this.map.destroy()
this.map = null
}
this.map = new this.AMap.Map('amapContainer', {
zoom: 12,
center: [116.397428, 39.90923], // 默认北京
resizeEnable: true
})
this.geocoder = new this.AMap.Geocoder()
// 初始化地点搜索插件
this.placeSearch = new this.AMap.PlaceSearch({
pageSize: 15, // 单页显示结果条数
pageIndex: 1, // 页码
autoFitView: false // 禁用自动调整视图,我们自己控制
})
// 监听地图点击
this.map.on('click', (e) => {
const lng = e.lnglat.getLng()
const lat = e.lnglat.getLat()
this.selectedPoi = '地图选点'
this.getCityByLngLat(lng, lat, true)
})
},
// 通过经纬度逆解析城市
getCityByLngLat(lng, lat, setCenter = false) {
this.geocoder.getAddress([lng, lat], (status, result) => {
if (status === 'complete' && result.regeocode) {
const addrComp = result.regeocode.addressComponent
let city = addrComp.city
// 直辖市的 city 可能是空的,取 province
if (!city || city === '[]' || city.length === 0) {
city = addrComp.province
}
this.selectedCity = city
this.addMarker(lng, lat)
if(setCenter) {
this.map.setCenter([lng, lat])
}
}
})
},
// 在地图上打点
addMarker(lng, lat) {
if (this.marker) {
this.marker.setMap(null)
}
this.marker = new this.AMap.Marker({
position: [lng, lat],
map: this.map,
animation: 'AMAP_ANIMATION_DROP' // 加上掉落动画
})
},
openMapDialog() {
this.dialogVisible = true
this.selectedCity = this.value || ''
this.selectedPoi = ''
this.searchKeyword = ''
this.searchResults = []
},
// 搜索地点核心方法
async searchLocation() {
if (!this.searchKeyword.trim()) {
this.searchResults = []
return
}
await this.loadAMap()
// 使用 PlaceSearch 搜索具体地点
this.placeSearch.search(this.searchKeyword, (status, result) => {
if (status === 'complete' && result.info === 'OK') {
// 提取返回的 POI 列表
const pois = result.poiList.pois
this.searchResults = pois.map(poi => ({
id: poi.id,
name: poi.name,
address: poi.address && typeof poi.address === 'string' ? poi.address : poi.adname,
location: poi.location, // 包含 lng/lat 的对象
city: poi.cityname || poi.pname // 城市名
}))
} else {
this.searchResults = []
this.$message.info('未找到相关地点,请尝试更换关键词')
}
})
},
// 选中左侧搜索结果列表的具体地点
selectLocation(poi) {
if (!poi.location) {
this.$message.warning('该地点缺少坐标信息')
return
}
const lng = poi.location.lng
const lat = poi.location.lat
// 设置地图中心点并放大(层级15看街道)
this.map.setZoomAndCenter(15, [lng, lat])
this.addMarker(lng, lat)
// 更新选择数据
this.selectedCity = poi.city
this.selectedPoi = poi.name
this.$message.success(`已定位到:${poi.name}`)
},
// 选中热门城市
async selectHotCity(city) {
await this.loadAMap()
this.selectedCity = city
this.selectedPoi = city
// 获取城市中心点坐标
this.geocoder.getLocation(city, (status, result) => {
if (status === 'complete' && result.geocodes.length) {
const loc = result.geocodes[0].location
this.map.setZoomAndCenter(11, [loc.lng, loc.lat])
this.addMarker(loc.lng, loc.lat)
}
})
},
confirmCity() {
if (this.selectedCity) {
this.cityName = this.selectedCity
// 组件 v-model 抛出城市名
this.$emit('input', this.selectedCity)
// 如果你需要具体的地点名,可以额外抛出一个事件
this.$emit('poi-change', { city: this.selectedCity, poi: this.selectedPoi })
this.closeDialog()
}
},
closeDialog() {
this.dialogVisible = false
}
}
}
</script>
<style lang="scss" scoped>
.amap-city-select { width: 100%; }
.map-selector { display: flex; gap: 20px; min-height: 450px;
.city-sidebar { width: 300px; flex-shrink: 0; display: flex; flex-direction: column;
.search-box { margin-bottom: 16px; }
.section-title { font-size: 14px; font-weight: bold; color: #303133; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid #ebeef5; }
.hot-cities .city-list { display: flex; flex-wrap: wrap; gap: 10px;
.city-item { padding: 6px 14px; background: #f4f4f5; color: #606266; border-radius: 4px; font-size: 13px; cursor: pointer; transition: all 0.2s;
&:hover { background: #409eff; color: white; }
}
}
/* 搜索结果列表样式升级 */
.search-results {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
}
.result-list {
flex: 1; overflow-y: auto; padding-right: 5px;
/* 自定义滚动条 */
&::-webkit-scrollbar { width: 4px; }
&::-webkit-scrollbar-thumb { background: #dcdfe6; border-radius: 4px; }
.result-item {
padding: 12px 10px; cursor: pointer; display: flex; align-items: flex-start; gap: 10px; border-bottom: 1px solid #ebeef5; transition: background 0.2s;
&:hover { background: #f0f7ff; }
i { color: #409eff; margin-top: 3px; font-size: 16px; }
.result-info {
flex: 1; overflow: hidden;
.poi-name { font-size: 14px; color: #303133; font-weight: 500; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.poi-address { font-size: 12px; color: #909399; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
}
}
}
.map-container { flex: 1; display: flex; flex-direction: column;
.amap-wrapper { flex: 1; width: 100%; border: 1px solid #dcdfe6; border-radius: 6px; overflow: hidden; }
.map-tip { margin-top: 10px; font-size: 12px; color: #909399; text-align: center; i { margin-right: 4px; color: #e6a23c; } }
}
}
.dialog-footer { display: flex; justify-content: space-between; align-items: center;
.selected-info { font-size: 14px; color: #606266; .selected-city { color: #409eff; font-weight: bold; font-size: 15px; } }
}
</style>

View File

@@ -182,6 +182,7 @@ export const constantRoutes = [
];
export const dynamicRoutes = [
{
path: "/system/user-auth",
component: Layout,
@@ -314,6 +315,7 @@ export const dynamicRoutes = [
},
],
},
];
let routerPush = Router.prototype.push;

View File

@@ -0,0 +1,98 @@
import { getCityByLocation } from '@/api/oa/amap'
const GEO_OPTIONS = {
enableHighAccuracy: false,
timeout: 20000,
maximumAge: 120000
}
export const EMPTY_GEOCODE = 'EMPTY_GEOCODE'
/**
* 将 AmapCityNameVo 格式化为展示用工作地点字符串
*/
export function formatWorkPlaceFromAmap (vo) {
if (!vo) {
return ''
}
const province = (vo.province || '').trim()
const cityName = (vo.cityName || '').trim()
const district = (vo.district || '').trim()
const parts = []
if (province) {
parts.push(province)
}
if (cityName && cityName !== province) {
parts.push(cityName)
}
if (district) {
parts.push(district)
}
const joined = parts.join(' ').trim()
return joined || cityName || province || ''
}
function getCurrentPositionAsync () {
return new Promise((resolve, reject) => {
if (typeof navigator === 'undefined' || !navigator.geolocation) {
reject(new Error('BROWSER_UNSUPPORTED'))
return
}
navigator.geolocation.getCurrentPosition(
position => resolve(position),
err => reject(err),
GEO_OPTIONS
)
})
}
/**
* 浏览器定位 + 后端逆地理 → 工作地点字符串
* @returns {Promise<string>}
*/
export async function resolveWorkPlaceFromBrowser () {
const position = await getCurrentPositionAsync()
const { longitude, latitude } = position.coords
const res = await getCityByLocation(longitude, latitude)
const vo = res && res.data
const text = formatWorkPlaceFromAmap(vo)
if (!text) {
const err = new Error(EMPTY_GEOCODE)
console.warn('[workPlace] 逆地理结果为空', { longitude, latitude, vo })
throw err
}
return text
}
/**
* 将定位/逆地理错误转换为用户可读文案
*/
export function geolocationUserMessage (err) {
if (!err) {
return '获取工作地点失败'
}
if (err.message === 'BROWSER_UNSUPPORTED') {
return '当前浏览器不支持定位,请更换浏览器或使用 HTTPS 访问后重试'
}
if (err.message === EMPTY_GEOCODE) {
return '无法根据当前位置解析城市请稍后重试若持续失败请联系管理员检查高德地图配置fad.amap.key'
}
const code = err.code
if (code === 1) {
return '您已拒绝定位权限,请在浏览器设置中允许本站点定位后点击「重新获取定位」'
}
if (code === 2) {
return '暂时无法获取位置信息,请到信号较好处点击「重新获取定位」重试'
}
if (code === 3) {
return '定位请求超时,请检查网络后点击「重新获取定位」重试'
}
const msg = err.message || ''
if (msg.includes('timeout') || msg.includes('超时')) {
return '接口请求超时,请稍后点击「重新获取定位」重试'
}
if (msg.includes('Network Error') || msg.includes('网络')) {
return '网络异常,请检查连接后点击「重新获取定位」重试'
}
return '获取工作地点失败,请点击「重新获取定位」重试'
}

View File

@@ -65,8 +65,8 @@
</el-row>
<el-form-item label="目的地" prop="destination">
<el-input v-model="form.destination" placeholder="城市/地址/项目现场" />
<div class="hint-text">填写具体目的地便于审批人判断出差必要性</div>
<amap-city-select v-model="form.destination" placeholder="请选择出差城市" />
<div class="hint-text">通过地图或搜索选择具体城市便于审批人判断出差必要性</div>
</el-form-item>
<div class="block-title">出差说明</div>
@@ -223,13 +223,15 @@ import { ccFlowTask, listFlowNode, listFlowTemplate } from '@/api/hrm/flow'
import FileUpload from '@/components/FileUpload'
import UserMultiSelect from '@/components/UserSelect/multi.vue'
import UserSelect from '@/components/UserSelect/single.vue'
import AmapCitySelect from '@/components/AmapCitySelect/index.vue'
export default {
name: 'HrmTravelRequest',
components: {
UserSelect,
FileUpload,
UserMultiSelect
UserMultiSelect,
AmapCitySelect
},
data () {
return {

View File

@@ -2,6 +2,30 @@
<BizDetailContainer :bizId="currentBizId" bizType="travel" :preview="preview">
<template slot-scope="{ detail }">
<div>
<!-- ===== 新增提前结束按钮区域 ===== -->
<div class="action-buttons" v-if="showEarlyEndButton(detail)">
<el-button
type="warning"
size="small"
icon="el-icon-finished"
:loading="earlyEndLoading"
@click="handleEarlyEnd"
>
提前结束
</el-button>
<span class="hint-text">提前结束将把当前时间记录为实际结束时间</span>
</div>
<!-- ===== 新增显示已提前结束的信息 ===== -->
<div v-if="detail.actualEndTime" class="early-end-info">
<el-alert
type="info"
:closable="false"
show-icon>
<template slot="default">
该出差已于 {{ formatDate(detail.actualEndTime) }} 提前结束
</template>
</el-alert>
</div>
<!-- 出差时间与行程 -->
<div class="block-title">出差时间与行程</div>
<el-card class="inner-card" shadow="never">
@@ -41,6 +65,7 @@
<script>
import FilePreview from "@/components/FilePreview/index.vue";
import BizDetailContainer from '@/views/hrm/components/BizDetailContainer/index.vue';
import { earlyEndTravel } from '@/api/hrm/travel'
export default {
name: 'TravelDetail',
@@ -53,7 +78,11 @@ export default {
BizDetailContainer,
FilePreview
},
name: 'HrmTravelDetail',
data() {
return {
earlyEndLoading: false
}
},
computed: {
currentBizId () {
return this.bizId || this.$route?.params?.bizId || this.$route?.query?.bizId || this.$route?.params?.id
@@ -66,7 +95,41 @@ export default {
const p = n => (n < 10 ? `0${n}` : n)
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`
},
// 新增:处理提前结束
showEarlyEndButton(detail) {
if (!detail) return false
// 已经提前结束的不显示
if (detail.actualEndTime) return false
// 只有已通过或进行中状态才显示
const status = detail.status
return status === 'approved' || status === 'in_progress'
},
handleEarlyEnd() {
this.$confirm('确认提前结束本次出差吗?结束后的实际时间将记录为当前时间。', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async () => {
this.earlyEndLoading = true
try {
const bizId = this.currentBizId
await earlyEndTravel(bizId)
this.$message.success('提前结束成功')
// 刷新页面
setTimeout(() => {
location.reload()
}, 1000)
} catch (error) {
this.$message.error(error.message || '提前结束失败')
} finally {
this.earlyEndLoading = false
}
}).catch(() => {})
},
}
}
</script>
@@ -375,4 +438,17 @@ export default {
display: none;
}
}
.action-buttons {
margin-bottom: 16px;
padding: 12px;
background: #fdf6ec;
border-radius: 8px;
display: flex;
align-items: center;
gap: 12px;
}
.early-end-info {
margin-bottom: 16px;
}
</style>

View File

@@ -0,0 +1,204 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
<el-form-item label="城市名称" prop="cityName">
<el-input
v-model="queryParams.cityName"
placeholder="请输入城市名称"
clearable
style="width: 200px"
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete">删除</el-button>
</el-col>
</el-row>
<!-- 表格取消所有固定宽度100%自适应铺满容器 -->
<el-table
v-loading="loading"
:data="cityList"
@selection-change="handleSelectionChange"
border stripe
style="width: 100%"
>
<el-table-column type="selection" align="center" />
<el-table-column label="序号" type="index" align="center" />
<el-table-column prop="cityCode" label="城市编码" align="center" />
<el-table-column prop="countryName" label="国家" align="center" />
<el-table-column prop="cityName" label="城市名称" align="center" />
<el-table-column prop="provinceName" label="所属省份" align="center" />
<el-table-column label="操作" align="center">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 弹窗表单 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="国家" prop="countryName">
<el-input v-model="form.countryName" placeholder="请输入国家(如:中国)" />
</el-form-item>
<el-form-item label="城市编码" prop="cityCode">
<el-input v-model="form.cityCode" placeholder="请输入城市编码" />
</el-form-item>
<el-form-item label="城市名称" prop="cityName">
<el-input v-model="form.cityName" placeholder="请输入城市名称" />
</el-form-item>
<el-form-item label="所属省份" prop="provinceName">
<el-input v-model="form.provinceName" placeholder="请输入所属省份" />
</el-form-item>
</el-form>
<div slot="footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listCity, getCity, delCity, addCity, updateCity } from "@/api/system/city";
import Pagination from "@/components/Pagination";
export default {
name: "City",
components: { Pagination },
data() {
return {
loading: false,
cityList: [],
total: 0,
queryParams: {
pageNum: 1,
pageSize: 50, // 已改成每页50条
cityName: null
},
ids: [],
multiple: true,
title: "",
open: false,
form: {},
rules: {
cityCode: [{ required: true, message: "城市编码不能为空", trigger: "blur" }],
cityName: [{ required: true, message: "城市名称不能为空", trigger: "blur" }]
}
};
},
created() {
this.getList();
},
methods: {
getList() {
this.loading = true;
listCity(this.queryParams).then(response => {
this.cityList = response.rows || [];
this.total = response.total || 0;
this.loading = false;
}).catch(() => {
this.loading = false;
});
},
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
resetQuery() {
this.queryParams = { pageNum: 1, pageSize: 50, cityName: null };
this.getList();
},
handleSelectionChange(selection) {
this.ids = selection.map(item => item.cityId);
this.multiple = !selection.length;
},
handleAdd() {
this.form = {};
this.open = true;
this.title = "添加城市";
},
handleUpdate(row) {
getCity(row.cityId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改城市";
});
},
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.cityId) {
updateCity(this.form).then(() => {
this.$message.success("修改成功");
this.open = false;
this.getList();
});
} else {
addCity(this.form).then(() => {
this.$message.success("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
handleDelete(row) {
const cityIds = row.cityId || this.ids.join(",");
this.$confirm("确认删除选中的城市吗?", "提示", { type: "warning" }).then(() => {
delCity(cityIds).then(() => {
this.$message.success("删除成功");
this.getList();
});
});
},
cancel() {
this.open = false;
}
}
};
</script>
<style scoped>
/* 全局弱化边框、阴影、降低层级 */
.app-container {
padding: 12px;
}
.el-table {
box-shadow: none !important;
border-radius: 4px;
}
.el-table th, .el-table td {
border-color: #f0f2f5 !important;
}
/* 按钮缩小、弱化样式 */
.el-button--mini {
padding: 3px 10px;
font-size: 12px;
}
/* 降低弹窗层级柔和化 */
.el-dialog {
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08) !important;
}
</style>

View File

@@ -87,7 +87,19 @@
</el-alert>
<el-form ref="form" :model="form" :rules="rules" label-width="96px">
<el-form-item label="工作地点" prop="workPlace">
<el-input v-model="form.workPlace" placeholder="请输入工作地点" />
<el-input
v-model="form.workPlace"
readonly
:placeholder="workPlaceLoading ? '正在获取定位…' : '请点击「重新获取定位」获取工作地点(不可手动输入)'"
>
<el-button
slot="append"
icon="el-icon-location-outline"
:loading="workPlaceLoading"
@click="refreshWorkPlace"
>重新获取定位</el-button>
</el-input>
<div v-if="workPlaceLocateError" class="work-place-error">{{ workPlaceLocateError }}</div>
</el-form-item>
<el-form-item label="是否出差" prop="isTrip">
<el-radio-group v-model="form.isTrip">
@@ -148,12 +160,19 @@ import { listDept } from "@/api/system/dept";
import { listUser } from "@/api/system/user";
import ProjectSelect from "@/components/fad-service/ProjectSelect";
import ProjectReportDetail from "@/views/oa/project/report/components/ProjectReportDetail.vue";
import {
EMPTY_GEOCODE,
geolocationUserMessage,
resolveWorkPlaceFromBrowser
} from "@/utils/geolocationWorkPlace";
export default {
name: "ProjectReport",
components: { ProjectReportDetail, ProjectSelect },
data () {
return {
workPlaceLoading: false,
workPlaceLocateError: "",
// 按钮loading
buttonLoading: false,
detailVisible: false,
@@ -230,6 +249,50 @@ export default {
this.getUserList();
},
methods: {
/**
* @param {{ silent?: boolean, force?: boolean }} options
*/
async syncWorkPlaceFromGeolocation (options = {}) {
const silent = !!options.silent;
const force = !!options.force;
if (!force && this.form && this.form.reportId) {
return;
}
this.workPlaceLoading = true;
this.workPlaceLocateError = "";
try {
const text = await resolveWorkPlaceFromBrowser();
this.$set(this.form, "workPlace", text);
if (!silent) {
this.$modal.msgSuccess("已根据定位更新工作地点");
}
} catch (e) {
console.error("[projectReport] 工作地点定位失败", e);
const msg = geolocationUserMessage(e);
this.workPlaceLocateError = msg;
this.$set(this.form, "workPlace", undefined);
const isBrowserGeoError =
e &&
(e.code === 1 ||
e.code === 2 ||
e.code === 3 ||
e.message === "BROWSER_UNSUPPORTED" ||
e.message === EMPTY_GEOCODE);
if (isBrowserGeoError) {
this.$modal.msgWarning(msg);
}
} finally {
this.workPlaceLoading = false;
this.$nextTick(() => {
if (this.$refs.form) {
this.$refs.form.validateField("workPlace");
}
});
}
},
refreshWorkPlace () {
this.syncWorkPlaceFromGeolocation({ silent: false, force: true });
},
/** 格式化日期为 yyyy-MM-dd 格式 */
formatDate (date) {
const year = date.getFullYear();
@@ -258,26 +321,31 @@ export default {
this.reset();
this.open = true;
this.title = "补录项目报工";
this.$nextTick(() => {
this.syncWorkPlaceFromGeolocation({ silent: true, force: false });
});
},
/** 检查今日报工 */
/** 检查今日报工(须返回 Promise供新增时 .finally 打开弹窗) */
checkTodayReport () {
getTodayProjectReport().then(response => {
if (response.data && response.data.reportId) {
this.hasTodayReport = true;
this.todayReportId = response.data.reportId;
this.form = {
...this.form,
...response.data
};
} else {
return getTodayProjectReport()
.then(response => {
if (response.data && response.data.reportId) {
this.hasTodayReport = true;
this.todayReportId = response.data.reportId;
this.form = {
...this.form,
...response.data
};
} else {
this.hasTodayReport = false;
this.todayReportId = null;
}
})
.catch(() => {
this.hasTodayReport = false;
this.todayReportId = null;
}
}).catch(() => {
this.hasTodayReport = false;
this.todayReportId = null;
});
});
},
getDeptList () {
@@ -313,6 +381,8 @@ export default {
},
// 表单重置
reset () {
this.workPlaceLoading = false;
this.workPlaceLocateError = "";
this.form = {
reportId: undefined,
handler: undefined,
@@ -359,9 +429,15 @@ export default {
handleAdd () {
this.reset();
this.suppVisible = false;
this.checkTodayReport();
this.open = true;
this.title = "添加项目报工";
this.checkTodayReport().finally(() => {
this.open = true;
this.$nextTick(() => {
if (!this.form.reportId) {
this.syncWorkPlaceFromGeolocation({ silent: true, force: false });
}
});
});
},
/** 修改按钮操作 */
handleUpdate (row) {
@@ -473,4 +549,11 @@ export default {
display: block;
margin-top: 2px;
}
.work-place-error {
color: #f56c6c;
font-size: 12px;
line-height: 1.5;
margin-top: 4px;
}
</style>

24
sql/oa_city.sql Normal file
View File

@@ -0,0 +1,24 @@
-- 城市管理表 oa_city
DROP TABLE IF EXISTS oa_city;
CREATE TABLE oa_city (
city_id BIGINT NOT NULL AUTO_INCREMENT COMMENT '城市主键ID',
country_name VARCHAR(64) NOT NULL COMMENT '国家',
city_name VARCHAR(64) NOT NULL COMMENT '城市',
status BIGINT DEFAULT 1 COMMENT '状态 1正常 0禁用',
remark VARCHAR(500) DEFAULT NULL COMMENT '备注',
del_flag TINYINT DEFAULT 0 COMMENT '删除标志0=正常1=已删除',
create_by VARCHAR(64) DEFAULT '' COMMENT '创建者',
create_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
update_by VARCHAR(64) DEFAULT '' COMMENT '更新者',
update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (city_id),
KEY idx_country_name (country_name),
KEY idx_city_name (city_name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='城市管理表';
INSERT INTO oa_city (country_name, city_name, status, remark) VALUES
('中国', '北京', 1, '默认城市'),
('中国', '上海', 1, '默认城市'),
('中国', '广州', 1, '默认城市'),
('中国', '深圳', 1, '默认城市'),
('中国', '杭州', 1, '默认城市');