Compare commits

...
5 Commits
Author SHA1 Message Date
c-hongqw1 216329a345 更新数据筛选在职状态,不更新退休人员吗,增加两个在职状态字段 2026-09-11 17:26:29 +08:00
c-hongqw1 b6a4a50e10 场地预约整改:审核默认同意
拉取数据筛选在职状态,不拉退休人员
选择福利界面增加已选择未选择
手机端主页活动回显
2026-09-11 16:02:26 +08:00
c-hongqw1 1906371506 场地预约整改:预约时间优化
拉取数据bug整改
2026-09-11 14:13:35 +08:00
c-hongqw1 ce773afea6 场地预约整改 2026-09-10 18:20:52 +08:00
c-hongqw1 68a838221b 场地预约整改:分工会/协会审核-校工会审核 2026-09-08 20:30:55 +08:00
63 changed files with 2094 additions and 684 deletions
@@ -33,14 +33,14 @@ public class SysCompletedController {
@Inject
private MainPageNeedItemsService mainPageNeedItemsService;
@Inject
private io.v.nutz.sys.services.SysCompletedService completedService;
/** 返回当前登录人的手机已办,已在 service 中校验目标页面权限。 */
@At
@ViReturn
public Object getCompletes(){
CndPlus cnd = CndPlus.create();
cnd.and("auditBy","=", ShiroUtil.getPrincipalProperty("id"));
cnd.and("YEAR(auditTime)","=",DateUtil.thisYear());
cnd.desc("auditTime");
return baseService.dao().query(Sys_completed.class,cnd);
return completedService.getCompletes();
}
@@ -51,7 +51,7 @@ public class SysCompletedController {
//审核完成前的待办
List<NeedItems> itemsList = Arrays.asList(items);
//审核完成后的待办
List<NeedItems> needItemsList = mainPageNeedItemsService.getNeedItems();
List<NeedItems> needItemsList = mainPageNeedItemsService.getNeedItems(true);
//过滤没有移动端地址和数量为0的待办
List<NeedItems> needItems = needItemsList.stream().filter(v-> v.getCount()>0 && Strings.isNotBlank(v.getMobileHref())).collect(Collectors.toList());
//审核前与审核后待办取差集
@@ -1,22 +1,13 @@
package io.v.nutz.sys.controllers.platform.sys;
import cn.wizzer.framework.base.Result;
import io.v.nutz.web.commons.utils.ShiroUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.Daos;
import org.nutz.dao.util.cri.Static;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import java.util.List;
/**
* 任务待办
@@ -27,67 +18,14 @@ import java.util.List;
public class SysLocalProcessController {
@Inject
private Dao dao;
private io.v.nutz.sys.services.SysLocalProcessService sysLocalProcessService;
/**
* 查询待办
* @param mode 1待处理 2已处理 3我发起的
* @return
*/
/** mode=1 待办、2 已办、3 本人发起;mobile=true 手机端,默认 PC;返回 code/data,data 为包含双端处理地址的任务数组。 */
@At
@RequiresAuthentication
@Ok("json:full")
public Result todoList(Integer mode) {
if (mode == 1 || mode == 2) {
Sql sql = Sqls.create("""
SELECT
t.taskNodeName,
t.createdByUserName,
t.formUrl,
t.formUrlView,
t.createdOn,
t2.processName,
t2.nodeName
FROM
sys_local_process_instance_task t
LEFT JOIN sys_local_process_instance t2 ON t2.processUniqueId = t.processUniqueId
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and(new Static("JSON_CONTAINS( t.assignments, '\"" + ShiroUtil.getPrincipalProperty("loginname") + "\"')"));
cnd.and("t.status", "=", mode);
cnd.and("t.taskDeleteFlag", "=", 0);
cnd.desc("t2.processInitiationTime");
sql.setCondition(cnd);
List<NutMap> list = (List<NutMap>) Daos.query(dao, sql.toString(), Sqls.callback.maps());
return Result.success(list);
} else if (mode == 3) {
Sql sql = Sqls.create("""
SELECT
t.id,
t.processUniqueId,
t.processName,
t.nodeName,
t.pcUrl,
t.mobileUrl,
t.pcUrl as formUrl,
t.processInstanceStatus,
t.processInitiationTime as createdOn,
u.username as createdByUserName
FROM
sys_local_process_instance t
LEFT JOIN sys_user u ON u.id = t.processInitiatorId
WHERE
t.processInitiatorId = @id
AND t.processDeleteFlag = 0
AND t.delFlag = 0
ORDER BY t.processInitiationTime DESC
""");
sql.setParam("id", ShiroUtil.getUserId());
List<NutMap> list = (List<NutMap>) Daos.query(dao, sql.toString(), Sqls.callback.maps());
return Result.success(list);
}
return null;
public Result todoList(Integer mode, Boolean mobile) {
if (mode == null || mode < 1 || mode > 3) return Result.error("请选择有效的待办查询类型");
return Result.success(sysLocalProcessService.todoList(mode, Boolean.TRUE.equals(mobile)));
}
}
@@ -5,7 +5,7 @@ import io.v.nutz.sys.services.SysTaskService;
import io.v.nutz.task.services.TaskPlatformService;
import io.v.nutz.web.commons.slog.annotation.SLog;
import io.v.nutz.base.utils.PageUtil;
import io.v.nutz.base.result.Result;;
import io.v.nutz.base.result.Result;
import io.v.nutz.web.commons.utils.ShiroUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
@@ -59,7 +59,8 @@ public class ClubExamineRegisterAgentController {
Sys_user user = (Sys_user) ShiroUtil.getPrincipal();
List<Sys_menu> menus = Optional.ofNullable(user).orElse(new Sys_user()).getMenus();
return result.stream().filter(v -> Strings.isNotBlank(v.getString("url")) && menus.stream().anyMatch(x -> Strings.isNotBlank(x.getHref()) && v.getString("url").contains(x.getHref()))).distinct().collect(Collectors.toList());
// 保留原有任务数据范围,再按当前账号的目标页面权限过滤入口。
return result.stream().filter(v -> Strings.isNotBlank(v.getString("url")) && menus.stream().anyMatch(x -> Strings.isNotBlank(x.getHref()) && v.getString("url").contains(x.getHref()))).filter(v -> io.v.nutz.sys.services.TodoAccessService.canAccess(v.getString("url"))).distinct().collect(Collectors.toList());
}
@@ -60,7 +60,8 @@ public class ClubNeedItemsController {
Sys_user user = (Sys_user) ShiroUtil.getPrincipal();
List<Sys_menu> menus = Optional.ofNullable(user).orElse(new Sys_user()).getMenus();
return result.stream().filter(v -> Strings.isNotBlank(v.getString("url")) && menus.stream().anyMatch(x -> Strings.isNotBlank(x.getHref()) && v.getString("url").contains(x.getHref()))).distinct().collect(Collectors.toList());
// 保留原有任务数据范围,再按当前账号的目标页面权限过滤入口。
return result.stream().filter(v -> Strings.isNotBlank(v.getString("url")) && menus.stream().anyMatch(x -> Strings.isNotBlank(x.getHref()) && v.getString("url").contains(x.getHref()))).filter(v -> io.v.nutz.sys.services.TodoAccessService.canAccess(v.getString("url"))).distinct().collect(Collectors.toList());
}
private int getClubRegistCount(Boolean flag, String roleId, Integer state) {
@@ -87,7 +88,8 @@ public class ClubNeedItemsController {
Sys_user user = (Sys_user) ShiroUtil.getPrincipal();
List<Sys_menu> menus = Optional.ofNullable(user).orElse(new Sys_user()).getMenus();
return result.stream().filter(v -> Strings.isNotBlank(v.getString("url")) && menus.stream().anyMatch(x -> Strings.isNotBlank(x.getHref()) && v.getString("url").contains(x.getHref()))).distinct().collect(Collectors.toList());
// 保留原有任务数据范围,再按当前账号的目标页面权限过滤入口。
return result.stream().filter(v -> Strings.isNotBlank(v.getString("url")) && menus.stream().anyMatch(x -> Strings.isNotBlank(x.getHref()) && v.getString("url").contains(x.getHref()))).filter(v -> io.v.nutz.sys.services.TodoAccessService.canAccess(v.getString("url"))).distinct().collect(Collectors.toList());
}
private int getClubApplyCount(String roleId, Integer state) {
@@ -116,7 +118,8 @@ public class ClubNeedItemsController {
Sys_user user = (Sys_user) ShiroUtil.getPrincipal();
List<Sys_menu> menus = Optional.ofNullable(user).orElse(new Sys_user()).getMenus();
return result.stream().filter(v -> Strings.isNotBlank(v.getString("url")) && menus.stream().anyMatch(x -> Strings.isNotBlank(x.getHref()) && v.getString("url").contains(x.getHref()))).distinct().collect(Collectors.toList());
// 保留原有任务数据范围,再按当前账号的目标页面权限过滤入口。
return result.stream().filter(v -> Strings.isNotBlank(v.getString("url")) && menus.stream().anyMatch(x -> Strings.isNotBlank(x.getHref()) && v.getString("url").contains(x.getHref()))).filter(v -> io.v.nutz.sys.services.TodoAccessService.canAccess(v.getString("url"))).distinct().collect(Collectors.toList());
}
private int getClubManageCount() {
@@ -139,7 +142,8 @@ public class ClubNeedItemsController {
Sys_user user = (Sys_user) ShiroUtil.getPrincipal();
List<Sys_menu> menus = Optional.ofNullable(user).orElse(new Sys_user()).getMenus();
return result.stream().filter(v -> Strings.isNotBlank(v.getString("url")) && menus.stream().anyMatch(x -> Strings.isNotBlank(x.getHref()) && v.getString("url").contains(x.getHref()))).distinct().collect(Collectors.toList());
// 保留原有任务数据范围,再按当前账号的目标页面权限过滤入口。
return result.stream().filter(v -> Strings.isNotBlank(v.getString("url")) && menus.stream().anyMatch(x -> Strings.isNotBlank(x.getHref()) && v.getString("url").contains(x.getHref()))).filter(v -> io.v.nutz.sys.services.TodoAccessService.canAccess(v.getString("url"))).distinct().collect(Collectors.toList());
}
private int getClubEvaluateCount(Boolean flag, String roleId, Integer state) {
@@ -366,6 +366,22 @@ public class Sys_user extends BaseModel implements Serializable {
@ColDefine(type = ColType.VARCHAR, width = 10)
private String userState;
/**
* 数据中心 ZZZTM 原始代码;源数据全量保存,人员更新仅处理代码为 100 的记录。
*/
@Column
@Comment("源人员状态代码(ZZZTM")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String zzztm;
/**
* 数据中心 ZZZTMC 原始名称,与 zzztm 配对保存,不替代现有 userState 字典值。
*/
@Column
@Comment("源人员状态名称(ZZZTMC")
@ColDefine(type = ColType.VARCHAR, width = 100)
private String zzztmc;
@Column
@Comment("人员类型")
@ColDefine(type = ColType.VARCHAR, width = 20)
@@ -0,0 +1,27 @@
package io.v.nutz.sys.services;
import cn.hutool.core.date.DateUtil;
import io.v.nutz.base.dao.CndPlus;
import io.v.nutz.sys.models.Sys_completed;
import io.v.nutz.web.commons.utils.ShiroUtil;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import java.util.List;
import java.util.stream.Collectors;
/** 旧版手机已办查询,权限过滤保留原有本人和年度范围。 */
@IocBean
public class SysCompletedService {
@Inject private Dao dao;
/** 无外部身份参数;返回当前登录人本年度、手机查看入口仍有权限的已办记录。 */
public List<Sys_completed> getCompletes() {
CndPlus cnd = CndPlus.create();
cnd.and("auditBy", "=", ShiroUtil.getUserId());
cnd.and("YEAR(auditTime)", "=", DateUtil.thisYear());
cnd.desc("auditTime");
return dao.query(Sys_completed.class, cnd).stream()
.filter(row -> TodoAccessService.canAccess(row.getMobileUrl())).collect(Collectors.toList());
}
}
@@ -4,6 +4,10 @@ import javax.validation.constraints.NotNull;
import java.util.List;
public interface SysLocalProcessService {
/** mode=1 待办、2 已办、3 本人发起;返回含原 PC 字段及手机处理/查看地址的任务列表,身份取当前登录人。 */
List<org.nutz.lang.util.NutMap> todoList(Integer mode);
/** mobile=true 按手机跳转地址鉴权,false 按 PC 地址鉴权;返回已过滤的任务数组。 */
List<org.nutz.lang.util.NutMap> todoList(Integer mode, boolean mobile);
/**
* 开始一个实例流程
@@ -7,6 +7,12 @@ import io.v.nutz.sys.models.Sys_unit;
* Created by wizzer on 2016/12/22.
*/
public interface SysUnitService extends ViService<Sys_unit> {
/**
* 无需参数,从数据中心同步全部单位,供单位维护及人员更新共同使用。
* 返回 void;同步失败抛出异常,由调用接口返回失败提示。
*/
void syncSourceUnits();
/**
* 保存单位
*
@@ -0,0 +1,86 @@
package io.v.nutz.sys.services;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.*;
import org.apache.shiro.subject.Subject;
import org.nutz.mvc.*;
import org.nutz.mvc.impl.MappingNode;
import org.nutz.lang.util.NutMap;
import java.lang.reflect.AnnotatedElement;
import java.net.URI;
import java.util.*;
import java.util.stream.Collectors;
/** 待办入口访问判断:读取 MVC 实际注册的路由及权限,不执行目标方法、不修改业务数据。 */
public class TodoAccessService {
private static final String KEY = TodoAccessService.class.getName();
private final Map<String, ActionInfo> exact = new HashMap<>();
private final MappingNode<ActionInfo> patterns = new MappingNode<>();
/** MVC 启动时登记入口;注册表跟随本次应用配置,重启后重新建立,不缓存用户权限。 */
public static synchronized void register(NutConfig config, ActionInfo info) {
// 待办点击使用 GET;同一路径的提交接口不能覆盖页面自身权限。
if (info.getHttpMethods() != null && !info.getHttpMethods().isEmpty()
&& info.getHttpMethods().stream().noneMatch(method -> "GET".equalsIgnoreCase(method))) return;
TodoAccessService service = (TodoAccessService) config.getAttribute(KEY);
if (service == null) { service = new TodoAccessService(); config.setAttribute(KEY, service); }
for (String path : info.getPaths()) {
if (!path.startsWith("/")) path = "/" + path;
service.exact.put(path, info);
service.patterns.add(path, info);
}
}
/** url 为待办真实跳转地址;返回当前登录账号能否访问。不存在的入口不展示。 */
public static boolean canAccess(String url) {
NutConfig config = Mvcs.getNutConfig();
TodoAccessService service = config == null ? null : (TodoAccessService) config.getAttribute(KEY);
return service != null && service.allowed(url, SecurityUtils.getSubject());
}
/** 去掉查询参数、锚点和应用上下文后匹配路由;权限保留原来的 AND/OR 组合语义。 */
public boolean allowed(String url, Subject subject) {
if (url == null || url.trim().isEmpty() || subject == null || !subject.isAuthenticated()) return false;
try {
URI uri = URI.create(url.trim());
// 允许配置为本系统绝对地址的旧任务,外部域名不能按本系统权限推断。
if (uri.isAbsolute() || uri.getRawAuthority() != null) {
String domain = io.v.nutz.web.commons.base.Globals.AppDomain;
if (domain == null || domain.isBlank()) return false;
URI app = URI.create(domain);
if (!Objects.equals(app.getScheme(), uri.getScheme()) || !Objects.equals(app.getRawAuthority(), uri.getRawAuthority())) return false;
}
String path = uri.getPath();
if (path == null || !path.startsWith("/")) return false;
if (Mvcs.getReq() != null) {
String context = Mvcs.getReq().getContextPath();
if (context != null && !context.isEmpty() && path.startsWith(context + "/")) path = path.substring(context.length());
}
ActionInfo info = exact.get(path);
if (info == null && path.endsWith("/")) info = exact.get(path.substring(0, path.length()-1));
if (info == null) info = patterns.get(new ActionContext().setPath(path), path);
return info != null && check(info.getModuleType(), subject) && check(info.getMethod(), subject);
} catch (IllegalArgumentException e) { return false; }
}
private boolean check(AnnotatedElement element, Subject subject) {
if (element == null) return true;
if (element.isAnnotationPresent(RequiresGuest.class)) return subject.getPrincipal() == null;
RequiresPermissions permission = element.getAnnotation(RequiresPermissions.class);
if (permission != null) {
boolean passed = permission.logical() == Logical.OR
? Arrays.stream(permission.value()).anyMatch(subject::isPermitted)
: Arrays.stream(permission.value()).allMatch(subject::isPermitted);
if (!passed) return false;
}
RequiresRoles roles = element.getAnnotation(RequiresRoles.class);
return roles == null || (roles.logical() == Logical.OR
? Arrays.stream(roles.value()).anyMatch(subject::hasRole)
: Arrays.stream(roles.value()).allMatch(subject::hasRole));
}
/** rows 为已有数据范围内的待办;urlField 是本端点击使用的地址字段,返回过滤后的列表。 */
public static List<NutMap> filter(List<NutMap> rows, String urlField) {
return rows.stream().filter(row -> canAccess(row.getString(urlField))).collect(Collectors.toList());
}
}
@@ -29,6 +29,80 @@ public class SysLocalProcessServiceImpl implements SysLocalProcessService {
@Inject
private Dao dao;
/**
* mode 为 1 待办、2 已办、3 本人发起;返回字段保留 PC 兼容,并增加 id、formMobileUrl、formMobileUrlView、endOn。
* 待办/已办按接收人工号查询,发起记录按当前用户 ID 查询;删除标记的任务和流程不再展示。
*/
@Override
public List<org.nutz.lang.util.NutMap> todoList(Integer mode) {
return todoList(mode, false);
}
@Override
public List<org.nutz.lang.util.NutMap> todoList(Integer mode, boolean mobile) {
if (mode == null || mode < 1 || mode > 3) throw new IllegalArgumentException("请选择有效的待办查询类型");
Sql sql;
if (mode == 1 || mode == 2) {
sql = Sqls.create("""
select t.id,t.processUniqueId,t.taskNodeName,t.createdByUserName,t.formUrl,t.formUrlView,
t.formMobileUrl,t.formMobileUrlView,t.createdOn,t.endOn,t2.processName,t2.nodeName
from sys_local_process_instance_task t
join sys_local_process_instance t2 on t2.processUniqueId=t.processUniqueId
where JSON_CONTAINS(t.assignments,JSON_QUOTE(@loginname)) and t.status=@mode
and coalesce(t.taskDeleteFlag,0)=0 and coalesce(t.delFlag,0)=0
and coalesce(t2.processDeleteFlag,0)=0 and coalesce(t2.delFlag,0)=0
order by t2.processInitiationTime desc,t.id desc
""").setParam("loginname",io.v.nutz.web.commons.utils.ShiroUtil.getPrincipalProperty("loginname"))
.setParam("mode",mode);
} else {
sql = Sqls.create("""
select t.id,t.processUniqueId,t.processName,t.nodeName,t.pcUrl,t.mobileUrl,t.pcUrl as formUrl,
t.mobileUrl as formMobileUrl,t.mobileUrl as formMobileUrlView,t.processInstanceStatus,
t.processInitiationTime as createdOn,u.username as createdByUserName
from sys_local_process_instance t left join sys_user u on u.id=t.processInitiatorId
where t.processInitiatorId=@id and coalesce(t.processDeleteFlag,0)=0 and coalesce(t.delFlag,0)=0
order by t.processInitiationTime desc
""").setParam("id",io.v.nutz.web.commons.utils.ShiroUtil.getUserId());
}
sql.setCallback(Sqls.callback.maps());
dao.execute(sql);
List<org.nutz.lang.util.NutMap> rows = sql.getList(org.nutz.lang.util.NutMap.class);
// 兼容历史会员申请任务:只修正返回的手机地址,不回写数据库,也不改变 PC 地址和查询权限。
for (org.nutz.lang.util.NutMap row : rows) {
if (!row.getString("processUniqueId", "").startsWith("MEMBER_APPLY@")) continue;
for (String field : List.of("formMobileUrl", "formMobileUrlView", "mobileUrl")) {
if (row.containsKey(field)) row.put(field, memberApplyMobileUrl(row.getString(field)));
}
}
// 权限仅进一步收紧已有候选人/本人范围;已办按查看入口判断,不能因历史授权继续展示。
return rows.stream().filter(row -> {
String url = mobile ? row.getString("formMobileUrl") : row.getString("formUrl");
if (mode == 2) {
String view = row.getString(mobile ? "formMobileUrlView" : "formUrlView");
if (view != null && !view.isBlank()) url = view;
}
return io.v.nutz.sys.services.TodoAccessService.canAccess(url);
}).collect(java.util.stream.Collectors.toList());
}
/**
* 输入历史手机 URL,返回对应 H5 地址;仅匹配已存在 H5 页面的三个会员申请入口。
* 保留查询参数与锚点,空值、正确 H5 地址及其他业务地址原样返回,避免重复添加 /h5。
*/
private String memberApplyMobileUrl(String url) {
if (url == null || url.isEmpty()) return url;
int end = url.length();
if (url.indexOf('?') >= 0) end = Math.min(end, url.indexOf('?'));
if (url.indexOf('#') >= 0) end = Math.min(end, url.indexOf('#'));
String path = url.substring(0, end);
if (path.endsWith("/")) path = path.substring(0, path.length() - 1);
if (List.of("/platform/member/apply/mine", "/platform/member/apply/branchUnion/audit",
"/platform/member/apply/schoolUnion/audit").contains(path)) {
return path + "/h5" + url.substring(end);
}
return url;
}
@Override
public void startProcess(String processName, String processUniqueId, String nodeName, String processInitiatorId, String pcUrl, String mobileUrl) {
int count = dao.count(Sys_local_process_instance.class, Cnd.where("processUniqueId", "=", processUniqueId));
@@ -1,5 +1,11 @@
package io.v.nutz.sys.services.impl;
import cn.hutool.core.bean.BeanUtil;
import io.v.nutz.zhgh.data.constant.SourceData;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import io.v.nutz.base.constant.RedisConstant;
import io.v.nutz.base.service.impl.ViServiceImpl;
import io.v.nutz.sys.models.Sys_unit;
@@ -25,6 +31,47 @@ public class SysUnitServiceImpl extends ViServiceImpl<Sys_unit> implements SysUn
super(dao);
}
/**
* 同步数据中心单位,无入参、无返回值;异常交由调用方处理。
* 保留现有层级规则及根单位映射,重复同步按映射后的主键更新。
*/
@Override
@Aop(TransAop.READ_COMMITTED)
public void syncSourceUnits() {
List<Sys_unit> units = SourceData.units();
Set<String> ids = query().stream().map(Sys_unit::getId).collect(Collectors.toSet());
for (Sys_unit unit : units) {
if (Strings.isBlank(unit.getId()) || Strings.isBlank(unit.getUnitcode())) {
throw new IllegalStateException("单位同步失败:源单位编号为空,请核对单位源数据。");
}
// 源根单位 100 在本系统保存为 1,必须先映射再判断是否已存在。
if ("100".equals(unit.getId())) {
unit.setId("1");
unit.setUnitcode("1");
unit.setUnitlevel(1);
}
if (ids.contains(unit.getId())) {
updateIgnoreNull(unit);
} else {
Map<String, Object> beanMap = BeanUtil.beanToMap(unit);
if (unit.getUnitcode().length() == 6) {
beanMap.put("unitlevel", 2);
beanMap.put("parentId", 1);
}
beanMap.remove("child");
insert("sys_unit", Chain.from(beanMap));
ids.add(unit.getId());
}
}
// 沿用原入口对子单位标志的维护规则。
for (Sys_unit unit : query()) {
if (count(Cnd.where("parentId", "=", unit.getId())) > 0) {
unit.setHasChildren(true);
update(unit);
}
}
}
/**
* 新增单位
*
@@ -56,6 +56,7 @@ public class NutShiroProcessor extends AbstractProcessor {
throw new IllegalStateException("this Processor have bean inited!!");
}
super.init(config, ai);
io.v.nutz.sys.services.TodoAccessService.register(config, ai);
match = NutShiro.match(ai.getMethod());
init = true;
}
@@ -7,6 +7,8 @@ import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.utils.PageUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.ioc.aop.Aop;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
@@ -70,22 +72,27 @@ public class SiteManageController {
@At
@ViReturn
@RequiresPermissions("activity.site.manage")
/** data 为新增场地表单,返回统一 code/msg;类型关联和校区校验由 service 完成。 */
@Aop(TransAop.READ_COMMITTED)
public Object doAdd(@Param("data") ActivitySiteInfo activitySiteInfo) {
siteInfoService.insert(activitySiteInfo);
siteInfoService.saveManagedSite(activitySiteInfo, false);
return null;
}
@At
@ViReturn
@RequiresPermissions("activity.site.manage")
/** data 为包含 id 的场地表单,返回统一 code/msg,成功后可重新查询校区回显。 */
@Aop(TransAop.READ_COMMITTED)
public Object doEdit(@Param("data") ActivitySiteInfo activitySiteInfo) {
siteInfoService.updateIgnoreNull(activitySiteInfo);
siteInfoService.saveManagedSite(activitySiteInfo, true);
return null;
}
@At
@ViReturn
@RequiresPermissions("activity.site.manage")
@Aop(TransAop.READ_COMMITTED)
public Object doDelete(String id) {
siteInfoService.delete(id);
return null;
@@ -28,6 +28,8 @@ import org.nutz.mvc.annotation.Param;
@At("/platform/activity/site/record")
public class SiteRecordController {
@Inject private io.v.nutz.zhgh.activity.services.impl.SiteBookingService siteBookingService;
@Inject
private SiteReserveService siteReserveService;
@@ -57,8 +59,7 @@ public class SiteRecordController {
ass.`stateName` state_name,
ass.`stateColor` state_color,
ass.stateAuditType,
count(sqid) days,
GROUP_CONCAT(reserve_day order by reserve_day asc) concat_day
count(distinct reserve_day) days
FROM
activity_site_reserve asr
LEFT JOIN
@@ -96,7 +97,7 @@ public class SiteRecordController {
cnd.groupBy("sqid");
sql.setCondition(cnd);
return siteReserveService.listPage(pageNumber, pageSize, sql);
return siteBookingService.reservationPage(pageNumber, pageSize, sql, month);
}
@@ -99,8 +99,7 @@ public class SiteReserveController {
ass.`stateName` state_name,
ass.`stateColor` state_color,
ass.stateAuditType,
count(sqid) days,
GROUP_CONCAT(reserve_day order by reserve_day asc) concat_day
count(distinct reserve_day) days
FROM
activity_site_reserve asr
LEFT JOIN
@@ -140,15 +139,19 @@ public class SiteReserveController {
cnd.groupBy("sqid");
sql.setCondition(cnd);
return siteReserveService.listPage(pageNumber, pageSize, sql);
return siteBookingService.reservationPage(pageNumber, pageSize, sql, time);
}
@At
@ViReturn
@RequiresPermissions("activity.site.reserve")
@Aop(TransAop.READ_COMMITTED)
/** id 为预约记录主键,op=1 删除已撤销申请、op=2 撤销申请;成功返回空 data,由 ViReturn 包装结果。 */
public Object doDelete(String id, Integer op) {
siteBookingService.cancel(id);
if (org.nutz.lang.Strings.isBlank(id)) throw new IllegalArgumentException("请选择预约记录");
if (Integer.valueOf(1).equals(op)) siteBookingService.deleteCancelled(id);
else if (Integer.valueOf(2).equals(op)) siteBookingService.cancel(id);
else throw new IllegalArgumentException("不支持的预约操作");
return null;
}
@@ -165,10 +168,16 @@ public class SiteReserveController {
@RequiresPermissions("activity.site.reserve")
/** data 为场地、类型、协会及事由;days 为日期数组,起止时间取 data;返回新申请 sqid。 */
@Aop(TransAop.READ_COMMITTED)
public Object doAdd(@Param("data") ActivitySiteReserve activitySiteReserve, @Param("days") String[] days) {
public Object doAdd(@Param("data") ActivitySiteReserve activitySiteReserve, @Param("days") String[] days, @Param("times") String[] times) {
List<NutMap> slots = new ArrayList<>();
if (activitySiteReserve == null || days == null) throw new IllegalArgumentException("请选择预约日期");
for (String day : days) slots.add(NutMap.NEW().setv("day",day).setv("start_time",activitySiteReserve.getStart_time()).setv("end_time",activitySiteReserve.getEnd_time()));
// times为所选HH:mm-HH:mm场次数组;保留旧客户端单场次参数的兼容。
if(times==null || times.length==0)times=new String[]{activitySiteReserve.getStart_time()+"-"+activitySiteReserve.getEnd_time()};
for(String day:days)for(String time:times){
String[] parts=time.split("-",-1);
if(parts.length!=2)throw new IllegalArgumentException("请选择有效预约场次");
slots.add(NutMap.NEW().setv("day",day).setv("start_time",parts[0]).setv("end_time",parts[1]));
}
return siteBookingService.submit(activitySiteReserve,slots);
}
@@ -253,4 +262,8 @@ public class SiteReserveController {
/** 返回当前用户有效协会数组(id/name),供个人所属协会展示和协会预约选择。 */
@At @ViReturn @org.apache.shiro.authz.annotation.RequiresAuthentication
public Object myClubs() { return siteBookingService.myClubs(); }
/** 无入参;返回统一code/datadata.id/name为当前申请人所属分工会,仅供表单展示。 */
@At @ViReturn @RequiresPermissions("activity.site.reserve")
public Object myUnion() { return siteBookingService.myBookingUnion(); }
}
@@ -28,13 +28,38 @@ public class ActivitySiteInfo {
@ColDefine(type = ColType.VARCHAR, width = 100)
private String name;
@Column
@Comment("校区名称,取自系统校区选项")
@ColDefine(type = ColType.VARCHAR, width = 100)
private String campus;
@Column
@Comment("预约时间段类型:1分段预约,2全天候预约;旧场地按分段兼容")
@ColDefine(type = ColType.INT)
private Integer reserveTimeType;
@Column
@Comment("禁用时段:date、startTime、endTime")
@ColDefine(type = ColType.MYSQL_JSON)
private List<org.nutz.lang.util.NutMap> notApplyTimeList;
@Column
@Comment("分段场次原始配置,保留切换前的时间及timeUnit分钟单位")
@ColDefine(type = ColType.MYSQL_JSON)
private List<org.nutz.lang.util.NutMap> segmentedOpenHours;
@Column
@Comment("全天候起止时间及timeUnit分钟单位")
@ColDefine(type = ColType.MYSQL_JSON)
private org.nutz.lang.util.NutMap fullDayOpenHour;
@Column
@Comment("场地地址")
@ColDefine(type = ColType.VARCHAR, width = 100)
private String address;
@Column
@Comment("联系人")
@Comment("场地管理员")
@ColDefine(type = ColType.VARCHAR, width = 32)
private String contact_person;
@@ -84,7 +109,7 @@ public class ActivitySiteInfo {
private Integer sexLimit;
@Column
@Comment("个人预约限定人数")
@Comment("限定人数")
@ColDefine(type = ColType.INT)
private Integer limitNum;
}
@@ -137,7 +137,7 @@ public class ActivitySiteReserve extends BaseModel {
private String joinUser;
@Column
@Comment("预约类型(1.个人预约,2.单位预约,3.协会预约)")
@Comment("预约类型(1.个人预约,2.分工会预约,3.协会预约)")
@ColDefine(type = ColType.INT, width = 10)
private Integer reserve_type;
}
@@ -5,4 +5,12 @@ import cn.wizzer.framework.base.service.BaseService;
import io.v.nutz.zhgh.activity.models.ActivitySiteInfo;
public interface SiteInfoService extends BaseService<ActivitySiteInfo> {
/** form 为场地表单,editing 区分新增和编辑;保存校区并由后端关联职工之家类型,返回 void。 */
void saveManagedSite(ActivitySiteInfo form, boolean editing);
/** 校验 day(yyyy-MM-dd)、start/end(HH:mm,结束可24:00)属于有效场次且不与禁用时间交叉;不通过抛出参数异常。 */
void validateBookingSlot(ActivitySiteInfo site, String day, String start, String end);
/** 查询某天可预约场次,reserveType=1/2/3;返回 start_time/end_time、code(1可约)、msg 和人数。 */
java.util.List<org.nutz.lang.util.NutMap> availableSlots(String siteId, String day, Integer reserveType);
/** 返回start/end范围内实际同时占用的峰值人数,避免配置扩大后把相邻历史场次累加成超额。 */
int occupiedCount(java.util.List<io.v.nutz.zhgh.activity.models.ActivitySiteReserve> rows, String start, String end);
}
@@ -30,11 +30,15 @@ import java.util.stream.Collectors;
@IocBean(args = {"refer:dao"})
public class SiteBookingService extends BaseServiceImpl<ActivitySiteReserve> {
public static final int UNION = 4000, CLUB = 4010, SCHOOL = 4020, PASS = 4030, REJECT = 4040, CANCEL = 4050;
/** 校工会节点统一按专属场地管理员角色分配待办和校验审核资格。 */
private static final String SCHOOL_REVIEW_ROLE = "SchoolUnionActivityVenueAdmin";
/** 兼容现有日历组件的状态字段;名称统一读取 state,不再读取 audit_state。 */
public static final String STATES = "(select state_id stateId,state_name stateName,state_color stateColor,"
+ "case when state_id=4030 then 3 when state_id in (4040,4050) then 1 else 0 end stateAuditType "
+ "from state where belong='activity_site')";
@Inject private SysLocalProcessService sysLocalProcessService;
@Inject private io.v.nutz.zhgh.activity.services.SiteInfoService siteInfoService;
@Inject private io.v.nutz.base.utils.MsgApi msgApi;
public SiteBookingService(Dao dao) { super(dao); }
@@ -48,17 +52,24 @@ public class SiteBookingService extends BaseServiceImpl<ActivitySiteReserve> {
+ "order by c.name").setParam("uid", uid()));
}
/** 预约类型 1 个人、2 单位、3 协会,返回应进入的首个状态 ID。 */
/** 无入参,返回当前申请人的id/name所属分工会;采用与提交相同的user视图组织来源,未配置时返回空字符串。 */
public NutMap myBookingUnion() {
List<NutMap> rows=listMap(Sqls.create("select u.unionid id,un.unionname name from `user` u left join sys_union un on un.id=u.unionid where u.id=@id")
.setParam("id",uid()));
return rows.isEmpty() ? NutMap.NEW().setv("id","").setv("name","") : rows.get(0);
}
/** 预约类型 1 历史个人、2 分工会、3 协会,返回应进入的首个状态 ID。 */
public int firstState(Integer type) {
if (Integer.valueOf(1).equals(type)) return UNION;
if (Integer.valueOf(2).equals(type)) return SCHOOL;
if (Integer.valueOf(2).equals(type)) return UNION;
if (Integer.valueOf(3).equals(type)) return CLUB;
throw new IllegalArgumentException("请选择有效的预约类型");
}
/** 按节点角色及组织范围查实际审核人;不允许空组织退化为全校范围。 */
private List<NutMap> reviewers(int node, ActivitySiteReserve booking) {
String role = node == UNION ? "gh01" : node == CLUB ? "club01" : "sysadmin";
String role = node == UNION ? "gh01" : node == CLUB ? "club01" : SCHOOL_REVIEW_ROLE;
String filter = "";
if (node == UNION) {
if (Strings.isBlank(booking.getReserve_person_unionid())) throw new IllegalArgumentException("申请人未关联分工会,请先完善所属分工会");
@@ -78,7 +89,7 @@ public class SiteBookingService extends BaseServiceImpl<ActivitySiteReserve> {
List<String> names = reviewers(node, booking).stream().map(v -> v.getString("loginname"))
.filter(Strings::isNotBlank).distinct().collect(Collectors.toList());
if (names.isEmpty()) throw new IllegalArgumentException(node == UNION ? "所属分工会未配置可用的分工会主席"
: node == CLUB ? "所选协会未配置可用的协会会长" : "未配置可用的校工会审核人(系统管理员");
: node == CLUB ? "所选协会未配置可用的协会会长" : "未配置可用的校工会场地管理员");
return names;
}
@@ -102,6 +113,8 @@ public class SiteBookingService extends BaseServiceImpl<ActivitySiteReserve> {
public String submit(ActivitySiteReserve form, List<NutMap> slots) {
if (form == null || Strings.isBlank(form.getSite_id())) throw new IllegalArgumentException("请选择场地");
int first = firstState(form.getReserve_type());
// 个人日期及共享容量规则按业务类型判断,不能随首审节点变更套用到分工会预约。
boolean personal = Integer.valueOf(1).equals(form.getReserve_type());
if (slots == null || slots.isEmpty()) throw new IllegalArgumentException("请选择预约时段");
listMap(Sqls.create("select id from activity_site_info where id=@id for update").setParam("id", form.getSite_id()));
ActivitySiteInfo site = dao().fetch(ActivitySiteInfo.class, form.getSite_id());
@@ -125,15 +138,25 @@ public class SiteBookingService extends BaseServiceImpl<ActivitySiteReserve> {
assignments(first, form);
assignments(SCHOOL, form);
List<NutMap> open = Json.fromJsonAsList(NutMap.class, Json.toJson(site.getOpen_hours()));
// 全天候按每个日期连续选择时间单位,避免跨禁用间隔或拆成多段。
if (Integer.valueOf(2).equals(site.getReserveTimeType())) {
Map<String,List<NutMap>> byDay=slots.stream().collect(Collectors.groupingBy(v->v.getString("day")));
for(List<NutMap> selected:byDay.values()) {
selected.sort(Comparator.comparing(v->v.getString("start_time")));
for(int i=1;i<selected.size();i++) if(!selected.get(i-1).getString("end_time").equals(selected.get(i).getString("start_time")))
throw new IllegalArgumentException("全天候预约请选择连续时段");
}
}
Set<String> distinct = new HashSet<>();
for (NutMap slot : slots) {
String day = slot.getString("day"), start = slot.getString("start_time"), end = slot.getString("end_time");
if (Strings.isBlank(day) || Strings.isBlank(start) || Strings.isBlank(end)) throw new IllegalArgumentException("预约日期和起止时间不能为空");
siteInfoService.validateBookingSlot(site,day,start,end);
LocalDate date = LocalDate.parse(day);
LocalTime startTime = LocalTime.parse(start), endTime = "24:00".equals(end) ? LocalTime.MIDNIGHT : LocalTime.parse(end);
if (!"24:00".equals(end) && !endTime.isAfter(startTime)) throw new IllegalArgumentException("结束时间必须晚于开始时间");
if (!LocalDateTime.of(date, startTime).isAfter(LocalDateTime.now())) throw new IllegalArgumentException("预约时段已过期");
if (first == UNION && !date.equals(LocalDate.now().plusDays(1))) throw new IllegalArgumentException("个人预约只支持预约明天的时间");
if (personal && !date.equals(LocalDate.now().plusDays(1))) throw new IllegalArgumentException("个人预约只支持预约明天的时间");
if (Boolean.TRUE.equals(site.getWorkday()) && date.getDayOfWeek().getValue() >= 6) throw new IllegalArgumentException("该场地仅支持工作日预约");
if (open == null || open.stream().noneMatch(v -> start.equals(v.getString("start_time")) && end.equals(v.getString("end_time"))))
throw new IllegalArgumentException("所选时段不在场地开放场次中,请刷新重选");
@@ -141,9 +164,9 @@ public class SiteBookingService extends BaseServiceImpl<ActivitySiteReserve> {
List<ActivitySiteReserve> existing = query(Cnd.where("site_id", "=", site.getId()).and("reserve_day", "=", day)
.and("start_time", "<", end).and("end_time", ">", start).and("reserve_state", "not in", Arrays.asList(REJECT, CANCEL)));
if (existing.stream().anyMatch(v -> uid().equals(v.getReserve_person_id()))) throw new IllegalArgumentException("您已预约该时间段");
if (first != UNION && !existing.isEmpty()) throw new IllegalArgumentException("该时段已有预约,协会或单位预约需要空闲时段");
if (first == UNION && (existing.stream().anyMatch(v -> !Integer.valueOf(1).equals(v.getReserve_type()))
|| site.getLimitNum() == null || existing.size() >= site.getLimitNum())) throw new IllegalArgumentException("该时段预约人数已满或已被单位/协会预约");
if (!personal && !existing.isEmpty()) throw new IllegalArgumentException("该时段已有预约,协会或分工会预约需要空闲时段");
if (personal && (existing.stream().anyMatch(v -> !Integer.valueOf(1).equals(v.getReserve_type()))
|| site.getLimitNum() == null || siteInfoService.occupiedCount(existing,start,end) >= site.getLimitNum())) throw new IllegalArgumentException("该时段预约人数已满或已被分工会/协会预约");
}
String sqid = UUID.randomUUID().toString().replace("-", "");
for (NutMap slot : slots) {
@@ -160,6 +183,7 @@ public class SiteBookingService extends BaseServiceImpl<ActivitySiteReserve> {
sysLocalProcessService.startProcess("场地预约:" + site.getName(), process(form), title(first), uid(),
"/platform/activity/site/reserve", "/mobile/activity/site/info/my");
createTask(first, form);
notifyBooking(form,first,null);
return sqid;
}
@@ -173,9 +197,52 @@ public class SiteBookingService extends BaseServiceImpl<ActivitySiteReserve> {
sysLocalProcessService.updateProcessNodeName(process(booking), title(node));
}
/**
* booking 为整条申请,state 为新待审节点或最终 PASS/REJECT,opinion 为最终审核意见(待审时为空)。
* 返回 void;每次按 sqid 组织一条钉钉消息、接收人工号去重,复用消息开关与发送日志。
* 只由首次提交和审核流转调用,撤回审核、新建恢复待办、撤销和删除不发送。
*/
@Aop(TransAop.READ_COMMITTED)
private void notifyBooking(ActivitySiteReserve booking,int state,String opinion) {
try {
boolean result = state == PASS || state == REJECT;
List<String> receivers;
if (result) {
Sys_user applicant = dao().fetch(Sys_user.class,booking.getReserve_person_id());
receivers = applicant == null || Strings.isBlank(applicant.getLoginname())
? Collections.emptyList() : Collections.singletonList(applicant.getLoginname());
} else receivers = assignments(state,booking);
if (receivers.isEmpty()) throw new IllegalArgumentException("消息接收人工号为空");
ActivitySiteInfo site = dao().fetch(ActivitySiteInfo.class,booking.getSite_id());
List<NutMap> slots = listMap(Sqls.create("select reserve_day,start_time,end_time from activity_site_reserve where sqid=@sqid")
.setParam("sqid",booking.getSqid()));
List<NutMap> groups = groupReservationTimes(slots);
// 长申请只列前五个日期,完整时段在业务页查看,避免超出消息长度限制。
List<String> days = new ArrayList<>();
for (NutMap group : groups.stream().limit(5).collect(Collectors.toList())) {
List<NutMap> ranges = (List<NutMap>) group.get("ranges");
String times = ranges.stream().limit(4).map(range -> range.getString("start") + "" + range.getString("end"))
.collect(Collectors.joining(""));
days.add(group.getString("date") + " " + times + (ranges.size()>4 ? "等时段" : ""));
}
String status = state == PASS ? "审核通过" : state == REJECT ? "审核拒绝" : "" + title(state);
String content = "申请人:" + booking.getReserve_person() + ";场地:" + (site == null ? "" : site.getName())
+ ";预约时段:" + String.join("",days) + (groups.size()>5 ? "等,共" + groups.size() + "" : "")
+ ";状态:" + status + (result && Strings.isNotBlank(opinion) ? ";审核意见:" + opinion : "")
+ (result ? "。请点击查看我的预约。" : "。请点击进入审核页面处理。");
String path = result ? "/mobile/activity/site/info/my" : "/mobile/activity/site/audit/" + stage(state);
String domain = Strings.sNull(io.v.nutz.web.commons.base.Globals.AppDomain).replaceAll("/+$","");
msgApi.sendMsgInsertLog(Collections.singletonList("DingTalk"),receivers.stream().distinct().collect(Collectors.toList()),
2,result ? "场地预约" + status : "场地预约审核通知",content,"",domain + path,"场地预约");
} catch (Exception e) {
// 外部发送失败不回滚已完成的预约操作;记录申请编号以便排查,避免用户重试造成重复申请。
org.nutz.log.Logs.get().error("场地预约钉钉通知失败,sqid=" + booking.getSqid() + "state=" + state,e);
}
}
/** 返回指定审核入口的数据范围,分工会/协会使用角色关系上的组织字段。 */
private String scope(int node) {
if (node == SCHOOL) return "exists(select 1 from sys_user_role ur join sys_role r on r.id=ur.roleId where ur.userId=@uid and r.code='sysadmin')";
if (node == SCHOOL) return "exists(select 1 from sys_user_role ur join sys_role r on r.id=ur.roleId where ur.userId=@uid and r.code='" + SCHOOL_REVIEW_ROLE + "')";
return "exists(select 1 from sys_user_role ur join sys_role r on r.id=ur.roleId where ur.userId=@uid and r.code='"
+ (node == UNION ? "gh01" : "club01") + "' and "
+ (node == UNION ? "ur.unionid=b.reserve_person_unionid" : "ur.stid=b.clubId") + ")";
@@ -210,16 +277,75 @@ public class SiteBookingService extends BaseServiceImpl<ActivitySiteReserve> {
.setParam("uid", uid()).setParam("keyword", Strings.sNull(keyword)).setParam("like", "%" + Strings.sNull(keyword) + "%")
.setParam("month", Strings.sNull(month)).setParam("typeId", Strings.sNull(typeId));
Pagination result = listPageMap(Math.max(1,page), Math.min(100,Math.max(1,size)), sql);
// 按当前页的申请一次读取原始时段,不依赖可能被数据库截断的group_concat。
List<String> sqids=result.<Map<String,Object>>getList().stream().map(row->String.valueOf(row.get("sqid"))).collect(Collectors.toList());
Map<String,List<NutMap>> slotsByBooking=new HashMap<>();
if(!sqids.isEmpty()) {
List<NutMap> slots=listMap(Sqls.create("select sqid,reserve_day,start_time,end_time from activity_site_reserve where sqid in (@sqids)").setParam("sqids",sqids));
slotsByBooking=slots.stream().collect(Collectors.groupingBy(row->row.getString("sqid")));
}
// 两端共用后端资格判断;真正撤回仍在加锁后复查,不能信任列表中的旧状态。
for (Map<String,Object> row : result.<Map<String,Object>>getList()) {
ActivitySiteReserve booking = fetch(String.valueOf(row.get("id")));
String reason = revokeReason(node, booking);
row.put("canRevoke", reason == null);
row.put("revokeReason", reason);
row.put("reservationTimeGroups",groupReservationTimes(slotsByBooking.getOrDefault(String.valueOf(row.get("sqid")),Collections.emptyList())));
}
return result;
}
/**
* pageNumber/pageSize 为分页参数,sql 为调用页已包含权限及筛选的分组查询,month 为可空的 YYYY-MM。
* 返回原分页结构,list 每行补充 reservationTimeGroups(日期及连续时段)和去重后的 days;不扩大月份范围。
*/
public Pagination reservationPage(int pageNumber, int pageSize, Sql sql, String month) {
Pagination page = listPage(pageNumber,pageSize,sql);
List<Record> rows = page.getList();
if (rows.isEmpty()) return page;
List<String> sqids = rows.stream().map(row -> row.getString("sqid")).collect(Collectors.toList());
List<NutMap> slots = listMap(Sqls.create("select sqid,reserve_day,start_time,end_time from activity_site_reserve "
+ "where sqid in (@sqids) and (@month='' or left(reserve_day,7)=@month)")
.setParam("sqids",sqids).setParam("month",Strings.sNull(month)));
Map<String,List<NutMap>> grouped = slots.stream().collect(Collectors.groupingBy(row -> row.getString("sqid")));
// 仅批量读取当前页申请,避免逐条查询及 group_concat 长度限制导致的时段丢失。
List<Map<String,Object>> output = new ArrayList<>();
for (Record row : rows) {
List<NutMap> groups = groupReservationTimes(grouped.getOrDefault(row.getString("sqid"),Collections.emptyList()));
// Record 会将新增键转成小写;转换后保留既有字段名及 Vue 所需的驼峰分组字段。
Map<String,Object> item = new LinkedHashMap<>(row);
item.put("reservationTimeGroups",groups);
item.put("days",groups.size());
output.add(item);
}
page.setList(output);
return page;
}
/**
* slots为原始reserve_day/start_time/end_time记录,返回按日期排序的[{date,ranges:[{start,end}]}]。
* 仅合并同日首尾相接的时段,跨日和有间隔的场次独立保留;不改变原始预约记录。
*/
public List<NutMap> groupReservationTimes(List<NutMap> slots) {
List<NutMap> ordered=new ArrayList<>(slots);
ordered.sort(Comparator.comparing((NutMap row)->row.getString("reserve_day"))
.thenComparing(row->row.getString("start_time")).thenComparing(row->row.getString("end_time")));
List<NutMap> groups=new ArrayList<>();
String day=null;
List<NutMap> ranges=null;
for(NutMap slot:ordered) {
String date=slot.getString("reserve_day"),start=slot.getString("start_time"),end=slot.getString("end_time");
if(!Objects.equals(day,date)) {
day=date;ranges=new ArrayList<>();
groups.add(NutMap.NEW().setv("date",date).setv("ranges",ranges));
}
NutMap previous=ranges.isEmpty() ? null : ranges.get(ranges.size()-1);
if(previous!=null && Objects.equals(previous.getString("end"),start))previous.setv("end",end);
else ranges.add(NutMap.NEW().setv("start",start).setv("end",end));
}
return groups;
}
/** 公共展示字段,保留既有组件所需别名,并显示预约类型和所属协会。 */
private String baseSelect() {
return "select b.*,u.loginname,u.sex,s.name site_name,c.name club_name,un.unionname union_name,st.stateName state_name,st.stateColor state_color,st.stateAuditType,"
@@ -245,8 +371,10 @@ public class SiteBookingService extends BaseServiceImpl<ActivitySiteReserve> {
NutMap result = listMap(Sqls.create(baseSelect() + " where b.id=@id").setParam("id",id)).get(0);
result.put("auditListTable",history);
// 日历仅携带本次申请的时段,避免通过详情获取其他申请人的资料。
result.put("site_info", listMap(Sqls.create("select b.*,st.stateAuditType from activity_site_reserve b left join "
+ STATES + " st on st.stateId=b.reserve_state where b.sqid=@sqid").setParam("sqid",b.getSqid())));
List<NutMap> slots=listMap(Sqls.create("select b.*,st.stateAuditType from activity_site_reserve b left join "
+ STATES + " st on st.stateId=b.reserve_state where b.sqid=@sqid").setParam("sqid",b.getSqid()));
result.put("site_info",slots);
result.put("reservationTimeGroups",groupReservationTimes(slots));
return result;
}
@@ -260,6 +388,7 @@ public class SiteBookingService extends BaseServiceImpl<ActivitySiteReserve> {
if (ids == null || ids.length == 0 || pass == null) throw new IllegalArgumentException("请选择申请及审核结果");
if (Strings.isBlank(opinion) || opinion.length() > 500) throw new IllegalArgumentException("请填写不超过500字的审核意见");
Set<String> handled = new HashSet<>();
List<ActivitySiteReserve> notifications = new ArrayList<>();
// 固定加锁顺序降低批量审核之间的死锁风险。
List<String> ordered = Arrays.stream(ids).sorted().collect(Collectors.toList());
for (String id : ordered) {
@@ -288,7 +417,11 @@ public class SiteBookingService extends BaseServiceImpl<ActivitySiteReserve> {
if (next == SCHOOL) createTask(SCHOOL,b);
else if (next == REJECT) sysLocalProcessService.refuseProcess(process(b),"审核拒绝,流程结束");
else sysLocalProcessService.completeProcess(process(b));
b.setReserve_state(next);
notifications.add(b);
}
// 整批审核业务处理完成后再通知,避免后续申请校验失败时提前发送前几条消息。
for (ActivitySiteReserve booking : notifications) notifyBooking(booking,booking.getReserve_state(),opinion);
}
/** 返回不可撤回原因;仅最近一次有效审核的本人且仍拥有该组织审核资格可以撤回。 */
@@ -332,6 +465,8 @@ public class SiteBookingService extends BaseServiceImpl<ActivitySiteReserve> {
throw new IllegalArgumentException("场地或场地类型已停用,不能恢复待审核预约");
assignments(node,booking);
List<ActivitySiteReserve> slots = query(Cnd.where("sqid","=",booking.getSqid()));
// 恢复预约同样受最新开放配置与禁用时间约束,不复活已禁用的时段。
for (ActivitySiteReserve slot : slots) siteInfoService.validateBookingSlot(site,slot.getReserve_day(),slot.getStart_time(),slot.getEnd_time());
if (Integer.valueOf(REJECT).equals(booking.getReserve_state())) {
for (ActivitySiteReserve slot : slots) {
List<ActivitySiteReserve> occupied = query(Cnd.where("site_id","=",booking.getSite_id())
@@ -341,7 +476,7 @@ public class SiteBookingService extends BaseServiceImpl<ActivitySiteReserve> {
boolean conflict = Integer.valueOf(1).equals(booking.getReserve_type())
? occupied.stream().anyMatch(row -> !Integer.valueOf(1).equals(row.getReserve_type())
|| row.getReserve_person_id().equals(slot.getReserve_person_id()))
|| site.getLimitNum() == null || occupied.size() >= site.getLimitNum()
|| site.getLimitNum() == null || siteInfoService.occupiedCount(occupied,slot.getStart_time(),slot.getEnd_time()) >= site.getLimitNum()
: !occupied.isEmpty();
if (conflict) throw new IllegalArgumentException("原预约时段已被占用或人数已满,不能撤回拒绝结果");
}
@@ -378,6 +513,26 @@ public class SiteBookingService extends BaseServiceImpl<ActivitySiteReserve> {
createTask(node,booking);
}
/**
* id 为申请中任一时段的记录主键,返回 void;仅系统管理员可删除全部已撤销的申请。
* 按 sqid 锁定并删除所有时段,关联流程和待办沿用系统删除标记,保留流程痕迹。
*/
@Aop(TransAop.READ_COMMITTED)
public void deleteCancelled(String id) {
if (!ShiroUtil.hasRole("sysadmin")) throw new IllegalArgumentException("仅系统管理员可删除已撤销预约");
ActivitySiteReserve booking = fetch(id);
if (booking == null) throw new IllegalArgumentException("预约不存在或已删除");
if (Strings.isBlank(booking.getSqid())) throw new IllegalArgumentException("预约申请编号缺失,不能删除");
List<NutMap> slots = listMap(Sqls.create("select id,reserve_state from activity_site_reserve where sqid=@sqid order by id for update")
.setParam("sqid",booking.getSqid()));
// 锁后再次检查整组状态,避免重复删除或误删同一申请中尚未撤销的时段。
if (slots.isEmpty()) throw new IllegalArgumentException("预约不存在或已删除");
if (slots.stream().anyMatch(slot -> slot.getInt("reserve_state") != CANCEL))
throw new IllegalArgumentException("只能删除已撤销的预约");
sysLocalProcessService.deleteProcessInstance(process(booking));
dao().clear(ActivitySiteReserve.class,Cnd.where("sqid","=",booking.getSqid()));
}
/** 仅申请人可撤销尚未处理的首节点申请;保留取消状态及流程记录。 */
@Aop(TransAop.READ_COMMITTED)
public void cancel(String id) {
@@ -6,6 +6,17 @@ import io.v.nutz.zhgh.activity.models.ActivitySiteInfo;
import io.v.nutz.zhgh.activity.services.SiteInfoService;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.IocBean;
import io.v.nutz.zhgh.activity.models.ActivityType;
import org.nutz.dao.Cnd;
import org.nutz.lang.Strings;
import org.nutz.ioc.aop.Aop;
import org.nutz.aop.interceptor.ioc.TransAop;
import java.util.*;
import java.time.*;
import org.nutz.json.Json;
import org.nutz.lang.util.NutMap;
import io.v.nutz.zhgh.activity.models.ActivitySiteReserve;
import io.v.nutz.web.commons.utils.ShiroUtil;
/**
* @author: Aaron
@@ -18,4 +29,151 @@ public class SiteInfoServiceImpl extends BaseServiceImpl<ActivitySiteInfo> imple
public SiteInfoServiceImpl(Dao dao) {
super(dao);
}
/**
* form 包含名称、校区、地址、管理员、电话、人数、开放时段和开关;editing=true 时必须携带有效 id。
* 返回 void;校区按 sys_dq 校验,typeId 不信任前端传值,避免隐藏类型选择后产生不可预约的场地。
*/
@Aop(TransAop.READ_COMMITTED)
public void saveManagedSite(ActivitySiteInfo form, boolean editing) {
// 名称支持选择或自定义输入,拒绝空白及超过实体字段100字符的值,类型关联仍沿用现有规则。
if (form == null || Strings.isBlank(form.getName())) throw new IllegalArgumentException("请选择或输入场地名称");
if (form.getName().length() > 100) throw new IllegalArgumentException("场地名称不能超过100字符");
if (Arrays.asList("青山湖科创中心", "不固定校区").contains(form.getCampus()) || Strings.isBlank(form.getCampus()) || form.getCampus().length() > 100
|| dao().count("sys_dq", Cnd.where("dq_name", "=", form.getCampus())) == 0)
throw new IllegalArgumentException("请选择有效校区");
if (Strings.isBlank(form.getAddress()) || form.getAddress().length() > 100)
throw new IllegalArgumentException("请填写不超过100字的场地地址");
if (Strings.isBlank(form.getContact_person()) || form.getContact_person().length() > 32)
throw new IllegalArgumentException("请填写不超过32字的场地管理员");
if (Strings.isBlank(form.getContact_phone()) || form.getContact_phone().length() > 30)
throw new IllegalArgumentException("请填写不超过30字的联系方式");
if (form.getLimitNum() == null || form.getLimitNum() < 1 || form.getLimitNum() > 100)
throw new IllegalArgumentException("限定人数应为1至100");
if (form.getState() == null) throw new IllegalArgumentException("请选择开启状态");
ActivitySiteInfo old = editing && Strings.isNotBlank(form.getId()) ? fetch(form.getId()) : null;
if (editing && old == null) throw new IllegalArgumentException("场地不存在,请刷新列表");
List<ActivityType> types = dao().query(ActivityType.class,
Cnd.where("meetingTypeName", "=", "职工之家").and("enabled", "=", true));
if (types.size() != 1) throw new IllegalArgumentException("请配置唯一且启用的职工之家场地类型");
// 保存和提交使用同一场地行锁,避免配置变更与预约提交并发穿透。
if (editing) {
org.nutz.dao.sql.Sql lock = org.nutz.dao.Sqls.create("select id from activity_site_info where id=@id for update").setParam("id", form.getId());
dao().execute(lock);
}
normalizeSchedule(form, editing);
form.setTypeId(types.get(0).getId());
// 控件已隐藏:新增不限制性别,编辑保留原值,避免未展示的字段被请求篡改。
form.setSexLimit(editing && old.getSexLimit()!=null ? old.getSexLimit() : 0);
if (editing) {
form.setCreate_username(old.getCreate_username());
form.setCreate_time(old.getCreate_time());
updateIgnoreNull(form);
} else {
form.setId(null);
insert(form);
}
}
/** 严格解析分钟,24:00仅用于结束边界,不接受跨日或秒级配置。 */
private int minute(String value, boolean end) {
if (end && "24:00".equals(value)) return 1440;
if (value == null || !value.matches("[0-2][0-9]:[0-5][0-9]")) throw new IllegalArgumentException("请填写有效的HH:mm时间");
try { LocalTime t = LocalTime.parse(value); return t.getHour()*60+t.getMinute(); }
catch (RuntimeException e) { throw new IllegalArgumentException("时间必须在00:00至24:00之间"); }
}
private String clockText(int value) {
return String.format("%02d:%02d",value/60,value%60);
}
/** 同一分钟先合并结束和开始事件,首尾相接的预约不会重复占用。 */
public int occupiedCount(List<ActivitySiteReserve> rows,String start,String end) {
SortedMap<Integer,Integer> events=new TreeMap<>();
int from=minute(start,false),to=minute(end,true),current=0,peak=0;
for(ActivitySiteReserve row:rows){
int a=Math.max(from,minute(row.getStart_time(),false)),b=Math.min(to,minute(row.getEnd_time(),true));
if(a<b){events.merge(a,1,Integer::sum);events.merge(b,-1,Integer::sum);}
}
for(int change:events.values()){current+=change;peak=Math.max(peak,current);}
return peak;
}
/** 两套原始配置独立保存,仅将当前模式展开为既有open_hours,兼容原有列表和日历。 */
private void normalizeSchedule(ActivitySiteInfo form, boolean editing) {
int mode = form.getReserveTimeType()==null ? (editing ? 1 : 2) : form.getReserveTimeType();
if (mode!=1 && mode!=2) throw new IllegalArgumentException("请选择有效预约时间段类型");
form.setReserveTimeType(mode);
List<NutMap> ranges = mode==2 ? Collections.singletonList(form.getFullDayOpenHour()) : form.getSegmentedOpenHours();
// 老场地第一次编辑没有独立配置时沿用原始场次,不擅自缩短预约时长。
if (mode==1 && (ranges==null || ranges.isEmpty())) ranges=Json.fromJsonAsList(NutMap.class,Json.toJson(form.getOpen_hours()));
if (ranges==null || ranges.isEmpty()) throw new IllegalArgumentException("请配置至少一个开放时间段");
List<NutMap> normalized=new ArrayList<>(), slots=new ArrayList<>();
for (NutMap row:ranges) {
if(row==null) throw new IllegalArgumentException("请配置开放起止时间");
int start=minute(row.getString("start_time"),false), end=minute(row.getString("end_time"),true);
if(end<=start) throw new IllegalArgumentException("开放结束时间必须晚于开始时间");
int unit=end-start;
if(row.get("timeUnit")!=null) {
try { unit=Integer.parseInt(String.valueOf(row.get("timeUnit"))); }
catch(RuntimeException e){throw new IllegalArgumentException("预约时间单位必须为正整数分钟");}
} else if(mode==2) throw new IllegalArgumentException("请配置全天候预约时间单位");
if(unit<1 || unit>end-start || (end-start)%unit!=0) throw new IllegalArgumentException("预约时间单位必须为正整数,且能整除开放时长");
for(NutMap previous:normalized) if(start<minute(previous.getString("end_time"),true) && end>minute(previous.getString("start_time"),false))
throw new IllegalArgumentException("分段场次不能互相重叠");
normalized.add(NutMap.NEW().setv("start_time",clockText(start)).setv("end_time",clockText(end)).setv("timeUnit",unit));
for(int cursor=start;cursor<end;cursor+=unit) slots.add(NutMap.NEW().setv("start_time",clockText(cursor)).setv("end_time",clockText(cursor+unit)));
}
slots.sort(Comparator.comparing(row->row.getString("start_time")));
if(mode==1)form.setSegmentedOpenHours(normalized);else form.setFullDayOpenHour(normalized.get(0));
form.setOpen_hours(slots);
List<NutMap> disabled=form.getNotApplyTimeList()==null ? new ArrayList<>() : form.getNotApplyTimeList();
for(NutMap row:disabled){
if(row==null)throw new IllegalArgumentException("请填写完整的禁用时间");
try{LocalDate.parse(row.getString("date"));}catch(RuntimeException e){throw new IllegalArgumentException("请选择有效的禁用日期");}
if(minute(row.getString("endTime"),true)<=minute(row.getString("startTime"),false))throw new IllegalArgumentException("禁用结束时间必须晚于开始时间");
}
form.setNotApplyTimeList(disabled);
}
/** 半开区间判定:结束恰好等于禁用开始允许预约,有实际交叉才拦截。 */
public void validateBookingSlot(ActivitySiteInfo site,String day,String start,String end) {
LocalDate date;
try{date=LocalDate.parse(day);}catch(RuntimeException e){throw new IllegalArgumentException("请选择有效预约日期");}
int from=minute(start,false),to=minute(end,true);
if(to<=from)throw new IllegalArgumentException("预约结束时间必须晚于开始时间");
if(Boolean.TRUE.equals(site.getWorkday()) && date.getDayOfWeek().getValue()>=6)throw new IllegalArgumentException("该场地仅支持工作日预约");
List<NutMap> open=Json.fromJsonAsList(NutMap.class,Json.toJson(site.getOpen_hours()));
if(open==null || open.stream().noneMatch(row->start.equals(row.getString("start_time")) && end.equals(row.getString("end_time"))))
throw new IllegalArgumentException("所选时段不在当前开放场次中,请刷新重选");
if(site.getNotApplyTimeList()!=null)for(NutMap range:site.getNotApplyTimeList()){
if(day.equals(range.getString("date")) && from<minute(range.getString("endTime"),true) && to>minute(range.getString("startTime"),false))
throw new IllegalArgumentException("所选时段与禁用时间冲突");
}
}
/** PC/H5共享可约判定,按重叠时段查占用,兼容历史整段预约与新拆分时段。 */
public List<NutMap> availableSlots(String siteId,String day,Integer reserveType){
ActivitySiteInfo site=fetch(siteId);
if(site==null || !Boolean.TRUE.equals(site.getState()))throw new IllegalArgumentException("场地不存在或已停用");
LocalDate date=LocalDate.parse(day);
String uid=String.valueOf(ShiroUtil.getPrincipalProperty("id"));
List<NutMap> slots=Json.fromJsonAsList(NutMap.class,Json.toJson(site.getOpen_hours()));
if(slots==null)return new ArrayList<>();
for(NutMap slot:slots){
String start=slot.getString("start_time"),end=slot.getString("end_time"),reason=null;
List<ActivitySiteReserve> occupied=dao().query(ActivitySiteReserve.class,Cnd.where("site_id","=",siteId).and("reserve_day","=",day)
.and("start_time","<",end).and("end_time",">",start).and("reserve_state","not in",Arrays.asList(4040,4050)));
try{validateBookingSlot(site,day,start,end);}catch(IllegalArgumentException e){reason=e.getMessage();}
if(reason==null && !LocalDateTime.of(date,LocalTime.parse(start)).isAfter(LocalDateTime.now()))reason="预约时段已过期";
if(reason==null && occupied.stream().anyMatch(row->uid.equals(row.getReserve_person_id())))reason="已预约";
if(reason==null && (occupied.stream().anyMatch(row->!Integer.valueOf(1).equals(row.getReserve_type()))
|| site.getLimitNum()==null || occupiedCount(occupied,start,end)>=site.getLimitNum()
|| reserveType!=null && reserveType!=1 && !occupied.isEmpty()))reason="已约满";
slot.setv("code",reason==null ? 1 : -2).setv("msg",reason==null ? "可预约" : reason)
.setv("limitNum",site.getLimitNum()).setv("reserveNum",occupiedCount(occupied,start,end)).setv("disabled",reason!=null)
.setv("backColor",reason==null ? "#e8ffef" : "").setv("color",reason==null ? "#52986a" : "");
}
return slots;
}
}
@@ -56,6 +56,8 @@ public interface SourceData {
put("SFZJH", new String[]{"idcard"}); // 身份证件号
put("ZZMMM", new String[]{"political"}); // 政治面貌码
put("DQZTM", new String[]{"userState", "personalStatus"}); // 在职状态码
put("ZZZTM", new String[]{"zzztm"}); // 保留源代码,供人员更新阶段筛选
put("ZZZTMC", new String[]{"zzztmc"}); // 保留源名称,不做字典转换
put("RYFLMC", new String[]{"personType"}); // 人员类型码
put("ZGXLM", new String[]{"education"}); // 最高学历码
put("ZGXWM", new String[]{"academicDegree"}); // 最高学位码
@@ -104,6 +106,7 @@ public interface SourceData {
// checkSuccess(map);
List<NutMap> data = map.getAsList("data", NutMap.class);
for (NutMap row : data) {
// 源人员全量保存,包括非 100 和状态缺失的记录;筛选统一放在人员更新阶段。
Map entity = new HashMap(500);
row.forEach((k, v) -> {
@@ -146,33 +149,51 @@ public interface SourceData {
}};
/**
* 获取单位
* 分页获取全部源单位,无入参;响应异常或空页时抛出异常,阻止不完整同步。
*
* @return units
* @return 单位列表,DWH 映射为 id/unitcodeDWMC 为名称,SJDWH 为父级编号
*/
static List<Sys_unit> units() {
List<Sys_unit> units = new ArrayList<>();
int page = 1;
String body = HttpUtil.createPost(DATA_URL).body(JSON.toJSONString(new NutMap().addv("address", "rsxt_dwjbsj").addv("params", new NutMap())
.addv("token", "3318a5a9-c2f2-4c8b-a8ea-e99dd68c165c").addv("pageIndex", page).addv("pageSize", 100))).execute().body();
NutMap map = Json.fromJson(NutMap.class, body);
// checkSuccess(map);
List<NutMap> data = map.getAsList("data", NutMap.class);
while (true) {
String body = HttpUtil.createPost(DATA_URL).body(JSON.toJSONString(new NutMap().addv("address", "rsxt_dwjbsj").addv("params", new NutMap())
.addv("token", "3318a5a9-c2f2-4c8b-a8ea-e99dd68c165c").addv("pageIndex", page).addv("pageSize", 100))).execute().body();
NutMap map = Json.fromJson(NutMap.class, body);
// 缺少数据或明确返回失败时不能当作同步成功,避免用不完整单位继续更新人员。
if (map == null || (map.containsKey("success") && !map.getBoolean("success"))
|| !map.containsKey("data") || !map.containsKey("totalCount")) {
throw new IllegalStateException("单位同步失败:数据中心响应异常,请核对单位源接口。");
}
List<NutMap> data = map.getAsList("data", NutMap.class);
int totalCount = map.getInt("totalCount");
if (data == null || data.isEmpty() || totalCount <= 0) {
throw new IllegalStateException("单位同步失败:数据中心返回空页或总数异常,第 " + page + " 页。");
}
for (NutMap row : data) {
Map entity = new HashMap(5);
row.forEach((k, v) -> {
if (UNIT_FIELD_RELATION.containsKey(k)) {
Object value = v;
/* if (UNIT_FIELD_PLUGIN.containsKey(k)) {
value = UNIT_FIELD_PLUGIN.get(k).run(v);
}*/
for (String key : UNIT_FIELD_RELATION.get(k)) {
entity.put(key, value);
}
for (NutMap row : data) {
if (row == null) {
throw new IllegalStateException("单位同步失败:源单位记录为空。");
}
});
units.add(BeanUtil.mapToBean(entity, Sys_unit.class, true));
Map entity = new HashMap(5);
row.forEach((k, v) -> {
if (UNIT_FIELD_RELATION.containsKey(k)) {
Object value = v;
/* if (UNIT_FIELD_PLUGIN.containsKey(k)) {
value = UNIT_FIELD_PLUGIN.get(k).run(v);
}*/
for (String key : UNIT_FIELD_RELATION.get(k)) {
entity.put(key, value);
}
}
});
units.add(BeanUtil.mapToBean(entity, Sys_unit.class, true));
}
// 根据源接口总数逐页拉取,避免原先只读取前 100 个单位。
if (units.size() >= totalCount) {
break;
}
page++;
}
return units;
}
@@ -1,17 +1,17 @@
package io.v.nutz.zhgh.data.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.wizzer.framework.base.Result;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.dao.CndPlus;
import io.v.nutz.base.query.PageForm;
import io.v.nutz.base.service.AsyncService;
import io.v.nutz.base.service.ViService;
import io.v.nutz.sys.services.SysUnitService;
import io.v.nutz.sys.models.Sys_unit;
import io.v.nutz.sys.services.SysDqService;
import io.v.nutz.sys.services.SysGxService;
import io.v.nutz.sys.services.SysUnitClassService;
import io.v.nutz.zhgh.data.constant.SourceData;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.ioc.aop.Aop;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
@@ -25,8 +25,6 @@ import org.nutz.mvc.annotation.Ok;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@At("/platform/data/unit")
@Ok("json:full")
@@ -35,8 +33,8 @@ public class UpdateUnitController {
private static final Log log = Logs.get();
@Inject("Sys_unit")
private ViService<Sys_unit> sysUnitService;
@Inject
private SysUnitService sysUnitService;
@Inject
private SysUnitClassService sysUnitClassService;
@@ -61,45 +59,16 @@ public class UpdateUnitController {
/**
* 单位数据更新
*
* @return {@link Object}
* 无入参,调用 service 同步单位;返回 null,由 ViReturn 转为 code/msg 响应。
* 同步异常由 ViReturn 返回失败提示。
* @return 同步成功返回 null
*/
@At
@ViReturn
@RequiresPermissions("sys.data.unit")
@Aop(TransAop.READ_COMMITTED)
public Object dataUpdate() {
List<Sys_unit> sys_units = sysUnitService.query();
List<String> list = sys_units.stream().map(Sys_unit::getId).collect(Collectors.toList());
// 从源数据中心拉取所有的单位
List<Sys_unit> units = SourceData.units();
for (Sys_unit unit : units) {
if (list.contains(unit.getId())) {
sysUnitService.updateIgnoreNull(unit);
} else {
Map<String, Object> beanMap = BeanUtil.beanToMap(unit);
String unitcode = beanMap.get("unitcode").toString();
if (unitcode.length() == 6) {
beanMap.put("unitlevel", 2);
beanMap.put("parentId", 1);
}
if (beanMap.get("id").equals("100")) {
beanMap.put("unitlevel", 1);
beanMap.put("id", 1);
beanMap.put("unitcode", 1);
}
beanMap.remove("child");
sysUnitService.insert("sys_unit", Chain.from(beanMap));
}
}
sys_units = sysUnitService.query();
sys_units.forEach(v -> {
if (sysUnitService.count(Cnd.where("parentId", "=", v.getId())) > 0) { //查询此单位是否有父级单位
v.setHasChildren(true); //设置子级菜单
sysUnitService.update(v);
}
});
sysUnitService.syncSourceUnits();
return null;
}
@@ -9,6 +9,8 @@ import cn.hutool.http.HtmlUtil;
import io.v.nutz.base.utils.ManyAddOrRenewUtil;
import io.v.nutz.base.utils.Roles;
import io.v.nutz.sys.models.Sys_user_role;
import io.v.nutz.sys.models.Sys_unit;
import io.v.nutz.sys.services.SysUnitService;
import io.v.nutz.sys.services.SysDictService;
import io.v.nutz.sys.services.SysUserRoleService;
import io.v.nutz.zhgh.activity.models.ActivityUserScope;
@@ -83,6 +85,8 @@ public class SourceUserServiceImpl extends ViServiceImpl<UserSource> implements
@Inject
private SysUserService sysUserService;
@Inject
private SysUnitService sysUnitService;
@Inject
private HistoryUserService historyUserService;
@Inject
private UserPartUpService userPatUpService;
@@ -109,25 +113,39 @@ public class SourceUserServiceImpl extends ViServiceImpl<UserSource> implements
dao().insert(users);
}
/**
* 先同步单位并校验人员引用,再按现有配置生成记录和更新人员。
* @param pullTime 已拉取人员数据的批次时间
* @param sourceType all 全部更新、add 新增人员、part 按组别及过滤字段更新,三种方式均只处理 zzztm=100
* @param columnNames 部分更新时忽略的字段名,可为空
* @param isUpSet 保留现有接口参数,当前方法不使用
* @param partGroupId 更新组别 ID,为空时使用整个批次
* @param isInvert 是否选择组别之外的人员
* @return 无返回值;同步或校验失败抛出异常,由接口返回 code/msg 提示
*/
@Override
@Aop(TransAop.READ_COMMITTED)
public void updateSysUser(String pullTime, String sourceType, String[] columnNames, String isUpSet, String partGroupId, boolean isInvert) {
try {
// 单位与后续校验使用当前事务,单位同步失败时不进入人员更新。
sysUnitService.syncSourceUnits();
List<UserSource> sources = new ArrayList<>();
Map<String, String> userPartMap = new HashMap<>();
// 三种更新方式及定时更新共用筛选;先于分组、单位校验和会员变更,其他源记录仍保留。
Cnd sourceCnd = Cnd.where("pullTime", "=", pullTime).and("zzztm", "=", "100");
if (Strings.isNotBlank(partGroupId)) {
//如果为true,更新组别之外人员
Sql sql = Sqls.create("select u.loginname from user_part up left join `user` u on u.id=up.userId where up.groupId = @groupId").setParam("groupId", partGroupId);
List<String> loginNameList = userPatUpService.listMap(sql).stream().map(o -> o.getString("loginname")).collect(Collectors.toList());
if (isInvert) {
sources = query(Cnd.where("pullTime", "=", pullTime).and("loginname", "not in", loginNameList).groupBy("loginname"));
sources = query(sourceCnd.and("loginname", "not in", loginNameList).groupBy("loginname"));
userPartMap = sources.stream().collect(Collectors.toMap(Sys_user::getLoginname, Sys_user::getLoginname));
} else {
userPartMap = userPatUpService.query(Cnd.where("groupId", "=", partGroupId)).stream().collect(Collectors.toMap(UserPartUp::getLoginname, UserPartUp::getLoginname));
sources = query(Cnd.where("pullTime", "=", pullTime).and("loginname", "in", loginNameList).groupBy("loginname"));
sources = query(sourceCnd.and("loginname", "in", loginNameList).groupBy("loginname"));
}
} else {
sources = query(Cnd.where("pullTime", "=", pullTime).groupBy("loginname"));
sources = query(sourceCnd.groupBy("loginname"));
}
// 查询所有用户,判断是否需要更新
@@ -172,104 +190,89 @@ public class SourceUserServiceImpl extends ViServiceImpl<UserSource> implements
Set<String> userIds = list.stream().map(SpecialStaff::getUserId).collect(Collectors.toSet());
// 创建一个固定大小的线程池 可以根据服务器性能调整线程池大小
int numberOfThreads = Runtime.getRuntime().availableProcessors() * 2;
List<CompletableFuture<Void>> futures = new CopyOnWriteArrayList<>();
// 每批处理的数据量,可以根据实际情况调整
int batchSize = 200;
// 写入人员、角色、历史之前统一校验;记录计算留在当前线程,读取本事务新同步的单位。
validateSourceUnits(sources, userMap, userIds, allowChangeFieldNames);
for (UserSource source : sources) {
//不更新会员和福利会员字段
source.setMember(null);
source.setWelfareMember(null);
Sys_user user = userMap.get(source.getLoginname());
for (int i = 0; i < sources.size(); i += batchSize) {
final int end = Math.min(i + batchSize, sources.size());
List<UserSource> batch = sources.subList(i, end);
Map<String, String> finalUserPartMap = userPartMap;
if (user != null && userIds.contains(user.getId())) {
continue;
}
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
for (UserSource source : batch) {
//不更新会员和福利会员字段
source.setMember(null);
source.setWelfareMember(null);
Sys_user user = userMap.get(source.getLoginname());
if (StrUtil.isBlank(source.getPersonType())) {
continue;
}
if (user != null && userIds.contains(user.getId())) {
continue;
}
// 这里是杭医的不进系统人员的判断,其他学校用不到的话删掉
boolean isNotEnterUser = NOT_ENTERING_PERSON_TYPE.contains(source.getPersonType())
|| NOT_ENTERING_USER_LOGIN_NAME.contains(source.getLoginname())
|| NOT_ENTERING_USER_STATE.contains(source.getUserState());
if (StrUtil.isBlank(source.getPersonType())) {
continue;
}
if (isAuto) {
checkMemberOrWelfareMember(changeConfig, source, user, addMemberUserIds, deleteMemberUserIds,
addWelfareMemberUserIds, deleteWelfareMemberUserIds);
} else {
if (user != null) {
source.setMember(user.getMember());
source.setWelfareMember(user.getWelfareMember());
}
}
// 这里是杭医的不进系统人员的判断,其他学校用不到的话删掉
boolean isNotEnterUser = NOT_ENTERING_PERSON_TYPE.contains(source.getPersonType())
|| NOT_ENTERING_USER_LOGIN_NAME.contains(source.getLoginname())
|| NOT_ENTERING_USER_STATE.contains(source.getUserState());
if (isAuto) {
checkMemberOrWelfareMember(changeConfig, source, user, addMemberUserIds, deleteMemberUserIds,
addWelfareMemberUserIds, deleteWelfareMemberUserIds);
} else {
if (user != null) {
source.setMember(user.getMember());
source.setWelfareMember(user.getWelfareMember());
}
}
Sys_user u = new Sys_user();
BeanUtils.copyProperties(source, u);
switch (sourceType) {
case "all" -> {
// 复制属性到一个新的user对象
u.setId(user == null ? source.getId() : user.getId());
if (user != null) {
needDoUpdateList.add(u);
}
}
case "add" -> {
u.setId(source.getId());
}
case "part" -> {
u.setId(user == null ? source.getId() : user.getId());
if (columnNames != null && columnNames.length > 0) {
String lockedColumn = String.join("|", columnNames);
FieldFilter fieldFilter = FieldFilter.create(Sys_user.class, null, "^" + lockedColumn + "$", true);
filterColumnDao.set(Daos.ext(dao(), fieldFilter));
}
if (Strings.isNotBlank(finalUserPartMap.get(u.getLoginname())) && user != null) {
needDoUpdateList.add(u);
}
}
}
if (isAuto) {
UserHistory history = createHistory(source, user, dictMap, allowChangeFieldNames);
if (Lang.isEmpty(history)) {
continue;
}
if (user != null) {
histories.add(history);
}
if (!isNotEnterUser && Lang.isNotEmpty(history.getChangeTypes()) && history.getChangeTypes().contains(MemberChangeType.NEW.getType())) {
needInitUserList.add(u);
histories.add(history);
}
} else {
SourceChangeMiddleTable table = createSourceChangeMiddleTable(source, user, dictMap, allowChangeFieldNames);
if (Lang.isEmpty(table)) {
continue;
}
if (user != null) {
middleTables.add(table);
}
if (!isNotEnterUser && Lang.isNotEmpty(table.getChangeTypes()) && table.getChangeTypes().contains(MemberChangeType.NEW.getType())) {
needInitUserList.add(u);
middleTables.add(table);
}
Sys_user u = new Sys_user();
BeanUtils.copyProperties(source, u);
switch (sourceType) {
case "all" -> {
// 复制属性到一个新的user对象
u.setId(user == null ? source.getId() : user.getId());
if (user != null) {
needDoUpdateList.add(u);
}
}
}, Executors.newFixedThreadPool(numberOfThreads));
futures.add(future);
}
case "add" -> {
u.setId(source.getId());
}
case "part" -> {
u.setId(user == null ? source.getId() : user.getId());
if (columnNames != null && columnNames.length > 0) {
String lockedColumn = String.join("|", columnNames);
FieldFilter fieldFilter = FieldFilter.create(Sys_user.class, null, "^" + lockedColumn + "$", true);
filterColumnDao.set(Daos.ext(dao(), fieldFilter));
}
if (Strings.isNotBlank(userPartMap.get(u.getLoginname())) && user != null) {
needDoUpdateList.add(u);
}
}
}
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
if (isAuto) {
UserHistory history = createHistory(source, user, dictMap, allowChangeFieldNames);
if (Lang.isEmpty(history)) {
continue;
}
if (user != null) {
histories.add(history);
}
if (!isNotEnterUser && Lang.isNotEmpty(history.getChangeTypes()) && history.getChangeTypes().contains(MemberChangeType.NEW.getType())) {
needInitUserList.add(u);
histories.add(history);
}
} else {
SourceChangeMiddleTable table = createSourceChangeMiddleTable(source, user, dictMap, allowChangeFieldNames);
if (Lang.isEmpty(table)) {
continue;
}
if (user != null) {
middleTables.add(table);
}
if (!isNotEnterUser && Lang.isNotEmpty(table.getChangeTypes()) && table.getChangeTypes().contains(MemberChangeType.NEW.getType())) {
needInitUserList.add(u);
middleTables.add(table);
}
}
}
//如果有新用户,增加到用户表同时增加角色
if (Lang.isNotEmpty(needInitUserList)) {
@@ -322,11 +325,69 @@ public class SourceUserServiceImpl extends ViServiceImpl<UserSource> implements
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e.getMessage());
throw new RuntimeException(e.getMessage(), e);
}
}
/**
* 校验本次范围内参与新增、更新或变更记录生成的单位,失败时阻断全部人员写入。
* @param sources 已按数据源时间、组别及反选条件筛选的人员
* @param userMap 以工号为键的现有人员,用于检查变更前单位
* @param excludedUserIds 按现有特殊人员规则不做变动的人员 ID
* @param allowChangeFieldNames 允许记录变更的字段,含 unitId 时核对变更前单位
* @return 无返回值;缺失时抛出包含单位编号、姓名和工号的异常,供接口 msg 展示
*/
private void validateSourceUnits(List<UserSource> sources, Map<String, Sys_user> userMap,
Set<String> excludedUserIds, Set<String> allowChangeFieldNames) {
Map<String, Sys_unit> units = sysUnitService.query().stream()
.collect(Collectors.toMap(Sys_unit::getId, unit -> unit));
List<String> missing = new ArrayList<>();
for (UserSource source : sources) {
Sys_user user = userMap.get(source.getLoginname());
if (StrUtil.isBlank(source.getPersonType()) || (user != null && excludedUserIds.contains(user.getId()))) {
continue;
}
// 不进系统规则只排除新增人员;现有人员仍按原逻辑生成变更记录。
if (user == null && (NOT_ENTERING_PERSON_TYPE.contains(source.getPersonType())
|| NOT_ENTERING_USER_LOGIN_NAME.contains(source.getLoginname())
|| (source.getUserState() != null && NOT_ENTERING_USER_STATE.contains(source.getUserState())))) {
continue;
}
collectMissingUnit(units, source.getUnitid(), "新单位", source, missing);
if (user != null && allowChangeFieldNames.contains("unitId")
&& !Objects.equals(source.getUnitid(), user.getUnitid())) {
collectMissingUnit(units, user.getUnitid(), "原单位", source, missing);
}
}
if (!missing.isEmpty()) {
// 页面提示限制长度,同时告知总数;完整明细写日志便于核对。
log.warn("人员更新单位校验失败:{}", String.join("", missing));
throw new IllegalStateException("单位同步校验后仍存在缺失单位或单位名称为空,本次人员更新已停止。"
+ String.join("", missing.subList(0, Math.min(10, missing.size())))
+ (missing.size() > 10 ? ";共 " + missing.size() + " 项,完整明细请查看服务日志" : "")
+ "。请核对单位源数据。");
}
}
/**
* 将不存在、编号为空或名称为空的单位加入提示明细;仅收集问题,不修改数据。
* @param units 当前事务同步后的单位,键为单位 ID
* @param unitId 人员引用的单位 ID,空值也需提示
* @param label 新单位或原单位,标明问题来源
* @param source 相关人员,提供姓名及工号
* @param missing 校验失败明细,返回结果追加到此集合;方法返回 void
*/
private void collectMissingUnit(Map<String, Sys_unit> units, String unitId, String label,
UserSource source, List<String> missing) {
Sys_unit unit = units.get(unitId);
if (StrUtil.isBlank(unitId) || unit == null || StrUtil.isBlank(unit.getName())) {
missing.add(label + "编号:" + Strings.sBlank(unitId, "未提供")
+ ",相关人员:" + Strings.sBlank(source.getUsername(), "未提供姓名")
+ "(工号:" + Strings.sBlank(source.getLoginname(), "未提供") + "");
}
}
/**
* 判断自动更新的会员和福利会员
* @param config 人员更新的配置
@@ -553,8 +614,9 @@ public class SourceUserServiceImpl extends ViServiceImpl<UserSource> implements
if (Lang.isEmpty(changeList)) {
return null;
}
// 单位缺失由前置校验阻断,其他字段的空值按原业务展示为无数据。
String changeInfos = changeList.stream().map(v -> {
return v.getString("fieldName") + "" + HtmlUtil.cleanHtmlTag(v.getString("sourceValue")) + "—>" + HtmlUtil.cleanHtmlTag(v.getString("newValue"));
return v.getString("fieldName") + "" + HtmlUtil.cleanHtmlTag(Strings.sBlank(v.getString("sourceValue"), "无数据")) + "—>" + HtmlUtil.cleanHtmlTag(Strings.sBlank(v.getString("newValue"), "无数据"));
}).collect(Collectors.joining(""));
// 比较变更数据
@@ -609,8 +671,9 @@ public class SourceUserServiceImpl extends ViServiceImpl<UserSource> implements
if (Lang.isEmpty(changeList)) {
return null;
}
// 单位缺失由前置校验阻断,其他字段的空值按原业务展示为无数据。
String changeInfos = changeList.stream().map(v -> {
return v.getString("fieldName") + "" + HtmlUtil.cleanHtmlTag(v.getString("sourceValue")) + "—>" + HtmlUtil.cleanHtmlTag(v.getString("newValue"));
return v.getString("fieldName") + "" + HtmlUtil.cleanHtmlTag(Strings.sBlank(v.getString("sourceValue"), "无数据")) + "—>" + HtmlUtil.cleanHtmlTag(Strings.sBlank(v.getString("newValue"), "无数据"));
}).collect(Collectors.joining(""));
// 比较变更数据
commonCompareChange(source, user, changeTypes);
@@ -134,7 +134,8 @@ public class GhkhLssjcxController {
if (ShiroUtil.hasAnyRoles("sysadmin,SchoolUnionAdmin")) {
result.add(new NutMap().setv("title", title).setv("url", "/platform/ghkh/xghsh").setv("iconClass", vi.getIconByPath("/platform/ghkh/xghsh")).setv("label", "校工会审核").setv("number", getXghCount()));
}
return result;
// 保留原有任务数据范围,再按当前账号的目标页面权限过滤入口。
return io.v.nutz.sys.services.TodoAccessService.filter(result, "url");
}
@@ -46,7 +46,8 @@ public class dbYxAgentController {
if (ShiroUtil.hasAnyRoles("sysadmin,SchoolUnionAdmin")) {
result.add(new NutMap().setv("title", title).setv("url", UNION).setv("iconClass", vi.getIconByPath(UNION)).setv("label", "待校工会审核").setv("number", getUnionCount()));
}
return result;
// 保留原有任务数据范围,再按当前账号的目标页面权限过滤入口。
return io.v.nutz.sys.services.TodoAccessService.filter(result, "url");
}
@@ -80,7 +80,8 @@ public class ActivitybxAgentController {
}
}
return result;
// 保留原有任务数据范围,再按当前账号的目标页面权限过滤入口。
return io.v.nutz.sys.services.TodoAccessService.filter(result, "url");
}
@@ -43,7 +43,8 @@ public class LxyAgentController {
result.add(new NutMap().setv("title", title).setv("url", FGHSH).setv("iconClass", vi.getIconByPath(FGHSH)).setv("label", "待院级工会审核").setv("number", getFghshCount()));
result.add(new NutMap().setv("title", title).setv("url", XGHSH).setv("iconClass", vi.getIconByPath(XGHSH)).setv("label", "待校工会审核").setv("number", getXghshCount().size()));
}
return result;
// 保留原有任务数据范围,再按当前账号的目标页面权限过滤入口。
return io.v.nutz.sys.services.TodoAccessService.filter(result, "url");
}
private List<Record> getXghshCount() {
@@ -171,8 +171,8 @@ public class MainPageNeedItemsController {
@At
@ViReturn
@RequiresAuthentication
public Object getNeedItems() {
return needItemsService.getNeedItems();
public Object getNeedItems(Boolean mobile) {
return needItemsService.getNeedItems(Boolean.TRUE.equals(mobile));
}
}
@@ -8,4 +8,6 @@ import java.util.List;
public interface MainPageNeedItemsService extends ViService<NeedItems> {
List<NeedItems> getNeedItems();
/** mobile 指明跳转端,返回当前权限可访问且数量大于零的待办。 */
List<NeedItems> getNeedItems(boolean mobile);
}
@@ -27,7 +27,10 @@ public class MainPageNeedItemsServiceImpl extends ViServiceImpl<NeedItems> imple
}
@Override
public List<NeedItems> getNeedItems() {
public List<NeedItems> getNeedItems() { return getNeedItems(false); }
@Override
public List<NeedItems> getNeedItems(boolean mobile) {
//查询数据库中的待办事项
List<NeedItems> needItemsList = dao().queryByJoin(NeedItems.class, "^needItemsSource$", Cnd.NEW());
@@ -91,6 +94,8 @@ public class MainPageNeedItemsServiceImpl extends ViServiceImpl<NeedItems> imple
List<NeedItems> result = needItemsList.stream().filter(v -> Strings.isNotBlank(v.getHref())
&& menus.stream().anyMatch(x -> Strings.isNotBlank(x.getHref()) && x.getHref().equals(v.getHref()))).distinct().collect(Collectors.toList());
return result.stream().filter(v -> v.getCount() > 0).collect(Collectors.toList());
return result.stream().filter(v -> v.getCount() > 0)
.filter(v -> io.v.nutz.sys.services.TodoAccessService.canAccess(mobile ? v.getMobileHref() : v.getHref()))
.collect(Collectors.toList());
}
}
@@ -50,7 +50,8 @@ public class ManuscriptAgentController {
Sys_user user = (Sys_user) ShiroUtil.getPrincipal();
List<Sys_menu> menus = Optional.ofNullable(user).orElse(new Sys_user()).getMenus();
return result.stream().filter(v -> Strings.isNotBlank(v.getString("url")) && menus.stream().anyMatch(x -> Strings.isNotBlank(x.getHref()) && v.getString("url").contains(x.getHref()))).distinct().collect(Collectors.toList());
// 保留原有任务数据范围,再按当前账号的目标页面权限过滤入口。
return result.stream().filter(v -> Strings.isNotBlank(v.getString("url")) && menus.stream().anyMatch(x -> Strings.isNotBlank(x.getHref()) && v.getString("url").contains(x.getHref()))).filter(v -> io.v.nutz.sys.services.TodoAccessService.canAccess(v.getString("url"))).distinct().collect(Collectors.toList());
}
@@ -148,8 +148,7 @@ public class SiteInfoMobileController {
info.name,
info.address,
`as`.stateAuditType,
count(sqid) days,
GROUP_CONCAT(reserve_day order by reserve_day asc) concat_day
count(distinct reserve_day) days
from
activity_site_reserve ar
left join activity_site_info info on info.id = ar.site_id
@@ -176,7 +175,8 @@ public class SiteInfoMobileController {
sql.setCondition(cnd);
return siteInfoService.listPage(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
return siteBookingService.reservationPage(pageForm.getPageNumber(), pageForm.getPageSize(), sql,
Boolean.TRUE.equals(timeSwitch) ? null : time);
}
@At("/getDetail")
@@ -207,65 +207,9 @@ public class SiteInfoMobileController {
@At("/getReserve")
@Ok("json:full")
@ViReturn
public Object getReserve(String siteId, String day) {
//获取场地的开放时间
ActivitySiteInfo fetch = siteInfoService.fetch(siteId);
List<NutMap> hours = fetch.getOpen_hours();
Integer limitNum = fetch.getLimitNum();
hours.forEach(item -> {
String startTime = item.getString("start_time");
String endTime = item.getString("end_time");
item.put("code", 1);
item.put("msg", "可预约");
item.put("backColor", "#e8ffef");
item.put("color", "#52986a");
item.put("limitNum", limitNum);
//如果这个时间段过了,显示已过期
String time = day + " " + startTime;
int compare = DateUtil.compare(new Date(), DateUtil.parse(time), "yyyy-MM-dd HH:mm");
if(compare > 0) {
item.put("code", -1);
item.put("msg", "已过期");
item.put("backColor", "");
item.put("color", "");
}
List<ActivitySiteReserve> list = siteReserveService.query(Cnd.NEW()
.and("reserve_day", "=", day)
.and("start_time", "=", startTime)
.and("end_time", "=", endTime)
.and("site_id", "=", siteId)
.and("reserve_state", "not in", java.util.Arrays.asList(4040,4050)));
//如果这个时间段被单位预约了,直接显示约满
ActivitySiteReserve reserve1 = list.stream().filter(o -> o.getReserve_type() != 1).findAny().orElse(null);
if(reserve1 != null) {
item.put("code", -2);
item.put("msg", "已约满");
item.put("backColor", "");
item.put("color", "");
}
//如果这个时间段预约的人数满了,显示约满
if(list.size() >= limitNum) {
item.put("code", -1);
item.put("msg", "已约满");
item.put("backColor", "");
item.put("color", "");
}
//如果预约过了,显示已预约
ActivitySiteReserve reserve = list.stream().filter(o -> o.getReserve_person_id().equals(ShiroUtil.getPrincipalProperty("id"))).findAny().orElse(null);
if(reserve != null && reserve.getReserve_type() != 2) {
item.put("code", -1);
item.put("msg", "已预约");
item.put("backColor", "#0e78c5");
item.put("color", "#fff3f3");
}
item.put("reserveNum", list.size());
});
return hours;
/** siteId为场地,day为日期,reserveType为1个人/2单位/3协会;返回带code/msg的可预约场次数组。 */
public Object getReserve(String siteId, String day, Integer reserveType) {
return siteInfoService.availableSlots(siteId,day,reserveType);
}
@At("/reserveDo")
@@ -109,6 +109,7 @@ public class MemberAgendaController {
Sys_user user = (Sys_user) ShiroUtil.getPrincipal();
List<Sys_menu> menus = Optional.ofNullable(user).orElse(new Sys_user()).getMenus();
return list.stream().filter(v -> Strings.isNotBlank(v.getString("url")) && menus.stream().anyMatch(x -> Strings.isNotBlank(x.getHref()) && v.getString("url").contains(x.getHref()))).distinct().collect(Collectors.toList());
// 保留原有任务数据范围,再按当前账号的目标页面权限过滤入口。
return list.stream().filter(v -> Strings.isNotBlank(v.getString("url")) && menus.stream().anyMatch(x -> Strings.isNotBlank(x.getHref()) && v.getString("url").contains(x.getHref()))).filter(v -> io.v.nutz.sys.services.TodoAccessService.canAccess(v.getString("url"))).distinct().collect(Collectors.toList());
}
}
@@ -56,7 +56,8 @@ public class MemberSelfAgentController {
.addv("mobileHref", "/mobile/member/edit?taskId=" + v.getId()));
});
}
return list;
// 保留原有任务数据范围,再按当前账号的目标页面权限过滤入口。
return io.v.nutz.sys.services.TodoAccessService.filter(list, "mobileHref");
}
@@ -9,6 +9,8 @@ import io.v.nutz.zhgh.staffmanage.member.model.MemberApplyRecord;
import io.v.nutz.zhgh.staffmanage.member.service.MemberCommonService;
import io.v.nutz.zhgh.staffmanage.member.service.impl.MemberCommonServiceImpl;
import lombok.Getter;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.ioc.aop.Aop;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
@@ -24,6 +26,7 @@ import java.util.stream.Collectors;
* @nameMemberApplyController
* @Date 2025/1/20 19:01
* @注释 会员申请流程
* 手机处理和查看地址必须指向 /h5;PC 页面依赖不能在手机 PJAX 容器内加载。
*/
@Getter
@@ -34,6 +37,7 @@ public enum MemberApplyToDoHandler {
*/
START_PROCESS() {
@Override
@Aop(TransAop.READ_COMMITTED)
public void exec(MemberApplyRecord record, NutMap extra) {
User user = dao.fetch(User.class, Cnd.where("id", "=", record.getUserId()));
localProcessService.startProcess(
@@ -42,7 +46,7 @@ public enum MemberApplyToDoHandler {
"",
record.getUserId(),
"/platform/member/apply/mine",
"/platform/member/apply/mine"
"/platform/member/apply/mine/h5"
);
}
},
@@ -53,6 +57,7 @@ public enum MemberApplyToDoHandler {
*/
CREATE_APPLY_RE_MODIFY_TASK() {
@Override
@Aop(TransAop.READ_COMMITTED)
public void exec(MemberApplyRecord record, NutMap extra) {
Sql sql = Sqls.fetchString(Sqls.create("select loginname from sys_user where id = @id").setParam("id", record.getUserId()).toString());
dao.execute(sql);
@@ -66,8 +71,8 @@ public enum MemberApplyToDoHandler {
List.of(loginname),
"/platform/member/apply/mine",
"/platform/member/apply/mine",
"/platform/member/apply/mine",
"/platform/member/apply/mine"
"/platform/member/apply/mine/h5",
"/platform/member/apply/mine/h5"
);
localProcessService.updateProcessNodeName("MEMBER_APPLY@" + record.getId(), "退回重新修改");
@@ -98,6 +103,7 @@ public enum MemberApplyToDoHandler {
*/
CREATE_SCHOOL_TASK() {
@Override
@Aop(TransAop.READ_COMMITTED)
public void exec(MemberApplyRecord record, NutMap extra) {
// 获取校工会会员管理员
List<String> schoolLeaderLoginNames = memberService.getSchoolOrBranchUnionMemberAdminLoginNames("school", record.getUserId());
@@ -109,8 +115,8 @@ public enum MemberApplyToDoHandler {
schoolLeaderLoginNames,
"/platform/member/apply/schoolUnion/audit",
"/platform/member/apply/schoolUnion/audit",
"/platform/member/apply/schoolUnion/audit",
"/platform/member/apply/schoolUnion/audit"
"/platform/member/apply/schoolUnion/audit/h5",
"/platform/member/apply/schoolUnion/audit/h5"
);
localProcessService.updateProcessNodeName("MEMBER_APPLY@" + record.getId(), "校工会审核");
@@ -141,6 +147,7 @@ public enum MemberApplyToDoHandler {
*/
CREATE_UNION_TASK() {
@Override
@Aop(TransAop.READ_COMMITTED)
public void exec(MemberApplyRecord record, NutMap extra) {
List<String> unionLeaderLoginNames = extra.getAsList("unionLeaderLoginNames", String.class);
localProcessService.createTask(
@@ -151,8 +158,8 @@ public enum MemberApplyToDoHandler {
unionLeaderLoginNames,
"/platform/member/apply/branchUnion/audit",
"/platform/member/apply/branchUnion/audit",
"/platform/member/apply/branchUnion/audit",
"/platform/member/apply/branchUnion/audit"
"/platform/member/apply/branchUnion/audit/h5",
"/platform/member/apply/branchUnion/audit/h5"
);
localProcessService.updateProcessNodeName("MEMBER_APPLY@" + record.getId(), "分工会审核");
}
@@ -39,7 +39,8 @@ public class WelfareAgendaController {
public Object getAgenda() {
List<NutMap> list = new ArrayList<>();
if (!ShiroUtil.hasAnyRoles("flwyh01,sysadmin")) {
return list;
// 保留原有任务数据范围,再按当前账号的目标页面权限过滤入口。
return io.v.nutz.sys.services.TodoAccessService.filter(list, "url");
}
int welfareMemberAuditNumber = service.count(Sqls.create("SELECT count(1) from welfare_member_apply_record WHERE stateId = @state").setParam("state", WelfareMemberApplyState.SCHOOL_UNION));
@@ -48,6 +49,7 @@ public class WelfareAgendaController {
// int welfareMemberChangeAuditNumber = service.count(Sqls.create("SELECT count(1) from member_change_record WHERE recordMode = @mode and stateId = @state").setParam("mode", MemberChangeRecordMode.WELFARE_MEMBER.getCode()).setParam("state", MemberChangeApplyState.SCHOOL_UNION));
// list.add(new NutMap().addv("iconClass", vi.getIconByPath("/platform/welfare/member/change/audit")).addv("label", "福利会员变更审核").addv("number", welfareMemberChangeAuditNumber).addv("url", "/platform/welfare/member/change/audit"));
return list;
// 保留原有任务数据范围,再按当前账号的目标页面权限过滤入口。
return io.v.nutz.sys.services.TodoAccessService.filter(list, "url");
}
}
@@ -53,6 +53,7 @@ public class WelfareSelfAgentController {
.addv("mobileHref", "/mobile/member/edit?taskId=" + v.getId()));
});
}
return list;
// 保留原有任务数据范围,再按当前账号的目标页面权限过滤入口。
return io.v.nutz.sys.services.TodoAccessService.filter(list, "mobileHref");
}
}
@@ -1,7 +1,6 @@
package io.v.nutz.zhgh.welfare.controller;
import cn.wizzer.framework.base.Result;
import cn.wizzer.framework.page.Pagination;
import io.v.nutz.base.annontation.ViReturn;
import io.v.nutz.base.query.PageForm;
import io.v.nutz.base.service.SimpleService;
@@ -15,13 +14,10 @@ import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.aop.Aop;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.json.Json;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
@@ -57,43 +53,25 @@ public class WelfareUserChooseController {
public void index() {
}
/**
* 当前用户福利项目分页查询。
*
* @param pageForm 分页参数,pageNumber 为页码,pageSize 为每页条数
* @param year 选择开始时间所属年度,为空时不限制年度
* @param isChoose 选择状态:1 为已选择,2 为未选择;未传时默认未选择
* @return Pagination 分页对象;list 为项目列表,totalCount 为总条数,
* 列表中 isChoose 为 1 表示已选择、0 表示未选择,gist_list 为所选福利说明
*/
@At
@ViReturn
@RequiresPermissions("welfare.user.choose")
public Object pageData(PageForm pageForm, Integer year) {
Sql sql = Sqls.create("""
SELECT
wp.*,
CASE
WHEN wus.selectUserId IS NOT NULL THEN 1
ELSE 0
END AS isChoose,
wus.selectTime,
GROUP_CONCAT( DISTINCT wuso.optionName, IF(wus.selectSpecs is not null, (CONCAT('—规格:', wus.selectSpecs)), ''), '', wus.selectNum, '份)' ) AS gist_list,
wus.receiveAddress
FROM
welfare_project wp
LEFT JOIN welfare_project_user_selection wus ON wp.id = wus.welfareId AND wus.selectUserId = @selectUserId
LEFT JOIN welfare_list wl ON wp.id = wl.projectId AND wl.userId = @selectUserId
LEFT JOIN welfare_project_subject_option wuso ON wus.selectOptionId = wuso.id
$condition
""");
sql.setParam("selectUserId", ShiroUtil.getUserId());
Cnd cnd = Cnd.NEW();
cnd.and("wp.provideMode", "in", "2,3");
cnd.and("wl.userId", "=", ShiroUtil.getUserId());
cnd.andEX("YEAR(wp.choiceTimeStart)", "in", year);
cnd.and("wp.isDisabled", "=", 0);
cnd.groupBy("wp.id");
cnd.desc("YEAR(wp.choiceTimeStart)");
sql.setCondition(cnd);
Pagination pagination = simpleService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
return pagination;
public Object pageData(PageForm pageForm, Integer year, Integer isChoose) {
if (isChoose != null && !Integer.valueOf(1).equals(isChoose) && !Integer.valueOf(2).equals(isChoose)) {
return Result.error("选择状态只能为已选择或未选择");
}
return welfareProjectService.userChoosePage(pageForm, year, isChoose, ShiroUtil.getUserId());
}
@At
@ViReturn
@Aop(TransAop.READ_COMMITTED)
@@ -1,5 +1,7 @@
package io.v.nutz.zhgh.welfare.service;
import cn.wizzer.framework.page.Pagination;
import io.v.nutz.base.query.PageForm;
import io.v.nutz.base.service.ViService;
import io.v.nutz.zhgh.welfare.model.WelfareProject;
@@ -22,6 +24,18 @@ public interface WelfareProjectService extends ViService<WelfareProject> {
*/
WelfareProject projectInfo(String projectId);
/**
* 按选择状态查询用户有资格选择的福利项目。
*
* @param pageForm 分页参数,pageNumber 为页码,pageSize 为每页条数
* @param year 选择开始时间所属年度,为空时不限制年度
* @param isChoose 1 为已选择,2 或 null 为未选择;调用方须校验其他值
* @param userId 当前登录用户 ID,由服务端获取
* @return Paginationlist 为项目列表,totalCount 为总条数;
* list 中 isChoose 为 1/0,分别表示已选择/未选择,gist_list 为所选福利说明
*/
Pagination userChoosePage(PageForm pageForm, Integer year, Integer isChoose, String userId);
List<WelfareProject> getIngWelfareProject();
}
@@ -1,6 +1,8 @@
package io.v.nutz.zhgh.welfare.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.wizzer.framework.page.Pagination;
import io.v.nutz.base.query.PageForm;
import io.v.nutz.base.service.BaseService;
import io.v.nutz.zhgh.data.model.MatchConditionStructure;
import io.v.nutz.base.service.impl.ViServiceImpl;
@@ -110,6 +112,48 @@ public class WelfareProjectServiceImpl extends ViServiceImpl<WelfareProject> imp
return project;
}
/**
* {@inheritDoc}
*/
@Override
public Pagination userChoosePage(PageForm pageForm, Integer year, Integer isChoose, String userId) {
Sql sql = Sqls.create("""
SELECT
wp.*,
CASE
WHEN wus.selectUserId IS NOT NULL THEN 1
ELSE 0
END AS isChoose,
wus.selectTime,
GROUP_CONCAT( DISTINCT wuso.optionName, IF(wus.selectSpecs is not null, (CONCAT('—规格:', wus.selectSpecs)), ''), '', wus.selectNum, '份)' ) AS gist_list,
wus.receiveAddress
FROM
welfare_project wp
LEFT JOIN welfare_project_user_selection wus ON wp.id = wus.welfareId AND wus.selectUserId = @selectUserId
LEFT JOIN welfare_list wl ON wp.id = wl.projectId AND wl.userId = @selectUserId
LEFT JOIN welfare_project_subject_option wuso ON wus.selectOptionId = wuso.id
$condition
""");
sql.setParam("selectUserId", userId);
Cnd cnd = Cnd.NEW();
cnd.and("wp.provideMode", "in", "2,3");
cnd.and("wl.userId", "=", userId);
cnd.andEX("YEAR(wp.choiceTimeStart)", "in", year);
cnd.and("wp.isDisabled", "=", 0);
// 与列表状态一致:存在当前用户的选择记录为已选择,否则为未选择。
if (Integer.valueOf(1).equals(isChoose)) {
cnd.and("wus.selectUserId", "is not", null);
} else {
cnd.and("wus.selectUserId", "is", null);
}
cnd.groupBy("wp.id");
cnd.desc("YEAR(wp.choiceTimeStart)");
sql.setCondition(cnd);
Pagination pagination = listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
return pagination;
}
@Override
public List<WelfareProject> getIngWelfareProject() {
return dao().query(WelfareProject.class, Cnd.where("choiceTimeStart", "<=", DateUtil.date())
@@ -150,7 +150,8 @@ public class XhkhLssjcxController {
if (ShiroUtil.hasAnyRoles("sysadmin,SchoolUnionAdmin")) {
result.add(new NutMap().setv("title", title).setv("url", "/platform/xhkh/xghsh").setv("iconClass", vi.getIconByPath("/platform/xhkh/xghsh")).setv("label", "校工会审核").setv("number", getXghCount()));
}
return result;
// 保留原有任务数据范围,再按当前账号的目标页面权限过滤入口。
return io.v.nutz.sys.services.TodoAccessService.filter(result, "url");
}
@@ -59,7 +59,8 @@ public class CondolenceAgentController {
result.add(new NutMap().setv("title", title).setv("url", ECR).setv("iconClass", vi.getIconByPath(ECR)).setv("label", "待工会常务副主席审核").setv("number", getEcrCount()));
Sys_user user = (Sys_user) ShiroUtil.getPrincipal();
List<Sys_menu> menus = Optional.ofNullable(user).orElse(new Sys_user()).getMenus();
return result.stream().filter(v -> Strings.isNotBlank(v.getString("url")) && menus.stream().anyMatch(x -> Strings.isNotBlank(x.getHref()) && v.getString("url").equals(x.getHref()))).distinct().collect(Collectors.toList());
// 保留原有任务数据范围,再按当前账号的目标页面权限过滤入口。
return result.stream().filter(v -> Strings.isNotBlank(v.getString("url")) && menus.stream().anyMatch(x -> Strings.isNotBlank(x.getHref()) && v.getString("url").equals(x.getHref()))).filter(v -> io.v.nutz.sys.services.TodoAccessService.canAccess(v.getString("url"))).distinct().collect(Collectors.toList());
}
@@ -64,7 +64,8 @@ public class rxdjAgentController {
}
}
return result;
// 保留原有任务数据范围,再按当前账号的目标页面权限过滤入口。
return io.v.nutz.sys.services.TodoAccessService.filter(result, "url");
}
public Integer getUnitCount() {
@@ -54,7 +54,8 @@ public class singleChildAgentController {
result.add(new NutMap().setv("url", SCHOOL).setv("iconClass", vi.getIconByPath(SCHOOL)).setv("label", "独生子女待工会主席审核").setv("number", getSchoolCount()));
}
}
return result;
// 保留原有任务数据范围,再按当前账号的目标页面权限过滤入口。
return io.v.nutz.sys.services.TodoAccessService.filter(result, "url");
}
@@ -22,7 +22,8 @@ body {
}
[v-cloak] {
display: none;
/* Vue 挂载前隐藏原始模板及弹框内容,避免被 #app 的 display 规则覆盖;挂载后 Vue 自动移除此属性。 */
display: none !important;
}
a, img {
@@ -33,7 +33,7 @@
<el-tab-pane label="预约基本信息" name="2">
<el-descriptions class="margin-top" :column="3" border>
<el-descriptions-item label="预约类型">{{ {1:'个人预约',2:'单位预约',3:'协会预约'}[viewData.reserve_type] }}</el-descriptions-item>
<el-descriptions-item label="预约类型">{{ {1:'个人预约',2:'分工会预约',3:'协会预约'}[viewData.reserve_type] }}</el-descriptions-item>
<el-descriptions-item label="所属协会">{{viewData.club_name || '—'}}</el-descriptions-item>
<el-descriptions-item label="预约人">{{ viewData.reserve_person }}</el-descriptions-item>
<el-descriptions-item :span="2" label="场地名称"> {{ viewData.site_name }}</el-descriptions-item>
@@ -41,8 +41,19 @@
<el-descriptions-item label="工号">{{ viewData.loginname }}</el-descriptions-item>
<el-descriptions-item label="所属单位">{{ viewData.reserve_person_unit }}</el-descriptions-item>
<el-descriptions-item label="联系电话">{{ viewData.reserve_person_phone }}</el-descriptions-item>
<el-descriptions-item label="预约时间"> ({{ viewData.concat_day }}) {{ viewData.start_time }} - {{ viewData.end_time }}</el-descriptions-item>
<el-descriptions-item label="预约状态">
<!-- 复用详情接口按日期合并的时段独占一行避免与状态事由挤在同一行 -->
<el-descriptions-item label="预约时间" :span="3">
<div class="reservation-times">
<div v-for="group in viewData.reservationTimeGroups" :key="group.date" class="reservation-time-day">
<span class="reservation-time-date">{{group.date}}</span>
<div class="reservation-time-ranges">
<span v-for="(range,index) in group.ranges" :key="index" class="reservation-time-range">{{range.start}}{{range.end}}</span>
</div>
</div>
<span v-if="!viewData.reservationTimeGroups || !viewData.reservationTimeGroups.length"></span>
</div>
</el-descriptions-item>
<el-descriptions-item label="预约状态" :span="3">
<span v-if="[0].includes(viewData.stateAuditType)" style="color: #e6a23c">{{viewData.state_name}}</span>
<span v-if="viewData.stateAuditType==3" style="color: #67c23a">{{viewData.state_name}}</span>
<span v-if="viewData.stateAuditType==1" style="color: #f56c6c">{{viewData.state_name}}</span>
@@ -146,4 +157,33 @@ module.exports = {
.el-descriptions-item__cell {
text-align: center !important;
}
/* 日期与完整时段整体居中,长时段列表仅在各时间段之间换行。 */
.reservation-times {
display: inline-block;
max-width: 100%;
text-align: left;
font-variant-numeric: tabular-nums;
vertical-align: middle;
}
.reservation-time-day {
display: flex;
align-items: baseline;
flex-wrap: wrap;
gap: 4px 12px;
padding: 3px 0;
line-height: 22px;
}
.reservation-time-date {
flex: 0 0 88px;
white-space: nowrap;
font-weight: 500;
}
.reservation-time-ranges {
display: flex;
flex-wrap: wrap;
gap: 2px 12px;
}
.reservation-time-range {
white-space: nowrap;
}
</style>
@@ -1,5 +1,15 @@
<!--# layout("/mobile/platform.html"){ #-->
<style>
/* 日期和每个时间段保持完整,同日连续场次由后端统一合并展示。 */
.site-audit .reservation-times { text-align:left; font-variant-numeric:tabular-nums; }
.site-audit .reservation-time-day { display:flex; align-items:baseline; flex-wrap:wrap; gap:4px 12px; padding:3px 0; line-height:22px; }
.site-audit .reservation-time-date { flex:0 0 88px; white-space:nowrap; font-weight:500; }
.site-audit .reservation-time-ranges { display:flex; flex-wrap:wrap; gap:2px 12px; }
.site-audit .reservation-time-range { white-space:nowrap; }
.site-audit .reservation-times { padding:4px 0 6px; font-size:14px; overflow-wrap:normal; }
.site-audit .reservation-time-day { display:block; padding:4px 0; }
.site-audit .reservation-time-date { display:block; color:#606266; }
.site-audit .van-doc-card { margin:14px; padding:12px; background:#fff; border-radius:10px; box-shadow:0 8px 12px #ebedf0; line-height:20px; font-size:15px; position:relative; }
.site-audit .card-title { font-size:18px; font-weight:bold; color:#1867b0; padding-left:4px; }
.site-audit .title-mark { position:absolute; left:0; top:12px; color:#1867b0; font-weight:bold; }
@@ -33,7 +43,13 @@
<div><span class="field-label">所属单位:</span>{{row.reserve_person_unit || '—'}}</div>
<div><span class="field-label">预约类型:</span>{{typeName(row.reserve_type)}}</div>
<div v-if="row.club_name"><span class="field-label">所属协会:</span>{{row.club_name}}</div>
<div><span class="field-label">预约时段:</span>{{row.concat_day}}</div>
<div><span class="field-label">预约时段:</span><div class="reservation-times">
<div v-for="group in row.reservationTimeGroups" :key="group.date" class="reservation-time-day">
<span class="reservation-time-date">{{group.date}}</span>
<div class="reservation-time-ranges"><span v-for="(range,index) in group.ranges" :key="index" class="reservation-time-range">{{range.start}}{{range.end}}</span></div>
</div>
<span v-if="!row.reservationTimeGroups || !row.reservationTimeGroups.length"></span>
</div></div>
</div>
<van-divider></van-divider>
<div class="card-footer">
@@ -134,7 +150,7 @@
this.clearPopupHistory(() => pjaxReplace('/mobile/index'))
}
},
typeName(type) { return {1:'个人预约',2:'单位预约',3:'协会预约'}[type] || '—' },
typeName(type) { return {1:'个人预约',2:'分工会预约',3:'协会预约'}[type] || '—' },
filterOpened() { this.$set(this, 'filterShow', true) },
filterClosed() { this.$set(this, 'filterShow', false) },
canReview(row) {
@@ -178,12 +194,13 @@
}
})
},
// 进入审核时默认同意;仅查看时不填意见,切换申请不保留上一条输入。
openDetail(row, approval) {
this.$set(this, 'auditReady', false)
this.$set(this, 'showApprovalForm', approval)
this.$set(this, 'formData', {
id: row.id, username: "${@shiro.getPrincipalProperty('username')}",
auditTime: moment().format('YYYY-MM-DD HH:mm:ss'), auditOpinion: ''
auditTime: moment().format('YYYY-MM-DD HH:mm:ss'), auditOpinion: approval ? '同意' : ''
})
this.$set(this, 'detailShow', true)
this.$nextTick(() => this.$refs.infoRef.onOpen(row.id))
@@ -19,7 +19,13 @@ const SITE_AUDIT_INFO = {
<van-cell title="当前状态">
<template #default><span :style="{color: viewData.state_color || null}">{{viewData.state_name}}</span></template>
</van-cell>
<van-cell title="预约时段" :label="viewData.concat_day"></van-cell>
<van-cell title="预约时段"><template #label><div class="reservation-times">
<div v-for="group in viewData.reservationTimeGroups" :key="group.date" class="reservation-time-day">
<span class="reservation-time-date">{{group.date}}</span>
<div class="reservation-time-ranges"><span v-for="(range,index) in group.ranges" :key="index" class="reservation-time-range">{{range.start}}{{range.end}}</span></div>
</div>
<span v-if="!viewData.reservationTimeGroups || !viewData.reservationTimeGroups.length">—</span>
</div></template></van-cell>
<van-cell title="预约事由" :label="viewData.reserve_cause" class="site-audit-text"></van-cell>
</template>
</van-cell-group>
@@ -40,7 +46,7 @@ const SITE_AUDIT_INFO = {
props: {reviewApi: {type: String, required: true}},
data() { return {viewData: {}, activeName: 'basic', expanded: true, detailLoading: false, requestId: 0} },
methods: {
typeName(type) { return {1:'个人预约',2:'单位预约',3:'协会预约'}[type] || '—' },
typeName(type) { return {1:'个人预约',2:'分工会预约',3:'协会预约'}[type] || '—' },
toggleExpanded() { this.$set(this, 'expanded', !this.expanded) },
// id 为预约记录主键;返回预约字段及 auditListTable 历史,loaded 通知父页核验可审核状态。
onOpen(id) {
@@ -198,10 +198,11 @@ layout("/mobile/platform.html"){
<van-list
:finished="finished"
:finished-text="tableData.length>0?'没有更多了':''" :immediate-check="false"
:error.sync="listError" error-text="加载失败,点击重试"
@load="onLoad"
v-model="loading">
<div class="van-doc-card" v-for="o in tableData">
<div class="van-doc-card" v-for="o in tableData" :key="o.id">
<div @click="openView(o)">
<div style="display: flex; justify-content: space-between">
@@ -221,7 +222,7 @@ layout("/mobile/platform.html"){
<div style="margin-top: 10px">
<van-row>
<van-col span="24"><span style="color: grey">&emsp;联系人</span>{{(o.unitname
<van-col span="24"><span style="color: grey">场地管理员</span>{{(o.unitname
? o.unitname :
'') + ' ' + o.contact_person}}
</van-col>
@@ -269,8 +270,10 @@ layout("/mobile/platform.html"){
(() => {
// PJAX 先执行内联脚本,等待历史组件加载;离开后的旧加载回调不能挂载到新页面。
const pageRoot = document.getElementById('app')
let pageStarted = false
const startPage = () => {
if (document.getElementById('app') !== pageRoot || !pageRoot.isConnected) return
if (pageStarted || document.getElementById('app') !== pageRoot || !pageRoot.isConnected) return
pageStarted = true
<!--# include("/platform/activity/includeJs/activityUtil.js"){} #-->
const siteTypeUtil = new typeUtil()
new Vue({
@@ -284,6 +287,9 @@ layout("/mobile/platform.html"){
list: ['a', 'b'],
typeList: [],
siteId: '',
// 初始化完成前禁止列表触发请求;requesting 独立于 Vant 的 loading 双向绑定。
listReady: false, requesting: false, requestVersion: 0, listError: false,
loading: true, mLoading: true,
}
},
watch: {
@@ -297,6 +303,9 @@ layout("/mobile/platform.html"){
beforeDestroy() {
// PJAX 替换 DOM 不会自动销毁实例,显式清理本页监听并触发历史 mixin 注销。
$(document).off('pjax:beforeReplace.siteList', this._siteListDispose)
// 离开页面后,类型请求和列表请求的旧回调均不能再发请求或追加数据。
this.$set(this, 'listReady', false)
this.$set(this, 'requestVersion', this.requestVersion + 1)
},
methods: {
setPopupState(key, value) { this.$set(this, key, value) },
@@ -332,17 +341,73 @@ layout("/mobile/platform.html"){
this.clearPopupHistory(()=>{location.href = '/mobile/activity/site/info/reserve?id=' + this.siteId})
},
doSearch() {
this.pageForm.pageNumber = 1
this.tableData = []
this.finished = false
if (!this.listReady || this._isDestroyed || this._isBeingDestroyed) return
// 新筛选拥有独立请求版本,旧响应及其 always 不能污染新列表或关闭新请求的 loading。
this.$set(this, 'requestVersion', this.requestVersion + 1)
this.$set(this, 'requesting', false)
this.$set(this.pageForm, 'pageNumber', 1)
this.$set(this.pageForm, 'totalCount', 0)
this.$set(this, 'tableData', [])
this.$set(this, 'finished', false)
this.$set(this, 'listError', false)
this.onLoad()
},
onLoad() {
this.loading=true;return $.post('/mobile/activity/site/info/pageData',this.pageForm).then((res)=>{if(res.code===0){this.tableData=this.tableData.concat(res.data.list);this.finished=this.tableData.length>=res.data.totalCount;if(!this.finished)this.pageForm.pageNumber++}else{vant.Toast(res.msg)}}).always(()=>{this.loading=false});
if (!this.listReady || this.requesting || this.finished || this._isDestroyed || this._isBeingDestroyed) return
const version = this.requestVersion
// 请求携带筛选和页码快照;成功后才推进页码,失败重试仍请求原页。
const params = Object.assign({}, this.pageForm)
this.$set(this, 'requesting', true)
this.$set(this, 'loading', true)
this.$set(this, 'listError', false)
return $.post('/mobile/activity/site/info/pageData', params).then((res) => {
if (version !== this.requestVersion) return
if (!res || res.code !== 0 || !res.data || !Array.isArray(res.data.list)) {
this.$set(this, 'listError', true)
vant.Toast(res && res.msg || '场地列表加载失败,请重试')
return
}
const rows = this.tableData.concat(res.data.list)
this.$set(this, 'tableData', rows)
this.$set(this.pageForm, 'totalCount', res.data.totalCount)
this.$set(this, 'finished', res.data.list.length === 0 || rows.length >= res.data.totalCount)
this.$set(this.pageForm, 'pageNumber', params.pageNumber + 1)
}, () => {
if (version !== this.requestVersion) return
this.$set(this, 'listError', true)
vant.Toast('场地列表加载失败,请重试')
}).always(() => {
if (version !== this.requestVersion) return
this.$set(this, 'requesting', false)
this.$set(this, 'loading', false)
this.$set(this, 'mLoading', false)
})
},
},
created() {
siteTypeUtil.getAllType().then((rows)=>{this.typeList=[{text:'全部场地类型'}].concat(rows);this.$set(this.pageForm,'typeId',this.typeList[0].value);this.onLoad()});
// 首屏取得职工之家实际类型 ID 后才查询;缺失或失败时不降级为全部类型。
siteTypeUtil.getAllType().then((rows) => {
if (this._isDestroyed || this._isBeingDestroyed) return
this.$set(this, 'typeList', rows)
if (!rows.length) {
this.$set(this, 'listError', true)
vant.Toast('未配置职工之家场地类型')
return
}
this.$set(this.pageForm, 'typeId', rows[0].value)
this.$set(this, 'listReady', true)
this.doSearch()
}, () => {
if (this._isDestroyed || this._isBeingDestroyed) return
this.$set(this, 'listError', true)
vant.Toast('场地类型加载失败,请重新进入')
}).always(() => {
if (this._isDestroyed || this._isBeingDestroyed) return
if (!this.listReady) {
this.$set(this, 'loading', false)
this.$set(this, 'mLoading', false)
}
})
}
})
}
@@ -163,6 +163,14 @@ layout("/mobile/platform.html"){
}
</style>
<style>
/* 我的预约按日期展示完整时段,不再重复使用申请中某一条记录的起止时间。 */
.site-my-times { font-variant-numeric:tabular-nums; line-height:22px; }
.site-my-day { padding:4px 0; }
.site-my-date { font-weight:500; }
.site-my-ranges { display:flex; flex-wrap:wrap; gap:2px 12px; }
.site-my-ranges span { white-space:nowrap; }
</style>
<div id="app" v-cloak>
<m-page-loading v-if="mLoading"></m-page-loading>
@@ -250,10 +258,14 @@ layout("/mobile/platform.html"){
</van-row>
<van-row>
<van-col span="24">
<span style="color: grey; float: left">预约时间:</span>
<span v-for="(item,index) in o.concat_day.split(',')">
<div :style="index !== 0 ? 'text-indent: 5em' : ''">{{getTime(o, item)}}</div>
</span>
<span style="color: grey">预约时间:</span>
<div class="site-my-times">
<div v-for="group in o.reservationTimeGroups" :key="group.date" class="site-my-day">
<div class="site-my-date">{{group.date}}</div>
<div class="site-my-ranges"><span v-for="(range,index) in group.ranges" :key="index">{{range.start}}{{range.end}}</span></div>
</div>
<span v-if="!o.reservationTimeGroups || !o.reservationTimeGroups.length"></span>
</div>
</van-col>
</van-row>
<van-row>
@@ -265,10 +277,10 @@ layout("/mobile/platform.html"){
<span style="color: #f56c6c" v-if="o.stateaudittype==1">{{o.statename}}</span>
</van-col>
</van-row>
<van-row v-if="o.stateaudittype == '1'">
<van-row v-if="Number(o.reserve_state) === 4040">
<van-col span="24">
<span style="color: grey">审核意见:</span>
<span>{{JSON.parse(o.auditlist).find(x => x.auditState === false).auditOption}}</span>
<span>{{rejectionOpinion(o)}}</span>
</van-col>
</van-row>
</div>
@@ -364,6 +376,16 @@ layout("/mobile/platform.html"){
$(document).off('pjax:beforeReplace.siteList', this._siteListDispose)
},
methods: {
// 历史审核记录可能是 JSON 字符串、数组或空值;仅取最近一条拒绝意见,缺失时不阻断整页渲染。
rejectionOpinion(row) {
let history = row.auditlist || row.auditList || []
if (typeof history === 'string') {
try { history = JSON.parse(history) } catch (error) { return '—' }
}
if (!Array.isArray(history)) return '—'
const rejection = history.slice().reverse().find(item => item && item.auditState === false)
return rejection && rejection.auditOption || '—'
},
setPopupState(key, value) { this.$set(this, key, value) },
// 列表由 PJAX replace 进入,导航返回明确回首页;有弹层时只关最上层。
goBack() {
@@ -427,11 +449,6 @@ layout("/mobile/platform.html"){
backDo() {
if(this.formLoading)return;if(!this.option.trim()){vant.Toast('请填写反馈意见');return}this.formLoading=true;$.post('/mobile/activity/site/info/backOption',{id:this.info.id,option:this.option}).then((res)=>{vant.Toast(res.msg);if(res.code===0)this.clearPopupHistory(()=>this.doSearch())}).always(()=>{this.formLoading=false});
},
getTime(o, day) {
const week = new Date(day).getDay()
const arr = ['日', '一', '二', '三', '四', '五', '六']
return moment(day).format('MM月DD日') + ' 周' + arr[week] + ' ' + o.start_time + '-' + o.end_time
},
doSearch() {
this.pageForm.pageNumber = 1
this.tableData = []
@@ -439,11 +456,27 @@ layout("/mobile/platform.html"){
this.onLoad()
},
onLoad() {
// 类型未加载成功时停止请求,避免筛选操作意外查询其他场地类型。
if (this.pageForm.typeId == null) { this.$set(this,'loading',false); return }
this.loading=true;return $.post('/mobile/activity/site/info/myReserve',this.pageForm).then((res)=>{if(res.code===0){this.tableData=this.tableData.concat(res.data.list);this.finished=this.tableData.length>=res.data.totalCount;if(!this.finished)this.pageForm.pageNumber++}else{vant.Toast(res.msg)}}).always(()=>{this.loading=false});
},
},
created() {
siteTypeUtil.getAllType().then((rows)=>{this.typeList=[{text:'全部场地类型'}].concat(rows);this.$set(this.pageForm,'typeId',this.typeList[0].value);this.timeList=[{text:'全部',value:'全部'}];this.$set(this.pageForm,'time','全部');this.$set(this.pageForm,'timeSwitch',true);this.onLoad()});
// 本页只查询职工之家,使用接口返回的实际类型 ID;类型缺失时不降级成全部类型查询。
siteTypeUtil.getAllType().then((rows) => {
const types = rows
this.$set(this, 'typeList', types)
if (!types.length) {
this.$set(this, 'finished', true)
vant.Toast('未配置职工之家场地类型')
return
}
this.$set(this.pageForm, 'typeId', types[0].value)
this.$set(this, 'timeList', [{text:'全部',value:'全部'}])
this.$set(this.pageForm, 'time', '全部')
this.$set(this.pageForm, 'timeSwitch', true)
this.onLoad()
}, () => { vant.Toast('场地类型加载失败,请重新进入') });
}
})
}
@@ -23,27 +23,28 @@ layout("/mobile/platform.html"){
font-size: 14px;
}
.time {
width: 45%;
.site-reserve-slots .time {
display: block;
text-align: center;
white-space: nowrap;
}
.num {
width: 30%;
/* 长禁用原因由内容撑开行高,避免固定高度导致文字覆盖下一场次。 */
.site-reserve-slots .state {
width: 100%;
display: block;
line-height: 18px;
white-space: normal;
overflow-wrap: anywhere;
text-align: center;
color: #1989fa;
}
.state {
width: 80px;
height: 36px;
text-align: center;
background-color: #f2f2f2;
border-radius: 2px;
color: #929292;
}
.container {
padding: 10px 0px;
.site-reserve-slots {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 18px 16px;
padding: 8px 0 66px;
background-color: white;
width: 95%;
margin: 0 auto;
@@ -51,10 +52,53 @@ layout("/mobile/platform.html"){
margin-top: 10px;
}
tr {
line-height: 36px;
/* 单个按钮容纳时间和状态,选中仅改变外观,继续复用原有时段选择逻辑。 */
.site-reserve-slots .slot-button {
min-width: 0;
min-height: 54px;
box-sizing: border-box;
padding: 8px 6px;
border: 1px solid #e6e8ed;
border-radius: 12px;
background: #fff;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
color: #323233;
font: inherit;
font-size: 13px;
line-height: 18px;
text-align: center;
cursor: pointer;
}
.site-reserve-slots .slot-button.is-selected {
background: #ecf6ff;
border-color: #a4d2ff;
color: #1989fa;
box-shadow: 0 4px 12px rgba(25, 137, 250, 0.08);
}
.site-reserve-slots .slot-button:disabled,
.site-reserve-slots .slot-button:disabled .state {
color: #969799;
background: #f7f8fa;
box-shadow: none;
cursor: default;
}
/* 全天候四列时间点:网格单元承载连续底色,按钮端点保留圆角及起终角标。 */
.site-reserve-slots.full-day-slots { grid-template-columns:repeat(4,minmax(0,1fr)); gap:18px 0; }
.full-day-slots .point-cell { min-width:0; padding:0 8px; display:flex; }
.full-day-slots .point-cell.in-range { background:#e2f1ff; padding:0; }
.full-day-slots .point-cell.range-start { padding-left:8px; background:linear-gradient(to right,#fff 8px,#e2f1ff 8px); }
.full-day-slots .point-cell.range-end { padding-right:8px; background:linear-gradient(to left,#fff 8px,#e2f1ff 8px); }
.full-day-slots .slot-button { width:100%; position:relative; padding:8px 2px; }
.full-day-slots .in-range .slot-button { border-radius:0; background:#e2f1ff; border-color:transparent; box-shadow:none; }
.full-day-slots .range-start .slot-button { border-radius:12px 0 0 12px; }
.full-day-slots .range-end .slot-button { border-radius:0 12px 12px 0; }
.full-day-slots .point-cell .range-boundary { border-color:#a4d2ff; color:#1989fa; background:#ecf6ff; }
.full-day-slots .range-mark { position:absolute; color:#fff; background:#1989fa; font-size:11px; line-height:18px; padding:0 4px; }
.full-day-slots .range-mark.start { top:0; left:0; border-radius:10px 0 5px 0; }
.full-day-slots .range-mark.end { bottom:0; right:0; border-radius:5px 0 10px 0; }
.van-action-sheet__content {
padding: 10px;
font-size: 15px;
@@ -182,34 +226,28 @@ layout("/mobile/platform.html"){
</div>
</div>
<div class="container">
<table>
<tr v-for="item in timeData">
<td class="time">{{item.start_time + '-' + item.end_time}}</td>
<td class="num">
<span v-if="item.code !== -2">
{{(item.limitNum - item.reserveNum) + '/' + item.limitNum}}
</span>
<span v-else>
{{0 + '/' + item.limitNum}}
</span>
</td>
<td v-if="item.code !== 1" @click.stop="">
<div class="state" :style="'background-color: ' + item.backColor + ';color:' +item.color">
{{item.msg}}
</div>
</td>
<td v-else @click.stop="chooseTime(item)">
<div class="state"
:style="'background-color: ' + item.backColor + ';color:' +item.color">
<span v-if="!times.map(o => o.fullDay).includes(selectDate.format('YYYY-MM-DD') + ' ' + item.start_time + '-' + item.end_time)">{{item.msg}}</span>
<span v-else>
<van-icon name="passed" size="26" style="line-height: 36px;position: unset"></van-icon>
</span>
</div>
</td>
</tr>
</table>
<div v-if="isFullDay" class="site-reserve-slots full-day-slots">
<div v-for="point in fullDayPoints" :key="point.time" class="point-cell"
:class="{'in-range':point.inRange,'range-start':point.mark==='起' && currentRange.end,'range-end':point.mark==='终'}">
<button type="button" class="slot-button" :class="{'range-boundary':!!point.mark}"
:disabled="slotsLoading || point.disabled" :aria-pressed="point.selected" :title="point.reason"
@click.stop="chooseFullDayPoint(point)">
<span class="time">{{point.time}}</span>
<span class="state">{{point.reason}}</span>
<span v-if="point.mark" class="range-mark" :class="point.mark==='起' ? 'start' : 'end'">{{point.mark}}</span>
</button>
</div>
</div>
<div v-else class="site-reserve-slots">
<button v-for="item in timeData" :key="item.start_time + '-' + item.end_time"
type="button" class="slot-button" :disabled="item.code !== 1"
:class="{'is-selected':item.code === 1 && times.map(o => o.fullDay).includes(selectDate.format('YYYY-MM-DD') + ' ' + item.start_time + '-' + item.end_time)}"
:aria-pressed="item.code === 1 && times.map(o => o.fullDay).includes(selectDate.format('YYYY-MM-DD') + ' ' + item.start_time + '-' + item.end_time)"
@click.stop="chooseTime(item)">
<span class="time">{{item.start_time + ' - ' + item.end_time}}</span>
<!-- 保留原状态文案;选中通过按钮高亮表示,不替换时间和状态内容。 -->
<span class="state">{{item.msg === '预约时段已过期' ? '已过期' : item.msg}}</span>
</button>
</div>
<div style="position: fixed; bottom: 0; width: 100%">
@@ -224,15 +262,17 @@ layout("/mobile/platform.html"){
<van-cell title="所属单位">{{unit}}</van-cell>
<van-cell title="联系电话">{{phone}}</van-cell>
<van-cell title="预约时间">
<div v-for="time in times">
<div v-for="time in confirmationTimes" :key="time.fullDay">
<van-tag closeable size="medium" type="primary" @close="close(time.fullDay)">
{{time.fullDay}}
</van-tag>
</div>
</van-cell>
<van-cell title="预约地点">{{site.name}}</van-cell>
<van-cell title="预约类型" :value="reserveTypeName" is-link class="reserve-choice" @click="openOptions('type')"></van-cell>
<van-cell title="所属协会" v-if="myClubs.length || reserve_type===3" class="reserve-choice"
<van-cell title="预约类型" required :value="reserveTypeName" is-link class="reserve-choice" @click="openOptions('type')"></van-cell>
<!-- 分工会使用后端查询的当前组织,只读显示;协会仅在协会预约时选择。 -->
<van-cell title="所属分工会" v-if="reserve_type===2" :value="unionLoading ? '加载中...' : bookingUnionName || '未配置所属分工会'"></van-cell>
<van-cell title="所属协会" v-if="reserve_type===3" class="reserve-choice"
:value="reserve_type===3 ? selectedClubName : myClubs.map(club=>club.name).join('、')"
:is-link="reserve_type===3" @click="openOptions('club')"></van-cell>
<div v-if="reserve_type===3 && !myClubs.length" style="padding:12px;color:#ee0a24">您暂无已通过入会审核的有效协会</div>
@@ -252,6 +292,7 @@ layout("/mobile/platform.html"){
rows="4"
autosize
label="预约事由"
required
type="textarea"
maxlength="50"
placeholder="请输入预约事由"
@@ -265,8 +306,8 @@ layout("/mobile/platform.html"){
<van-button @click="reserveDo" :loading="formLoading" color="#246fb4" style="width: 47%" size="small" type="info">确认</van-button>
</div>
</van-action-sheet>
<!-- 选项弹层后于确认表单打开,由 Vant 分配更高层级;选择或返回只关闭本层。 -->
<van-popup v-model="optionsShow" position="top" class="site-reserve-options" safe-area-inset-top>
<!-- 预约类型和所属协会共用底部选项层,适配底部安全区域;选择或返回只关闭本层。 -->
<van-popup v-model="optionsShow" position="bottom" class="site-reserve-options" safe-area-inset-bottom>
<van-nav-bar :title="optionKind==='type' ? '选择预约类型' : '选择所属协会'"
left-text="返回" left-arrow @click-left="closeOptions"></van-nav-bar>
<van-cell v-for="option in selectionOptions" :key="option.value" :title="option.text" clickable
@@ -301,9 +342,12 @@ layout("/mobile/platform.html"){
return {
historyPopupKeys: ['show','calendarVisible','optionsShow'],
optionsShow: false, optionKind: 'type',
reserveTypeOptions: [{text:'个人预约',value:1},{text:'单位预约',value:2},{text:'协会预约',value:3}],
// 新申请仅开放分工会和协会,个人类型保留用于历史数据。
reserveTypeOptions: [{text:'分工会预约',value:2},{text:'协会预约',value:3}],
bookingUnionName:'', unionLoading:false,
myClubs: [], clubId: '', formLoading: false,
reserve_type: 1,
// 新预约须主动选择类型,初始不选中任何选项。
reserve_type: null,
person: "${@shiro.getPrincipalProperty('username')}",
unit: "${@shiro.getPrincipalProperty('unit').getName()}",
phone: "${@shiro.getPrincipalProperty('mobile')}",
@@ -312,15 +356,47 @@ layout("/mobile/platform.html"){
site_id: '',
site: {},
timeData: [],
slotRequestVersion:0, slotsLoading:false,
times: [],
// 每个日期独立保存起止边界;times仍保存原接口要求的逐场次记录。
fullDayRanges: {}, slotsFailed:false,
weekList: [],
joinUser: '',
calendarVisible: false,
selectDate: null,
}
},
watch: {
// 分工会与协会预约的时段占用规则一致,切换时保留跨日期选择,仅刷新场次状态;提交时仍由后端校验冲突。
reserve_type() { this.getReserve() }
},
computed: {
reserveTypeName() { return this.reserveTypeOptions.find(option => option.value===this.reserve_type).text },
isFullDay() { return Number(this.site.reserveTimeType || this.site.reservetimetype || 1) === 2 },
currentRange() { return this.fullDayRanges[this.selectDate.format('YYYY-MM-DD')] || {start:'',end:''} },
// 结束点包括最后一个场次的结束边界,24:00保留原字符串,不转换为次日00:00。
fullDayPoints() {
const range=this.currentRange, choosingEnd=range.start && !range.end
return Array.from(new Set(this.timeData.flatMap(row=>[row.start_time,row.end_time]))).sort().map(time=>{
const row=this.timeData.find(slot=>slot.start_time===time)
const selected=time===range.start || !!range.end && time>=range.start && time<=range.end
const validEnd=choosingEnd && this.fullDaySlots(range.start,time)
const disabled=!selected && (choosingEnd ? !validEnd : !row || row.code!==1)
const reason=disabled ? choosingEnd ? '不可选' : row ? row.msg==='预约时段已过期' ? '已过期' : row.msg : '仅结束时间' : '可预约'
return {time,selected,disabled,reason,inRange:!!range.end && selected,mark:time===range.start ? '起' : time===range.end ? '终' : ''}
})
},
confirmationTimes() {
if (!this.isFullDay) return this.times
return Object.keys(this.fullDayRanges).sort().filter(day=>this.fullDayRanges[day].end).map(day=>{
const range=this.fullDayRanges[day]
return {day,fullDay:day+' '+range.start+'-'+range.end}
})
},
reserveTypeName() {
// 未选择时显示提示,避免读取不存在的选项名称。
const option = this.reserveTypeOptions.find(item => item.value===this.reserve_type)
return option ? option.text : '请选择预约类型'
},
selectedClubName() {
const club = this.myClubs.find(item => item.id===this.clubId)
return club ? club.name : '请选择所属协会'
@@ -367,6 +443,7 @@ layout("/mobile/platform.html"){
// PJAX 替换页面时显式销毁,触发统一历史 mixin 的监听注销。
this._reserveDispose = () => this.$destroy()
$(document).one('pjax:beforeReplace.siteReserve', this._reserveDispose)
this.loadBookingUnion()
$.post('/platform/activity/site/reserve/myClubs').then((res)=>{
if(res.code===0){this.$set(this,'myClubs',res.data);this.$set(this,'clubId',res.data.length===1 ? res.data[0].id : '')}
else{vant.Toast(res.msg)}
@@ -374,8 +451,53 @@ layout("/mobile/platform.html"){
},
beforeDestroy() {
$(document).off('pjax:beforeReplace.siteReserve', this._reserveDispose)
this.$set(this,'slotRequestVersion',this.slotRequestVersion+1)
},
methods: {
// start/end为HH:mm边界,返回全部连续可约场次;空范围、禁用或断档返回null。
fullDaySlots(start,end) {
if (!start || !end || end<=start) return null
const rows=this.timeData.filter(row=>row.start_time>=start && row.end_time<=end).slice().sort((a,b)=>a.start_time.localeCompare(b.start_time))
if (!rows.length || rows[0].start_time!==start || rows[rows.length-1].end_time!==end || rows.some((row,i)=>row.code!==1 || i>0 && rows[i-1].end_time!==row.start_time)) return null
return rows
},
// 仅清除指定日期的完整范围及提交记录,其他日期的选择保持不变。
clearFullDay(day) {
this.$set(this.fullDayRanges,day,{start:'',end:''})
this.$set(this,'times',this.times.filter(row=>row.day!==day))
},
chooseFullDayPoint(point) {
if (this.slotsLoading || this.formLoading || point.disabled) return
const day=this.selectDate.format('YYYY-MM-DD'),range=this.currentRange
if (point.selected) { this.clearFullDay(day); return }
if (!range.start || range.end) {
this.clearFullDay(day)
this.$set(this.fullDayRanges,day,{start:point.time,end:''})
return
}
const rows=this.fullDaySlots(range.start,point.time)
if (!rows) return
this.$set(this.fullDayRanges,day,{start:range.start,end:point.time})
this.$set(this,'times',this.times.filter(row=>row.day!==day).concat(rows.map(row=>Object.assign({},row,{day,fullDay:day+' '+row.start_time+'-'+row.end_time}))))
},
// 任一日期仅选起点都不能确认,避免跨日切换后漏提交未完成的范围。
validateFullDay() {
if (this.isFullDay && Object.values(this.fullDayRanges).some(range=>range.start && !range.end)) {
vant.Toast('请选择结束时间或取消未完成的选择'); return false
}
return true
},
// 与PC共用所属分工会接口,页面销毁后的响应不再更新界面。
loadBookingUnion() {
this.$set(this,'unionLoading',true)
$.post('/platform/activity/site/reserve/myUnion').then(res=>{
if(this._isDestroyed || this._isBeingDestroyed)return
if(res && res.code===0)this.$set(this,'bookingUnionName',res.data && res.data.name || '')
else vant.Toast(res && res.msg || '所属分工会加载失败')
},()=>{if(!this._isDestroyed && !this._isBeingDestroyed)vant.Toast('所属分工会加载失败,请重新进入')}).always(()=>{
if(!this._isDestroyed && !this._isBeingDestroyed)this.$set(this,'unionLoading',false)
})
},
// type 显示预约类型,club 仅在协会预约时可选;不修改所属协会的成员校验规则。
openOptions(kind) {
if (this.formLoading || this.optionsShow || kind==='club' && this.reserve_type!==3) return
@@ -403,6 +525,11 @@ layout("/mobile/platform.html"){
else this.clearPopupHistory(() => pjaxReplace('/mobile/activity/site/info'))
},
close(f) {
if (this.isFullDay) {
if (this.confirmationTimes.length===1) { vant.Toast('必须保留一个时间段'); return }
this.clearFullDay(f.split(' ')[0])
return
}
if (this.times.length === 1) {
vant.Toast('必须保留一个时间段')
return
@@ -413,6 +540,7 @@ layout("/mobile/platform.html"){
onConfirm(date) {
this.selectDate = moment(date)
this.setWeekList(this.selectDate)
this.getReserve()
this.calendarVisible = false
},
//这里要排除掉休息日
@@ -435,6 +563,7 @@ layout("/mobile/platform.html"){
this.getReserve()
},
reserve() {
if (this.slotsLoading || this.slotsFailed || !this.validateFullDay()) return
if (this.times.length === 0) {
vant.Toast('请选择要预约的时段')
return
@@ -442,14 +571,29 @@ layout("/mobile/platform.html"){
this.show = true
},
reserveDo() {
if(this.slotsLoading || this.formLoading)return
if(this.slotsFailed || !this.validateFullDay())return
if(!this.times.length){vant.Toast('请选择预约时段');return}
if(this.isFullDay){
const days=Array.from(new Set(this.times.map(row=>row.day)))
const gaps=days.some(day=>{
const selected=this.times.filter(row=>row.day===day).slice().sort((a,b)=>a.start_time.localeCompare(b.start_time))
return selected.some((row,i)=>i>0 && selected[i-1].end_time!==row.start_time)
})
if(gaps){vant.Toast('全天候预约请选择连续时段');return}
}
// 类型必须为当前可选项,事由不能为空或仅含空白;校验通过后才发送预约请求。
if(!this.reserveTypeOptions.some(option => option.value===this.reserve_type)){vant.Toast('请选择预约类型');return}
if(!this.message || !this.message.trim()){vant.Toast('请填写预约事由');return}
if(this.reserve_type===3 && !this.clubId){vant.Toast('请选择所属协会');return}
this.formLoading=true;
$.post('/mobile/activity/site/info/reserveDo',{siteId:this.site_id,times:JSON.stringify(this.times),message:this.message,reserve_type:this.reserve_type,clubId:this.clubId}).then((res)=>{
if(res.code===0){this.clearPopupHistory(()=>{vant.Toast('预约成功');this.times=[];this.message='';this.getReserve();this.onLoad()})}
if(res.code===0){this.clearPopupHistory(()=>{vant.Toast('预约成功');this.times=[];this.$set(this,'fullDayRanges',{});this.message='';this.getReserve();this.onLoad()})}
else{vant.Toast(res.msg)}
}).always(()=>{this.formLoading=false})
},
chooseTime(item) {
if(this.slotsLoading || item.code!==1)return
const cloneItem = clone(item)
const map = this.times.map(o => o.fullDay)
const index = map.indexOf(this.selectDate.format('YYYY-MM-DD') + ' ' + cloneItem.start_time + '-' + cloneItem.end_time)
@@ -467,7 +611,29 @@ layout("/mobile/platform.html"){
},
getReserve() {
return $.post('/mobile/activity/site/info/getReserve',{siteId:this.site_id,day:moment(this.selectDate).format('YYYY-MM-DD')}).then((res)=>{if(res.code===0){this.timeData=res.data}else{vant.Toast(res.msg)}});
if(!this.site_id || !this.selectDate)return
const version=this.slotRequestVersion+1
this.$set(this,'slotRequestVersion',version)
this.$set(this,'slotsLoading',true)
this.$set(this,'slotsFailed',false)
this.$set(this,'timeData',[])
// 未选类型时仍按团体预约规则查询占用,仅用于场次查询,不回填表单类型。
return $.post('/mobile/activity/site/info/getReserve',{siteId:this.site_id,day:moment(this.selectDate).format('YYYY-MM-DD'),reserveType:this.reserve_type===null ? 2 : this.reserve_type}).then(res=>{
if(version!==this.slotRequestVersion)return
if(res && res.code===0 && Array.isArray(res.data)) {
this.$set(this,'timeData',res.data)
// 切换日期或类型后重新核验该日范围,保留其他日期;占用变化时整段清空。
if (this.isFullDay) {
const range=this.currentRange
if (range.start && (range.end ? !this.fullDaySlots(range.start,range.end) : !res.data.some(row=>row.start_time===range.start && row.code===1))) {
this.clearFullDay(this.selectDate.format('YYYY-MM-DD'))
vant.Toast('所选时间已失效,请重新选择')
}
}
} else { this.$set(this,'slotsFailed',true); vant.Toast(res && res.msg || '场次加载失败') }
},()=>{if(version===this.slotRequestVersion){this.$set(this,'slotsFailed',true);vant.Toast('场次加载失败,请重试')}}).always(()=>{
if(version===this.slotRequestVersion)this.$set(this,'slotsLoading',false)
})
},
//获取最新的一个工作日设为当前时间
getLatestWorkDay() {
+124 -42
View File
@@ -240,9 +240,10 @@ layout("/mobile/platform.html"){
{{ item.name }}
</div>
<div style="margin-top: 6px; color: grey; font-size: 11px">
<div>开始时间:{{ moment(item.startDate).format('MM/DD HH:mm') }}
<!-- 场地入口仅显示时分秒,其他活动保留原日期格式。 -->
<div>开始时间:{{ moment(item.startDate).format(item.id === 'home_site_reserve_entry' ? 'HH:mm:ss' : 'MM/DD HH:mm') }}
</div>
<div>结束时间:{{ moment(item.endDate).format('MM/DD HH:mm') }}
<div>结束时间:{{ moment(item.endDate).format(item.id === 'home_site_reserve_entry' ? 'HH:mm:ss' : 'MM/DD HH:mm') }}
</div>
</div>
</van-col>
@@ -332,13 +333,22 @@ layout("/mobile/platform.html"){
<div style="background-color: #f6f7f9; min-height: 100vh" v-if="active === 1">
<van-notice-bar
background="#ecf9ff" color="#1989fa" left-icon="volume-o"
text="温馨提示:只显示当前年份的待办和已办事项"
text="温馨提示:点击待办进行处理,点击已办查看办理情况"
></van-notice-bar>
<van-loading v-if="legacyTaskLoading" style="text-align: center; padding: 8px">正在加载其他办理事项</van-loading>
<div v-if="legacyTaskError" style="text-align: center; padding: 8px" @click="initData">其他办理事项加载失败,点击重试</div>
<van-tabs @click="initData" v-model="activeName">
<van-tab name="0" title="待办">
<div style="min-height: 80vh">
<div v-for="o in needItems">
<van-loading v-if="taskLoading" style="padding: 16px; text-align: center">正在加载办理事项</van-loading>
<div v-if="taskError" style="padding: 16px; text-align: center" @click="loadLocalTasks">流程待办加载失败,点击重试</div>
<div v-for="o in localNeedItems" :key="'pending-' + o.id" class="van-doc-card" @click="openLocalTask(o, false)">
<div class="title">{{ o.processName }}</div>
<div>{{ o.taskNodeName }}</div>
<div style="color: grey; margin-top: 6px">{{ o.createdByUserName }} · {{ o.createdOn }}</div>
</div>
<div v-for="o in visibleNeedItems">
<div @click="toUrl(o)" class="van-doc-card" v-if="o.count > 0">
<div class="title">{{ o.title }}</div>
<div style="display: flex; align-items: center; justify-content: space-between;">
@@ -356,14 +366,21 @@ layout("/mobile/platform.html"){
description="暂无待办"
image="https://img01.yzcdn.cn/vant/custom-empty-image.png"
style="margin-top: 44px"
v-if="needItems.length === 0"
v-if="!taskLoading && !taskError && !legacyTaskLoading && !legacyTaskError && visibleNeedItems.length === 0 && localNeedItems.length === 0"
></van-empty>
</div>
</van-tab>
<van-tab name="1" title="已办">
<div style="min-height: 80vh">
<div @click="toHref(o)" class="van-doc-card" v-for="o in completedItems">
<van-loading v-if="taskLoading" style="padding: 16px; text-align: center">正在加载办理事项</van-loading>
<div v-if="taskError" style="padding: 16px; text-align: center" @click="loadLocalTasks">流程已办加载失败,点击重试</div>
<div v-for="o in localCompletedItems" :key="'completed-' + o.id" class="van-doc-card" @click="openLocalTask(o, true)">
<div class="title">{{ o.processName }}</div>
<div>{{ o.taskNodeName }} · 已办理</div>
<div style="color: grey; margin-top: 6px">{{ o.createdByUserName }} · {{ o.endOn || o.createdOn }}</div>
</div>
<div @click="toHref(o)" class="van-doc-card" v-for="o in visibleCompletedItems">
<div class="title">{{ o.moduleName }}</div>
<div style="display: flex; align-items: center; justify-content: space-between;">
<div>
@@ -379,7 +396,7 @@ layout("/mobile/platform.html"){
description="暂无已办"
image="https://img01.yzcdn.cn/vant/custom-empty-image.png"
style="margin-top: 44px"
v-if="completedItems.length === 0"
v-if="!taskLoading && !taskError && !legacyTaskLoading && !legacyTaskError && visibleCompletedItems.length === 0 && localCompletedItems.length === 0"
></van-empty>
</div>
</van-tab>
@@ -517,7 +534,13 @@ layout("/mobile/platform.html"){
moduleMenus: [],
roles: [],
active: 0,
needCount: 0,
localNeedItems: [],
localCompletedItems: [],
taskLoading: false,
taskError: false,
taskRequestVersion: 0,
legacyTaskLoading: false,
legacyTaskError: false,
needItems: [],
activeName: '0',
completedItems: [],
@@ -545,6 +568,20 @@ layout("/mobile/platform.html"){
activityQrCodeShow: false,
}
},
computed: {
// 同一手机入口已接入流程任务时,不再重复显示旧接口的汇总卡片。
visibleNeedItems() {
const urls = this.localNeedItems.map(o => this.taskPath(o.formMobileUrl));
return this.needItems.filter(o => !urls.includes(this.taskPath(o.mobileHref)));
},
visibleCompletedItems() {
const urls = this.localCompletedItems.map(o => this.taskPath(o.formMobileUrlView || o.formMobileUrl));
return this.completedItems.filter(o => !urls.includes(this.taskPath(o.mobileUrl)));
},
needCount() {
return this.visibleNeedItems.length + this.localNeedItems.length > 0;
}
},
components: {},
methods: {
async getMenus() {
@@ -571,7 +608,6 @@ layout("/mobile/platform.html"){
tabbrChange(o) {
console.log(o)
sessionStorage.setItem("zhgh-mobile-home-active",o)
this.needItems = []
this.initData()
},
toUrl(o) {
@@ -580,14 +616,11 @@ layout("/mobile/platform.html"){
toHref(o) {
pjaxReplace(o.mobileUrl + '?audit=1');
},
async getNeedItems() {
const {data, code} = await $.get('/platform/needItems/getNeedItems')
if (code === 0) {
const obj = data.filter(v => {
return v.mobileHref != null && v.count > 0
})
this.needItems = obj
}
getNeedItems() {
// mobile=true 由后端按实际手机入口过滤,返回数组用于数量及红点计算。
return $.get('/platform/needItems/getNeedItems', {mobile: true}).then(res => {
if (res.code === 0) this.$set(this, 'needItems', res.data.filter(v => v.mobileHref && v.count > 0));
});
},
async getCompletes() {
const {data, code} = await $.get('/platform/sys/completed/getCompletes')
@@ -615,23 +648,72 @@ layout("/mobile/platform.html"){
this.needItems = this.needItems.concat(data.filter(v => v.count > 0))
}
},
async initData() {
await this.getNeedItems();
await this.getMemberCheckSelfAgenda()
await this.getWelfareCheckSelfAgenda()
await this.getCompletes();
await this.getMsg()
await this.listActivity();
this.needCount = this.needItems.length
// 双端共用流程任务来源;只使用手机地址,避免手机进入 PC 表单。
taskPath(url) {
return (url || '').split('?')[0].replace(/\/$/, '');
},
async setNeedItems() {
const {data, code} = await $.get('/platform/needItems/getNeedItems')
if (code === 0) {
const obj = data.filter(v => {
return v.mobileHref != null && v.count > 0
})
window.localStorage.setItem('needItems', escape(JSON.stringify(obj)))
openLocalTask(row, completed) {
const url = completed ? (row.formMobileUrlView || row.formMobileUrl) : row.formMobileUrl;
if (url) pjaxReplace(url);
},
loadLocalTasks() {
const version = this.taskRequestVersion + 1;
this.$set(this, 'taskRequestVersion', version);
this.$set(this, 'taskLoading', true);
this.$set(this, 'taskError', false);
let remaining = 2;
// mode=1 待办、2 已办;data 是任务数组。忽略旧请求,防止快速切换覆盖新结果。
[1, 2].forEach(mode => {
$.post('/platform/sys/localProcess/todoList', {mode: mode, mobile: true})
.then(res => {
if (version !== this.taskRequestVersion || this._isDestroyed) return;
if (res.code !== 0 || !Array.isArray(res.data)) {
this.$set(this, 'taskError', true);
return;
}
const ids = new Set();
const rows = res.data.filter(row => {
const url = mode === 1 ? row.formMobileUrl : (row.formMobileUrlView || row.formMobileUrl);
if (!url || ids.has(row.id)) return false;
ids.add(row.id);
return true;
});
this.$set(this, mode === 1 ? 'localNeedItems' : 'localCompletedItems', rows);
}, () => {
if (version === this.taskRequestVersion && !this._isDestroyed) this.$set(this, 'taskError', true);
}).always(() => {
remaining--;
if (remaining === 0 && version === this.taskRequestVersion && !this._isDestroyed) this.$set(this, 'taskLoading', false);
});
});
},
initData() {
// 活动独立启动,返回其完成状态供首页选择默认栏目,不等待待办加载。
const activityRequest = this.listActivity().catch(() => {});
this.loadLocalTasks();
// 保留原有业务待办;重复点击不并发追加旧接口的汇总记录。
if (!this.legacyTaskLoading) {
this.$set(this, 'legacyTaskLoading', true);
this.$set(this, 'legacyTaskError', false);
// jQuery 1.11 的请求链不支持catch/finally;先由原生Promise接管,并等待各待办请求依次完成。
Promise.resolve().then(() => this.getNeedItems())
.then(() => this.getMemberCheckSelfAgenda())
.then(() => this.getWelfareCheckSelfAgenda())
.then(() => this.getCompletes())
.catch(() => this.$set(this, 'legacyTaskError', true))
.finally(() => this.$set(this, 'legacyTaskLoading', false));
}
// 消息独立加载,不阻塞活动和办理事项展示。
this.getMsg().catch(() => {});
return activityRequest;
},
setNeedItems() {
return $.get('/platform/needItems/getNeedItems', {mobile: true}).then(res => {
if (res.code === 0) {
const items = res.data.filter(v => v.mobileHref && v.count > 0);
window.localStorage.setItem('needItems', escape(JSON.stringify(items)));
}
});
},
//获取站内消息
async getMsg() {
@@ -719,18 +801,18 @@ layout("/mobile/platform.html"){
beforeMount() {
this.setNeedItems();
},
async created() {
await this.getMenus();
created() {
this.getAllMonth();
this.createYearList();
await this.initData();
const active = sessionStorage.getItem("zhgh-mobile-home-active")
this.active = active ? parseInt(active) : 0
if (!this.activityList || !this.activityList.length > 0) {
this.clickIndex = 2
this.clickMenu = this.moduleMenus.find(o => o.moduleName === '职工权益')
}
const active = sessionStorage.getItem("zhgh-mobile-home-active");
this.$set(this, 'active', active ? parseInt(active) : 0);
// 菜单加载失败不应阻止待办请求;活动和菜单加载完成后再选择默认栏目。
Promise.all([this.getMenus().catch(() => {}), this.initData()]).then(() => {
if (!this.activityList || this.activityList.length === 0) {
this.$set(this, 'clickIndex', 2);
this.$set(this, 'clickMenu', this.moduleMenus.find(o => o.moduleName === '职工权益') || {});
}
});
}
})
@@ -1,9 +1,10 @@
class typeUtil {
// 返回类型数组,text/value 为现有选择组件需要的别名;默认保留停用类型用于历史筛选
// 场地模块查询只提供职工之家;保留接口实际 ID,text/value 供双端筛选组件使用,不改类型管理数据
getAllType(enabledOnly = false) {
return $.post('/platform/activity/site/type/findAll', {enabledOnly}).then((resp) => {
if (resp.code !== 0) return [];
return resp.data.map((row) => Object.assign({}, row, {text:row.meetingTypeName,value:row.id}));
return resp.data.filter((row) => row.meetingTypeName === '职工之家')
.map((row) => Object.assign({}, row, {text:row.meetingTypeName,value:row.id}));
});
}
}
@@ -55,7 +55,7 @@ layout("/layouts/platform.html"){
prop="name"></el-table-column>
<el-table-column align="center" show-overflow-tooltip header-align="center" label="场地地址"
prop="address"></el-table-column>
<el-table-column align="center" show-overflow-tooltip header-align="center" label="联系人"
<el-table-column align="center" show-overflow-tooltip header-align="center" label="场地管理员"
prop="contact_person"></el-table-column>
<el-table-column align="center" show-overflow-tooltip header-align="center" label="联系方式"
prop="contact_phone"></el-table-column>
@@ -137,20 +137,39 @@ layout("/layouts/platform.html"){
<el-row :gutter="20">
<el-col :span="12">
<el-form-item prop="name" label="场地名称">
<el-input maxlength="100" placeholder="请填写场地名称" v-model="formData.name"></el-input>
<!-- 保留常用名称选项,其他名称可输入后选择创建项或按回车确认。 -->
<el-select v-model="formData.name" filterable allow-create default-first-option
placeholder="请选择或输入场地名称" style="width:100%">
<el-option label="职工之家" value="职工之家"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="campus" label="校区">
<el-select v-model="formData.campus" placeholder="请选择校区" style="width:100%">
<el-option v-for="item in campusList" :key="item.campus_id" :label="item.campus_name" :value="item.campus_name"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item prop="address" label="场地地址">
<el-input maxlength="100" placeholder="请填写场地地址" v-model="formData.address"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="limitNum" label="限定人数">
<el-input-number v-model="formData.limitNum" :min="1" :max="100"
placeholder="请输入限定人数" style="width: 100%"></el-input-number>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item prop="contact_person" label="联系人">
<el-input v-model="formData.contact_person" placeholder="请填写联系人" type="text"></el-input>
<el-form-item prop="contact_person" label="场地管理员">
<el-input v-model="formData.contact_person" placeholder="请填写场地管理员" type="text"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
@@ -160,24 +179,6 @@ layout("/layouts/platform.html"){
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item prop="typeId" label="场地类型">
<el-select v-model="formData.typeId" style="width: 100%" filterable
placeholder="请选择场地类型">
<el-option v-for="item in activityTypeList" :label="item.meetingTypeName"
:value="item.id" :disabled="!item.enabled"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="limitNum" label="个人预约限定人数">
<el-input-number v-model="formData.limitNum" :min="1" :max="100"
placeholder="请输入个人预约限定人数" style="width: 100%"></el-input-number>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item prop="state" label="开启状态">
@@ -206,6 +207,7 @@ layout("/layouts/platform.html"){
</el-col>-->
</el-row>
<!-- 性别限制暂不开放配置,新增默认不限制,编辑保留历史设置。
<el-row :gutter="20">
<el-col :span="12">
<el-form-item prop="sexLimit" label="性别限制">
@@ -217,41 +219,37 @@ layout("/layouts/platform.html"){
</el-form-item>
</el-col>
</el-row>
-->
<el-form-item label="添加场次&emsp;" label-width="110px" class="view-header">
<el-button style="float: right;margin-bottom: 10px" icon="el-icon-plus" size="mini"
type="primary" @click="formData.open_hours.push({})">添加
</el-button>
<el-table :data="formData.open_hours" border size="mini">
<el-table-column prop="start_time" label="开始时间" align="center" header-align="center">
<template slot-scope="{row}">
<el-time-select
placeholder="开始时间"
v-model="row.start_time"
:picker-options="{ start: '00:00',step: '00:30',end: '24:00'}">
</el-time-select>
</template>
</el-table-column>
<el-table-column prop="end_time" label="结束时间" align="center" header-align="center">
<template slot-scope="{row}">
<el-time-select
placeholder="结束时间"
v-model="row.end_time"
:picker-options="{start: '00:00',step: '00:30',end: '24:00',minTime: row.start_time }">
</el-time-select>
</template>
</el-table-column>
<el-table-column label="操作" align="center" header-align="center" width="100px">
<template slot-scope="scope">
<el-button type="danger" icon="el-icon-delete" circle
:disabled="formData.open_hours.length==0"
@click="formData.open_hours.splice(scope.$index, 1)"></el-button>
</template>
</el-table-column>
<el-row :gutter="20">
<el-col :span="12"><el-form-item label="预约时间段类型" prop="reserveTimeType">
<el-radio-group v-model="formData.reserveTimeType" @change="changeTimeMode">
<el-radio-button :label="2">全天候预约</el-radio-button>
<el-radio-button :label="1">分段预约</el-radio-button>
</el-radio-group>
</el-form-item></el-col>
<el-col :span="12"><el-form-item label="禁用时间">
<el-button type="primary" size="small" @click="openDisabledTimes">点击设置禁用时间</el-button>
<span> 已设置 {{(formData.notApplyTimeList || []).length}} 个禁用时间</span>
</el-form-item></el-col>
</el-row>
<!-- 两种模式独立保留原始配置,open_hours由后端按时间单位展开。 -->
<el-form-item label="场次信息">
<div>{{formData.reserveTimeType===2 ? '全天候预约:配置一个开放范围,预约人按时间单位选择连续时段。' : '分段预约:配置一个或多个互不重叠的场次。'}}</div>
<el-button v-if="formData.reserveTimeType===1" type="primary" size="mini" @click="addOpenRange">添加场次</el-button>
<el-table :data="editableRanges" border size="mini">
<el-table-column label="开始时间"><template slot-scope="{row}">
<el-time-select v-model="row.start_time" :picker-options="{start:'00:00',step:'00:05',end:'23:55'}" placeholder="开始时间"></el-time-select>
</template></el-table-column>
<el-table-column label="结束时间"><template slot-scope="{row}">
<el-time-select v-model="row.end_time" :picker-options="{start:'00:05',step:'00:05',end:'24:00',minTime:row.start_time}" placeholder="结束时间"></el-time-select>
</template></el-table-column>
<el-table-column label="预约时间单位(分钟)"><template slot-scope="{row}">
<el-input-number v-model="row.timeUnit" :min="1" :max="1440" :precision="0" style="width:150px"></el-input-number>
</template></el-table-column>
<el-table-column v-if="formData.reserveTimeType===1" label="操作" width="100"><template slot-scope="{$index}">
<el-button type="danger" size="mini" :disabled="formData.segmentedOpenHours.length<=1" @click="removeOpenRange($index)">删除</el-button>
</template></el-table-column>
</el-table>
</el-form-item>
@@ -265,6 +263,28 @@ layout("/layouts/platform.html"){
<template #view>
</template>
</guava>
<el-dialog title="设置禁用时间" :visible.sync="disabledTimesShow" width="850px" append-to-body>
<el-date-picker v-model="disabledDates" type="dates" value-format="yyyy-MM-dd" placeholder="选择一个或多个日期" @change="syncDisabledDates" style="width:100%"></el-date-picker>
<div class="mt10">
<el-time-select v-model="disabledStart" :picker-options="{start:'00:00',step:'00:05',end:'23:55'}" placeholder="批量开始时间"></el-time-select>
<el-time-select v-model="disabledEnd" :picker-options="{start:'00:05',step:'00:05',end:'24:00'}" placeholder="批量结束时间"></el-time-select>
<el-button type="primary" @click="batchDisabledTimes">应用到全部日期</el-button>
</div>
<el-table :data="formData.notApplyTimeList || []" max-height="420" class="mt10">
<el-table-column label="日期" prop="date" width="115"></el-table-column>
<el-table-column label="开始时间"><template slot-scope="{row}">
<el-time-select v-model="row.startTime" :picker-options="{start:'00:00',step:'00:05',end:'23:55'}"></el-time-select>
</template></el-table-column>
<el-table-column label="结束时间"><template slot-scope="{row}">
<el-time-select v-model="row.endTime" :picker-options="{start:'00:05',step:'00:05',end:'24:00',minTime:row.startTime}"></el-time-select>
</template></el-table-column>
<el-table-column label="操作" width="160"><template slot-scope="{row,$index}">
<el-button size="mini" @click="addDisabledRange(row.date)">新增</el-button>
<el-button size="mini" type="danger" @click="removeDisabledRange($index)">删除</el-button>
</template></el-table-column>
</el-table>
<span slot="footer"><el-button type="primary" @click="finishDisabledTimes">确定</el-button></span>
</el-dialog>
</div>
<script>
@@ -275,6 +295,8 @@ layout("/layouts/platform.html"){
data() {
return {
activityTypeList: [],
campusList: [],
disabledTimesShow:false, disabledDates:[], disabledStart:'', disabledEnd:'',
tabKey: '',
tableLoading: false,
subDis: false,
@@ -284,6 +306,9 @@ layout("/layouts/platform.html"){
open_hours: [{}],
sexLimit: '0',
workday: false,
reserveTimeType:2, notApplyTimeList:[],
segmentedOpenHours:[{start_time:'',end_time:'',timeUnit:30}],
fullDayOpenHour:{start_time:'',end_time:'',timeUnit:30},
},
pageForm: {
searchName: "name",
@@ -296,20 +321,78 @@ layout("/layouts/platform.html"){
year: ""
},
formRules: {
name: [{required: true, message: '请填写场地名称', trigger: ['blur', 'change']}],
// 自定义名称与后端保持一致:必填、拒绝全空格且不超过实体字段的100字符。
name: [
{required: true, whitespace: true, message: '请选择或输入场地名称', trigger: ['blur', 'change']},
{max: 100, message: '场地名称不能超过100字符', trigger: ['blur', 'change']}
],
address: [{required: true, message: '请填写场地地址', trigger: ['blur', 'change']}],
contact_person: [{required: true, message: '请填写联系人', trigger: ['blur', 'change']}],
contact_person: [{required: true, message: '请填写场地管理员', trigger: ['blur', 'change']}],
contact_phone: [{required: true, message: '请填写联系电话', trigger: ['blur', 'change']}],
state: [{required: true, message: '请选择开启状态', trigger: ['blur', 'change']}],
typeId: [{required: true, message: '请选择场地类型', trigger: ['blur', 'change']}],
limitNum: [{required: true, message: '请填写个人预约限定人数', trigger: ['blur', 'change']}],
campus: [{required: true, message: '请选择校区', trigger: 'change'}],
limitNum: [{required: true, message: '请填写限定人数', trigger: ['blur', 'change']}],
}
}
},
computed: {
editableRanges() { return this.formData.reserveTimeType===2 ? [this.formData.fullDayOpenHour] : this.formData.segmentedOpenHours || [] }
},
components: {
'guava': httpVueLoader('/components/plugins/Guava.vue'),
},
methods: {
// 老数据以原场次长度作为时间单位,避免首次编辑自动拆分既有场次。
initSchedule(row) {
this.$set(row, 'reserveTimeType', row.reserveTimeType || 1)
this.$set(row, 'notApplyTimeList', row.notApplyTimeList || [])
if (!row.segmentedOpenHours || !row.segmentedOpenHours.length) this.$set(row, 'segmentedOpenHours', (row.open_hours || []).map(item => ({
start_time:item.start_time, end_time:item.end_time,
timeUnit:this.timeMinutes(item.end_time)-this.timeMinutes(item.start_time)
})))
if (!row.fullDayOpenHour) this.$set(row, 'fullDayOpenHour', {start_time:'',end_time:'',timeUnit:30})
},
timeMinutes(value) { const parts=(value || '').split(':'); return Number(parts[0])*60+Number(parts[1]) },
changeTimeMode() {
// 切换只改变展示,保留两套场次配置。
if (!this.formData.segmentedOpenHours.length) this.addOpenRange()
},
addOpenRange() { this.$set(this.formData, 'segmentedOpenHours', this.formData.segmentedOpenHours.concat([{start_time:'',end_time:'',timeUnit:30}])) },
removeOpenRange(index) { this.$set(this.formData, 'segmentedOpenHours', this.formData.segmentedOpenHours.filter((row,i)=>i!==index)) },
openDisabledTimes() {
this.$set(this, 'disabledDates', Array.from(new Set((this.formData.notApplyTimeList || []).map(row=>row.date))))
this.$set(this, 'disabledTimesShow', true)
},
syncDisabledDates(dates) {
const selected=dates || []
const rows=(this.formData.notApplyTimeList || []).filter(row=>selected.includes(row.date))
selected.forEach(date=>{if(!rows.some(row=>row.date===date))rows.push({date,startTime:'',endTime:''})})
this.$set(this.formData, 'notApplyTimeList', rows.sort((a,b)=>a.date.localeCompare(b.date)))
},
addDisabledRange(date) { this.$set(this.formData, 'notApplyTimeList', this.formData.notApplyTimeList.concat([{date,startTime:'',endTime:''}])) },
removeDisabledRange(index) {
this.$set(this.formData, 'notApplyTimeList', this.formData.notApplyTimeList.filter((row,i)=>i!==index))
this.$set(this, 'disabledDates', Array.from(new Set(this.formData.notApplyTimeList.map(row=>row.date))))
},
batchDisabledTimes() {
if(!this.disabledStart || !this.disabledEnd || this.disabledStart>=this.disabledEnd){this.$message.warning('请设置有效的禁用起止时间');return}
this.formData.notApplyTimeList.forEach(row=>{this.$set(row,'startTime',this.disabledStart);this.$set(row,'endTime',this.disabledEnd)})
},
validDisabledTimes() { return (this.formData.notApplyTimeList || []).every(row=>row.date && row.startTime && row.endTime && row.startTime<row.endTime) },
finishDisabledTimes() {
if(!this.validDisabledTimes()){this.$message.warning('请完整填写禁用日期及起止时间');return}
this.$set(this, 'disabledTimesShow', false)
},
validateSchedule() {
if(!this.validDisabledTimes()){this.$message.warning('请完整填写禁用日期及起止时间');return false}
const rows=this.editableRanges
if(!rows.length || rows.some(row=>!row || !row.start_time || !row.end_time || row.start_time>=row.end_time || !Number.isInteger(row.timeUnit) || row.timeUnit<=0 || (this.timeMinutes(row.end_time)-this.timeMinutes(row.start_time))%row.timeUnit!==0)){
this.$message.warning('请配置有效开放时间,时间单位须为正整数且能整除开放时长');return false
}
const ordered=rows.slice().sort((a,b)=>a.start_time.localeCompare(b.start_time))
if(ordered.some((row,i)=>i>0 && row.start_time<ordered[i-1].end_time)){this.$message.warning('分段场次不能重叠');return false}
return true
},
doDelete(row) {
this.$confirm('此操作将删除【' + row.name + '】场地的所有信息!', '提示', {
confirmButtonText: '确定',
@@ -330,6 +413,7 @@ layout("/layouts/platform.html"){
});
},
operation() {
if (!this.validateSchedule()) return
this.$refs.addForm.validate((valid)=>{if(!valid)return;this.formLoading=true;this.subDis=true;
$.post(loc()+(this.formData.id ? '/doEdit' : '/doAdd'),{data:JSON.stringify(this.formData)}).then((res)=>{if(res.code===0){this.pageData();this.$refs.guava.index()}else{this.$message.error(res.msg)}}).always(()=>{this.formLoading=false;this.subDis=false})
});
@@ -341,10 +425,13 @@ layout("/layouts/platform.html"){
this.$refs.guava.view()
},
openEdit(id) {
this.findOneSite(id).then((row)=>{if(row){this.formData=row;this.$refs.guava.edit()}});
this.findOneSite(id).then((row)=>{if(row){this.initSchedule(row);this.$set(this, 'formData', row);this.$refs.guava.edit()}});
},
openAdd() {
this.formData = {
// 新建时名称留空,由用户选择或输入;校区由用户明确选择,不沿用上次编辑值。
this.$set(this, 'formData', {
name: '',
campus: '',
state: true,
multiple: true,
open_hours: [{}],
@@ -352,12 +439,13 @@ layout("/layouts/platform.html"){
create_time: moment().format('YYYY-MM-DD'),
sexLimit: '0',
workday: false,
}
reserveTimeType:2, notApplyTimeList:[],
segmentedOpenHours:[{start_time:'',end_time:'',timeUnit:30}],
fullDayOpenHour:{start_time:'',end_time:'',timeUnit:30},
})
this.$refs.guava.edit()
if (this.$refs['addForm']) {
this.$refs['addForm'].resetFields()
}
this.$nextTick(() => { if (this.$refs.addForm) this.$refs.addForm.clearValidate() })
},
doSearch() {
this.tabKey = new Date().getTime()
@@ -398,6 +486,11 @@ layout("/layouts/platform.html"){
},
created() {
this.pageData();activityUtil.getAllType().then((rows)=>{this.activityTypeList=rows});
// 校区复用系统选项接口,value 保存校区名称,与现有业务页面一致。
$.post('/platform/vi/common/getCampus').then((res) => {
if (res && res.code===0) this.$set(this, 'campusList', res.data.filter(row=>!['青山湖科创中心','不固定校区'].includes(row.campus_name)))
else this.$message.error(res && res.msg || '校区加载失败')
}, () => this.$message.error('校区加载失败,请刷新重试'))
}
})
</script>
@@ -1,6 +1,14 @@
<!--#
layout("/layouts/platform.html"){
#-->
<style>
/* 预约列表按日期分组,日期和完整时段整体居中,长内容只在时段之间换行。 */
.site-booking-times { display:inline-block; max-width:100%; text-align:left; vertical-align:middle; font-variant-numeric:tabular-nums; }
.site-booking-day { display:flex; align-items:baseline; flex-wrap:wrap; gap:4px 12px; padding:3px 0; line-height:22px; }
.site-booking-date { flex:0 0 88px; white-space:nowrap; font-weight:500; }
.site-booking-ranges { display:flex; flex-wrap:wrap; gap:2px 12px; }
.site-booking-range { white-space:nowrap; }
</style>
<div id="app" v-cloak>
<guava ref="guava">
<template>
@@ -53,23 +61,17 @@ layout("/layouts/platform.html"){
<el-table-column align="center" sortable show-overflow-tooltip header-align="center"
label="预约天数"
prop="days"></el-table-column>
<el-table-column align="center" sortable show-overflow-tooltip header-align="center"
label="预约日期"
prop="concat_day"></el-table-column>
<el-table-column align="center" sortable show-overflow-tooltip header-align="center"
label="开始时间"
prop="start_time">
<template slot-scope="{row}">
<span>{{row.start_time}}</span>
</template>
</el-table-column>
<el-table-column align="center" sortable show-overflow-tooltip header-align="center"
label="结束时间"
prop="end_time">
<template slot-scope="{row}">
<span>{{row.end_time}}</span>
</template>
</el-table-column>
<el-table-column align="center" header-align="center" label="预约时段" min-width="245">
<template slot-scope="{row}">
<div class="site-booking-times">
<div v-for="group in row.reservationTimeGroups" :key="group.date" class="site-booking-day">
<span class="site-booking-date">{{group.date}}</span>
<div class="site-booking-ranges"><span v-for="(range,index) in group.ranges" :key="index" class="site-booking-range">{{range.start}}{{range.end}}</span></div>
</div>
<span v-if="!row.reservationTimeGroups || !row.reservationTimeGroups.length"></span>
</div>
</template>
</el-table-column>
<el-table-column align="center" show-overflow-tooltip header-align="center" label="反馈意见"
prop="back_option">
<template slot-scope="{row}">
@@ -148,7 +150,7 @@ layout("/layouts/platform.html"){
}
},
components: {
'reserve-info': httpVueLoader('/components/activity/site/ReserveInfo.vue'),
'reserve-info': httpVueLoader('/components/activity/site/ReserveInfo.vue?v=20260910-2'),
},
methods: {
openView(id) {
@@ -190,9 +192,11 @@ layout("/layouts/platform.html"){
}
}
},
async created() {
this.activityTypeList = await activityUtil.getAllType()
this.pageData();
created() {
activityUtil.getAllType().then((rows) => {
this.$set(this, 'activityTypeList', rows)
this.pageData()
}, () => { this.$message.error('场地类型加载失败,请刷新重试') })
},
})
</script>
@@ -101,6 +101,25 @@ layout("/layouts/platform.html"){
</style>
<style>
/* 预约列表按日期分组,日期和完整时段整体居中,长内容只在时段之间换行。 */
.site-booking-times { display:inline-block; max-width:100%; text-align:left; vertical-align:middle; font-variant-numeric:tabular-nums; }
.site-booking-day { display:flex; align-items:baseline; flex-wrap:wrap; gap:4px 12px; padding:3px 0; line-height:22px; }
.site-booking-date { flex:0 0 88px; white-space:nowrap; font-weight:500; }
.site-booking-ranges { display:flex; flex-wrap:wrap; gap:2px 12px; }
.site-booking-range { white-space:nowrap; }
/* 时间选择区平铺全部选项,日期和按钮自动换行;禁用原因仅通过悬停提示展示。 */
.site-time-dates { display:flex; flex-wrap:wrap; gap:8px; margin:12px 0 20px; }
.site-time-group { display:flex; gap:16px; margin:20px 0; align-items:flex-start; }
.site-time-heading { flex:0 0 140px; line-height:36px; color:#606266; white-space:nowrap; }
.site-time-options { display:flex; flex-wrap:wrap; gap:8px; flex:1; }
.site-time-options .el-button { margin:0; position:relative; min-width:82px; min-height:36px; }
.site-time-options .is-range { background:#ecf5ff; border-color:#409eff; color:#1672bd; }
.site-time-mark { position:absolute; top:2px; right:3px; font-size:10px; line-height:12px; font-weight:bold; }
.site-time-summary { margin:16px 0; color:#303133; line-height:24px; }
.site-time-help { color:#909399; line-height:24px; }
@media (max-width:800px) { .site-time-group { flex-direction:column; gap:4px; } .site-time-heading { flex-basis:auto; } }
</style>
<div id="app" v-cloak>
<guava ref="guava">
@@ -222,23 +241,17 @@ layout("/layouts/platform.html"){
<el-table-column align="center" sortable show-overflow-tooltip header-align="center"
label="预约天数"
prop="days"></el-table-column>
<el-table-column align="center" sortable show-overflow-tooltip header-align="center"
label="预约日期"
prop="concat_day"></el-table-column>
<el-table-column align="center" sortable show-overflow-tooltip header-align="center"
label="开始时间"
prop="start_time">
<template slot-scope="{row}">
<span>{{row.start_time}}</span>
</template>
</el-table-column>
<el-table-column align="center" sortable show-overflow-tooltip header-align="center"
label="结束时间"
prop="end_time">
<template slot-scope="{row}">
<span>{{row.end_time}}</span>
</template>
</el-table-column>
<el-table-column align="center" header-align="center" label="预约时段" min-width="245">
<template slot-scope="{row}">
<div class="site-booking-times">
<div v-for="group in row.reservationTimeGroups" :key="group.date" class="site-booking-day">
<span class="site-booking-date">{{group.date}}</span>
<div class="site-booking-ranges"><span v-for="(range,index) in group.ranges" :key="index" class="site-booking-range">{{range.start}}{{range.end}}</span></div>
</div>
<span v-if="!row.reservationTimeGroups || !row.reservationTimeGroups.length"></span>
</div>
</template>
</el-table-column>
<el-table-column align="center" header-align="center" label="联系方式"
prop="reserve_person_phone"></el-table-column>
<el-table-column align="center" show-overflow-tooltip header-align="center" label="预约事由"
@@ -274,13 +287,14 @@ layout("/layouts/platform.html"){
</el-dropdown-item>
<!--# if(@shiro.hasRole('sysadmin')){ #-->
<el-dropdown-item
v-if="Number(scope.row.reserve_state) === 4050"
:command="{type:'delete',data:scope.row}">
删除
</el-dropdown-item>
<!--# } #-->
<el-dropdown-item
v-if="scope.row.reserve_person_id === '${@shiro.getPrincipalProperty('id')}'"
v-if="scope.row.reserve_person_id === '${@shiro.getPrincipalProperty('id')}' && Number(scope.row.reserve_state) !== 4050"
:command="{type:'cancel',data:scope.row}">
撤销预约
</el-dropdown-item>
@@ -317,7 +331,7 @@ layout("/layouts/platform.html"){
您正在预约【<span style="color: #409EFF">{{infoViewData.name}}</span>】活动场地
</div>
<div style="color:#909399;">
开放时间段为:<span v-for="(item,index) in infoViewData.open_hours" style="color: #303133">
开放时间段为:<span v-for="(item,index) in displayedOpenHours" style="color: #303133">
<span v-if="infoViewData.workday === true && index === 0">工作日</span>
【{{item.start_time}} - {{item.end_time}}】
</span>
@@ -365,7 +379,32 @@ layout("/layouts/platform.html"){
<el-dialog title="新增场地预约" class="dia" :close-on-click-modal="false" @close="diaClose"
:visible.sync="addDialogVisible" custom-class="ViewDialogClass" width="70%" top="2%">
<vi-title :title="'您已选择的预约日期为:'+ dayArray.toString()" style="margin-left: 48px"></vi-title>
<el-tabs :value="bookingTab" :before-leave="beforeBookingTabLeave" @input="changeBookingTab">
<el-tab-pane label="选择时间" name="time">
<div>已选择的预约日期</div>
<div class="site-time-dates"><el-tag v-for="day in dayArray" :key="day">{{day}}</el-tag></div>
<div class="site-time-help">所有选中日期使用同一组时间,只有全部日期均可预约的时间才能选择。</div>
<div class="site-time-summary">{{isFullDayBooking ? '先点击开始时间,再点击结束时间;再次点击已选时间可取消本次选择。' : '点击时间段选择,再次点击取消,可选择多个时间段。'}}</div>
<div v-loading="slotsLoading" style="min-height:160px">
<div v-if="slotsLoadFailed"><el-alert title="时间加载失败,请重试" type="error" :closable="false"></el-alert><el-button @click="loadBookingSlots">重新加载</el-button></div>
<div v-else-if="!slotsLoading && !bookingSlots.length" class="site-time-help">暂无开放时段</div>
<div v-for="group in bookingTimeGroups" :key="group.label" class="site-time-group">
<div class="site-time-heading">{{group.label}}</div>
<div class="site-time-options">
<el-button v-for="item in group.items" :key="item.key" size="small"
:disabled="slotsLoading || item.disabled" :title="item.reason || item.label"
:type="item.mark ? 'primary' : 'default'" :class="{'is-range':item.selected && !item.mark}"
@click="chooseBookingTime(item)">
{{item.label}}<span v-if="item.mark" class="site-time-mark">{{item.mark}}</span>
</el-button>
</div>
</div>
</div>
<div class="site-time-summary">已选时间:{{bookingTimeSummary}}</div>
<el-button size="small" :disabled="slotsLoading" @click="clearBookingTime">清空选择</el-button>
</el-tab-pane>
<el-tab-pane label="填写信息" name="info">
<div class="site-time-dates"><el-tag v-for="day in dayArray" :key="day">{{day}}</el-tag></div>
<el-form :model="formData" ref="addForm" :rules="formRules" size="small" label-position="right"
label-width="100px">
@@ -424,13 +463,8 @@ layout("/layouts/platform.html"){
</el-form-item>-->
<el-form-item label="预约时间" prop="time">
<el-select v-model="formData.time" style="width: 100%" filterable @change="timeChange"
placeholder="请选择预约时间">
<el-option v-for="item in infoViewData.open_hours"
:label="item.disabled ? item.start_time + ' - ' + item.end_time + '(已约满)' : item.start_time + ' - ' + item.end_time"
:disabled="item.disabled"
:value="item.start_time + '-' + item.end_time"></el-option>
</el-select>
<span>{{bookingTimeSummary}}</span>
<el-button type="text" :disabled="formLoading" @click="changeBookingTab('time')">修改时间</el-button>
</el-form-item>
<!--<el-form-item label="预约时间" prop="start_time">
@@ -459,13 +493,18 @@ layout("/layouts/platform.html"){
</el-row>
</el-form-item>-->
<el-form-item label="预约类型" prop="reserve_type">
<el-radio-group v-model="formData.reserve_type" size="medium">
<el-radio-button :label="1">个人预约</el-radio-button>
<el-radio-button :label="2">单位预约</el-radio-button>
<el-radio-group v-model="formData.reserve_type" @change="loadBookingSlots" size="medium">
<!-- PC暂不开放个人预约,保留历史类型值及其他入口的兼容。 -->
<!--<el-radio-button :label="1">个人预约</el-radio-button>-->
<el-radio-button :label="2">分工会预约</el-radio-button>
<el-radio-button :label="3">协会预约</el-radio-button>
</el-radio-group>
</el-form-item>
<!-- 所属协会仅用于协会预约,个人和单位预约不展示该字段-->
<!-- 分工会由后端按当前申请人解析,只读展示,不接受前端指定组织-->
<el-form-item label="所属分工会" v-if="formData.reserve_type===2">
<el-input :value="bookingUnionName" readonly :placeholder="unionLoading ? '正在加载所属分工会' : '未配置所属分工会'"></el-input>
</el-form-item>
<!-- 所属协会仅用于协会预约。 -->
<el-form-item label="所属协会" v-if="formData.reserve_type===3">
<el-select v-model="formData.clubId" placeholder="请选择所属协会" style="width:100%">
<el-option v-for="club in myClubs" :key="club.id" :label="club.name" :value="club.id"></el-option>
@@ -478,10 +517,14 @@ layout("/layouts/platform.html"){
type="textarea" :autosize="{ minRows: 4, maxRows: 6}"></el-input>
</el-form-item>
</el-form>
</el-tab-pane>
</el-tabs>
<span slot="footer" class="dialog-footer">
<el-button @click="closeAdd">取 消</el-button>
<el-button type="primary" :disabled="subDis" @click="doAdd">确 定</el-button>
<el-button :disabled="formLoading" @click="closeAdd">取 消</el-button>
<el-button v-if="bookingTab==='info'" :disabled="formLoading" @click="changeBookingTab('time')">上一步</el-button>
<el-button v-if="bookingTab==='time'" type="primary" :disabled="slotsLoading" @click="nextBookingTab">下一步</el-button>
<el-button v-else type="primary" :loading="formLoading" :disabled="subDis || slotsLoading" @click="doAdd">确 定</el-button>
</span>
</el-dialog>
@@ -503,6 +546,9 @@ layout("/layouts/platform.html"){
max: 24,
min: 0,
myClubs: [],
bookingUnionName:'', unionLoading:false, unionRequestVersion:0,
bookingSlots:[], slotsLoading:false, slotsVersion:0,
bookingTab:'time', bookingRangeStart:'', bookingRangeEnd:'', slotsLoadFailed:false,
formLoading: false,
slider_width: 0,
single_width: 0,
@@ -529,7 +575,7 @@ layout("/layouts/platform.html"){
end_time: '',
reserve_person_phone: '',
reserve_cause: '',
time: '',
time: [],
sex: "${@shiro.getPrincipalProperty('sex')}",
loginname: "${@shiro.getPrincipalProperty('loginname')}"
},
@@ -551,26 +597,183 @@ layout("/layouts/platform.html"){
start_time: [{required: true, message: '请选择预约时间', trigger: ['blur', 'change']}],
time: [{required: true, message: '请选择预约时间', trigger: ['blur', 'change']}],
reserve_type: [{required: true, message: '请选择预约类型', trigger: ['blur', 'change']}],
/*reserve_cause: [{required: true, message: '请选择预约事由', trigger: ['blur', 'change']}],*/
// 与后端必填要求一致,显示星号并阻止空白事由提交。
reserve_cause: [{required: true, whitespace: true, message: '请填写预约事由', trigger: ['blur', 'change']}],
},
dayArray: [],
holidays: ['2022-06-03', '2022-06-04', '2022-06-05', '2022-09-10', '2022-09-11', '2022-09-12',
'2022-10-01', '2022-10-02', '2022-10-03', '2022-10-04', '2022-10-05', '2022-10-06', '2022-10-07',],
}
},
computed: {
isFullDayBooking() {
return Number(this.infoViewData.reserveTimeType || this.infoViewData.reservetimetype || 1) === 2
},
bookingTimeSummary() {
if (this.isFullDayBooking) return this.bookingRangeEnd ? this.bookingRangeStart + ' - ' + this.bookingRangeEnd : this.bookingRangeStart ? this.bookingRangeStart + ' 起(请选择结束时间)' : '尚未选择'
return (this.formData.time || []).join('、') || '尚未选择'
},
// 全天候展示时间边界(含最后结束点),分段展示完整场次;12:00及之后统一归入下午。
bookingTimeGroups() {
let items
if (this.isFullDayBooking) {
const points = Array.from(new Set(this.bookingSlots.flatMap(row => [row.start_time, row.end_time]))).sort()
const choosingEnd = this.bookingRangeStart && !this.bookingRangeEnd
items = points.map(point => {
const startSlot = this.bookingSlots.find(row => row.start_time === point)
const validEnd = choosingEnd && this.rangeBookingSlots(this.bookingRangeStart, point)
// 已选端点和范围内时间保持可点击,包括仅可作为结束边界的最后时间点,方便取消选择。
const selected = point === this.bookingRangeStart || !!this.bookingRangeEnd && point >= this.bookingRangeStart && point <= this.bookingRangeEnd
const disabled = !selected && (choosingEnd ? !validEnd : !startSlot || startSlot.disabled)
return {key:point, point, label:point, disabled,
reason:disabled ? choosingEnd ? '不可作为结束' : startSlot ? startSlot.msg : '仅结束时间' : '',
selected,
mark:point === this.bookingRangeStart ? '起' : point === this.bookingRangeEnd ? '终' : ''}
})
} else {
items = this.bookingSlots.map(row => ({key:row.start_time + '-' + row.end_time, point:row.start_time,
label:row.start_time + ' - ' + row.end_time, disabled:row.disabled, reason:row.msg,
selected:(this.formData.time || []).includes(row.start_time + '-' + row.end_time), mark:''}))
}
return [{label:'上午(00:00 - 12:00',items:items.filter(row => row.point < '12:00')},
{label:'下午(12:00 - 24:00',items:items.filter(row => row.point >= '12:00')}].filter(group => group.items.length)
},
// 全天候场次仅在标题中合并为完整范围,保留原始时段供选择和提交;旧数据按分段展示。
displayedOpenHours() {
const hours = this.infoViewData.open_hours || []
if (Number(this.infoViewData.reserveTimeType || this.infoViewData.reservetimetype || 1) !== 2 || !hours.length) return hours
// 独立计算最早开始和最晚结束时间,不依赖接口顺序,也不修改原始数组。
return [{
start_time: hours.reduce((start, row) => row.start_time < start ? row.start_time : start, hours[0].start_time),
end_time: hours.reduce((end, row) => row.end_time > end ? row.end_time : end, hours[0].end_time)
}]
}
},
components: {
'guava': httpVueLoader('/components/plugins/Guava.vue'),
'reserve-info': httpVueLoader('/components/activity/site/ReserveInfo.vue'),
'reserve-info': httpVueLoader('/components/activity/site/ReserveInfo.vue?v=20260910-2'),
},
methods: {
diaClose() {
this.formData.time = ''
this.formData.start_time = ''
this.formData.end_time = ''
// start/end为HH:mm边界,返回可提交场次数组;不连续、跨禁用段或边界不匹配时返回null。
rangeBookingSlots(start, end) {
if (!start || !end || end <= start) return null
const rows = this.bookingSlots.filter(row => row.start_time >= start && row.end_time <= end).slice().sort((a,b) => a.start_time.localeCompare(b.start_time))
if (!rows.length || rows[0].start_time !== start || rows[rows.length-1].end_time !== end || rows.some((row,index) => row.disabled || index > 0 && rows[index-1].end_time !== row.start_time)) return null
return rows.map(row => row.start_time + '-' + row.end_time)
},
timeChange(o) {
this.formData.start_time = o.split('-')[0]
this.formData.end_time = o.split('-')[1]
clearBookingTime() {
this.$set(this,'bookingRangeStart','')
this.$set(this,'bookingRangeEnd','')
this.$set(this.formData,'time',[])
this.timeChange([])
},
// 全天候两次点击确定起止范围;分段切换单个场次,统一同步原接口使用的time数组。
chooseBookingTime(item) {
if (this.slotsLoading || this.formLoading || item.disabled) return
if (this.isFullDayBooking) {
// 全天候取消的是完整连续范围,不能留下中间缺口;只选起点时也允许再次点击清空。
if (item.point === this.bookingRangeStart || this.bookingRangeEnd && item.point >= this.bookingRangeStart && item.point <= this.bookingRangeEnd) {
this.clearBookingTime()
return
}
if (!this.bookingRangeStart || this.bookingRangeEnd) {
this.clearBookingTime()
this.$set(this,'bookingRangeStart',item.point)
return
}
const times = this.rangeBookingSlots(this.bookingRangeStart,item.point)
if (!times) return
this.$set(this,'bookingRangeEnd',item.point)
this.$set(this.formData,'time',times)
} else {
const times = (this.formData.time || []).slice()
const index = times.indexOf(item.key)
if (index >= 0) times.splice(index,1)
else times.push(item.key)
this.$set(this.formData,'time',times.sort())
}
this.timeChange(this.formData.time)
},
// 切换到表单及提交前共用校验,防止绕过第一步或提交加载失败、已失效的时段。
validateBookingTime(showMessage = true) {
const times = this.formData.time || []
const range = this.isFullDayBooking ? this.rangeBookingSlots(this.bookingRangeStart,this.bookingRangeEnd) : null
const valid = !this.slotsLoading && !this.slotsLoadFailed && times.length > 0
&& times.every(time => this.bookingSlots.some(row => !row.disabled && row.start_time + '-' + row.end_time === time))
&& (!this.isFullDayBooking || range && range.length === times.length && range.every(time => times.includes(time)))
if (!valid && showMessage) this.$message.warning('请选择完整且可预约的时间')
return !!valid
},
beforeBookingTabLeave(name) {
return !this.formLoading && (name !== 'info' || this.validateBookingTime())
},
changeBookingTab(name) {
if (!this.formLoading) this.$set(this,'bookingTab',name)
},
nextBookingTab() {
if (this.validateBookingTime()) this.changeBookingTab('info')
},
// 每次打开表单刷新组织信息;结果只用于展示,提交仍由服务端取得真实组织。
loadBookingUnion() {
const version=this.unionRequestVersion+1
this.$set(this,'unionRequestVersion',version)
this.$set(this,'bookingUnionName','')
this.$set(this,'unionLoading',true)
$.post('/platform/activity/site/reserve/myUnion').then(res=>{
if(version!==this.unionRequestVersion)return
if(res && res.code===0)this.$set(this,'bookingUnionName',res.data && res.data.name || '')
else this.$message.error(res && res.msg || '所属分工会加载失败')
},()=>{if(version===this.unionRequestVersion)this.$message.error('所属分工会加载失败,请重新打开表单')}).always(()=>{
if(version===this.unionRequestVersion)this.$set(this,'unionLoading',false)
})
},
diaClose() {
// 关闭后令在途时段请求失效,避免旧弹框响应污染下一次选择。
this.$set(this,'slotsVersion',this.slotsVersion+1)
this.$set(this,'slotsLoading',false)
this.$set(this,'bookingTab','time')
this.clearBookingTime()
},
timeChange(values) {
const times=values.slice().sort()
this.$set(this.formData, 'start_time', times.length ? times[0].split('-')[0] : '')
this.$set(this.formData, 'end_time', times.length ? times[times.length-1].split('-')[1] : '')
},
// 分工会与协会切换时保留已选时间,仅刷新所有所选日期的可用场次;版本号阻止旧响应覆盖。
loadBookingSlots() {
const version=this.slotsVersion+1
this.$set(this,'slotsVersion',version)
this.$set(this,'slotsLoading',true)
this.$set(this,'slotsLoadFailed',false)
this.$set(this,'bookingSlots',[])
const days=this.dayArray.slice(), results=[]
let pending=days.length, failed=false
if(!pending){this.$set(this,'slotsLoading',false);return}
days.forEach(day=>{
$.post('/mobile/activity/site/info/getReserve',{siteId:this.formData.site_id,day,reserveType:this.formData.reserve_type}).then(res=>{
if(version!==this.slotsVersion)return
if(res && res.code===0 && Array.isArray(res.data))results.push(res.data.map(row => Object.assign({},row,{sourceDay:day})))
else{failed=true;this.$message.error(res && res.msg || '场次加载失败')}
},()=>{if(version===this.slotsVersion){failed=true;this.$message.error('场次加载失败')}}).always(()=>{
if(version!==this.slotsVersion)return
pending--
if(pending===0){
if(!failed && results.length)this.$set(this,'bookingSlots',results[0].map(row=>{
const blocked=results.map(rows=>rows.find(item=>item.start_time===row.start_time && item.end_time===row.end_time)).find(item=>!item || item.code!==1)
const missing=results.some(rows=>!rows.some(item=>item.start_time===row.start_time && item.end_time===row.end_time))
return Object.assign({},row,{disabled:missing || !!blocked,msg:missing ? '场次已变化' : blocked ? blocked.sourceDay + ' ' + blocked.msg : row.msg})
}).sort((a,b)=>a.start_time.localeCompare(b.start_time)))
this.$set(this,'slotsLoadFailed',failed)
this.$set(this,'slotsLoading',false)
// 类型切换后仅保留仍有效的完整选择;失效则返回时间页重新选择。
if ((this.formData.time.length || this.bookingRangeStart) && !this.validateBookingTime(false)) {
this.clearBookingTime()
this.$set(this,'bookingTab','time')
this.$message.warning('所选时间已失效,请重新选择')
}
}
})
})
},
dropdownCommand(command) {
const {type, data} = command
@@ -705,7 +908,7 @@ layout("/layouts/platform.html"){
this.$set(this.formData, "reserve_person", '${@shiro.getPrincipalProperty("username")}')
this.$set(this.formData, "reserve_person_unit", '${@shiro.getPrincipalProperty("unit").getName()}')
this.$set(this.formData, "reserve_person_phone", '${@shiro.getPrincipalProperty("mobile")}')
this.$set(this.formData, 'reserve_type', 1)
this.$set(this.formData, 'reserve_type', 2)
// 加载协会预约的可选协会;只有一个时默认选中,多协会由申请人选择。
$.post('/platform/activity/site/reserve/myClubs').then((res)=>{
if(res.code===0){this.myClubs=res.data;this.$set(this.formData,'clubId',res.data.length===1 ? res.data[0].id : null)}
@@ -716,19 +919,21 @@ layout("/layouts/platform.html"){
this.$refs['addForm'].resetFields()
}
this.$set(this.formData, 'reserve_type', 2)
// 新开申请时清空上次时段;类型切换刷新场次时不重置选择。
this.clearBookingTime()
this.$set(this,'bookingTab','time')
this.loadBookingUnion()
this.addDialogVisible = true
this.loadBookingSlots()
this.$nextTick(() => {
this.flushSliderWidth()
$(window).resize(() => {
vue.flushSliderWidth()
})
})
// 原滑块已停用,打开弹框不再读取不存在的滑块节点或注册resize事件。
},
doDelete(id, op) {
this.$confirm('确定撤销此预约?已审核的申请不能撤销。','提示').then(()=>{
// op=1 删除已撤销申请的全部时段,op=2 仅撤销申请,分别明确操作后果。
const message = op === 1 ? '确定删除此已撤销预约及其全部时段?删除后不可恢复。' : '确定撤销此预约?已审核的申请不能撤销。'
this.$confirm(message,'提示').then(()=>{
this.formLoading=true;
return $.post(loc()+'/doDelete',{id,op}).then((res)=>{if(res.code===0){this.pageData()}else{this.$message.error(res.msg)}}).always(()=>{this.formLoading=false})
}).catch(()=>{});
@@ -737,12 +942,17 @@ layout("/layouts/platform.html"){
return (moment("1970-01-01 " + hm).valueOf() + HOUR8) / HOUR1
},
doAdd() {
if (!this.formData.time) { this.$message.warning('请选择预约时间'); return; }
if (this.formLoading) return
if (!this.validateBookingTime()) { this.$set(this,'bookingTab','time'); return; }
if (this.formData.reserve_type===3 && !this.formData.clubId) { this.$message.warning('请选择所属协会'); return; }
const selected=this.formData.time.slice().sort()
if(Number(this.infoViewData.reserveTimeType || this.infoViewData.reservetimetype || 1)===2 && selected.some((time,i)=>i>0 && selected[i-1].split('-')[1]!==time.split('-')[0])){
this.$message.warning('全天候预约请选择连续时段');return
}
this.$refs.addForm.validate((valid)=>{
if(!valid) return;
this.formLoading=true; this.subDis=true;
$.post(loc()+'/doAdd',{data:JSON.stringify(this.formData),days:JSON.stringify(this.dayArray)}).then((res)=>{
$.post(loc()+'/doAdd',{data:JSON.stringify(this.formData),days:JSON.stringify(this.dayArray),times:JSON.stringify(this.formData.time)}).then((res)=>{
if(res.code===0){this.addDialogVisible=false;this.$message.success('预约成功');this.pageData();this.$refs.guava.index()}
else{this.$message.error(res.msg)}
}).always(()=>{this.formLoading=false;this.subDis=false})
@@ -1,4 +1,14 @@
<!--# layout("/layouts/platform.html"){ #-->
<style>
/* 日期和每个时间段保持完整,同日连续场次由后端统一合并展示。 */
.reservation-times { text-align:left; font-variant-numeric:tabular-nums; }
.reservation-time-day { display:flex; align-items:baseline; flex-wrap:wrap; gap:4px 12px; padding:3px 0; line-height:22px; }
.reservation-time-date { flex:0 0 88px; white-space:nowrap; font-weight:500; }
.reservation-time-ranges { display:flex; flex-wrap:wrap; gap:2px 12px; }
.reservation-time-range { white-space:nowrap; }
/* 仅审核列表居中整个日期时段块,详情继续使用原有对齐。 */
.reservation-times-list { display:inline-block; max-width:100%; vertical-align:middle; }
</style>
<div id="app" v-cloak>
<guava ref="guava">
<template>
@@ -44,7 +54,13 @@
<el-table-column align="center" header-align="center" label="所属协会" min-width="130">
<template slot-scope="{row}">{{row.club_name || '—'}}</template>
</el-table-column>
<el-table-column align="center" header-align="center" label="预约时段" prop="concat_day" min-width="230"></el-table-column>
<el-table-column align="center" header-align="center" label="预约时段" min-width="245"><template slot-scope="{row}"><div class="reservation-times reservation-times-list">
<div v-for="group in row.reservationTimeGroups" :key="group.date" class="reservation-time-day">
<span class="reservation-time-date">{{group.date}}</span>
<div class="reservation-time-ranges"><span v-for="(range,index) in group.ranges" :key="index" class="reservation-time-range">{{range.start}}{{range.end}}</span></div>
</div>
<span v-if="!row.reservationTimeGroups || !row.reservationTimeGroups.length"></span>
</div></template></el-table-column>
<!-- 状态颜色取自后端 state 配置,未配置时使用页面默认字体颜色。 -->
<el-table-column align="center" header-align="center" label="申请状态" prop="state_name" min-width="120">
<template slot-scope="{row}"><span :style="{color: row.state_color || null}">{{row.state_name}}</span></template>
@@ -135,7 +151,7 @@
})
}).catch(() => {})
},
typeName(type) { return {1:'个人预约',2:'单位预约',3:'协会预约'}[type] || '—' },
typeName(type) { return {1:'个人预约',2:'分工会预约',3:'协会预约'}[type] || '—' },
// 以申请实际节点决定审核入口,已流转的申请只允许查看。
canReview(row) {
const stage = this.reviewApi.substring(this.reviewApi.lastIndexOf('/') + 1)
@@ -145,13 +161,14 @@
this.$refs.guava.view()
this.$refs.viewInfoRef.onOpen(row.id)
},
// 每次打开审核都重置意见,默认同意,避免沿用上一条申请填写的内容。
openReview(row) {
this.$set(this, 'auditReady', false)
this.$set(this, 'formData', {
id: row.id,
username: "${@shiro.getPrincipalProperty('username')}",
auditTime: moment().format('YYYY-MM-DD HH:mm:ss'),
auditOpinion: ''
auditOpinion: '同意'
})
this.$refs.guava.edit()
this.$nextTick(() => this.$refs.form.clearValidate())
@@ -195,7 +212,7 @@
},
created() {
this.pageData()
// 历史审核可按停用的场地类型查询,复用记录页面的类型列表工具
// 三个审核页面共用职工之家的类型选项,不再展示其他场地类型
new typeUtil().getAllType().then((types) => {
this.$set(this, 'activityTypeList', types)
}).fail(() => { this.$message.error('场地类型加载失败,请刷新重试') })
@@ -13,7 +13,13 @@ const info = {
<el-descriptions-item label="场地名称" :span="2">{{viewData.site_name}}</el-descriptions-item>
<!-- 详情与审核列表使用同一状态配置颜色 -->
<el-descriptions-item label="申请状态"><span :style="{color: viewData.state_color || null}">{{viewData.state_name}}</span></el-descriptions-item>
<el-descriptions-item label="预约时段" :span="3">{{viewData.concat_day}}</el-descriptions-item>
<el-descriptions-item label="预约时段" :span="3"><div class="reservation-times">
<div v-for="group in viewData.reservationTimeGroups" :key="group.date" class="reservation-time-day">
<span class="reservation-time-date">{{group.date}}</span>
<div class="reservation-time-ranges"><span v-for="(range,index) in group.ranges" :key="index" class="reservation-time-range">{{range.start}}{{range.end}}</span></div>
</div>
<span v-if="!viewData.reservationTimeGroups || !viewData.reservationTimeGroups.length"></span>
</div></el-descriptions-item>
<el-descriptions-item label="预约事由" :span="3">
<div class="text-left" style="white-space:pre-wrap">{{viewData.reserve_cause}}</div>
</el-descriptions-item>
@@ -39,7 +45,7 @@ const info = {
return {viewData: {}, activeName: 'info', detailLoading: false, requestId: 0}
},
methods: {
typeName(type) { return {1:'个人预约',2:'单位预约',3:'协会预约'}[type] || '—' },
typeName(type) { return {1:'个人预约',2:'分工会预约',3:'协会预约'}[type] || '—' },
// id 为预约记录主键,activeName 为申请信息或审核标签;结果含预约字段及 auditListTable 审核历史。
onOpen(id, activeName = 'info') {
const requestId = this.requestId + 1
@@ -232,13 +232,17 @@ layout("/layouts/platform.html"){
}
})
},
async getLatelyUpdateTimes() {
const resp = await $.get("/platform/data/user/update/latelyUpdateTimes")
if(resp.code===0){
this.latelyDeleteTimes = resp.data
}else{
this.$message.warning(resp.msg)
}
getLatelyUpdateTimes() {
// 批次查询失败只提示刷新异常,不改变已经确认的拉取结果。
return $.get("/platform/data/user/update/latelyUpdateTimes").then((resp) => {
if (resp && resp.code === 0) {
this.latelyDeleteTimes = resp.data
} else {
this.$message.warning((resp && resp.msg) || '拉取批次刷新失败,请刷新页面查看')
}
}, () => {
this.$message.warning('拉取批次刷新失败,请刷新页面查看')
})
},
openDeleteUser() {
if (!this.latelyDeleteTimes.length) {
@@ -276,20 +280,44 @@ layout("/layouts/platform.html"){
this.selection = val;
},
pull(isIncrement) {
// 请求未结束时禁止重复提交,避免同一人员数据被重复拉取成多个批次。
if (this.pullLoading) {
return
}
this.$confirm('确定要从数据中心拉取数据吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async () => {
this.pullLoading = true
const resp = await $.post(loc() + '/pull')
this.pullLoading = false
if(resp.code===0){
await this.getLatelyUpdateTimes()
this.pageData()
}else{
this.$message.warning(resp.msg)
}).then(() => {
if (this.pullLoading) {
return
}
this.pullLoading = true
// 无请求参数;code=0 表示后端已完成拉取,msg 为业务失败说明。
// HTTP 异常不能证明后台失败,提示核对批次,不自动重试。
$.post(loc() + '/pull').then((resp) => {
if (resp && resp.code === 0) {
this.$message.success('人员数据拉取成功')
return true
}
this.$message.warning((resp && resp.msg) || '未收到有效的拉取结果,请刷新核对最新批次,避免重复拉取')
return false
}, () => {
this.$message.warning('未收到拉取完成确认,请刷新核对最新批次,避免重复拉取')
return false
}).always(() => {
this.pullLoading = false
}).done((success) => {
// 先结束拉取 loading,再独立刷新批次和列表,刷新异常不误报拉取失败。
if (success) {
this.getLatelyUpdateTimes()
this.pageData().fail(() => {
this.$message.warning('人员数据已拉取成功,但列表刷新失败,请刷新页面查看')
})
}
})
}, () => {
// 用户取消确认时未提交拉取请求,无需显示请求失败提示。
})
},
@@ -18,8 +18,8 @@ const activity = {
<i class="el-icon-star-on" style="color: red; font-size: 17px"></i>{{item.name}}
<el-tag type="danger" v-if="moment(item.endDate).valueOf()<moment().valueOf()" size="mini">报名已结束</el-tag>
</div>
<div style="font-size: 12px; line-height: 20px; color: #999">开始时间{{moment(item.startDate).format('YYYY-MM-DD HH:mm')}}</div>
<div style="font-size: 12px; line-height: 20px; color: #999">结束时间{{moment(item.endDate).format('YYYY-MM-DD HH:mm')}}</div>
<div style="font-size: 12px; line-height: 20px; color: #999">开始时间{{formatActivityTime(item, item.startDate)}}</div>
<div style="font-size: 12px; line-height: 20px; color: #999">结束时间{{formatActivityTime(item, item.endDate)}}</div>
</div>
<div @click="enterActivity(item)">
<el-tag style="cursor: pointer">查看<i class="el-icon-s-promotion"></i></el-tag>
@@ -43,6 +43,10 @@ const activity = {
"open-qr-code": httpVueLoader("/components/plugins/OpenQRCode.vue?v=" + new Date().getTime())
},
methods: {
// 场地入口仅展示每日时间;其他活动仍展示完整日期,数据库日期继续用于首页有效期筛选。
formatActivityTime(item, value) {
return moment(value).format(item.id === 'home_site_reserve_entry' ? 'HH:mm:ss' : 'YYYY-MM-DD HH:mm')
},
listActivity() {
$.get("/platform/sys/homeActivity/listHomeActivity").then((resp) => {
if (resp.code === 0) {
@@ -14,7 +14,7 @@ const todo = {
<el-table-column label="流程流转环节" prop="nodeName"></el-table-column>
<el-table-column label="操作">
<template scope="{row}">
<el-button @click="sublime.jumpPagePjax(row.formUrl)" size="mini" type="primary">查看</el-button>
<el-button @click="sublime.jumpPagePjax(todoActive === '2' ? (row.formUrlView || row.formUrl) : row.formUrl)" size="mini" type="primary">查看</el-button>
</template>
</el-table-column>
</el-table>
@@ -32,7 +32,7 @@ const todo = {
<el-table-column label="流程流转环节" prop="nodeName"></el-table-column>
<el-table-column label="操作">
<template scope="{row}">
<el-button @click="sublime.jumpPagePjax(row.formUrl)" size="mini" type="primary">查看</el-button>
<el-button @click="sublime.jumpPagePjax(todoActive === '2' ? (row.formUrlView || row.formUrl) : row.formUrl)" size="mini" type="primary">查看</el-button>
</template>
</el-table-column>
</el-table>
@@ -50,7 +50,7 @@ const todo = {
<el-table-column label="流程流转环节" prop="nodeName"></el-table-column>
<el-table-column label="操作">
<template scope="{row}">
<el-button @click="sublime.jumpPagePjax(row.formUrl)" size="mini" type="primary">查看</el-button>
<el-button @click="sublime.jumpPagePjax(todoActive === '2' ? (row.formUrlView || row.formUrl) : row.formUrl)" size="mini" type="primary">查看</el-button>
</template>
</el-table-column>
</el-table>
@@ -69,7 +69,7 @@ const todo = {
<!-- <el-table-column label="流程流转环节" prop="nodeName"></el-table-column>-->
<!-- <el-table-column label="操作" width="100">-->
<!-- <template scope="{row}">-->
<!-- <el-button @click="sublime.jumpPagePjax(row.formUrl)" size="mini" type="primary">查看</el-button>-->
<!-- <el-button @click="sublime.jumpPagePjax(todoActive === '2' ? (row.formUrlView || row.formUrl) : row.formUrl)" size="mini" type="primary">查看</el-button>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- </el-table>-->
@@ -78,7 +78,11 @@ layout("/layouts/platform.html"){
<el-card class="mt10" shadow="never">
<table-tool :app="this" label="福利项目">
<template #func>
<!-- 仅提供已选择、未选择两种状态,切换时复用公共查询并回到第一页。 -->
<el-radio-group @change="doSearch" class="mr10" size="small" v-model="pageForm.isChoose">
<el-radio-button :label="1">已选择</el-radio-button>
<el-radio-button :label="2">未选择</el-radio-button>
</el-radio-group>
</template>
</table-tool>
@@ -475,7 +479,8 @@ layout("/layouts/platform.html"){
projectInfo: {},
welfareSubject: {},
pageForm: {
isChoose: false,
// 与筛选按钮取值一致,首次进入默认查询未选择项目。
isChoose: 2,
year: moment().format('YYYY')
},
tableColumns: [