| | |
| | | // generator.table="sys_host"; |
| | | // sqlserver |
| | | generator.sqlOsType = SqlOsType.SQL_SERVER; |
| | | generator.url="127.0.0.1:1433;databasename=phpsasrs"; |
| | | generator.url="127.0.0.1:1433;databasename=flsbasrs"; |
| | | generator.username="sa"; |
| | | generator.password="sa@123"; |
| | | generator.table="man_bom_mat"; |
| | | generator.packagePath="com.zy.asrs"; |
| | | generator.table="sys_role_pda_resource"; |
| | | generator.packagePath="com.zy.system"; |
| | | generator.build(); |
| | | } |
| | | |
| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.*; |
| | | import com.core.common.AesUtils; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.common.CodeRes; |
| | | import com.zy.common.entity.Parameter; |
| | |
| | | import com.zy.common.properties.SystemProperties; |
| | | import com.zy.common.utils.RandomValidateCodeUtil; |
| | | import com.zy.system.entity.*; |
| | | import com.zy.system.entity.license.LicenseVerify; |
| | | import com.zy.system.service.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | @Autowired |
| | | private ResourceService resourceService; |
| | | @Autowired |
| | | private PdaResourceService pdaResourceService; |
| | | @Autowired |
| | | private RoleResourceService roleResourceService; |
| | | @Autowired |
| | | private PermissionService permissionService; |
| | | @Autowired |
| | | private RolePermissionService rolePermissionService; |
| | | @Autowired |
| | | private RolePdaResourceService rolePdaResourceService; |
| | | |
| | | @RequestMapping("/login.action") |
| | | @ManagerAuth(value = ManagerAuth.Auth.NONE, memo = "登录") |
| | | public R loginAction(String username, String password){ |
| | | //验证许可证是否有效 |
| | | LicenseVerify licenseVerify = new LicenseVerify(); |
| | | boolean verify = licenseVerify.verify(); |
| | | if (!verify) {//许可证已失效 |
| | | return R.parse(CodeRes.SYSTEM_20001); |
| | | } |
| | | // LicenseVerify licenseVerify = new LicenseVerify(); |
| | | // boolean verify = licenseVerify.verify(); |
| | | // if (!verify) {//许可证已失效 |
| | | // return R.parse(CodeRes.SYSTEM_20001); |
| | | // } |
| | | if (username.equals("super") && password.equals(Cools.md5(superPwd))) { |
| | | Map<String, Object> res = new HashMap<>(); |
| | | res.put("username", username); |
| | |
| | | return R.parse(CodeRes.USER_10003); |
| | | } |
| | | String token = Cools.enToken(System.currentTimeMillis() + username, user.getPassword()); |
| | | userLoginService.delete(new EntityWrapper<UserLogin>().eq("user_id", user.getId())); |
| | | userLoginService.delete(new EntityWrapper<UserLogin>().eq("user_id", user.getId()).eq("system", "WMS")); |
| | | UserLogin userLogin = new UserLogin(); |
| | | userLogin.setUserId(user.getId()); |
| | | userLogin.setToken(token); |
| | | userLogin.setCreateTime(new Date()); |
| | | userLogin.setSystem("WMS"); |
| | | userLoginService.insert(userLogin); |
| | | Map<String, Object> res = new HashMap<>(); |
| | | res.put("username", user.getUsername()); |
| | |
| | | |
| | | // 功能模块 |
| | | Map<String, Object> functions = new HashMap<>(); |
| | | functions.put("title", "指定功能"); |
| | | functions.put("title", "pda功能"); |
| | | functions.put("id", "function"); |
| | | functions.put("spread", true); |
| | | List<Map> funcs = new ArrayList<>(); |
| | | functions.put("children", funcs); |
| | | List<Permission> permissions = permissionService.selectList(new EntityWrapper<Permission>().eq("status", 1)); |
| | | for (Permission permission : permissions) { |
| | | Map<String, Object> func = new HashMap<>(); |
| | | func.put("title", permission.getName()); |
| | | func.put("id", permission.getAction()); |
| | | func.put("spread", true); |
| | | funcs.add(func); |
| | | List<PdaResource> oneLevs = pdaResourceService.selectList(new EntityWrapper<PdaResource>().eq("level", 1).eq("status", 1).orderBy("sort")); |
| | | // 一级 |
| | | for (PdaResource oneLev : oneLevs) { |
| | | List<Map> twoLevelsList = new ArrayList<>(); |
| | | Map<String, Object> oneLevelMap = new HashMap<>(); |
| | | oneLevelMap.put("title", oneLev.getName()); |
| | | oneLevelMap.put("id", oneLev.getId()); |
| | | oneLevelMap.put("spread", true); |
| | | oneLevelMap.put("checked", false); |
| | | oneLevelMap.put("children", twoLevelsList); |
| | | |
| | | List<PdaResource> twoLevels = pdaResourceService.selectList(new EntityWrapper<PdaResource>().eq("resource_id", oneLev.getId()).eq("level", 2).eq("status", 1).orderBy("sort")); |
| | | // 二级 |
| | | for (PdaResource twoLevel : twoLevels){ |
| | | Map<String, Object> twoLevelMap = new HashMap<>(); |
| | | twoLevelMap.put("title", twoLevel.getName()); |
| | | twoLevelMap.put("id", twoLevel.getId()); |
| | | twoLevelMap.put("spread", false); |
| | | twoLevelMap.put("checked", false); |
| | | List<Map> threeLevelsList = new ArrayList<>(); |
| | | twoLevelMap.put("children", threeLevelsList); |
| | | // 三级 |
| | | List<PdaResource> threeLevels = pdaResourceService.selectList(new EntityWrapper<PdaResource>().eq("resource_id", twoLevel.getId()).eq("level", 3).eq("status", 1).orderBy("sort")); |
| | | for (PdaResource threeLevel : threeLevels){ |
| | | Map<String, Object> threeLevelMap = new HashMap<>(); |
| | | threeLevelMap.put("title", threeLevel.getName()); |
| | | threeLevelMap.put("id", threeLevel.getId()); |
| | | threeLevelMap.put("checked", false); |
| | | threeLevelsList.add(threeLevelMap); |
| | | } |
| | | twoLevelsList.add(twoLevelMap); |
| | | } |
| | | funcs.add(oneLevelMap); |
| | | } |
| | | result.add(functions); |
| | | |
| | |
| | | result.add(permission.getAction()); |
| | | } |
| | | } |
| | | // pda权限 |
| | | List<RolePdaResource> rolePdaResources = rolePdaResourceService.selectList(new EntityWrapper<RolePdaResource>().eq("role_id", roleId)); |
| | | for (RolePdaResource rolePdaResource : rolePdaResources) { |
| | | PdaResource pdaResource = pdaResourceService.selectById(rolePdaResource.getResourceId()); |
| | | if (!Cools.isEmpty(pdaResource)) { |
| | | if (pdaResource.getLevel() == 1){ |
| | | List<PdaResource> pdaResources = pdaResourceService.selectList(new EntityWrapper<PdaResource>().eq("resource_id", pdaResource.getId())); |
| | | if (Cools.isEmpty(pdaResources)) { |
| | | result.add(pdaResource.getId()); |
| | | } |
| | | } |
| | | if (pdaResource.getLevel() == 2){ |
| | | List<PdaResource> pdaResources = pdaResourceService.selectList(new EntityWrapper<PdaResource>().eq("resource_id", pdaResource.getId())); |
| | | if (Cools.isEmpty(pdaResources)) { |
| | | result.add(pdaResource.getId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return R.ok(result); |
| | | } |
| | | |
| | |
| | | Long leaderId = role.getLeader(); |
| | | roleResourceService.delete(new EntityWrapper<RoleResource>().eq("role_id", roleId)); |
| | | rolePermissionService.delete(new EntityWrapper<RolePermission>().eq("role_id", roleId)); |
| | | rolePdaResourceService.delete(new EntityWrapper<RolePdaResource>().eq("role_id", roleId)); |
| | | if (!Cools.isEmpty(powers)){ |
| | | List<PowerDto> dtos = JSON.parseArray(powers, PowerDto.class); |
| | | for (PowerDto dto : dtos) { |
| | |
| | | roleResource.setResourceId(resource.getId()); |
| | | roleResourceService.insert(roleResource); |
| | | } |
| | | |
| | | } else { |
| | | if (dto.getTwo().substring(0,1).contains("-")) { |
| | | PdaResource pdaResource = pdaResourceService.selectOne(new EntityWrapper<PdaResource>().eq("id", dto.getTwo()).eq("level", 1)); |
| | | if (!Cools.isEmpty(pdaResource)) { |
| | | // 校验上级权限 |
| | | if (leaderId != null) { |
| | | RolePdaResource rolePdaResource = rolePdaResourceService.selectOne(new EntityWrapper<RolePdaResource>().eq("role_id", leaderId).eq("resource_id", pdaResource.getId())); |
| | | if (null == rolePdaResource) { |
| | | throw new CoolException(pdaResource.getName().concat("无法授权给").concat(role.getName())); |
| | | } |
| | | } |
| | | RolePdaResource rolePdaResource = new RolePdaResource(); |
| | | rolePdaResource.setRoleId(roleId); |
| | | rolePdaResource.setResourceId(pdaResource.getId()); |
| | | rolePdaResourceService.insert(rolePdaResource); |
| | | } |
| | | } else { |
| | | Permission permission = permissionService.selectOne(new EntityWrapper<Permission>().eq("action", dto.getTwo())); |
| | | if (!Cools.isEmpty(permission)){ |
| | |
| | | rolePermissionService.insert(rolePermission); |
| | | } |
| | | } |
| | | |
| | | } |
| | | for (String three : dto.getThree()){ |
| | | if (three.substring(0,1).contains("-")) { |
| | | PdaResource pdaResource = pdaResourceService.selectOne(new EntityWrapper<PdaResource>().eq("id", three).eq("level", 2)); |
| | | if (!Cools.isEmpty(pdaResource)) { |
| | | // 校验上级权限 |
| | | if (leaderId != null) { |
| | | RolePdaResource rolePdaResource = rolePdaResourceService.selectOne(new EntityWrapper<RolePdaResource>().eq("role_id", leaderId).eq("resource_id", pdaResource.getId())); |
| | | if (null == rolePdaResource) { |
| | | throw new CoolException(pdaResource.getName().concat("无法授权给").concat(role.getName())); |
| | | } |
| | | } |
| | | RolePdaResource rolePdaResource = new RolePdaResource(); |
| | | rolePdaResource.setRoleId(roleId); |
| | | rolePdaResource.setResourceId(pdaResource.getId()); |
| | | rolePdaResourceService.insert(rolePdaResource); |
| | | } |
| | | } else { |
| | | Resource resource1 = resourceService.selectOne(new EntityWrapper<Resource>().eq("id", three).eq("level", 3)); |
| | | if (!Cools.isEmpty(resource1)) { |
| | | // 校验上级权限 |
| | |
| | | roleResource.setResourceId(resource1.getId()); |
| | | roleResourceService.insert(roleResource); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | @RequestMapping("/menu/pda/auth") |
| | | @ManagerAuth |
| | | public R menuPda(){ |
| | | public R menuPda(@RequestBody HashMap<String,String> params){ |
| | | Long userId = getUserId(); |
| | | List<RolePermission> rolePermissions; |
| | | String level = params.get("level"); |
| | | Long id = Long.valueOf(params.get("id")); |
| | | List<RolePdaResource> rolePdaResources; |
| | | if (userId == 9527L) { |
| | | rolePermissions = rolePermissionService.selectList(new EntityWrapper<>()); |
| | | rolePdaResources = rolePdaResourceService.selectList(new EntityWrapper<>()); |
| | | } else { |
| | | Long roleId = getUser().getRoleId(); |
| | | rolePermissions = rolePermissionService.selectList(new EntityWrapper<RolePermission>().eq("role_id", roleId)); |
| | | rolePdaResources = rolePdaResourceService.selectList(new EntityWrapper<RolePdaResource>().eq("role_id", roleId)); |
| | | } |
| | | if (Cools.isEmpty(rolePermissions)) { |
| | | if (Cools.isEmpty(rolePdaResources)) { |
| | | return R.ok(); |
| | | } |
| | | List<Long> collect = rolePermissions.stream().map(RolePermission::getPermissionId).distinct().collect(Collectors.toList()); |
| | | List<Permission> permissions = permissionService.selectBatchIds(collect); |
| | | return R.ok().add(permissions); |
| | | List<Long> collect = rolePdaResources.stream().map(RolePdaResource::getResourceId).distinct().collect(Collectors.toList()); |
| | | List<PdaResource> pdaResources = pdaResourceService.selectBatchIds(collect); |
| | | List<PdaResource> results = new ArrayList<>(); |
| | | |
| | | for (PdaResource pdaResource : pdaResources) { |
| | | if (Integer.parseInt(level) == 1) { |
| | | if (pdaResource.getLevel().equals(Short.valueOf(level))) { |
| | | results.add(pdaResource); |
| | | } |
| | | } else { |
| | | if (pdaResource.getLevel().equals(Short.valueOf(level)) && pdaResource.getResourceId().equals(id)) { |
| | | results.add(pdaResource); |
| | | } |
| | | } |
| | | } |
| | | return R.ok().add(results); |
| | | } |
| | | |
| | | } |
| | |
| | | private TagService tagService; |
| | | @Autowired |
| | | private NodeService nodeService; |
| | | |
| | | @Autowired |
| | | private UserLoginService userLoginService; |
| | | |
| | | protected Node getOriginNode(){ |
| | | Node node = nodeService.getTop(); |
| | | if (node == null) { |
| | | throw new CoolException("库区数据错误"); |
| | | } |
| | | return node; |
| | | } |
| | | |
| | | protected Long getHostId(){ |
| | | if (getUserId() == 9527) { |
| | | return null; |
| | | } |
| | | User user = getUser(); |
| | | if (user.getRoleId() == 1) { |
| | | String hostId = String.valueOf(request.getAttribute("hostId")); |
| | | if (Cools.isEmpty(hostId)) { |
| | | UserLogin userLogin = userLoginService.selectOne(new EntityWrapper<UserLogin>().eq("user_id", user.getId())); |
| | | if (userLogin != null) { |
| | | return userLogin.getHostId(); |
| | | } |
| | | } |
| | | return Long.parseLong(hostId); |
| | | } else { |
| | | return user.getHostId(); |
| | | } |
| | | } |
| | | |
| | | protected Long getUserId(){ |
| | | if(Cools.isEmpty(request.getAttribute("userId"))){ |
| | | return 000L; |
| | | } |
| | | return Long.parseLong(String.valueOf(request.getAttribute("userId"))); |
| | | } |
| | | |
| | |
| | | return tagService.getTop(); |
| | | } |
| | | |
| | | protected <T> void hostEq(EntityWrapper<T> wrapper){ |
| | | Long hostId = getHostId(); |
| | | if (hostId != null) { |
| | | wrapper.eq("host_id", hostId); |
| | | protected Node getOriginNode(){ |
| | | Node node = nodeService.getTop(); |
| | | if (node == null) { |
| | | throw new CoolException("库区数据错误"); |
| | | } |
| | | return node; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | |
| | | public static boolean isJSON(String str) { |
| | | if (Cools.isEmpty(str)) { |
| | | return false; |
| | | } else { |
| | | str = str.trim(); |
| | | if (str.startsWith("{") && str.endsWith("}")) { |
| | | return true; |
| | | } else if (str.startsWith("[") && str.endsWith("]")) { |
| | | return true; |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | protected <T> void hostEq(EntityWrapper<T> wrapper){ |
| | | Long hostId = getHostId(); |
| | | if (hostId != null) { |
| | | wrapper.eq("host_id", hostId); |
| | | } |
| | | } |
| | | |
| | | protected Long getHostId(){ |
| | | if (getUserId() == 9527) { |
| | | return null; |
| | | } |
| | | User user = getUser(); |
| | | if (user.getRoleId() == 1) { |
| | | String hostId = String.valueOf(request.getAttribute("hostId")); |
| | | if (Cools.isEmpty(hostId)) { |
| | | UserLogin userLogin = userLoginService.selectOne(new EntityWrapper<UserLogin>().eq("user_id", user.getId())); |
| | | if (userLogin != null) { |
| | | //return userLogin.getHostId(); |
| | | return 1L; |
| | | } |
| | | } |
| | | return Long.parseLong(hostId); |
| | | } else { |
| | | return user.getHostId(); |
| | | } |
| | | } |
| | | |
| | | public static boolean isNumber(String str){ |
| | | for (int i = str.length();--i>=0;){ |
| | | if (!Character.isDigit(str.charAt(i))){ |
New file |
| | |
| | | package com.zy.system.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.core.common.DateUtils; |
| | | import com.zy.system.entity.PdaResource; |
| | | import com.zy.system.entity.Resource; |
| | | import com.zy.system.service.PdaResourceService; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.zy.common.web.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | public class PdaResourceController extends BaseController { |
| | | |
| | | @Autowired |
| | | private PdaResourceService pdaResourceService; |
| | | |
| | | @RequestMapping(value = "/pdaResource/{id}/auth") |
| | | @ManagerAuth |
| | | public R get(@PathVariable("id") String id) { |
| | | return R.ok(pdaResourceService.selectById(String.valueOf(id))); |
| | | } |
| | | |
| | | @RequestMapping(value = "/pdaResource/list/auth") |
| | | @ManagerAuth |
| | | public R list(@RequestParam(defaultValue = "1")Integer curr, |
| | | @RequestParam(defaultValue = "10")Integer limit, |
| | | @RequestParam(required = false)String orderByField, |
| | | @RequestParam(required = false)String orderByType, |
| | | @RequestParam(required = false)String condition, |
| | | @RequestParam Map<String, Object> param){ |
| | | EntityWrapper<PdaResource> wrapper = new EntityWrapper<>(); |
| | | excludeTrash(param); |
| | | convert(param, wrapper); |
| | | allLike(PdaResource.class, param.keySet(), wrapper, condition); |
| | | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} |
| | | return R.ok(pdaResourceService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | } |
| | | |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | String val = String.valueOf(entry.getValue()); |
| | | if (val.contains(RANGE_TIME_LINK)){ |
| | | String[] dates = val.split(RANGE_TIME_LINK); |
| | | wrapper.ge(entry.getKey(), DateUtils.convert(dates[0])); |
| | | wrapper.le(entry.getKey(), DateUtils.convert(dates[1])); |
| | | } else { |
| | | wrapper.like(entry.getKey(), val); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/pdaResource/add/auth") |
| | | @ManagerAuth(memo = "菜单添加") |
| | | public R add(PdaResource pdaResource) { |
| | | pdaResourceService.insert(pdaResource); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/pdaResource/update/auth") |
| | | @ManagerAuth |
| | | public R update(PdaResource pdaResource){ |
| | | if (Cools.isEmpty(pdaResource) || null==pdaResource.getId()){ |
| | | return R.error(); |
| | | } |
| | | pdaResourceService.updateById(pdaResource); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/pdaResource/delete/auth") |
| | | @ManagerAuth |
| | | public R delete(@RequestParam(value="ids[]") Long[] ids){ |
| | | for (Long id : ids){ |
| | | pdaResourceService.deleteById(id); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/pdaResource/export/auth") |
| | | @ManagerAuth |
| | | public R export(@RequestBody JSONObject param){ |
| | | EntityWrapper<PdaResource> wrapper = new EntityWrapper<>(); |
| | | List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); |
| | | Map<String, Object> map = excludeTrash(param.getJSONObject("pdaResource")); |
| | | convert(map, wrapper); |
| | | List<PdaResource> list = pdaResourceService.selectList(wrapper); |
| | | return R.ok(exportSupport(list, fields)); |
| | | } |
| | | |
| | | @RequestMapping(value = "/pdaResourceQuery/auth") |
| | | @ManagerAuth |
| | | public R query(String condition) { |
| | | EntityWrapper<PdaResource> wrapper = new EntityWrapper<>(); |
| | | wrapper.like("name", condition); |
| | | Page<PdaResource> page = pdaResourceService.selectPage(new Page<>(0, 10), wrapper); |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (PdaResource pdaResource : page.getRecords()){ |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", pdaResource.getId()); |
| | | map.put("value", pdaResource.getId()); |
| | | result.add(map); |
| | | } |
| | | return R.ok(result); |
| | | } |
| | | |
| | | @RequestMapping(value = "/pdaResource/check/column/auth") |
| | | @ManagerAuth |
| | | public R query(@RequestBody JSONObject param) { |
| | | Wrapper<PdaResource> wrapper = new EntityWrapper<PdaResource>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val")); |
| | | if (null != pdaResourceService.selectOne(wrapper)){ |
| | | return R.parse(BaseRes.REPEAT).add(getComment(PdaResource.class, String.valueOf(param.get("key")))); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/pdaResource/tree/auth") |
| | | @ManagerAuth |
| | | public R tree(@RequestParam(defaultValue = "1")Integer curr, |
| | | @RequestParam(defaultValue = "10")Integer limit, |
| | | @RequestParam(required = false)String orderByField, |
| | | @RequestParam(required = false)String orderByType, |
| | | @RequestParam Map<String, Object> param){ |
| | | EntityWrapper<PdaResource> wrapper = new EntityWrapper<>(); |
| | | excludeTrash(param); |
| | | convert(param, wrapper); |
| | | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} |
| | | else { |
| | | wrapper.orderBy("sort"); |
| | | } |
| | | return R.parse("0-操作成功").add(pdaResourceService.selectList(wrapper)); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.system.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.core.common.DateUtils; |
| | | import com.zy.system.entity.RolePdaResource; |
| | | import com.zy.system.service.RolePdaResourceService; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.zy.common.web.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | public class RolePdaResourceController extends BaseController { |
| | | |
| | | @Autowired |
| | | private RolePdaResourceService rolePdaResourceService; |
| | | |
| | | @RequestMapping(value = "/rolePdaResource/{id}/auth") |
| | | @ManagerAuth |
| | | public R get(@PathVariable("id") String id) { |
| | | return R.ok(rolePdaResourceService.selectById(String.valueOf(id))); |
| | | } |
| | | |
| | | @RequestMapping(value = "/rolePdaResource/list/auth") |
| | | @ManagerAuth |
| | | public R list(@RequestParam(defaultValue = "1")Integer curr, |
| | | @RequestParam(defaultValue = "10")Integer limit, |
| | | @RequestParam(required = false)String orderByField, |
| | | @RequestParam(required = false)String orderByType, |
| | | @RequestParam Map<String, Object> param){ |
| | | EntityWrapper<RolePdaResource> wrapper = new EntityWrapper<>(); |
| | | excludeTrash(param); |
| | | convert(param, wrapper); |
| | | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} |
| | | return R.ok(rolePdaResourceService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | } |
| | | |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | String val = String.valueOf(entry.getValue()); |
| | | if (val.contains(RANGE_TIME_LINK)){ |
| | | String[] dates = val.split(RANGE_TIME_LINK); |
| | | wrapper.ge(entry.getKey(), DateUtils.convert(dates[0])); |
| | | wrapper.le(entry.getKey(), DateUtils.convert(dates[1])); |
| | | } else { |
| | | wrapper.like(entry.getKey(), val); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/rolePdaResource/add/auth") |
| | | @ManagerAuth |
| | | public R add(RolePdaResource rolePdaResource) { |
| | | rolePdaResourceService.insert(rolePdaResource); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/rolePdaResource/update/auth") |
| | | @ManagerAuth |
| | | public R update(RolePdaResource rolePdaResource){ |
| | | if (Cools.isEmpty(rolePdaResource) || null==rolePdaResource.getId()){ |
| | | return R.error(); |
| | | } |
| | | rolePdaResourceService.updateById(rolePdaResource); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/rolePdaResource/delete/auth") |
| | | @ManagerAuth |
| | | public R delete(@RequestParam(value="ids[]") Long[] ids){ |
| | | for (Long id : ids){ |
| | | rolePdaResourceService.deleteById(id); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/rolePdaResource/export/auth") |
| | | @ManagerAuth |
| | | public R export(@RequestBody JSONObject param){ |
| | | EntityWrapper<RolePdaResource> wrapper = new EntityWrapper<>(); |
| | | List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); |
| | | Map<String, Object> map = excludeTrash(param.getJSONObject("rolePdaResource")); |
| | | convert(map, wrapper); |
| | | List<RolePdaResource> list = rolePdaResourceService.selectList(wrapper); |
| | | return R.ok(exportSupport(list, fields)); |
| | | } |
| | | |
| | | @RequestMapping(value = "/rolePdaResourceQuery/auth") |
| | | @ManagerAuth |
| | | public R query(String condition) { |
| | | EntityWrapper<RolePdaResource> wrapper = new EntityWrapper<>(); |
| | | wrapper.like("id", condition); |
| | | Page<RolePdaResource> page = rolePdaResourceService.selectPage(new Page<>(0, 10), wrapper); |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (RolePdaResource rolePdaResource : page.getRecords()){ |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", rolePdaResource.getId()); |
| | | map.put("value", rolePdaResource.getId()); |
| | | result.add(map); |
| | | } |
| | | return R.ok(result); |
| | | } |
| | | |
| | | @RequestMapping(value = "/rolePdaResource/check/column/auth") |
| | | @ManagerAuth |
| | | public R query(@RequestBody JSONObject param) { |
| | | Wrapper<RolePdaResource> wrapper = new EntityWrapper<RolePdaResource>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val")); |
| | | if (null != rolePdaResourceService.selectOne(wrapper)){ |
| | | return R.parse(BaseRes.REPEAT).add(getComment(RolePdaResource.class, String.valueOf(param.get("key")))); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.system.entity; |
| | | |
| | | import com.core.common.Cools;import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import com.core.common.SpringUtils; |
| | | import com.zy.system.service.ResourceService; |
| | | import com.zy.system.entity.Resource; |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @TableName("sys_pda_resource") |
| | | public class PdaResource implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 编号 |
| | | */ |
| | | @ApiModelProperty(value= "编号") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 菜单编码 |
| | | */ |
| | | @ApiModelProperty(value= "菜单编码") |
| | | private String code; |
| | | |
| | | /** |
| | | * 菜单名称 |
| | | */ |
| | | @ApiModelProperty(value= "菜单名称") |
| | | private String name; |
| | | |
| | | /** |
| | | * 菜单标题 |
| | | */ |
| | | @ApiModelProperty(value= "菜单标题") |
| | | private String title; |
| | | |
| | | /** |
| | | * 父级菜单 |
| | | */ |
| | | @ApiModelProperty(value= "父级菜单") |
| | | @TableField("resource_id") |
| | | private Long resourceId; |
| | | |
| | | /** |
| | | * 菜单等级 1: 一级菜单 2: 二级菜单 |
| | | */ |
| | | @ApiModelProperty(value= "菜单等级 1: 一级菜单 2: 二级菜单 ") |
| | | private Short level; |
| | | |
| | | /** |
| | | * 排序 |
| | | */ |
| | | @ApiModelProperty(value= "排序") |
| | | private Integer sort; |
| | | |
| | | /** |
| | | * 状态 1: 正常 0: 禁用 |
| | | */ |
| | | @ApiModelProperty(value= "状态 1: 正常 0: 禁用 ") |
| | | private Short status; |
| | | |
| | | public PdaResource() {} |
| | | |
| | | public PdaResource(String code,String name,String title,Long resourceId,Short level,Integer sort,Short status) { |
| | | this.code = code; |
| | | this.name = name; |
| | | this.title = title; |
| | | this.resourceId = resourceId; |
| | | this.level = level; |
| | | this.sort = sort; |
| | | this.status = status; |
| | | } |
| | | |
| | | // PdaResource pdaResource = new PdaResource( |
| | | // null, // 菜单编码[非空] |
| | | // null, // 菜单名称[非空] |
| | | // null, // 菜单标题[非空] |
| | | // null, // 父级菜单 |
| | | // null, // 菜单等级[非空] |
| | | // null, // 排序 |
| | | // null // 状态[非空] |
| | | // ); |
| | | |
| | | public String getResourceId$(){ |
| | | ResourceService service = SpringUtils.getBean(ResourceService.class); |
| | | Resource resource = service.selectById(this.resourceId); |
| | | if (!Cools.isEmpty(resource)){ |
| | | return String.valueOf(resource.getName()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getLevel$(){ |
| | | if (null == this.level){ return null; } |
| | | switch (this.level){ |
| | | case 1: |
| | | return "一级菜单"; |
| | | case 2: |
| | | return "二级菜单"; |
| | | default: |
| | | return String.valueOf(this.level); |
| | | } |
| | | } |
| | | |
| | | public String getStatus$(){ |
| | | if (null == this.status){ return null; } |
| | | switch (this.status){ |
| | | case 1: |
| | | return "正常"; |
| | | case 0: |
| | | return "禁用"; |
| | | default: |
| | | return String.valueOf(this.status); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.system.entity; |
| | | |
| | | import com.core.common.Cools;import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @TableName("sys_role_pda_resource") |
| | | public class RolePdaResource implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value= "") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value= "") |
| | | @TableField("role_id") |
| | | private Long roleId; |
| | | |
| | | @ApiModelProperty(value= "") |
| | | @TableField("resource_id") |
| | | private Long resourceId; |
| | | |
| | | public RolePdaResource() {} |
| | | |
| | | public RolePdaResource(Long roleId,Long resourceId) { |
| | | this.roleId = roleId; |
| | | this.resourceId = resourceId; |
| | | } |
| | | |
| | | // RolePdaResource rolePdaResource = new RolePdaResource( |
| | | // null, // [非空] |
| | | // null // [非空] |
| | | // ); |
| | | |
| | | |
| | | } |
| | |
| | | import com.zy.system.service.UserService; |
| | | import com.core.common.Cools; |
| | | import com.core.common.SpringUtils; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | @TableName("sys_user_login") |
| | | @Data |
| | | public class UserLogin implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 所属项目 |
| | | */ |
| | | @ApiModelProperty(value= "所属项目") |
| | | @TableField("host_id") |
| | | private Long hostId; |
| | | /** |
| | | * 员工 |
| | | */ |
| | |
| | | @TableField("create_time") |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 登录系统 |
| | | */ |
| | | @TableField("system") |
| | | private String system; |
| | | |
| | | public Long getId() { |
| | | return id; |
| | | } |
| | |
| | | this.id = id; |
| | | } |
| | | |
| | | public Long getHostId() { |
| | | return hostId; |
| | | } |
| | | |
| | | public void setHostId(Long hostId) { |
| | | this.hostId = hostId; |
| | | } |
| | | public Long getUserId() { |
| | | return userId; |
| | | } |
| | |
| | | this.createTime = createTime; |
| | | } |
| | | |
| | | public String getSystem() { |
| | | return system; |
| | | } |
| | | |
| | | public void setSystem(String system) { |
| | | this.system = system; |
| | | } |
| | | } |
New file |
| | |
| | | package com.zy.system.mapper; |
| | | |
| | | import com.zy.system.entity.PdaResource; |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface PdaResourceMapper extends BaseMapper<PdaResource> { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.system.mapper; |
| | | |
| | | import com.zy.system.entity.RolePdaResource; |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface RolePdaResourceMapper extends BaseMapper<RolePdaResource> { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.system.service; |
| | | |
| | | import com.zy.system.entity.PdaResource; |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | |
| | | public interface PdaResourceService extends IService<PdaResource> { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.system.service; |
| | | |
| | | import com.zy.system.entity.RolePdaResource; |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | |
| | | public interface RolePdaResourceService extends IService<RolePdaResource> { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.system.service.impl; |
| | | |
| | | import com.zy.system.mapper.PdaResourceMapper; |
| | | import com.zy.system.entity.PdaResource; |
| | | import com.zy.system.service.PdaResourceService; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service("pdaResourceService") |
| | | public class PdaResourceServiceImpl extends ServiceImpl<PdaResourceMapper, PdaResource> implements PdaResourceService { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.system.service.impl; |
| | | |
| | | import com.zy.system.mapper.RolePdaResourceMapper; |
| | | import com.zy.system.entity.RolePdaResource; |
| | | import com.zy.system.service.RolePdaResourceService; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service("rolePdaResourceService") |
| | | public class RolePdaResourceServiceImpl extends ServiceImpl<RolePdaResourceMapper, RolePdaResource> implements RolePdaResourceService { |
| | | |
| | | } |
New file |
| | |
| | | -- save pdaResource record |
| | | -- mysql |
| | | insert into `sys_resource` ( `code`, `name`, `resource_id`, `level`, `sort`, `status`) values ( 'pdaResource/pdaResource.html', 'pdaResource管理', null , '2', null , '1'); |
| | | |
| | | insert into `sys_resource` ( `code`, `name`, `resource_id`, `level`, `sort`, `status`) values ( 'pdaResource#view', '查询', '', '3', '0', '1'); |
| | | insert into `sys_resource` ( `code`, `name`, `resource_id`, `level`, `sort`, `status`) values ( 'pdaResource#btn-add', '新增', '', '3', '1', '1'); |
| | | insert into `sys_resource` ( `code`, `name`, `resource_id`, `level`, `sort`, `status`) values ( 'pdaResource#btn-edit', '编辑', '', '3', '2', '1'); |
| | | insert into `sys_resource` ( `code`, `name`, `resource_id`, `level`, `sort`, `status`) values ( 'pdaResource#btn-delete', '删除', '', '3', '3', '1'); |
| | | insert into `sys_resource` ( `code`, `name`, `resource_id`, `level`, `sort`, `status`) values ( 'pdaResource#btn-export', '导出', '', '3', '4', '1'); |
| | | |
| | | -- sqlserver |
| | | insert [dbo].[sys_resource] ( [code], [name], [resource_id], [level], [sort], [status]) values ( N'pdaResource/pdaResource.html', N'pdaResource管理', null, '2', null, '1'); |
| | | |
| | | insert [dbo].[sys_resource] ( [code], [name], [resource_id], [level], [sort], [status]) values ( N'pdaResource#view', N'查询', '', '3', '0', '1'); |
| | | insert [dbo].[sys_resource] ( [code], [name], [resource_id], [level], [sort], [status]) values ( N'pdaResource#btn-add', N'新增', '', '3', '1', '1'); |
| | | insert [dbo].[sys_resource] ( [code], [name], [resource_id], [level], [sort], [status]) values ( N'pdaResource#btn-edit', N'编辑', '', '3', '2', '1'); |
| | | insert [dbo].[sys_resource] ( [code], [name], [resource_id], [level], [sort], [status]) values ( N'pdaResource#btn-delete', N'删除', '', '3', '3', '1'); |
| | | insert [dbo].[sys_resource] ( [code], [name], [resource_id], [level], [sort], [status]) values ( N'pdaResource#btn-export', N'导出', '', '3', '4', '1'); |
New file |
| | |
| | | -- save rolePdaResource record |
| | | -- mysql |
| | | insert into `sys_resource` ( `code`, `name`, `resource_id`, `level`, `sort`, `status`) values ( 'rolePdaResource/rolePdaResource.html', 'rolePdaResource管理', null , '2', null , '1'); |
| | | |
| | | insert into `sys_resource` ( `code`, `name`, `resource_id`, `level`, `sort`, `status`) values ( 'rolePdaResource#view', '查询', '', '3', '0', '1'); |
| | | insert into `sys_resource` ( `code`, `name`, `resource_id`, `level`, `sort`, `status`) values ( 'rolePdaResource#btn-add', '新增', '', '3', '1', '1'); |
| | | insert into `sys_resource` ( `code`, `name`, `resource_id`, `level`, `sort`, `status`) values ( 'rolePdaResource#btn-edit', '编辑', '', '3', '2', '1'); |
| | | insert into `sys_resource` ( `code`, `name`, `resource_id`, `level`, `sort`, `status`) values ( 'rolePdaResource#btn-delete', '删除', '', '3', '3', '1'); |
| | | insert into `sys_resource` ( `code`, `name`, `resource_id`, `level`, `sort`, `status`) values ( 'rolePdaResource#btn-export', '导出', '', '3', '4', '1'); |
| | | |
| | | -- sqlserver |
| | | insert [dbo].[sys_resource] ( [code], [name], [resource_id], [level], [sort], [status]) values ( N'rolePdaResource/rolePdaResource.html', N'rolePdaResource管理', null, '2', null, '1'); |
| | | |
| | | insert [dbo].[sys_resource] ( [code], [name], [resource_id], [level], [sort], [status]) values ( N'rolePdaResource#view', N'查询', '', '3', '0', '1'); |
| | | insert [dbo].[sys_resource] ( [code], [name], [resource_id], [level], [sort], [status]) values ( N'rolePdaResource#btn-add', N'新增', '', '3', '1', '1'); |
| | | insert [dbo].[sys_resource] ( [code], [name], [resource_id], [level], [sort], [status]) values ( N'rolePdaResource#btn-edit', N'编辑', '', '3', '2', '1'); |
| | | insert [dbo].[sys_resource] ( [code], [name], [resource_id], [level], [sort], [status]) values ( N'rolePdaResource#btn-delete', N'删除', '', '3', '3', '1'); |
| | | insert [dbo].[sys_resource] ( [code], [name], [resource_id], [level], [sort], [status]) values ( N'rolePdaResource#btn-export', N'导出', '', '3', '4', '1'); |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.zy.system.mapper.PdaResourceMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.zy.system.entity.PdaResource"> |
| | | <id column="id" property="id" /> |
| | | <result column="code" property="code" /> |
| | | <result column="name" property="name" /> |
| | | <result column="title" property="title" /> |
| | | <result column="resource_id" property="resourceId" /> |
| | | <result column="level" property="level" /> |
| | | <result column="sort" property="sort" /> |
| | | <result column="status" property="status" /> |
| | | |
| | | </resultMap> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.zy.system.mapper.RolePdaResourceMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.zy.system.entity.RolePdaResource"> |
| | | <id column="id" property="id" /> |
| | | <result column="role_id" property="roleId" /> |
| | | <result column="resource_id" property="resourceId" /> |
| | | |
| | | </resultMap> |
| | | |
| | | </mapper> |
New file |
| | |
| | | var pageCurr; |
| | | layui.config({ |
| | | base: baseUrl + "/static/layui/lay/modules/" |
| | | }).use(['table','laydate', 'form', 'admin'], function(){ |
| | | var table = layui.table; |
| | | var $ = layui.jquery; |
| | | var layer = layui.layer; |
| | | var layDate = layui.laydate; |
| | | var form = layui.form; |
| | | var admin = layui.admin; |
| | | |
| | | // 数据渲染 |
| | | tableIns = table.render({ |
| | | elem: '#pdaResource', |
| | | headers: {token: localStorage.getItem('token')}, |
| | | url: baseUrl+'/pdaResource/list/auth', |
| | | page: true, |
| | | limit: 15, |
| | | limits: [15, 30, 50, 100, 200, 500], |
| | | toolbar: '#toolbar', |
| | | cellMinWidth: 50, |
| | | height: 'full-120', |
| | | cols: [[ |
| | | {type: 'checkbox'} |
| | | ,{field: 'id', align: 'center',title: '编号'} |
| | | ,{field: 'code', align: 'center',title: '菜单编码'} |
| | | ,{field: 'name', align: 'center',title: '菜单名称'} |
| | | ,{field: 'title', align: 'center',title: '菜单标题'} |
| | | ,{field: 'resourceId$', align: 'center',title: '父级菜单'} |
| | | ,{field: 'level$', align: 'center',title: '菜单等级'} |
| | | ,{field: 'sort', align: 'center',title: '排序'} |
| | | ,{field: 'status$', align: 'center',title: '状态'} |
| | | |
| | | ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:120} |
| | | ]], |
| | | request: { |
| | | pageName: 'curr', |
| | | pageSize: 'limit' |
| | | }, |
| | | parseData: function (res) { |
| | | return { |
| | | 'code': res.code, |
| | | 'msg': res.msg, |
| | | 'count': res.data.total, |
| | | 'data': res.data.records |
| | | } |
| | | }, |
| | | response: { |
| | | statusCode: 200 |
| | | }, |
| | | done: function(res, curr, count) { |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } |
| | | pageCurr=curr; |
| | | limit(); |
| | | } |
| | | }); |
| | | |
| | | // 监听排序事件 |
| | | table.on('sort(pdaResource)', function (obj) { |
| | | var searchData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | searchData[this.name] = this.value; |
| | | }); |
| | | searchData['orderByField'] = obj.field; |
| | | searchData['orderByType'] = obj.type; |
| | | tableIns.reload({ |
| | | where: searchData, |
| | | page: {curr: 1} |
| | | }); |
| | | }); |
| | | |
| | | // 监听头工具栏事件 |
| | | table.on('toolbar(pdaResource)', function (obj) { |
| | | var checkStatus = table.checkStatus(obj.config.id).data; |
| | | switch(obj.event) { |
| | | case 'addData': |
| | | showEditModel(); |
| | | break; |
| | | case 'deleteData': |
| | | if (checkStatus.length === 0) { |
| | | layer.msg('请选择要删除的数据', {icon: 2}); |
| | | return; |
| | | } |
| | | del(checkStatus.map(function (d) { |
| | | return d.id; |
| | | })); |
| | | break; |
| | | case 'exportData': |
| | | admin.confirm('确定导出Excel吗', {shadeClose: true}, function(){ |
| | | var titles=[]; |
| | | var fields=[]; |
| | | obj.config.cols[0].map(function (col) { |
| | | if (col.type === 'normal' && col.hide === false && col.toolbar == null) { |
| | | titles.push(col.title); |
| | | fields.push(col.field); |
| | | } |
| | | }); |
| | | var exportData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | exportData[this.name] = this.value; |
| | | }); |
| | | var param = { |
| | | 'pdaResource': exportData, |
| | | 'fields': fields |
| | | }; |
| | | $.ajax({ |
| | | url: baseUrl+"/pdaResource/export/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: JSON.stringify(param), |
| | | dataType:'json', |
| | | contentType:'application/json;charset=UTF-8', |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.closeAll(); |
| | | if (res.code === 200) { |
| | | table.exportFile(titles,res.data,'xls'); |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } else { |
| | | layer.msg(res.msg, {icon: 2}) |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | | break; |
| | | } |
| | | }); |
| | | |
| | | // 监听行工具事件 |
| | | table.on('tool(pdaResource)', function(obj){ |
| | | var data = obj.data; |
| | | switch (obj.event) { |
| | | case 'edit': |
| | | showEditModel(data); |
| | | break; |
| | | case "del": |
| | | del([data.id]); |
| | | break; |
| | | } |
| | | }); |
| | | |
| | | /* 弹窗 - 新增、修改 */ |
| | | function showEditModel(mData) { |
| | | admin.open({ |
| | | type: 1, |
| | | area: '600px', |
| | | title: (mData ? '修改' : '添加') + '订单状态', |
| | | content: $('#editDialog').html(), |
| | | success: function (layero, dIndex) { |
| | | layDateRender(mData); |
| | | form.val('detail', mData); |
| | | form.on('submit(editSubmit)', function (data) { |
| | | var loadIndex = layer.load(2); |
| | | $.ajax({ |
| | | url: baseUrl+"/pdaResource/"+(mData?'update':'add')+"/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: data.field, |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.close(loadIndex); |
| | | if (res.code === 200){ |
| | | layer.close(dIndex); |
| | | layer.msg(res.msg, {icon: 1}); |
| | | tableReload(); |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | }else { |
| | | layer.msg(res.msg, {icon: 2}); |
| | | } |
| | | } |
| | | }) |
| | | return false; |
| | | }); |
| | | $(layero).children('.layui-layer-content').css('overflow', 'visible'); |
| | | layui.form.render('select'); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /* 删除 */ |
| | | function del(ids) { |
| | | layer.confirm('确定要删除选中数据吗?', { |
| | | skin: 'layui-layer-admin', |
| | | shade: .1 |
| | | }, function (i) { |
| | | layer.close(i); |
| | | var loadIndex = layer.load(2); |
| | | $.ajax({ |
| | | url: baseUrl+"/pdaResource/delete/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: {ids: ids}, |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.close(loadIndex); |
| | | if (res.code === 200){ |
| | | layer.msg(res.msg, {icon: 1}); |
| | | tableReload(); |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | } else { |
| | | layer.msg(res.msg, {icon: 2}); |
| | | } |
| | | } |
| | | }) |
| | | }); |
| | | } |
| | | |
| | | // 搜索 |
| | | form.on('submit(search)', function (data) { |
| | | pageCurr = 1; |
| | | tableReload(false); |
| | | }); |
| | | |
| | | // 重置 |
| | | form.on('submit(reset)', function (data) { |
| | | pageCurr = 1; |
| | | clearFormVal($('#search-box')); |
| | | tableReload(false); |
| | | }); |
| | | |
| | | // 时间选择器 |
| | | function layDateRender(data) { |
| | | setTimeout(function () { |
| | | |
| | | }, 300); |
| | | } |
| | | layDateRender(); |
| | | |
| | | }); |
| | | |
| | | // 关闭动作 |
| | | $(document).on('click','#data-detail-close', function () { |
| | | parent.layer.closeAll(); |
| | | }); |
| | | |
| | | function tableReload(child) { |
| | | var searchData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | searchData[this.name] = this.value; |
| | | }); |
| | | tableIns.reload({ |
| | | where: searchData, |
| | | page: {curr: pageCurr} |
| | | }); |
| | | } |
New file |
| | |
| | | var pageCurr; |
| | | layui.config({ |
| | | base: baseUrl + "/static/layui/lay/modules/" |
| | | }).use(['table','laydate', 'form', 'admin'], function(){ |
| | | var table = layui.table; |
| | | var $ = layui.jquery; |
| | | var layer = layui.layer; |
| | | var layDate = layui.laydate; |
| | | var form = layui.form; |
| | | var admin = layui.admin; |
| | | |
| | | // 数据渲染 |
| | | tableIns = table.render({ |
| | | elem: '#rolePdaResource', |
| | | headers: {token: localStorage.getItem('token')}, |
| | | url: baseUrl+'/rolePdaResource/list/auth', |
| | | page: true, |
| | | limit: 15, |
| | | limits: [15, 30, 50, 100, 200, 500], |
| | | toolbar: '#toolbar', |
| | | cellMinWidth: 50, |
| | | height: 'full-120', |
| | | cols: [[ |
| | | {type: 'checkbox'} |
| | | ,{field: 'id', align: 'center',title: ''} |
| | | ,{field: 'roleId', align: 'center',title: ''} |
| | | ,{field: 'resourceId', align: 'center',title: ''} |
| | | |
| | | ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:120} |
| | | ]], |
| | | request: { |
| | | pageName: 'curr', |
| | | pageSize: 'limit' |
| | | }, |
| | | parseData: function (res) { |
| | | return { |
| | | 'code': res.code, |
| | | 'msg': res.msg, |
| | | 'count': res.data.total, |
| | | 'data': res.data.records |
| | | } |
| | | }, |
| | | response: { |
| | | statusCode: 200 |
| | | }, |
| | | done: function(res, curr, count) { |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } |
| | | pageCurr=curr; |
| | | limit(); |
| | | } |
| | | }); |
| | | |
| | | // 监听排序事件 |
| | | table.on('sort(rolePdaResource)', function (obj) { |
| | | var searchData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | searchData[this.name] = this.value; |
| | | }); |
| | | searchData['orderByField'] = obj.field; |
| | | searchData['orderByType'] = obj.type; |
| | | tableIns.reload({ |
| | | where: searchData, |
| | | page: {curr: 1} |
| | | }); |
| | | }); |
| | | |
| | | // 监听头工具栏事件 |
| | | table.on('toolbar(rolePdaResource)', function (obj) { |
| | | var checkStatus = table.checkStatus(obj.config.id).data; |
| | | switch(obj.event) { |
| | | case 'addData': |
| | | showEditModel(); |
| | | break; |
| | | case 'deleteData': |
| | | if (checkStatus.length === 0) { |
| | | layer.msg('请选择要删除的数据', {icon: 2}); |
| | | return; |
| | | } |
| | | del(checkStatus.map(function (d) { |
| | | return d.id; |
| | | })); |
| | | break; |
| | | case 'exportData': |
| | | admin.confirm('确定导出Excel吗', {shadeClose: true}, function(){ |
| | | var titles=[]; |
| | | var fields=[]; |
| | | obj.config.cols[0].map(function (col) { |
| | | if (col.type === 'normal' && col.hide === false && col.toolbar == null) { |
| | | titles.push(col.title); |
| | | fields.push(col.field); |
| | | } |
| | | }); |
| | | var exportData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | exportData[this.name] = this.value; |
| | | }); |
| | | var param = { |
| | | 'rolePdaResource': exportData, |
| | | 'fields': fields |
| | | }; |
| | | $.ajax({ |
| | | url: baseUrl+"/rolePdaResource/export/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: JSON.stringify(param), |
| | | dataType:'json', |
| | | contentType:'application/json;charset=UTF-8', |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.closeAll(); |
| | | if (res.code === 200) { |
| | | table.exportFile(titles,res.data,'xls'); |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } else { |
| | | layer.msg(res.msg, {icon: 2}) |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | | break; |
| | | } |
| | | }); |
| | | |
| | | // 监听行工具事件 |
| | | table.on('tool(rolePdaResource)', function(obj){ |
| | | var data = obj.data; |
| | | switch (obj.event) { |
| | | case 'edit': |
| | | showEditModel(data); |
| | | break; |
| | | case "del": |
| | | del([data.id]); |
| | | break; |
| | | } |
| | | }); |
| | | |
| | | /* 弹窗 - 新增、修改 */ |
| | | function showEditModel(mData) { |
| | | admin.open({ |
| | | type: 1, |
| | | area: '600px', |
| | | title: (mData ? '修改' : '添加') + '订单状态', |
| | | content: $('#editDialog').html(), |
| | | success: function (layero, dIndex) { |
| | | layDateRender(mData); |
| | | form.val('detail', mData); |
| | | form.on('submit(editSubmit)', function (data) { |
| | | var loadIndex = layer.load(2); |
| | | $.ajax({ |
| | | url: baseUrl+"/rolePdaResource/"+(mData?'update':'add')+"/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: data.field, |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.close(loadIndex); |
| | | if (res.code === 200){ |
| | | layer.close(dIndex); |
| | | layer.msg(res.msg, {icon: 1}); |
| | | tableReload(); |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | }else { |
| | | layer.msg(res.msg, {icon: 2}); |
| | | } |
| | | } |
| | | }) |
| | | return false; |
| | | }); |
| | | $(layero).children('.layui-layer-content').css('overflow', 'visible'); |
| | | layui.form.render('select'); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /* 删除 */ |
| | | function del(ids) { |
| | | layer.confirm('确定要删除选中数据吗?', { |
| | | skin: 'layui-layer-admin', |
| | | shade: .1 |
| | | }, function (i) { |
| | | layer.close(i); |
| | | var loadIndex = layer.load(2); |
| | | $.ajax({ |
| | | url: baseUrl+"/rolePdaResource/delete/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: {ids: ids}, |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.close(loadIndex); |
| | | if (res.code === 200){ |
| | | layer.msg(res.msg, {icon: 1}); |
| | | tableReload(); |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | } else { |
| | | layer.msg(res.msg, {icon: 2}); |
| | | } |
| | | } |
| | | }) |
| | | }); |
| | | } |
| | | |
| | | // 搜索 |
| | | form.on('submit(search)', function (data) { |
| | | pageCurr = 1; |
| | | tableReload(false); |
| | | }); |
| | | |
| | | // 重置 |
| | | form.on('submit(reset)', function (data) { |
| | | pageCurr = 1; |
| | | clearFormVal($('#search-box')); |
| | | tableReload(false); |
| | | }); |
| | | |
| | | // 时间选择器 |
| | | function layDateRender(data) { |
| | | setTimeout(function () { |
| | | |
| | | }, 300); |
| | | } |
| | | layDateRender(); |
| | | |
| | | }); |
| | | |
| | | // 关闭动作 |
| | | $(document).on('click','#data-detail-close', function () { |
| | | parent.layer.closeAll(); |
| | | }); |
| | | |
| | | function tableReload(child) { |
| | | var searchData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | searchData[this.name] = this.value; |
| | | }); |
| | | tableIns.reload({ |
| | | where: searchData, |
| | | page: {curr: pageCurr} |
| | | }); |
| | | } |
| | |
| | | <!-- 头部 --> |
| | | <div class="layui-header"> |
| | | <div class="layui-logo"> |
| | | <img src="../static/image/logo2.png" style="display: inline-block; width: 40%;height: auto"> |
| | | <img src="../static/image/logo1.png" style="display: inline-block; width: 40%;height: auto"> |
| | | <!-- <span style="margin-top: 0; letter-spacing: 10px">中扬立库</span>--> |
| | | <!-- <img src="../static/image/logo.svg"/>--> |
| | | <!-- <cite>中扬 - Zoneyung</cite>--> |
New file |
| | |
| | | <!DOCTYPE html> |
| | | <html lang="en"> |
| | | <head> |
| | | <meta charset="utf-8"> |
| | | <title></title> |
| | | <meta name="renderer" content="webkit"> |
| | | <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| | | <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> |
| | | <link rel="stylesheet" href="../../static/layui/css/layui.css" media="all"> |
| | | <link rel="stylesheet" href="../../static/css/admin.css?v=318" media="all"> |
| | | <link rel="stylesheet" href="../../static/css/cool.css" media="all"> |
| | | <link rel="stylesheet" href="../../static/css/common.css" media="all"> |
| | | <style> |
| | | #detail { |
| | | padding: 25px 30px 0 0; |
| | | } |
| | | .ew-tree-table-box { |
| | | height: 100%; |
| | | } |
| | | </style> |
| | | </head> |
| | | <body> |
| | | |
| | | |
| | | <!-- 正文开始 --> |
| | | <div class="layui-fluid"> |
| | | <div class="layui-card"> |
| | | <div class="layui-card-body"> |
| | | <!-- 数据表格 --> |
| | | <table id="resource"></table> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | <script type="text/html" id="operate"> |
| | | <a class="layui-btn layui-btn-primary layui-btn-xs btn-edit" lay-event="edit">修改</a> |
| | | <a class="layui-btn layui-btn-danger layui-btn-xs btn-del" lay-event="del">删除</a> |
| | | </script> |
| | | |
| | | <!-- 表单弹窗 --> |
| | | <script type="text/html" id="editDialog"> |
| | | <form id="detail" lay-filter="detail" class="layui-form" style="margin: 0"> |
| | | <input name="id" type="hidden"> |
| | | <input name="uuid" type="hidden"> |
| | | <input name="level" type="hidden"> |
| | | <div class="layui-row"> |
| | | |
| | | <div class="layui-col-md6"> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">上级菜单</label> |
| | | <div class="layui-input-block"> |
| | | <div id="resourceParentSel" class="ew-xmselect-tree"></div> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label layui-form-required">菜单编码</label> |
| | | <div class="layui-input-block"> |
| | | <input name="code" placeholder="请输入菜单编码" class="layui-input" lay-vertype="tips" lay-verify="required" required=""> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label layui-form-required">类型</label> |
| | | <div class="layui-input-block"> |
| | | <select name="level" lay-vertype="tips" lay-verify="required" required=""> |
| | | <option value="">请选择类型</option> |
| | | <option value="1">一级菜单</option> |
| | | <option value="2">二级菜单</option> |
| | | <option value="3">按钮</option> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label layui-form-required">状态</label> |
| | | <div class="layui-input-block"> |
| | | <select name="status" lay-vertype="tips" lay-verify="required" required=""> |
| | | <option value="">请选择状态</option> |
| | | <option value="1">正常</option> |
| | | <option value="0">禁用</option> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | |
| | | </div> |
| | | |
| | | <div class="layui-col-md6"> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label layui-form-required">菜单标题</label> |
| | | <div class="layui-input-block"> |
| | | <input name="title" placeholder="请输入菜单标题" class="layui-input" lay-vertype="tips" lay-verify="required" required=""> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label layui-form-required">菜单名称</label> |
| | | <div class="layui-input-block"> |
| | | <input name="name" placeholder="请输入菜单名称" class="layui-input" lay-vertype="tips" lay-verify="required" required=""> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">排序</label> |
| | | <div class="layui-input-block"> |
| | | <input name="sort" placeholder="请输入排序" class="layui-input" lay-verify="number"> |
| | | </div> |
| | | </div> |
| | | |
| | | |
| | | </div> |
| | | </div> |
| | | <hr class="layui-bg-gray"> |
| | | <div class="layui-form-item text-right"> |
| | | <button class="layui-btn" lay-filter="editSubmit" lay-submit="">保存</button> |
| | | <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button> |
| | | </div> |
| | | </form> |
| | | </script> |
| | | <script type="text/html" id="typeTpl"> |
| | | {{# if( d.level === 1 ){ }} |
| | | <span name="level" class="layui-badge layui-badge-green">菜单</span> |
| | | {{# } else if(d.level === 2){ }} |
| | | <span name="level" class="layui-badge layui-badge-green">菜单</span> |
| | | {{# } else if(d.level === 3){ }} |
| | | <span name="level" class="layui-badge layui-badge-gray">按钮</span> |
| | | {{# } }} |
| | | </script> |
| | | <script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script> |
| | | <script type="text/javascript" src="../../static/layui/layui.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/cool.js" charset="utf-8"></script> |
| | | |
| | | <script> |
| | | layui.config({ |
| | | base: baseUrl + "/static/layui/lay/modules/" |
| | | }).use(['form','treeTable', 'admin', 'xmSelect'], function() { |
| | | var $ = layui.jquery; |
| | | var layer = layui.layer; |
| | | var form = layui.form; |
| | | var admin = layui.admin; |
| | | var treeTable = layui.treeTable; |
| | | var xmSelect = layui.xmSelect; |
| | | var tbDataList = []; |
| | | |
| | | var insTb = treeTable.render({ |
| | | elem: '#resource', |
| | | url: baseUrl+'/pdaResource/tree/auth', |
| | | headers: {token: localStorage.getItem('token')}, |
| | | height: 'full-200', |
| | | toolbar: ['<p>', |
| | | '<button lay-event="add" class="layui-btn layui-btn-sm icon-btn"><i class="layui-icon"></i>添加</button> ', |
| | | '<button lay-event="del" class="layui-btn layui-btn-sm layui-btn-danger icon-btn"><i class="layui-icon"></i>删除</button>', |
| | | '</p>'].join(''), |
| | | tree: { |
| | | iconIndex: 2, // 折叠图标显示在第几列 |
| | | isPidData: true, // 是否是id、pid形式数据 |
| | | idName: 'id', // id字段名称 |
| | | pidName: 'resourceId' // pid字段名称 |
| | | }, |
| | | cols: [[ |
| | | {type: 'checkbox', fixed: 'left'} |
| | | ,{field: 'id', title: 'ID', sort: true,align: 'center', fixed: 'left', width: 80, hide: true} |
| | | ,{field: 'name', align: 'left',title: '菜单名称'} |
| | | ,{field: 'title', align: 'left',title: '菜单标题'} |
| | | ,{field: 'code', align: 'center',title: '菜单编码'} |
| | | // ,{field: 'resourceName', align: 'center',title: '父级菜单'} |
| | | // ,{field: 'level$', align: 'center',title: '菜单等级'} |
| | | ,{field: 'type', align: 'center',title: '类型', templet: '#typeTpl', width: 120} |
| | | ,{field: 'sort', align: 'center',title: '排序'} |
| | | |
| | | ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:150} |
| | | ]], |
| | | done: function (data) { |
| | | $('.ew-tree-table-box').css('height', '100%'); |
| | | // insTb.expandAll(); |
| | | tbDataList = data; |
| | | limit(); |
| | | } |
| | | }); |
| | | |
| | | /* 表格头工具栏点击事件 */ |
| | | treeTable.on('toolbar(resource)', function (obj) { |
| | | if (obj.event === 'add') { // 添加 |
| | | showEditModel(); |
| | | } else if (obj.event === 'del') { // 删除 |
| | | var checkRows = insTb.checkStatus(); |
| | | if (checkRows.length === 0) { |
| | | layer.msg('请选择要删除的数据', {icon: 2}); |
| | | return; |
| | | } |
| | | var ids = checkRows.map(function (d) { |
| | | if (!d.LAY_INDETERMINATE) { |
| | | return d.id; |
| | | } else { |
| | | return null; |
| | | } |
| | | }); |
| | | doDel({ids: ids}); |
| | | } |
| | | }); |
| | | |
| | | /* 表格操作列点击事件 */ |
| | | treeTable.on('tool(resource)', function (obj) { |
| | | if (obj.event === 'edit') { // 修改 |
| | | showEditModel(obj.data); |
| | | } else if (obj.event === 'del') { // 删除 |
| | | doDel(obj); |
| | | } |
| | | }); |
| | | |
| | | /* 显示表单弹窗 */ |
| | | function showEditModel(mData) { |
| | | admin.open({ |
| | | type: 1, |
| | | area: '600px', |
| | | title: (mData ? '修改' : '添加') + '菜单', |
| | | content: $('#editDialog').html(), |
| | | success: function (layero, dIndex) { |
| | | // 回显表单数据 |
| | | form.val('detail', mData); |
| | | // 表单提交事件 |
| | | form.on('submit(editSubmit)', function (data) { |
| | | data.field.resourceId = insXmSel.getValue('valueStr'); |
| | | var loadIndex = layer.load(2); |
| | | $.ajax({ |
| | | url: baseUrl+"/pdaResource/"+(mData?'update':'add')+"/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: data.field, |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.close(loadIndex); |
| | | if (res.code === 200){ |
| | | layer.close(dIndex); |
| | | layer.msg(res.msg, {icon: 1}); |
| | | insTb.refresh(); |
| | | setTimeout(function () { |
| | | insTb.expand(data.field.resourceId); |
| | | }, 200) |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | }else { |
| | | layer.msg(res.msg, {icon: 2}); |
| | | } |
| | | } |
| | | }) |
| | | return false; |
| | | }); |
| | | |
| | | // 渲染下拉树 |
| | | var insXmSel = xmSelect.render({ |
| | | el: '#resourceParentSel', |
| | | height: '250px', |
| | | data: insTb.options.data, |
| | | initValue: mData&&mData.resourceId!=null ? [mData.resourceId] : [], |
| | | model: {label: {type: 'text'}}, |
| | | prop: { |
| | | name: 'name', |
| | | value: 'id' |
| | | }, |
| | | radio: true, |
| | | clickClose: true, |
| | | tree: { |
| | | show: true, |
| | | indent: 15, |
| | | strict: false, |
| | | expandedKeys: false |
| | | } |
| | | }); |
| | | // 弹窗不出现滚动条 |
| | | $(layero).children('.layui-layer-content').css('overflow', 'visible'); |
| | | layui.form.render('select'); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /* 删除 */ |
| | | function doDel(obj) { |
| | | layer.confirm('确定要删除选中数据吗?', { |
| | | skin: 'layui-layer-admin', |
| | | shade: .1 |
| | | }, function (i) { |
| | | layer.close(i); |
| | | var loadIndex = layer.load(2); |
| | | var ids; |
| | | if (obj.data) { |
| | | ids = []; |
| | | ids[0] = obj.data.id; |
| | | } else { |
| | | ids = obj.ids; |
| | | } |
| | | $.ajax({ |
| | | url: baseUrl+"/pdaResource/delete/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: {ids: ids}, |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.close(loadIndex); |
| | | if (res.code === 200){ |
| | | layer.msg(res.msg, {icon: 1}); |
| | | insTb.refresh(); |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | } else { |
| | | layer.msg(res.msg, {icon: 2}); |
| | | } |
| | | } |
| | | }) |
| | | }); |
| | | } |
| | | |
| | | }); |
| | | </script> |
| | | </body> |
| | | </html> |
| | | |
New file |
| | |
| | | <!DOCTYPE html> |
| | | <html lang="en"> |
| | | <head> |
| | | <meta charset="utf-8"> |
| | | <title></title> |
| | | <meta name="renderer" content="webkit"> |
| | | <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| | | <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> |
| | | <link rel="stylesheet" href="../../static/layui/css/layui.css" media="all"> |
| | | <link rel="stylesheet" href="../../static/css/admin.css?v=318" media="all"> |
| | | <link rel="stylesheet" href="../../static/css/cool.css" media="all"> |
| | | </head> |
| | | <body> |
| | | |
| | | <div class="layui-fluid"> |
| | | <div class="layui-card"> |
| | | <div class="layui-card-body"> |
| | | <div class="layui-form toolbar" id="search-box"> |
| | | <div class="layui-form-item"> |
| | | <div class="layui-inline"> |
| | | <label class="layui-form-label">编号:</label> |
| | | <div class="layui-input-inline"> |
| | | <input class="layui-input" type="text" name="id" placeholder="编号" autocomplete="off"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-inline">  |
| | | <button class="layui-btn icon-btn" lay-filter="search" lay-submit> |
| | | <i class="layui-icon"></i>搜索 |
| | | </button> |
| | | <button class="layui-btn icon-btn" lay-filter="reset" lay-submit> |
| | | <i class="layui-icon"></i>重置 |
| | | </button> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <table class="layui-hide" id="rolePdaResource" lay-filter="rolePdaResource"></table> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | <script type="text/html" id="toolbar"> |
| | | <div class="layui-btn-container"> |
| | | <button class="layui-btn layui-btn-sm" id="btn-add" lay-event="addData">新增</button> |
| | | <button class="layui-btn layui-btn-sm layui-btn-danger" id="btn-delete" lay-event="deleteData">删除</button> |
| | | <button class="layui-btn layui-btn-primary layui-btn-sm" id="btn-export" lay-event="exportData" style="float: right">导出</button> |
| | | </div> |
| | | </script> |
| | | |
| | | <script type="text/html" id="operate"> |
| | | <a class="layui-btn layui-btn-primary layui-btn-xs btn-edit" lay-event="edit">修改</a> |
| | | <a class="layui-btn layui-btn-danger layui-btn-xs btn-edit" lay-event="del">删除</a> |
| | | </script> |
| | | |
| | | <script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script> |
| | | <script type="text/javascript" src="../../static/layui/layui.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/cool.js" charset="utf-8"></script> |
| | | <script type="text/javascript" src="../../static/js/rolePdaResource/rolePdaResource.js" charset="utf-8"></script> |
| | | </body> |
| | | <!-- 表单弹窗 --> |
| | | <script type="text/html" id="editDialog"> |
| | | <form id="detail" lay-filter="detail" class="layui-form admin-form model-form"> |
| | | <input name="id" type="hidden"> |
| | | <div class="layui-row"> |
| | | <div class="layui-col-md12"> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label layui-form-required">: </label> |
| | | <div class="layui-input-block"> |
| | | <input class="layui-input" name="roleId" placeholder="请输入" lay-vertype="tips" lay-verify="required"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label layui-form-required">: </label> |
| | | <div class="layui-input-block"> |
| | | <input class="layui-input" name="resourceId" placeholder="请输入" lay-vertype="tips" lay-verify="required"> |
| | | </div> |
| | | </div> |
| | | |
| | | </div> |
| | | </div> |
| | | <hr class="layui-bg-gray"> |
| | | <div class="layui-form-item text-right"> |
| | | <button class="layui-btn" lay-filter="editSubmit" lay-submit="">保存</button> |
| | | <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button> |
| | | </div> |
| | | </form> |
| | | </script> |
| | | </html> |
| | | |