From 590b26dac0340559c892b9168c637336b208bf52 Mon Sep 17 00:00:00 2001 From: yutou Date: Fri, 25 Jun 2021 18:26:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=A7=8B=E6=95=B4=E6=96=B0=E6=9D=83?= =?UTF-8?q?=E9=99=90=E7=AE=A1=E7=90=86=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/yutou/tools/BiliBili/Live.java | 9 +- .../tools/Tools/AuthManagerController.java | 154 ++++++++++++++++++ .../yutou/tools/Tools/PasswordManager.java | 21 ++- .../tools/bangumi/AnimationController.java | 19 +-- .../java/com/yutou/tools/other/tools.java | 2 +- .../java/com/yutou/tools/utils/APIFilter.java | 2 +- .../yutou/tools/utils/NasDepotManager.java | 7 +- .../java/com/yutou/tools/utils/Tools.java | 75 ++++++++- .../yutou/tools/ToolsApplicationTests.java | 19 +++ web/html/body/tools/auth.html | 121 ++++++++++++++ web/html/body/tools/password.html | 7 +- 11 files changed, 398 insertions(+), 38 deletions(-) create mode 100644 src/main/java/com/yutou/tools/Tools/AuthManagerController.java create mode 100644 web/html/body/tools/auth.html diff --git a/src/main/java/com/yutou/tools/BiliBili/Live.java b/src/main/java/com/yutou/tools/BiliBili/Live.java index 9ecdd5e..3cd8456 100644 --- a/src/main/java/com/yutou/tools/BiliBili/Live.java +++ b/src/main/java/com/yutou/tools/BiliBili/Live.java @@ -16,12 +16,11 @@ import java.util.Date; import java.util.List; @Controller -@RequestMapping("bili/live") public class Live { @Resource BilibiliLiveDao bilibiliLiveDao; - @RequestMapping(value = "add/url.do") + @RequestMapping(value = "/bili/live/add/url.do") @ResponseBody public String addLiveUrl(String url){ String cid; @@ -49,7 +48,7 @@ public class Live { } @ResponseBody - @RequestMapping("get/url.do") + @RequestMapping("/bili/live/get/url.do") public String getLiveUrl(){ List list=bilibiliLiveDao.selectByExample(new BilibiliLiveExample()); JSONObject json=new JSONObject(); @@ -59,7 +58,7 @@ public class Live { return json.toJSONString(); } @ResponseBody - @RequestMapping("set/update.do") + @RequestMapping("/bili/live/set/update.do") public String configDown(String id,String url,String cid,String status){ JSONObject json=new JSONObject(); BilibiliLive live=bilibiliLiveDao.selectByPrimaryKey(Integer.parseInt(id)); @@ -86,7 +85,7 @@ public class Live { return json.toJSONString(); } @ResponseBody - @RequestMapping("set/delete.do") + @RequestMapping("/bili/live/set/delete.do") public String delUrl(String id){ JSONObject json=new JSONObject(); try{ diff --git a/src/main/java/com/yutou/tools/Tools/AuthManagerController.java b/src/main/java/com/yutou/tools/Tools/AuthManagerController.java new file mode 100644 index 0000000..7d94e94 --- /dev/null +++ b/src/main/java/com/yutou/tools/Tools/AuthManagerController.java @@ -0,0 +1,154 @@ +package com.yutou.tools.Tools; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.yutou.tools.mybatis.dao.PermissionDao; +import com.yutou.tools.mybatis.dao.UKeyDao; +import com.yutou.tools.mybatis.model.Permission; +import com.yutou.tools.mybatis.model.PermissionExample; +import com.yutou.tools.mybatis.model.UKey; +import com.yutou.tools.mybatis.model.UKeyExample; +import com.yutou.tools.utils.Tools; +import org.springframework.stereotype.Controller; +import org.springframework.util.ObjectUtils; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.annotation.Resource; +import java.util.List; + +@Controller +public class AuthManagerController { + @Resource + UKeyDao keyDao; + @Resource + PermissionDao permissionDao; + + @ResponseBody + @RequestMapping("/tools/auth/all.do") + public JSONObject getUserList() { + JSONObject json = new JSONObject(); + JSONArray array = new JSONArray(); + List list = keyDao.selectByExample(new UKeyExample()); + for (UKey uKey : list) { + JSONObject item = new JSONObject(); + item.put("id", uKey.getId()); + item.put("key", uKey.getKey()); + item.put("authSize", JSONArray.parseArray(uKey.getPower()).size()); + array.add(item); + } + json.put("code", 0); + json.put("msg", "ok"); + json.put("data", array); + json.put("count", array.size()); + return json; + } + + @ResponseBody + @RequestMapping("/tools/auth/user.do") + public JSONObject getUserAuth(String uid) { + JSONObject json = new JSONObject(); + if (ObjectUtils.isEmpty(uid)) { + json.put("code", -1); + json.put("msg", "uid为空"); + return json; + } + JSONArray allPermission = new JSONArray(); + JSONArray userPermission = new JSONArray(); + UKey key = keyDao.selectByPrimaryKey(Integer.parseInt(uid)); + List permission = Tools.getUrls("com.yutou.tools", null); + JSONArray powers = JSONArray.parseArray(key.getPower()); + System.out.println("总权限:" + permission.size()); + JSONObject admin = new JSONObject(); + admin.put("value", "-1"); + admin.put("title", "管理员"); + admin.put("disabled", ""); + admin.put("checked", ""); + allPermission.add(admin); + List list = powers.toJavaList(String.class); + if (list.contains("-1")) { + userPermission.add("-1"); + } + + int index = 1; + for (String per : permission) { + index++; + JSONObject item = new JSONObject(); + item.put("value", index + ""); + item.put("title", per); + item.put("disabled", ""); + item.put("checked", ""); + PermissionExample example = new PermissionExample(); + example.createCriteria().andUrlEqualTo(per); + List permissions = permissionDao.selectByExample(example); + allPermission.add(item); + if (permissions.size() == 0) { + Permission p = new Permission(); + p.setTitle(per); + p.setUrl(per); + permissionDao.insert(p); + } else { + permissions.get(0).getId(); + if (list.contains(permissions.get(0).getId() + "")) { + userPermission.add(index + ""); + } + } + } + JSONObject data = new JSONObject(); + data.put("all", allPermission); + data.put("user", userPermission); + json.put("data", data); + json.put("msg", "ok"); + json.put("code", 0); + return json; + } + @ResponseBody + @RequestMapping("/a/t.do") + public JSONObject test(){ + return new JSONObject(); + } + @ResponseBody + @RequestMapping("/tools/auth/set.do") + public JSONObject updateAuth(String uid, String auth, String type) { + JSONObject json = new JSONObject(); + System.out.println("uid = " + uid + ", auth = " + auth + ", type = " + type); + JSONArray array = JSONArray.parseArray(auth); + UKey key = keyDao.selectByPrimaryKey(Integer.parseInt(uid)); + JSONArray powers = JSONArray.parseArray(key.getPower()); + if ("add".equals(type) && auth.contains("管理员")) { + powers.clear(); + powers.add("-1"); + } else { + for (Object o : array) { + JSONObject item = (JSONObject) o; + PermissionExample example = new PermissionExample(); + example.createCriteria().andUrlEqualTo(item.getString("auth")); + List list = permissionDao.selectByExample(example); + Permission permission = null; + if (list.size() > 0) { + permission = list.get(0); + } + if ("add".equals(type)) { + if (permission != null) { + powers.remove("-1"); + powers.add(permission.getId() + ""); + } + } else if ("remove".equals(type)) { + if (permission == null) { + powers.remove("-1"); + } else { + System.out.println("移除:" + permission.getId()); + powers.remove(permission.getId() + ""); + } + } + System.out.println("设置权限:" + powers.toJSONString()); + } + } + key.setPower(powers.toJSONString()); + keyDao.updateByPrimaryKey(key); + json.put("code", 0); + json.put("msg", "操作成功"); + return json; + } +} diff --git a/src/main/java/com/yutou/tools/Tools/PasswordManager.java b/src/main/java/com/yutou/tools/Tools/PasswordManager.java index f00978f..8588d89 100644 --- a/src/main/java/com/yutou/tools/Tools/PasswordManager.java +++ b/src/main/java/com/yutou/tools/Tools/PasswordManager.java @@ -21,7 +21,6 @@ import javax.servlet.http.HttpServletRequest; import java.util.List; @Controller -@RequestMapping("/tools/password/") public class PasswordManager { @Resource @@ -32,7 +31,7 @@ public class PasswordManager { tools tls; @ResponseBody - @RequestMapping(value = "get/list.do",method = RequestMethod.GET) + @RequestMapping(value = "/tools/password/get/list.do",method = RequestMethod.GET) public String getPasswordList(HttpServletRequest request,String type){ JSONObject json=new JSONObject(); int id=tls.getUid(request); @@ -48,7 +47,7 @@ public class PasswordManager { return json.toJSONString(); } @ResponseBody - @RequestMapping(value = "get/password.do",method = RequestMethod.GET) + @RequestMapping(value = "/tools/password/get/password.do",method = RequestMethod.GET) public String getPassword(HttpServletRequest request,String id){ JSONObject json=new JSONObject(); int uid=tls.getUid(request); @@ -60,7 +59,7 @@ public class PasswordManager { return json.toJSONString(); } @ResponseBody - @RequestMapping(value = "get/all.do",method = RequestMethod.GET) + @RequestMapping(value = "/tools/password/get/all.do",method = RequestMethod.GET) public String getAllPassword(HttpServletRequest request){ JSONObject json=new JSONObject(); JSONArray array=new JSONArray(); @@ -84,7 +83,7 @@ public class PasswordManager { return json.toJSONString(); } @ResponseBody - @RequestMapping(value = "type/get/list.do",method = RequestMethod.GET) + @RequestMapping(value = "/tools/password/type/get/list.do",method = RequestMethod.GET) public String getPasswordType(HttpServletRequest request){ JSONObject json=new JSONObject(); int uid=tls.getUid(request); @@ -97,7 +96,7 @@ public class PasswordManager { return json.toJSONString(); } @ResponseBody - @RequestMapping(value = "type/set/add.do",method = RequestMethod.POST) + @RequestMapping(value = "/tools/password/type/set/add.do",method = RequestMethod.POST) public String addPasswordType(HttpServletRequest request,String type){ JSONObject json=new JSONObject(); try{ @@ -116,7 +115,7 @@ public class PasswordManager { return json.toJSONString(); } @ResponseBody - @RequestMapping(value = "set/add.do",method = RequestMethod.POST) + @RequestMapping(value = "/tools/password/set/add.do",method = RequestMethod.POST) public String addPassword(HttpServletRequest request,String title,String username,String password,String url,String info,String type){ JSONObject json=new JSONObject(); try{ @@ -172,7 +171,7 @@ public class PasswordManager { return json.toJSONString(); } @ResponseBody - @RequestMapping(value = "set/update.do",method = RequestMethod.POST) + @RequestMapping(value = "/tools/password/set/update.do",method = RequestMethod.POST) public String updatePassword(HttpServletRequest request,String title,String username,String password,String url,String info,String id){ JSONObject json=new JSONObject(); try{ @@ -207,7 +206,7 @@ public class PasswordManager { return json.toJSONString(); } @ResponseBody - @RequestMapping(value = "type/set/update.do",method = RequestMethod.POST) + @RequestMapping(value = "/tools/password/type/set/update.do",method = RequestMethod.POST) public String updatePasswordType(HttpServletRequest request,String type,String id){ JSONObject json=new JSONObject(); try { @@ -229,7 +228,7 @@ public class PasswordManager { return json.toJSONString(); } @ResponseBody - @RequestMapping(value = "set/remove.do",method = RequestMethod.POST) + @RequestMapping(value = "/tools/password/set/remove.do",method = RequestMethod.POST) public String removePassword(HttpServletRequest request,String id){ JSONObject json=new JSONObject(); try { @@ -247,7 +246,7 @@ public class PasswordManager { return json.toJSONString(); } @ResponseBody - @RequestMapping(value = "type/set/remove.do",method = RequestMethod.POST) + @RequestMapping(value = "/tools/password/type/set/remove.do",method = RequestMethod.POST) public String removePasswordType(HttpServletRequest request,String id){ JSONObject json=new JSONObject(); try { diff --git a/src/main/java/com/yutou/tools/bangumi/AnimationController.java b/src/main/java/com/yutou/tools/bangumi/AnimationController.java index 6b67882..e578fa2 100644 --- a/src/main/java/com/yutou/tools/bangumi/AnimationController.java +++ b/src/main/java/com/yutou/tools/bangumi/AnimationController.java @@ -18,7 +18,6 @@ import javax.annotation.Resource; import java.util.List; @Controller -@RequestMapping("anim/") public class AnimationController { @Resource BangumiListDao listDao; @@ -26,7 +25,7 @@ public class AnimationController { BangumiItemDao itemDao; @ResponseBody - @RequestMapping(value = "rss/data.do", method = RequestMethod.GET) + @RequestMapping(value = "/anim/rss/data.do", method = RequestMethod.GET) public String getAnimList(String key,String type,String team, int page) { boolean isNull = key.length() == 0; if(!StringUtils.isEmpty(type)&&type.length()>2) { @@ -53,7 +52,7 @@ public class AnimationController { } @ResponseBody - @RequestMapping(value = "type/add.do", method = RequestMethod.POST) + @RequestMapping(value = "/anim/type/add.do", method = RequestMethod.POST) public String addRssType(String title) { BangumiList bangumiList = new BangumiList(); bangumiList.setTitle(title); @@ -66,7 +65,7 @@ public class AnimationController { } @ResponseBody - @RequestMapping(value = "type/list.do", method = RequestMethod.GET) + @RequestMapping(value = "/anim/type/list.do", method = RequestMethod.GET) public String getRssTypeList() { JSONObject json = new JSONObject(); json.put("code", 0); @@ -75,7 +74,7 @@ public class AnimationController { return json.toJSONString(); } @ResponseBody - @RequestMapping(value = "type/del.do", method = RequestMethod.POST) + @RequestMapping(value = "/anim/type/del.do", method = RequestMethod.POST) public String delType(int id){ BangumiItemExample example=new BangumiItemExample(); example.createCriteria().andBidEqualTo(id+""); @@ -88,7 +87,7 @@ public class AnimationController { } @ResponseBody - @RequestMapping(value = "rss/add.do", method = RequestMethod.POST) + @RequestMapping(value = "/anim/rss/add.do", method = RequestMethod.POST) public String addAnimationRss(String title, String author, String categories, String titleKey, String bid) { BangumiItem item = new BangumiItem(); item.setTitle(title); @@ -105,7 +104,7 @@ public class AnimationController { } @ResponseBody - @RequestMapping(value = "rss/list.do", method = RequestMethod.GET) + @RequestMapping(value = "/anim/rss/list.do", method = RequestMethod.GET) public String getAnimationRssList(String type) { JSONObject json = new JSONObject(); BangumiItemExample example=new BangumiItemExample(); @@ -116,7 +115,7 @@ public class AnimationController { return json.toJSONString(); } @ResponseBody - @RequestMapping(value = "rss/del.do", method = RequestMethod.POST) + @RequestMapping(value = "/anim/rss/del.do", method = RequestMethod.POST) public String delAnimation(int id){ int i=itemDao.deleteByPrimaryKey(id); JSONObject json=new JSONObject(); @@ -125,7 +124,7 @@ public class AnimationController { return json.toJSONString(); } @ResponseBody - @RequestMapping(value = "rss/edit.do",method = RequestMethod.POST) + @RequestMapping(value = "/anim/rss/edit.do",method = RequestMethod.POST) public JSONObject editAnimation(int id,String title, String author, String categories, String titleKey,String enable){ JSONObject json=new JSONObject(); BangumiItem item =itemDao.selectByPrimaryKey(id); @@ -154,7 +153,7 @@ public class AnimationController { return json; } @ResponseBody - @RequestMapping(value = "client/get.do", method = RequestMethod.GET) + @RequestMapping(value = "/anim/client/get.do", method = RequestMethod.GET) public String clientApi(){ AnimationData animationData=new AnimationData(); List list=itemDao.selectByExample(new BangumiItemExample()); diff --git a/src/main/java/com/yutou/tools/other/tools.java b/src/main/java/com/yutou/tools/other/tools.java index 5b9d345..a51287a 100644 --- a/src/main/java/com/yutou/tools/other/tools.java +++ b/src/main/java/com/yutou/tools/other/tools.java @@ -27,7 +27,7 @@ public class tools { UKeyDao keyDao; @ResponseBody - @RequestMapping(value = "tools/get.do") + @RequestMapping(value = "/tools/get.do") public String getJs(HttpServletRequest request, HttpServletResponse response) throws Exception { Enumeration name = request.getHeaderNames(); while (name.hasMoreElements()) { diff --git a/src/main/java/com/yutou/tools/utils/APIFilter.java b/src/main/java/com/yutou/tools/utils/APIFilter.java index 3903ca4..ee00395 100644 --- a/src/main/java/com/yutou/tools/utils/APIFilter.java +++ b/src/main/java/com/yutou/tools/utils/APIFilter.java @@ -69,7 +69,7 @@ public class APIFilter implements Filter { pExample.createCriteria().andUrlEqualTo(url); List permissions = permissionDao.selectByExample(pExample); if (permissions != null && permissions.size() > 0) { - if (powers.toJavaList(Integer.class).contains(permissions.get(0).getId())) { + if (powers.toJavaList(String.class).contains(permissions.get(0).getId()+"")) { isToken = true; } } diff --git a/src/main/java/com/yutou/tools/utils/NasDepotManager.java b/src/main/java/com/yutou/tools/utils/NasDepotManager.java index 8ebdb89..e2525ca 100644 --- a/src/main/java/com/yutou/tools/utils/NasDepotManager.java +++ b/src/main/java/com/yutou/tools/utils/NasDepotManager.java @@ -8,12 +8,11 @@ import org.springframework.web.bind.annotation.ResponseBody; @Controller -@RequestMapping("/nas/depot/") public class NasDepotManager { private static final String DEPOT_NAME = "nas_depot"; @ResponseBody - @RequestMapping("/add.do") + @RequestMapping("/nas/depot/add.do") public JSONObject addNasPath(String path,String type) { JSONObject json=new JSONObject(); JSONObject item=new JSONObject(); @@ -32,7 +31,7 @@ public class NasDepotManager { } @ResponseBody - @RequestMapping("/list.do") + @RequestMapping("/nas/depot/list.do") public JSONObject getNasList() { JSONObject json=new JSONObject(); json.put("code",1); @@ -41,7 +40,7 @@ public class NasDepotManager { return json; } @ResponseBody - @RequestMapping("/remove.do") + @RequestMapping("/nas/depot/remove.do") public JSONObject removeNas(String path) { JSONObject json=new JSONObject(); json.put("code",1); diff --git a/src/main/java/com/yutou/tools/utils/Tools.java b/src/main/java/com/yutou/tools/utils/Tools.java index f01fb2f..44f85ea 100644 --- a/src/main/java/com/yutou/tools/utils/Tools.java +++ b/src/main/java/com/yutou/tools/utils/Tools.java @@ -3,11 +3,18 @@ package com.yutou.tools.utils; import com.alibaba.fastjson.JSONArray; import com.yutou.tools.interfaces.DownloadInterface; import com.yutou.tools.nas.UpdateIp; +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; +import org.springframework.core.annotation.AnnotationUtils; import org.springframework.core.io.FileSystemResource; +import org.springframework.core.type.filter.TypeFilter; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; @@ -15,6 +22,8 @@ import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLDecoder; @@ -22,9 +31,7 @@ import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.text.SimpleDateFormat; -import java.util.Base64; -import java.util.Date; -import java.util.Random; +import java.util.*; public class Tools { /** @@ -351,4 +358,66 @@ public class Tools { public static String getToDayTime() { return new SimpleDateFormat("yyyy-MM-dd").format(new Date()); } + + /** + * 扫描使用注解的类 + * @param packageName 扫描包名 + * @param annotation 注解类 + * @return 扫描到的集合 + */ + public static List scanClass(String packageName, Class annotation) { + List classList = new ArrayList<>(); + if (ObjectUtils.isEmpty(packageName)) { + return classList; + } + ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false); + TypeFilter includeFilter = (metadataReader, metadataReaderFactory) -> true; + provider.addIncludeFilter(includeFilter); + Set beanDefinitionSet = new HashSet<>(); + // 指定扫描的包名 + Set candidateComponents = provider.findCandidateComponents(packageName); + beanDefinitionSet.addAll(candidateComponents); + + beanDefinitionSet.forEach(beanDefinition -> { + try { + Class clazz = Class.forName(beanDefinition.getBeanClassName()); + + if (!ObjectUtils.isEmpty(annotation)) { + if (!ObjectUtils.isEmpty(AnnotationUtils.getAnnotation(clazz, annotation))) { + classList.add(clazz); + } + } else { + classList.add(clazz); + } + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } +// System.out.println(definition.getBeanClassName()); + }); + return classList; + } + + /** + * 获取Url + * @param packageName 扫描包名 + * @param className 指定类,如无指定类,为null即可 + * @return url集合 + */ + public static List getUrls(String packageName,String className){ + List list= scanClass(packageName, Controller.class); + List urls=new ArrayList<>(); + for (Class aClass : list) { + if(className!=null&&!aClass.getSimpleName().equals(className)){ + continue; + } + Method[] methods= aClass.getDeclaredMethods(); + for (Method method : methods) { + RequestMapping ls=method.getAnnotation(RequestMapping.class); + if(ls!=null) { + urls.add(ls.value()[0]); + } + } + } + return urls; + } } diff --git a/src/test/java/com/yutou/tools/ToolsApplicationTests.java b/src/test/java/com/yutou/tools/ToolsApplicationTests.java index 0b92ddc..b39e391 100644 --- a/src/test/java/com/yutou/tools/ToolsApplicationTests.java +++ b/src/test/java/com/yutou/tools/ToolsApplicationTests.java @@ -1,7 +1,14 @@ package com.yutou.tools; +import com.alibaba.fastjson.JSONObject; +import com.yutou.tools.Tools.AuthManagerController; +import com.yutou.tools.utils.Tools; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import java.util.List; @SpringBootTest class ToolsApplicationTests { @@ -10,4 +17,16 @@ class ToolsApplicationTests { void contextLoads() { } + @Test + void main(){ + List list=Tools.getUrls("com.yutou.tools",null); + for (String aClass : list) { + System.out.println(aClass); + } + } + @Test + void ptest(){ + JSONObject json=new AuthManagerController().getUserAuth("3"); + System.out.println(json.toJSONString()); + } } diff --git a/web/html/body/tools/auth.html b/web/html/body/tools/auth.html new file mode 100644 index 0000000..6906155 --- /dev/null +++ b/web/html/body/tools/auth.html @@ -0,0 +1,121 @@ + + + + + + + 权限管理 + + + + +
+ +
+
+
用户权限管理
+
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/web/html/body/tools/password.html b/web/html/body/tools/password.html index 9478bc2..ed6985b 100644 --- a/web/html/body/tools/password.html +++ b/web/html/body/tools/password.html @@ -47,7 +47,7 @@ let tabid = -1; layui.use(['layer', 'form', 'element', 'table'], function () { - var layer = layui.layer + let layer = layui.layer , form = layui.form , table = layui.table , element = layui.element; @@ -66,7 +66,6 @@ } }); form.render() - console.log(1) element.on('tab(type)', function (data) { tabid = $(this).attr('lay-id') @@ -84,6 +83,9 @@ , { field: 'info', title: '备注', width: 200 } , { field: "right", width: 200, toolbar: '#listTools' } ]] + ,done:function (res,curr,count) { + form.render(); + } }); }) element.on('tabDelete(type)', function (data) { @@ -114,7 +116,6 @@ }) }) table.on('tool(listTools)', function (obj) { - if (obj.event === 'edit') { $.get('/tools/password/get/password.do?id=' + obj.data.id, function (udata) { let json = JSON.parse(udata);