diff --git a/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java b/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java index e850b3d3..39e5b166 100644 --- a/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java +++ b/src/com/engine/organization/entity/extend/bo/ExtendInfoBO.java @@ -47,7 +47,7 @@ public class ExtendInfoBO { public static String DATE_Time_TO = "_end"; // 封装对象为table组件 - public static List> convertInfoListToTable(User user, List infoPOList, int viewAttr, boolean showLabel) { + public static List> convertInfoListToTable(User user, List infoPOList, int viewAttr, boolean showLabel, boolean checkBox) { List> lsCol = new ArrayList<>(); Map col; @@ -56,19 +56,23 @@ public class ExtendInfoBO { String tmpkey = extendInfoPO.getFieldName(); col = new HashMap<>(); col.put("title", extendInfoPO.getFieldNameDesc()); - col.put("key", tmpkey); col.put("dataIndex", tmpkey); col.put("com", getFieldDetailInfo(user, extendInfoPO, viewAttr, showLabel, width)); - col.put("width", width + "%"); - + if (checkBox && Integer.valueOf(7).equals(extendInfoPO.getControlType())) { + col.put("checkType", "checkbox"); + } lsCol.add(col); } return lsCol; } + public static List> convertInfoListToTable(User user, List infoPOList, int viewAttr, boolean showLabel) { + return convertInfoListToTable(user, infoPOList, viewAttr, showLabel, false); + } + /** * 新增自定义字段时,对象转换 * @@ -160,9 +164,9 @@ public class ExtendInfoBO { /** * 明细表字段 * - * @param user 当前用户 + * @param user 当前用户 * @param extendInfoPO 名字表字段实体 - * @param viewAttr 操作类型 + * @param viewAttr 操作类型 */ private static List getFieldDetailInfo(User user, ExtendInfoPO extendInfoPO, int viewAttr, boolean showLabel, int width) { List ls = new ArrayList<>(); @@ -174,11 +178,11 @@ public class ExtendInfoBO { /** * 创建列表字段信息 * - * @param user 当前用户 + * @param user 当前用户 * @param extendInfoPO 字段信息 - * @param viewAttr 操作类型 - * @param showLabel 展示名字 - * @param width 宽度 + * @param viewAttr 操作类型 + * @param showLabel 展示名字 + * @param width 宽度 */ private static FieldItem createField(User user, ExtendInfoPO extendInfoPO, int viewAttr, boolean showLabel, int width) { FieldItem fieldItem = new FieldItem(); @@ -260,7 +264,7 @@ public class ExtendInfoBO { String fieldid = Util.null2String(extendInfoPO.getId());//字段id String fieldname = Util.null2String(extendInfoPO.getFieldName());//字段名 // String fieldlabel = Util.null2String(extendInfoPO.getFieldNameDesc());//字段显示名 - String fieldlabel = "502327";//字段显示名 + String fieldlabel = "502327";//字段显示名 String fieldhtmltype = Util.null2String(extendInfoPO.getControlType());//字段类型 String detailtype = Util.null2String(extendInfoPO.getBrowserType());//字段二级类型(浏览框--单人力) String customValue = Util.null2String(extendInfoPO.getCustomValue()); @@ -320,7 +324,7 @@ public class ExtendInfoBO { } default: if (detailtype.equals("161") || detailtype.equals("162") || detailtype.equals("256") || detailtype.equals("257")) { - BrowserBean browserbean = new BrowserBean( Util.null2String(detailtype)); + BrowserBean browserbean = new BrowserBean(Util.null2String(detailtype)); BrowserInitUtil browserInitUtil = new BrowserInitUtil(); String fielddbtype = customValue; if (!customValue.startsWith("browser.")) { diff --git a/src/com/engine/organization/mapper/personnelcard/CardButtonMapper.java b/src/com/engine/organization/mapper/personnelcard/CardButtonMapper.java index b2f70821..667e1c01 100644 --- a/src/com/engine/organization/mapper/personnelcard/CardButtonMapper.java +++ b/src/com/engine/organization/mapper/personnelcard/CardButtonMapper.java @@ -1,7 +1,9 @@ package com.engine.organization.mapper.personnelcard; import com.engine.organization.entity.personnelcard.po.CardButtonPO; +import org.apache.ibatis.annotations.Param; +import java.util.Collection; import java.util.List; /** @@ -16,4 +18,8 @@ public interface CardButtonMapper { List listEnableButton(); + + List listAllId(); + + int deleteByIds(@Param("ids")Collection ids); } diff --git a/src/com/engine/organization/mapper/personnelcard/CardButtonMapper.xml b/src/com/engine/organization/mapper/personnelcard/CardButtonMapper.xml index 558ee6f7..7058c7ca 100644 --- a/src/com/engine/organization/mapper/personnelcard/CardButtonMapper.xml +++ b/src/com/engine/organization/mapper/personnelcard/CardButtonMapper.xml @@ -30,6 +30,12 @@ , t.create_time , t.update_time + + delete from jcl_org_cardbutton where id in + + #{id} + + + \ No newline at end of file diff --git a/src/com/engine/organization/service/impl/CardAccessServiceImpl.java b/src/com/engine/organization/service/impl/CardAccessServiceImpl.java index 35bad0d6..fc745631 100644 --- a/src/com/engine/organization/service/impl/CardAccessServiceImpl.java +++ b/src/com/engine/organization/service/impl/CardAccessServiceImpl.java @@ -4,19 +4,24 @@ import com.cloudstore.eccom.result.WeaResultMsg; import com.engine.core.impl.Service; import com.engine.organization.component.OrganizationWeaTable; import com.engine.organization.entity.extend.bo.ExtendInfoBO; +import com.engine.organization.entity.extend.param.ExtendInfoParams; import com.engine.organization.entity.extend.po.ExtendInfoPO; import com.engine.organization.entity.personnelcard.po.CardAccessPO; import com.engine.organization.entity.personnelcard.po.CardButtonPO; import com.engine.organization.entity.personnelcard.vo.CardAccessVO; +import com.engine.organization.mapper.extend.ExtMapper; import com.engine.organization.mapper.personnelcard.CardAccessMapper; import com.engine.organization.mapper.personnelcard.CardButtonMapper; import com.engine.organization.service.CardAccessService; import com.engine.organization.transmethod.SystemTransMethod; import com.engine.organization.util.HasRightUtil; import com.engine.organization.util.db.MapperProxyFactory; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import weaver.general.Util; import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; /** @@ -65,12 +70,12 @@ public class CardAccessServiceImpl extends Service implements CardAccessService List dataList = new ArrayList<>(); for (int i = 0; i < rowNum; i++) { CardAccessPO data = CardAccessPO.builder() - .id(Util.getIntValue((String)params.get("id_"+i))) - .status(Util.getIntValue((String)params.get("status_"+i))) - .allPeople(Util.getIntValue((String)params.get("all_people_"+i))) - .superior(Util.getIntValue((String)params.get("superior_"+i))) - .allSuperior(Util.getIntValue((String)params.get("all_superior_"+i))) - .custom(Util.null2String(params.get("custom_"+i))) + .id(Util.getIntValue((String) params.get("id_" + i))) + .status(Util.getIntValue((String) params.get("status_" + i))) + .allPeople(Util.getIntValue((String) params.get("all_people_" + i))) + .superior(Util.getIntValue((String) params.get("superior_" + i))) + .allSuperior(Util.getIntValue((String) params.get("all_superior_" + i))) + .custom(Util.null2String(params.get("custom_" + i))) .updateTime(new Date()) .build(); dataList.add(data); @@ -89,40 +94,78 @@ public class CardAccessServiceImpl extends Service implements CardAccessService } @Override - public int updateTabName(String name,Integer id) { - return getCardAccessMapper().updateTabName(name,id); + public int updateTabName(String name, Integer id) { + return getCardAccessMapper().updateTabName(name, id); } @Override public Map getCardButtonTable() { List infoPOList = new ArrayList<>(); infoPOList.add(ExtendInfoPO.builder().id(null).fieldName("name").fieldNameDesc("按钮名称").fieldType("varchar(50)").controlType(1).browserType("1").customValue("[\"input\",\"text\",\"50\"]").showOrder(1).isrequired(0).isSystemDefault(0).build()); - infoPOList.add(ExtendInfoPO.builder().id(null).fieldName("status").fieldNameDesc("启用").fieldType("char(1)").controlType(4).browserType("1").customValue("[\"check\"]").showOrder(2).isrequired(0).isSystemDefault(0).build()); + infoPOList.add(ExtendInfoPO.builder().id(null).fieldName("status").fieldNameDesc("启用").fieldType("char(1)").controlType(7).browserType("1").customValue("[\"check\"]").showOrder(2).isrequired(0).isSystemDefault(0).build()); infoPOList.add(ExtendInfoPO.builder().id(null).fieldName("url").fieldNameDesc("跳转地址").fieldType("varchar(1000)").controlType(1).browserType("1").customValue("[\"input\",\"text\",\"1000\"]").showOrder(3).isrequired(0).isSystemDefault(0).build()); infoPOList.add(ExtendInfoPO.builder().id(null).fieldName("roles").fieldNameDesc("角色").fieldType("text").controlType(3).browserType("65").customValue("[\"browser\",{\"valueSpan\":\"多角色\",\"replaceDatas\":[{\"itemorderid\":\"65\",\"name\":\"多角色\",\"id\":\"65\",\"parenttitle\":\"人员\",\"title\":\"人员-多角色\"}],\"value\":\"65\"}]").showOrder(4).isrequired(0).isSystemDefault(0).build()); Map tabInfoMap = new HashMap<>(); - tabInfoMap.put("columns", ExtendInfoBO.convertInfoListToTable(user, infoPOList, 2, false)); + tabInfoMap.put("columns", ExtendInfoBO.convertInfoListToTable(user, infoPOList, 2, false, true)); List cardButtonPOS = getCardButtonMapper().listAll(); + List isUsed = new ArrayList<>(); + AtomicInteger index = new AtomicInteger(0); List> collect = cardButtonPOS.stream().map(item -> { Map resultMap = new HashMap<>(); resultMap.put("id", item.getId()); resultMap.put("name", item.getName()); - resultMap.put("status", item.getStatus()); + resultMap.put("status", ""); + if (1 == item.getStatus()) { + isUsed.add(index.get()); + } + index.getAndIncrement(); resultMap.put("url", item.getUrl()); resultMap.put("roles", item.getRoles()); resultMap.put("rolesspan", SystemTransMethod.getRoleName(item.getRoles())); return resultMap; }).collect(Collectors.toList()); + tabInfoMap.put("datas", collect); tabInfoMap.put("api_status", true); + Map> isUsedMap = new HashMap<>(); + isUsedMap.put("status", isUsed); + tabInfoMap.put("selectedData", isUsedMap); + tabInfoMap.put("isModalEdit", false); return tabInfoMap; } @Override public int saveCardButton(Map params) { - return 0; + String tableName = "JCL_ORG_CARDBUTTON"; + int rowNum = Util.getIntValue((String) params.get("rownum")); + int count = 0; + List allIds = getCardButtonMapper().listAllId(); + for (int i = 0; i < rowNum; i++) { + String recordIndex = "_" + i; + Map recordData = new HashMap<>(); + recordData.put("name", params.get("name" + recordIndex)); + recordData.put("status", params.get("status" + recordIndex)); + recordData.put("url", params.get("url" + recordIndex)); + recordData.put("roles", params.get("roles" + recordIndex)); + String id = Util.null2String(params.get("id" + recordIndex)); + if (StringUtils.isNotBlank(id)) { + // 更新 + long buttonId = Long.parseLong(id); + count += MapperProxyFactory.getProxy(ExtMapper.class).updateTable(ExtendInfoParams.builder().tableName(tableName).id(buttonId).params(recordData).build()); + allIds.remove(buttonId); + } else { + //插入 + recordData.put("sys_default", 1); + recordData.put("delete_type", 0); + count += MapperProxyFactory.getProxy(ExtMapper.class).insertTable(ExtendInfoParams.builder().tableName(tableName).params(recordData).build()); + } + } + if (CollectionUtils.isNotEmpty(allIds)) { + count += getCardButtonMapper().deleteByIds(allIds); + } + return count; } diff --git a/src/com/engine/organization/service/impl/ExtServiceImpl.java b/src/com/engine/organization/service/impl/ExtServiceImpl.java index 93179f7d..9a06c1d5 100644 --- a/src/com/engine/organization/service/impl/ExtServiceImpl.java +++ b/src/com/engine/organization/service/impl/ExtServiceImpl.java @@ -160,7 +160,12 @@ public class ExtServiceImpl extends Service implements ExtService { boolean checkRight = true; if ("4".equals(extendType) && !user.isAdmin()) { checkRight = false; - infoPOList.removeIf(item -> !"1".equals(Util.null2String(item.getIsModify()))); + String ecResourceId = MapperProxyFactory.getProxy(HrmResourceMapper.class).getEcResourceId(String.valueOf(id)); + if (Util.null2String(user.getUID()).equals(ecResourceId)) { + infoPOList.removeIf(item -> !"1".equals(Util.null2String(item.getIsModify()))); + }else{ + infoPOList = new ArrayList<>(); + } } // 查询所有分布模块,拓展明细表信息 diff --git a/src/com/engine/organization/web/CardAccessController.java b/src/com/engine/organization/web/CardAccessController.java index 0775e1b9..2ea30535 100644 --- a/src/com/engine/organization/web/CardAccessController.java +++ b/src/com/engine/organization/web/CardAccessController.java @@ -79,4 +79,17 @@ public class CardAccessController { return ReturnResult.exceptionHandle(e); } } + + @POST + @Path("/saveCardButton") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult saveCardButton(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + return ReturnResult.successed(getCardAccessWrapper(user).saveCardButton(map)); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e); + } + } } diff --git a/src/com/engine/organization/wrapper/CardAccessWrapper.java b/src/com/engine/organization/wrapper/CardAccessWrapper.java index fcfc9605..a4d88489 100644 --- a/src/com/engine/organization/wrapper/CardAccessWrapper.java +++ b/src/com/engine/organization/wrapper/CardAccessWrapper.java @@ -35,4 +35,8 @@ public class CardAccessWrapper extends OrganizationWrapper { public Map getCardButtonTable() { return getCardAccessService(user).getCardButtonTable(); } + + public int saveCardButton(Map params) { + return getCardAccessService(user).saveCardButton(params); + } }