更新基础框架

pull/1/head
iamsongpeng 2020-03-12 14:25:37 +08:00
parent 37bc8c7973
commit f391d962ac
29 changed files with 383 additions and 640 deletions

View File

@ -35,7 +35,8 @@
* https://gitee.com/whvse/treetable-lay * https://gitee.com/whvse/treetable-lay
* 图标库使用 * 图标库使用
* http://www.fontawesome.com.cn/faicons * http://www.fontawesome.com.cn/faicons
* 发送 ajax 示例:[详情](./docs/ajax.md) * 发送 Ajax 示例:[详情](./docs/ajax.md)
* FreeMarker 文档:[详情](./docs/FreeMarker.md)
* 后端 * 后端
* Hutool 是一个小而全的Java工具类库通过静态方法封装降低相关API的学习成本提高工作效率使Java拥有函数式语言般的优雅让Java语言也可以“甜甜的”。 * Hutool 是一个小而全的Java工具类库通过静态方法封装降低相关API的学习成本提高工作效率使Java拥有函数式语言般的优雅让Java语言也可以“甜甜的”。
* 枚举 * 枚举

12
docs/FreeMarker.md Normal file
View File

@ -0,0 +1,12 @@
### FreeMarker 文档
* html 或者 js 中遍历 model 中的 `List<Map<String, Object>> result`
```
<#list result as map>
<#list map?keys as key> //关键点
console.log('${key}')
console.log('${map[key]}')
</#list>
</#list>
```

View File

@ -20,12 +20,12 @@ import javax.servlet.http.HttpServletRequest;
@ControllerAdvice @ControllerAdvice
public class ExceptionAdvice { public class ExceptionAdvice {
Logger log = LoggerFactory.getLogger(ExceptionAdvice.class); Logger logger = LoggerFactory.getLogger(ExceptionAdvice.class);
@ExceptionHandler(AuthorizationException.class) @ExceptionHandler(AuthorizationException.class)
@ResponseBody @ResponseBody
public Object handleAuthorizationException(AuthorizationException e, HttpServletRequest request) { public Object handleAuthorizationException(AuthorizationException e, HttpServletRequest request) {
log.error(e.getMessage(), e); logger.error(e.getMessage(), e);
if (HttpUtil.isAjax(request)) { if (HttpUtil.isAjax(request)) {
return Result.failure("未授权"); return Result.failure("未授权");
} }
@ -35,7 +35,7 @@ public class ExceptionAdvice {
@ExceptionHandler(DuplicateKeyException.class) @ExceptionHandler(DuplicateKeyException.class)
@ResponseBody @ResponseBody
public Object handleDuplicateKeyException(DuplicateKeyException e, HttpServletRequest request) { public Object handleDuplicateKeyException(DuplicateKeyException e, HttpServletRequest request) {
log.error(e.getMessage(), e); logger.error(e.getMessage(), e);
if (HttpUtil.isAjax(request)) { if (HttpUtil.isAjax(request)) {
return Result.failure("数据重复"); return Result.failure("数据重复");
} }
@ -45,7 +45,7 @@ public class ExceptionAdvice {
@ExceptionHandler({Exception.class}) @ExceptionHandler({Exception.class})
@ResponseBody @ResponseBody
public Object handleException(Exception e, HttpServletRequest request) { public Object handleException(Exception e, HttpServletRequest request) {
log.error(e.getMessage(), e); logger.error(e.getMessage(), e);
if (HttpUtil.isAjax(request)) { if (HttpUtil.isAjax(request)) {
return Result.failure("服务器错误,请联系管理员"); return Result.failure("服务器错误,请联系管理员");
} }

View File

@ -17,18 +17,18 @@ import java.time.LocalDateTime;
@Component @Component
public class SpMetaObjectHandler implements MetaObjectHandler { public class SpMetaObjectHandler implements MetaObjectHandler {
Logger log = LoggerFactory.getLogger(SpMetaObjectHandler.class); Logger logger = LoggerFactory.getLogger(SpMetaObjectHandler.class);
@Override @Override
public void insertFill(MetaObject metaObject) { public void insertFill(MetaObject metaObject) {
log.info("start insert fill ..."); logger.info("start insert fill ...");
this.setInsertData(metaObject); this.setInsertData(metaObject);
this.setUpdateData(metaObject); this.setUpdateData(metaObject);
} }
@Override @Override
public void updateFill(MetaObject metaObject) { public void updateFill(MetaObject metaObject) {
log.info("start update fill ..."); logger.info("start update fill ...");
this.setUpdateData(metaObject); this.setUpdateData(metaObject);
} }

View File

@ -0,0 +1,27 @@
package com.songpeng.sparchetype.common.controller.admin;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* Controller
*
* @author SongPeng
* @date 2020/3/11
*/
@RequestMapping("/admin/common")
@Controller("adminCommonController")
public class CommonController {
/**
* UI
* @param fileName
* @return
*/
@GetMapping({"/ui/{fileName}"})
public String searchPanelUI(@PathVariable String fileName) {
return "/common/" + fileName;
}
}

View File

@ -19,7 +19,7 @@ import java.util.Random;
*/ */
public class RandomVerificationCodeUtil { public class RandomVerificationCodeUtil {
private static final Logger log = LoggerFactory.getLogger(RandomVerificationCodeUtil.class); private static final Logger logger = LoggerFactory.getLogger(RandomVerificationCodeUtil.class);
/** /**
* sessionkey * sessionkey
@ -104,7 +104,7 @@ public class RandomVerificationCodeUtil {
for (int i = 1; i <= stringNum; i++) { for (int i = 1; i <= stringNum; i++) {
randomString = drowString(g, randomString, i); randomString = drowString(g, randomString, i);
} }
log.info(randomString); logger.info(randomString);
// 将生成的随机字符串保存到session中 // 将生成的随机字符串保存到session中
session.removeAttribute(RANDOM_CODE_KEY); session.removeAttribute(RANDOM_CODE_KEY);
session.setAttribute(RANDOM_CODE_KEY, randomString); session.setAttribute(RANDOM_CODE_KEY, randomString);
@ -113,7 +113,7 @@ public class RandomVerificationCodeUtil {
// 将内存中的图片通过流动形式输出到客户端 // 将内存中的图片通过流动形式输出到客户端
ImageIO.write(image, "JPEG", response.getOutputStream()); ImageIO.write(image, "JPEG", response.getOutputStream());
} catch (Exception e) { } catch (Exception e) {
log.error("将内存中的图片通过流形式输出到客户端失败", e); logger.error("将内存中的图片通过流形式输出到客户端失败", e);
} }
} }

View File

@ -17,7 +17,7 @@ import java.util.concurrent.atomic.AtomicInteger;
*/ */
public class RetryLimitCredentialsMatcher extends HashedCredentialsMatcher { public class RetryLimitCredentialsMatcher extends HashedCredentialsMatcher {
Logger log = LoggerFactory.getLogger(RetryLimitCredentialsMatcher.class); Logger logger = LoggerFactory.getLogger(RetryLimitCredentialsMatcher.class);
private Cache<String, AtomicInteger> loginRetryCache; private Cache<String, AtomicInteger> loginRetryCache;
@ -48,9 +48,9 @@ public class RetryLimitCredentialsMatcher extends HashedCredentialsMatcher {
String username = (String) token.getPrincipal(); String username = (String) token.getPrincipal();
//retry count + 1 //retry count + 1
AtomicInteger retryCount = loginRetryCache.get(username) == null ? new AtomicInteger(0) : loginRetryCache.get(username); AtomicInteger retryCount = loginRetryCache.get(username) == null ? new AtomicInteger(0) : loginRetryCache.get(username);
log.info("retryCount:{}, username:{}", retryCount, username); logger.info("retryCount:{}, username:{}", retryCount, username);
if (retryCount.incrementAndGet() > this.maxRetryCount) { if (retryCount.incrementAndGet() > this.maxRetryCount) {
log.warn("username: {} tried to login more than {} times in perid", username, this.maxRetryCount); logger.warn("username: {} tried to login more than {} times in perid", username, this.maxRetryCount);
throw new ExcessiveAttemptsException("username: " + username + "tried to login more than " + this.maxRetryCount + " times in perid"); throw new ExcessiveAttemptsException("username: " + username + "tried to login more than " + this.maxRetryCount + " times in perid");
} }
boolean matches = super.doCredentialsMatch(token, info); boolean matches = super.doCredentialsMatch(token, info);
@ -59,7 +59,7 @@ public class RetryLimitCredentialsMatcher extends HashedCredentialsMatcher {
loginRetryCache.remove(username); loginRetryCache.remove(username);
} else { } else {
loginRetryCache.put(username, retryCount); loginRetryCache.put(username, retryCount);
log.info(String.valueOf(retryCount.get())); logger.info(String.valueOf(retryCount.get()));
} }
return matches; return matches;
} }

View File

@ -31,7 +31,7 @@ import java.util.Set;
*/ */
public class ShiroRealm extends AuthorizingRealm { public class ShiroRealm extends AuthorizingRealm {
Logger log = LoggerFactory.getLogger(ShiroRealm.class); Logger logger = LoggerFactory.getLogger(ShiroRealm.class);
@Autowired @Autowired
private ISysUserService sysUserService; private ISysUserService sysUserService;
@ -64,19 +64,19 @@ public class ShiroRealm extends AuthorizingRealm {
try { try {
user = sysUserService.getUserAndRoleAndMenuByUsername(username); user = sysUserService.getUserAndRoleAndMenuByUsername(username);
} catch (Exception e) { } catch (Exception e) {
log.error("账号数据查询异常,请联系管理员", e); logger.error("账号数据查询异常,请联系管理员", e);
throw new UnknownAccountException("账号数据查询异常,请联系管理员"); throw new UnknownAccountException("账号数据查询异常,请联系管理员");
} }
// 账号不存在 // 账号不存在
if (null == user) { if (null == user) {
log.error("账号不存在"); logger.error("账号不存在");
throw new UnknownAccountException("账号不存在"); throw new UnknownAccountException("账号不存在");
} }
// 账号锁定 // 账号锁定
if (!user.getDeleted().equals(SysUserEnum.DELETED_NORMAL.getCode())) { if (!user.getDeleted().equals(SysUserEnum.DELETED_NORMAL.getCode())) {
log.error("账号已被锁定,请联系管理员"); logger.error("账号已被锁定,请联系管理员");
throw new LockedAccountException("账号已被锁定,请联系管理员"); throw new LockedAccountException("账号已被锁定,请联系管理员");
} }
// TODO 根据用户名(唯一不可变)作为密码加盐,当然也可以自定义加盐方式,如增加数据库字段等 // TODO 根据用户名(唯一不可变)作为密码加盐,当然也可以自定义加盐方式,如增加数据库字段等

View File

@ -16,7 +16,7 @@ import javax.servlet.http.HttpServletResponse;
*/ */
public class SpLoginFormFilter extends FormAuthenticationFilter { public class SpLoginFormFilter extends FormAuthenticationFilter {
private static final Logger log = LoggerFactory.getLogger(SpLoginFormFilter.class); private static final Logger logger = LoggerFactory.getLogger(SpLoginFormFilter.class);
@Override @Override
protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception { protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
@ -24,20 +24,20 @@ public class SpLoginFormFilter extends FormAuthenticationFilter {
HttpServletResponse httpServletResponse = (HttpServletResponse) response; HttpServletResponse httpServletResponse = (HttpServletResponse) response;
if (isLoginRequest(request, response)) { if (isLoginRequest(request, response)) {
if (isLoginSubmission(request, response)) { if (isLoginSubmission(request, response)) {
if (log.isTraceEnabled()) { if (logger.isTraceEnabled()) {
log.trace("Login submission detected. Attempting to execute login."); logger.trace("Login submission detected. Attempting to execute login.");
} }
return executeLogin(request, response); return executeLogin(request, response);
} else { } else {
if (log.isTraceEnabled()) { if (logger.isTraceEnabled()) {
log.trace("Login page view."); logger.trace("Login page view.");
} }
//allow them to see the login page //allow them to see the login page
return true; return true;
} }
} else { } else {
if (log.isTraceEnabled()) { if (logger.isTraceEnabled()) {
log.trace("Attempting to access a path which requires authentication. Forwarding to the " + logger.trace("Attempting to access a path which requires authentication. Forwarding to the " +
"Authentication url [" + getLoginUrl() + "]"); "Authentication url [" + getLoginUrl() + "]");
} }
//如果是Ajax请求不跳转登录 //如果是Ajax请求不跳转登录

View File

@ -34,7 +34,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
@RequestMapping("/admin/sys/department") @RequestMapping("/admin/sys/department")
public class SysDepartmentController extends BaseController { public class SysDepartmentController extends BaseController {
Logger log = LoggerFactory.getLogger(SysDepartmentController.class); Logger logger = LoggerFactory.getLogger(SysDepartmentController.class);
@Autowired @Autowired
private ISysDepartmentService sysDepartmentService; private ISysDepartmentService sysDepartmentService;

View File

@ -35,7 +35,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
@RequestMapping("/admin/sys/dict") @RequestMapping("/admin/sys/dict")
public class SysDictController extends BaseController { public class SysDictController extends BaseController {
Logger log = LoggerFactory.getLogger(SysDictController.class); Logger logger = LoggerFactory.getLogger(SysDictController.class);
@Autowired @Autowired
private ISysDictService sysDictService; private ISysDictService sysDictService;

View File

@ -1,5 +1,6 @@
package com.songpeng.sparchetype.system.controller.admin; package com.songpeng.sparchetype.system.controller.admin;
import com.songpeng.sparchetype.common.BaseController;
import com.songpeng.sparchetype.common.Result; import com.songpeng.sparchetype.common.Result;
import com.songpeng.sparchetype.system.service.ISysMenuService; import com.songpeng.sparchetype.system.service.ISysMenuService;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -22,9 +23,9 @@ import java.util.Map;
*/ */
@RequestMapping("/admin") @RequestMapping("/admin")
@Controller("adminSysLoginController") @Controller("adminSysLoginController")
public class SysLoginController { public class SysLoginController extends BaseController {
Logger log = LoggerFactory.getLogger(SysLoginController.class); Logger logger = LoggerFactory.getLogger(SysLoginController.class);
/** /**
* Service * Service

View File

@ -21,7 +21,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
@RequestMapping("/admin/sys/tool") @RequestMapping("/admin/sys/tool")
public class SysToolController extends BaseController { public class SysToolController extends BaseController {
Logger log = LoggerFactory.getLogger(SysToolController.class); Logger logger = LoggerFactory.getLogger(SysToolController.class);
/** /**
* *

View File

@ -35,7 +35,7 @@ import java.util.List;
@RequestMapping("/admin/sys/user") @RequestMapping("/admin/sys/user")
public class SysUserController extends BaseController { public class SysUserController extends BaseController {
Logger log = LoggerFactory.getLogger(SysUserController.class); Logger logger = LoggerFactory.getLogger(SysUserController.class);
@Autowired @Autowired
private ISysUserService sysUserService; private ISysUserService sysUserService;
@ -52,6 +52,12 @@ public class SysUserController extends BaseController {
@ResponseBody @ResponseBody
public Result page(SysUserPageReq req) throws Exception { public Result page(SysUserPageReq req) throws Exception {
QueryWrapper qw = new QueryWrapper(); QueryWrapper qw = new QueryWrapper();
if (StringUtils.isNotEmpty(req.getNameLike())) {
qw.likeRight("name", req.getNameLike());
}
if (StringUtils.isNotEmpty(req.getUsernameLike())) {
qw.likeRight("username", req.getUsernameLike());
}
qw.orderByDesc(req.getOrderBy()); qw.orderByDesc(req.getOrderBy());
IPage page = sysUserService.page(req, qw); IPage page = sysUserService.page(req, qw);
return Result.success(page); return Result.success(page);

View File

@ -26,7 +26,7 @@ import javax.servlet.http.HttpServletResponse;
@Controller("clientSysLoginController") @Controller("clientSysLoginController")
public class SysLoginController { public class SysLoginController {
Logger log = LoggerFactory.getLogger(SysLoginController.class); Logger logger = LoggerFactory.getLogger(SysLoginController.class);
/** /**
* *
@ -55,7 +55,7 @@ public class SysLoginController {
// 输出验证码图片方法 // 输出验证码图片方法
randomValidateCode.getRandcode(request, response); randomValidateCode.getRandcode(request, response);
} catch (Exception e) { } catch (Exception e) {
log.error("获取验证码失败", e); logger.error("获取验证码失败", e);
} }
} }
@ -90,25 +90,25 @@ public class SysLoginController {
subject.login(token); subject.login(token);
return Result.success(); return Result.success();
} catch (LockedAccountException e) { } catch (LockedAccountException e) {
log.error("锁定的帐号", e); logger.error("锁定的帐号", e);
return Result.failure("锁定的帐号"); return Result.failure("锁定的帐号");
} catch (DisabledAccountException e) { } catch (DisabledAccountException e) {
log.error("禁用的帐号", e); logger.error("禁用的帐号", e);
return Result.failure("禁用的帐号"); return Result.failure("禁用的帐号");
} catch (UnknownAccountException e) { } catch (UnknownAccountException e) {
log.error("错误的帐号", e); logger.error("错误的帐号", e);
return Result.failure("错误的帐号"); return Result.failure("错误的帐号");
} catch (ExcessiveAttemptsException e) { } catch (ExcessiveAttemptsException e) {
log.error("登录失败次数过多", e); logger.error("登录失败次数过多", e);
return Result.failure("登录失败次数过多"); return Result.failure("登录失败次数过多");
} catch (IncorrectCredentialsException e) { } catch (IncorrectCredentialsException e) {
log.error("错误的凭证", e); logger.error("错误的凭证", e);
return Result.failure("错误的凭证"); return Result.failure("错误的凭证");
} catch (ExpiredCredentialsException e) { } catch (ExpiredCredentialsException e) {
log.error("过期的凭证", e); logger.error("过期的凭证", e);
return Result.failure("过期的凭证"); return Result.failure("过期的凭证");
} catch (AuthenticationException e) { } catch (AuthenticationException e) {
log.error("用户或密码错误", e); logger.error("用户或密码错误", e);
return Result.failure("用户或密码错误"); return Result.failure("用户或密码错误");
} }
} }

View File

@ -12,4 +12,29 @@ import com.songpeng.sparchetype.common.BasePageReq;
*/ */
public class SysUserPageReq extends BasePageReq { public class SysUserPageReq extends BasePageReq {
/**
*
*/
private String nameLike;
/**
*
*/
private String usernameLike;
public String getNameLike() {
return nameLike;
}
public void setNameLike(String nameLike) {
this.nameLike = nameLike;
}
public String getUsernameLike() {
return usernameLike;
}
public void setUsernameLike(String usernameLike) {
this.usernameLike = usernameLike;
}
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@ -1,7 +1,5 @@
/** /**
* date:2019/08/16 * 宋鹏layui 自定义组件配置
* author:Mr.Chung
* description:此处放layui自定义扩展
*/ */
window.rootPath = (function (src) { window.rootPath = (function (src) {
src = document.scripts[document.scripts.length - 1].src; src = document.scripts[document.scripts.length - 1].src;
@ -13,7 +11,15 @@ layui.config({
version: true version: true
}).extend({ }).extend({
// layui扩展 // layui扩展
splayui: "splayui/splayui", spLayui: "sp/spLayui",
// 自定义layer扩展组件
spLayer: 'sp/spLayer',
// 自定义table扩展组件
spTable: 'sp/spTable',
// 自定义table扩展组件
spSearchPanel: 'sp/spSearchPanel',
// 大气风格的网络公司企业模版
spCompany: 'sp/spCompany',
// 分步表单扩展 // 分步表单扩展
step: 'step-lay/step', step: 'step-lay/step',
//table树形扩展 //table树形扩展
@ -22,16 +28,6 @@ layui.config({
tableSelect: 'tableSelect/tableSelect', tableSelect: 'tableSelect/tableSelect',
// fa图标选择扩展 // fa图标选择扩展
iconPickerFa: 'iconPicker/iconPickerFa', iconPickerFa: 'iconPicker/iconPickerFa',
// echarts图表扩展
echarts: 'echarts/echarts',
// echarts图表主题扩展
echartsTheme: 'echarts/echartsTheme',
// wangEditor富文本扩展 // wangEditor富文本扩展
wangEditor: 'wangEditor/wangEditor', wangEditor: 'wangEditor/wangEditor'
// 自定义layer扩展组件
splayer: 'splayer/splayer',
// 自定义table扩展组件
sptable: 'sptable/sptable',
// 大气风格的网络公司企业模版
company: 'company/company'
}); });

File diff suppressed because one or more lines are too long

View File

@ -1,492 +0,0 @@
layui.define(function(exports) {
exports('echartsTheme',
{
"color": [
"#3fb1e3",
"#6be6c1",
"#626c91",
"#a0a7e6",
"#c4ebad",
"#96dee8"
],
"backgroundColor": "rgba(252,252,252,0)",
"textStyle": {},
"title": {
"textStyle": {
"color": "#666666"
},
"subtextStyle": {
"color": "#999999"
}
},
"line": {
"itemStyle": {
"normal": {
"borderWidth": "3"
}
},
"lineStyle": {
"normal": {
"width": "4"
}
},
"symbolSize": "10",
"symbol": "emptyCircle",
"smooth": true
},
"radar": {
"itemStyle": {
"normal": {
"borderWidth": "3"
}
},
"lineStyle": {
"normal": {
"width": "4"
}
},
"symbolSize": "10",
"symbol": "emptyCircle",
"smooth": true
},
"bar": {
"itemStyle": {
"normal": {
"barBorderWidth": 0,
"barBorderColor": "#ccc"
},
"emphasis": {
"barBorderWidth": 0,
"barBorderColor": "#ccc"
}
}
},
"pie": {
"itemStyle": {
"normal": {
"borderWidth": 0,
"borderColor": "#ccc"
},
"emphasis": {
"borderWidth": 0,
"borderColor": "#ccc"
}
}
},
"scatter": {
"itemStyle": {
"normal": {
"borderWidth": 0,
"borderColor": "#ccc"
},
"emphasis": {
"borderWidth": 0,
"borderColor": "#ccc"
}
}
},
"boxplot": {
"itemStyle": {
"normal": {
"borderWidth": 0,
"borderColor": "#ccc"
},
"emphasis": {
"borderWidth": 0,
"borderColor": "#ccc"
}
}
},
"parallel": {
"itemStyle": {
"normal": {
"borderWidth": 0,
"borderColor": "#ccc"
},
"emphasis": {
"borderWidth": 0,
"borderColor": "#ccc"
}
}
},
"sankey": {
"itemStyle": {
"normal": {
"borderWidth": 0,
"borderColor": "#ccc"
},
"emphasis": {
"borderWidth": 0,
"borderColor": "#ccc"
}
}
},
"funnel": {
"itemStyle": {
"normal": {
"borderWidth": 0,
"borderColor": "#ccc"
},
"emphasis": {
"borderWidth": 0,
"borderColor": "#ccc"
}
}
},
"gauge": {
"itemStyle": {
"normal": {
"borderWidth": 0,
"borderColor": "#ccc"
},
"emphasis": {
"borderWidth": 0,
"borderColor": "#ccc"
}
}
},
"candlestick": {
"itemStyle": {
"normal": {
"color": "#e6a0d2",
"color0": "transparent",
"borderColor": "#e6a0d2",
"borderColor0": "#3fb1e3",
"borderWidth": "2"
}
}
},
"graph": {
"itemStyle": {
"normal": {
"borderWidth": 0,
"borderColor": "#ccc"
}
},
"lineStyle": {
"normal": {
"width": "1",
"color": "#cccccc"
}
},
"symbolSize": "10",
"symbol": "emptyCircle",
"smooth": true,
"color": [
"#3fb1e3",
"#6be6c1",
"#626c91",
"#a0a7e6",
"#c4ebad",
"#96dee8"
],
"label": {
"normal": {
"textStyle": {
"color": "#ffffff"
}
}
}
},
"map": {
"itemStyle": {
"normal": {
"areaColor": "#eeeeee",
"borderColor": "#aaaaaa",
"borderWidth": 0.5
},
"emphasis": {
"areaColor": "rgba(63,177,227,0.25)",
"borderColor": "#3fb1e3",
"borderWidth": 1
}
},
"label": {
"normal": {
"textStyle": {
"color": "#ffffff"
}
},
"emphasis": {
"textStyle": {
"color": "rgb(63,177,227)"
}
}
}
},
"geo": {
"itemStyle": {
"normal": {
"areaColor": "#eeeeee",
"borderColor": "#aaaaaa",
"borderWidth": 0.5
},
"emphasis": {
"areaColor": "rgba(63,177,227,0.25)",
"borderColor": "#3fb1e3",
"borderWidth": 1
}
},
"label": {
"normal": {
"textStyle": {
"color": "#ffffff"
}
},
"emphasis": {
"textStyle": {
"color": "rgb(63,177,227)"
}
}
}
},
"categoryAxis": {
"axisLine": {
"show": true,
"lineStyle": {
"color": "#cccccc"
}
},
"axisTick": {
"show": false,
"lineStyle": {
"color": "#333"
}
},
"axisLabel": {
"show": true,
"textStyle": {
"color": "#999999"
}
},
"splitLine": {
"show": true,
"lineStyle": {
"color": [
"#eeeeee"
]
}
},
"splitArea": {
"show": false,
"areaStyle": {
"color": [
"rgba(250,250,250,0.05)",
"rgba(200,200,200,0.02)"
]
}
}
},
"valueAxis": {
"axisLine": {
"show": true,
"lineStyle": {
"color": "#cccccc"
}
},
"axisTick": {
"show": false,
"lineStyle": {
"color": "#333"
}
},
"axisLabel": {
"show": true,
"textStyle": {
"color": "#999999"
}
},
"splitLine": {
"show": true,
"lineStyle": {
"color": [
"#eeeeee"
]
}
},
"splitArea": {
"show": false,
"areaStyle": {
"color": [
"rgba(250,250,250,0.05)",
"rgba(200,200,200,0.02)"
]
}
}
},
"logAxis": {
"axisLine": {
"show": true,
"lineStyle": {
"color": "#cccccc"
}
},
"axisTick": {
"show": false,
"lineStyle": {
"color": "#333"
}
},
"axisLabel": {
"show": true,
"textStyle": {
"color": "#999999"
}
},
"splitLine": {
"show": true,
"lineStyle": {
"color": [
"#eeeeee"
]
}
},
"splitArea": {
"show": false,
"areaStyle": {
"color": [
"rgba(250,250,250,0.05)",
"rgba(200,200,200,0.02)"
]
}
}
},
"timeAxis": {
"axisLine": {
"show": true,
"lineStyle": {
"color": "#cccccc"
}
},
"axisTick": {
"show": false,
"lineStyle": {
"color": "#333"
}
},
"axisLabel": {
"show": true,
"textStyle": {
"color": "#999999"
}
},
"splitLine": {
"show": true,
"lineStyle": {
"color": [
"#eeeeee"
]
}
},
"splitArea": {
"show": false,
"areaStyle": {
"color": [
"rgba(250,250,250,0.05)",
"rgba(200,200,200,0.02)"
]
}
}
},
"toolbox": {
"iconStyle": {
"normal": {
"borderColor": "#999999"
},
"emphasis": {
"borderColor": "#666666"
}
}
},
"legend": {
"textStyle": {
"color": "#999999"
}
},
"tooltip": {
"axisPointer": {
"lineStyle": {
"color": "#cccccc",
"width": 1
},
"crossStyle": {
"color": "#cccccc",
"width": 1
}
}
},
"timeline": {
"lineStyle": {
"color": "#626c91",
"width": 1
},
"itemStyle": {
"normal": {
"color": "#626c91",
"borderWidth": 1
},
"emphasis": {
"color": "#626c91"
}
},
"controlStyle": {
"normal": {
"color": "#626c91",
"borderColor": "#626c91",
"borderWidth": 0.5
},
"emphasis": {
"color": "#626c91",
"borderColor": "#626c91",
"borderWidth": 0.5
}
},
"checkpointStyle": {
"color": "#3fb1e3",
"borderColor": "rgba(63,177,227,0.15)"
},
"label": {
"normal": {
"textStyle": {
"color": "#626c91"
}
},
"emphasis": {
"textStyle": {
"color": "#626c91"
}
}
}
},
"visualMap": {
"color": [
"#2a99c9",
"#afe8ff"
]
},
"dataZoom": {
"backgroundColor": "rgba(255,255,255,0)",
"dataBackgroundColor": "rgba(222,222,222,1)",
"fillerColor": "rgba(114,230,212,0.25)",
"handleColor": "#cccccc",
"handleSize": "100%",
"textStyle": {
"color": "#999999"
}
},
"markPoint": {
"label": {
"normal": {
"textStyle": {
"color": "#ffffff"
}
},
"emphasis": {
"textStyle": {
"color": "#ffffff"
}
}
}
}
});
});

View File

@ -93,5 +93,5 @@ layui.define(['jquery', 'element', 'carousel', 'laypage'], function (exports) {
}); });
}); });
exports('company', {}); exports('spCompany', {});
}); });

View File

@ -1,13 +1,11 @@
/** /**
* date: 2019/12/24 * 组件扩展layui弹出框
* author: SongPeng
* description: 扩展layui弹出框 框架扩展
*/ */
layui.define(['layer'], function (exports) { layui.define(['layer'], function (exports) {
var $ = layui.jquery, var $ = layui.jquery,
layer = layui.layer; layer = layui.layer;
var splayer = { var spLayer = {
// 渲染弹出框 // 渲染弹出框
open: function (param) { open: function (param) {
// 默认配置 // 默认配置
@ -20,6 +18,12 @@ layui.define(['layer'], function (exports) {
//点击确认触发 iframe 内容中的按钮提交 //点击确认触发 iframe 内容中的按钮提交
var submit = layero.find('iframe').contents().find("#js-submit"); var submit = layero.find('iframe').contents().find("#js-submit");
submit.click(); submit.click();
// 如果是搜索弹窗面板,之下如下逻辑,以便调用页面可以通过回调函数获取数据
if (param.spCallback && (param.spCallback instanceof Function)) {
var callbackData = layero.find('iframe')[0].contentWindow.callbackData();
param.spCallback(callbackData);
}
}, },
btn2: function (index, layero) { btn2: function (index, layero) {
//按钮【按钮二】的回调 //按钮【按钮二】的回调
@ -41,9 +45,10 @@ layui.define(['layer'], function (exports) {
content: param.content + '?' + spUtil.parseParam(param.spWhere) content: param.content + '?' + spUtil.parseParam(param.spWhere)
}); });
layer.open(config); return layer.open(config);
} },
checkStatus: {}
}; };
exports('splayer', splayer); exports('spLayer', spLayer);
}); });

View File

@ -1,7 +1,5 @@
/** /**
* date:2019/06/10 * 组件后台管理页面
* author:Mr.Chung
* description:splayui 框架扩展
*/ */
layui.define(["element", "jquery"], function (exports) { layui.define(["element", "jquery"], function (exports) {
var element = layui.element, var element = layui.element,
@ -13,7 +11,7 @@ layui.define(["element", "jquery"], function (exports) {
return layer.alert("请先将项目部署至web容器Apache/Tomcat/Nginx/IIS/等),否则部分数据将无法显示"); return layer.alert("请先将项目部署至web容器Apache/Tomcat/Nginx/IIS/等),否则部分数据将无法显示");
} }
splayui = new function () { spLayui = new function () {
/** /**
* 系统配置 * 系统配置
@ -42,20 +40,20 @@ layui.define(["element", "jquery"], function (exports) {
*/ */
this.init = function (url) { this.init = function (url) {
var loading = layer.load(0, {shade: false, time: 2 * 1000}); var loading = layer.load(0, {shade: false, time: 2 * 1000});
splayui.initBgColor(); spLayui.initBgColor();
splayui.initDevice(); spLayui.initDevice();
$.getJSON(url, function (data, status) { $.getJSON(url, function (data, status) {
if (!data.data) { if (!data.data) {
splayui.msg_error('暂无菜单信息'); spLayui.msg_error('暂无菜单信息');
} else { } else {
splayui.initHome(data.data.homeInfo); spLayui.initHome(data.data.homeInfo);
splayui.initLogo(data.data.logoInfo); spLayui.initLogo(data.data.logoInfo);
splayui.initClear(data.data.clearInfo); spLayui.initClear(data.data.clearInfo);
splayui.initMenu(data.data.menuInfo); spLayui.initMenu(data.data.menuInfo);
splayui.initTab(); spLayui.initTab();
} }
}).fail(function () { }).fail(function () {
splayui.msg_error('菜单接口有误'); spLayui.msg_error('菜单接口有误');
}); });
layer.close(loading); layer.close(loading);
}; };
@ -64,7 +62,7 @@ layui.define(["element", "jquery"], function (exports) {
* 初始化设备端 * 初始化设备端
*/ */
this.initDevice = function () { this.initDevice = function () {
if (splayui.checkMobile()) { if (spLayui.checkMobile()) {
$('.splayui-tool i').attr('data-side-fold', 0); $('.splayui-tool i').attr('data-side-fold', 0);
$('.splayui-tool i').attr('class', 'fa fa-indent'); $('.splayui-tool i').attr('class', 'fa fa-indent');
$('.layui-layout-body').attr('class', 'layui-layout-body splayui-admin'); $('.layui-layout-body').attr('class', 'layui-layout-body splayui-admin');
@ -108,9 +106,9 @@ layui.define(["element", "jquery"], function (exports) {
this.initBgColor = function () { this.initBgColor = function () {
var bgcolorId = sessionStorage.getItem('splayuiBgcolorId'); var bgcolorId = sessionStorage.getItem('splayuiBgcolorId');
if (bgcolorId == null || bgcolorId == undefined || bgcolorId == '') { if (bgcolorId == null || bgcolorId == undefined || bgcolorId == '') {
bgcolorId = splayui.config('BgColorDefault'); bgcolorId = spLayui.config('BgColorDefault');
} }
var bgcolorData = splayui.bgColorConfig(bgcolorId); var bgcolorData = spLayui.bgColorConfig(bgcolorId);
var styleHtml = '.layui-layout-admin .layui-header{background-color:' + bgcolorData.headerRight + '!important;}\n' + var styleHtml = '.layui-layout-admin .layui-header{background-color:' + bgcolorData.headerRight + '!important;}\n' +
'.layui-header>ul>.layui-nav-item.layui-this,.splayui-tool i:hover{background-color:' + bgcolorData.headerRightThis + '!important;}\n' + '.layui-header>ul>.layui-nav-item.layui-this,.splayui-tool i:hover{background-color:' + bgcolorData.headerRightThis + '!important;}\n' +
'.layui-layout-admin .layui-logo {background-color:' + bgcolorData.headerLogo + '!important;}\n' + '.layui-layout-admin .layui-logo {background-color:' + bgcolorData.headerLogo + '!important;}\n' +
@ -186,13 +184,13 @@ layui.define(["element", "jquery"], function (exports) {
var href = urlArr.pop(); var href = urlArr.pop();
// 判断链接是否有效 // 判断链接是否有效
var checkUrl = splayui.checkUrl(href); var checkUrl = spLayui.checkUrl(href);
if (checkUrl != true) { if (checkUrl != true) {
return splayui.msg_error(checkUrl); return spLayui.msg_error(checkUrl);
} }
// 判断tab是否存在 // 判断tab是否存在
var checkTab = splayui.checkTab(href); var checkTab = spLayui.checkTab(href);
if (!checkTab) { if (!checkTab) {
var title = href, var title = href,
tabId = href; tabId = href;
@ -200,7 +198,7 @@ layui.define(["element", "jquery"], function (exports) {
var checkHref = $(this).attr("data-tab"); var checkHref = $(this).attr("data-tab");
// 判断是否带参数了 // 判断是否带参数了
if (splayui.config('urlSuffixDefault')) { if (spLayui.config('urlSuffixDefault')) {
if (href.indexOf("mpi=") > -1) { if (href.indexOf("mpi=") > -1) {
var menuParameId = $(this).attr('data-tab-mpi'); var menuParameId = $(this).attr('data-tab-mpi');
if (checkHref.indexOf("?") > -1) { if (checkHref.indexOf("?") > -1) {
@ -259,13 +257,13 @@ layui.define(["element", "jquery"], function (exports) {
} }
if (splayuiHomeTab != href && splayuiHomeHref != href) { if (splayuiHomeTab != href && splayuiHomeHref != href) {
splayui.addTab(tabId, href, title, true); spLayui.addTab(tabId, href, title, true);
splayui.changeTab(tabId); spLayui.changeTab(tabId);
} }
} }
} }
if (splayui.config('urlHashLocation')) { if (spLayui.config('urlHashLocation')) {
splayui.hashTab(); spLayui.hashTab();
} }
}; };
@ -391,7 +389,7 @@ layui.define(["element", "jquery"], function (exports) {
if (bgcolorId == null || bgcolorId == undefined || bgcolorId == '') { if (bgcolorId == null || bgcolorId == undefined || bgcolorId == '') {
bgcolorId = 0; bgcolorId = 0;
} }
var bgColorConfig = splayui.bgColorConfig(); var bgColorConfig = spLayui.bgColorConfig();
$.each(bgColorConfig, function (key, val) { $.each(bgColorConfig, function (key, val) {
if (key == bgcolorId) { if (key == bgcolorId) {
html += '<li class="layui-this" data-select-bgcolor="' + key + '">\n'; html += '<li class="layui-this" data-select-bgcolor="' + key + '">\n';
@ -522,7 +520,7 @@ layui.define(["element", "jquery"], function (exports) {
* @returns {boolean} * @returns {boolean}
*/ */
this.checkUrl = function (url) { this.checkUrl = function (url) {
if (!splayui.config('checkUrlDefault')) { if (!spLayui.config('checkUrlDefault')) {
return true; return true;
} }
var msg = true; var msg = true;
@ -661,9 +659,9 @@ layui.define(["element", "jquery"], function (exports) {
$parent = $(this).parent(); $parent = $(this).parent();
tabId = $parent.attr('lay-id'); tabId = $parent.attr('lay-id');
if (tabId != undefined || tabId != null) { if (tabId != undefined || tabId != null) {
splayui.delTab(tabId); spLayui.delTab(tabId);
} }
splayui.tabRoll(); spLayui.tabRoll();
layer.close(loading); layer.close(loading);
}); });
@ -684,7 +682,7 @@ layui.define(["element", "jquery"], function (exports) {
title = title.replace('style="display: none;"', ''); title = title.replace('style="display: none;"', '');
// 拼接参数 // 拼接参数
if (splayui.config('urlSuffixDefault')) { if (spLayui.config('urlSuffixDefault')) {
var menuParameId = $(this).attr('data-tab-mpi'); var menuParameId = $(this).attr('data-tab-mpi');
if (href.indexOf("?") > -1) { if (href.indexOf("?") > -1) {
href = href + '&mpi=' + menuParameId; href = href + '&mpi=' + menuParameId;
@ -696,22 +694,22 @@ layui.define(["element", "jquery"], function (exports) {
} }
// 判断链接是否有效 // 判断链接是否有效
var checkUrl = splayui.checkUrl(href); var checkUrl = spLayui.checkUrl(href);
if (checkUrl != true) { if (checkUrl != true) {
return splayui.msg_error(checkUrl); return spLayui.msg_error(checkUrl);
} }
if (tabId == null || tabId == undefined) { if (tabId == null || tabId == undefined) {
tabId = new Date().getTime(); tabId = new Date().getTime();
} }
// 判断该窗口是否已经打开过 // 判断该窗口是否已经打开过
var checkTab = splayui.checkTab(tabId); var checkTab = spLayui.checkTab(tabId);
if (!checkTab) { if (!checkTab) {
splayui.addTab(tabId, href, title, true); spLayui.addTab(tabId, href, title, true);
} }
element.tabChange('splayuiTab', tabId); element.tabChange('splayuiTab', tabId);
splayui.initDevice(); spLayui.initDevice();
splayui.tabRoll(); spLayui.tabRoll();
layer.close(loading); layer.close(loading);
}); });
@ -735,7 +733,7 @@ layui.define(["element", "jquery"], function (exports) {
tabId = new Date().getTime(); tabId = new Date().getTime();
} }
// 判断该窗口是否已经打开过 // 判断该窗口是否已经打开过
var checkTab = splayui.checkTab(tabId, true); var checkTab = spLayui.checkTab(tabId, true);
if (!checkTab) { if (!checkTab) {
var splayuiTabInfo = JSON.parse(sessionStorage.getItem("splayuiTabInfo")); var splayuiTabInfo = JSON.parse(sessionStorage.getItem("splayuiTabInfo"));
if (splayuiTabInfo == null) { if (splayuiTabInfo == null) {
@ -750,7 +748,7 @@ layui.define(["element", "jquery"], function (exports) {
}); });
} }
parent.layui.element.tabChange('splayuiTab', tabId); parent.layui.element.tabChange('splayuiTab', tabId);
splayui.tabRoll(); spLayui.tabRoll();
parent.layer.close(loading); parent.layer.close(loading);
}); });
@ -785,17 +783,17 @@ layui.define(["element", "jquery"], function (exports) {
$.getJSON(clearUrl, function (data, status) { $.getJSON(clearUrl, function (data, status) {
layer.close(loading); layer.close(loading);
if (data.code != 1) { if (data.code != 1) {
return splayui.msg_error(data.msg); return spLayui.msg_error(data.msg);
} else { } else {
return splayui.msg_success(data.msg); return spLayui.msg_success(data.msg);
} }
}).fail(function () { }).fail(function () {
layer.close(loading); layer.close(loading);
return splayui.msg_error('清理缓存接口有误'); return spLayui.msg_error('清理缓存接口有误');
}); });
} else { } else {
layer.close(loading); layer.close(loading);
return splayui.msg_success('清除缓存成功'); return spLayui.msg_success('清除缓存成功');
} }
}); });
@ -804,7 +802,7 @@ layui.define(["element", "jquery"], function (exports) {
*/ */
$('body').on('click', '[data-refresh]', function () { $('body').on('click', '[data-refresh]', function () {
$(".layui-tab-item.layui-show").find("iframe")[0].contentWindow.location.reload(); $(".layui-tab-item.layui-show").find("iframe")[0].contentWindow.location.reload();
splayui.msg_success('刷新成功'); spLayui.msg_success('刷新成功');
}); });
/** /**
@ -819,15 +817,15 @@ layui.define(["element", "jquery"], function (exports) {
if (id != 'splayuiHomeTabId') { if (id != 'splayuiHomeTabId') {
var tabClass = $(this).attr('class'); var tabClass = $(this).attr('class');
if (closeType == 'all') { if (closeType == 'all') {
splayui.delTab(tabId); spLayui.delTab(tabId);
} else { } else {
if (tabClass != 'layui-this') { if (tabClass != 'layui-this') {
splayui.delTab(tabId); spLayui.delTab(tabId);
} }
} }
} }
}); });
splayui.tabRoll(); spLayui.tabRoll();
layer.close(loading); layer.close(loading);
}); });
@ -846,7 +844,7 @@ layui.define(["element", "jquery"], function (exports) {
$('.splayui-tool i').attr('class', 'fa fa-outdent'); $('.splayui-tool i').attr('class', 'fa fa-outdent');
$('.layui-layout-body').attr('class', 'layui-layout-body splayui-all'); $('.layui-layout-body').attr('class', 'layui-layout-body splayui-all');
} }
splayui.tabRoll(); spLayui.tabRoll();
element.init(); element.init();
layer.close(loading); layer.close(loading);
}); });
@ -879,7 +877,7 @@ layui.define(["element", "jquery"], function (exports) {
$('body').on('click', '[data-bgcolor]', function () { $('body').on('click', '[data-bgcolor]', function () {
var loading = layer.load(0, {shade: false, time: 2 * 1000}); var loading = layer.load(0, {shade: false, time: 2 * 1000});
var clientHeight = (document.documentElement.clientHeight) - 95; var clientHeight = (document.documentElement.clientHeight) - 95;
var bgColorHtml = splayui.buildBgColorHtml(); var bgColorHtml = spLayui.buildBgColorHtml();
var html = '<div class="splayui-color">\n' + var html = '<div class="splayui-color">\n' +
'<div class="color-title">\n' + '<div class="color-title">\n' +
'<span>配色方案</span>\n' + '<span>配色方案</span>\n' +
@ -914,8 +912,8 @@ layui.define(["element", "jquery"], function (exports) {
$('.splayui-color .color-content ul .layui-this').attr('class', ''); $('.splayui-color .color-content ul .layui-this').attr('class', '');
$(this).attr('class', 'layui-this'); $(this).attr('class', 'layui-this');
sessionStorage.setItem('splayuiBgcolorId', bgcolorId); sessionStorage.setItem('splayuiBgcolorId', bgcolorId);
splayui.initBgColor(); spLayui.initBgColor();
}); });
exports("splayui", splayui); exports("spLayui", spLayui);
}); })

View File

@ -1,13 +1,11 @@
/** /**
* date: 2019/12/24 * 组件扩展layui数据表格
* author: SongPeng
* description: 扩展layui数据表格 框架扩展
*/ */
layui.define(['table'], function (exports) { layui.define(['table'], function (exports) {
var $ = layui.jquery, var $ = layui.jquery,
table = layui.table; table = layui.table;
var sptable = { var spSearchPanel = {
// 渲染表格 // 渲染表格
render: function (param) { render: function (param) {
var defaultConfig = { var defaultConfig = {
@ -39,5 +37,5 @@ layui.define(['table'], function (exports) {
} }
}; };
exports('sptable', sptable); exports('spSearchPanel', spSearchPanel);
}); });

View File

@ -0,0 +1,41 @@
/**
* 组件扩展layui数据表格
*/
layui.define(['table'], function (exports) {
var $ = layui.jquery,
table = layui.table;
var spTable = {
// 渲染表格
render: function (param) {
var defaultConfig = {
elem: '#js-record-table',
toolbar: '#js-record-table-toolbar-top',
method: 'POST',
limits: [10, 20, 50, 100],
limit: 10,
page: true,
height: 'full-' + ($('#js-search-form').height() + 40),
request: {
pageName: 'current'
, limitName: 'size'
},
parseData: function (res) {
return {
"code": res.code,
"msg": res.msg,
"count": res.data ? res.data.total : 0,
"data": res.data ? res.data.records : []
};
}
};
var config = $.extend({}, defaultConfig, param, {
});
return table.render(config);
}
};
exports('spTable', spTable);
});

File diff suppressed because one or more lines are too long

View File

@ -89,12 +89,12 @@
</div> </div>
</div> </div>
<script> <script>
layui.use(['element', 'layer', 'splayui'], function () { layui.use(['element', 'layer', 'spLayui'], function () {
var element = layui.element, var element = layui.element,
layer = layui.layer, layer = layui.layer,
splayui = layui.splayui; spLayui = layui.spLayui;
splayui.init('${request.contextPath}/admin/list/index/menu/tree'); spLayui.init('${request.contextPath}/admin/list/index/menu/tree');
}); });
</script> </script>
</body> </body>

View File

@ -27,7 +27,7 @@
</div> </div>
</div> </div>
<div class="layui-inline"> <div class="layui-inline">
<a class="layui-btn" lay-submit lay-filter="js-search-filter"><i class="layui-icon layui-icon-search layuiadmin-button-btn"></i></a> <a class="layui-btn" lay-submit lay-filter="js-search-filter"><i class="layui-icon layui-icon-search"></i></a>
</div> </div>
</div> </div>
</form> </form>
@ -43,6 +43,7 @@
<button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="deleteBatch"><i class="layui-icon">&#xe640;</i>批量删除</button> <button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="deleteBatch"><i class="layui-icon">&#xe640;</i>批量删除</button>
<@shiro.hasPermission name="user:add"> <@shiro.hasPermission name="user:add">
<button class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon">&#xe61f;</i>添加</button> <button class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon">&#xe61f;</i>添加</button>
<button class="layui-btn layui-btn-sm" lay-event="spSearchPanel"><i class="layui-icon">&#xe61f;</i>测试搜索弹框</button>
</@shiro.hasPermission> </@shiro.hasPermission>
</div> </div>
</script> </script>
@ -55,14 +56,14 @@
<!--js逻辑--> <!--js逻辑-->
<script> <script>
layui.use(['form', 'table', 'splayer', 'sptable'], function () { layui.use(['form', 'table', 'spLayer', 'spTable'], function () {
var form = layui.form, var form = layui.form,
table = layui.table, table = layui.table,
splayer = layui.splayer, spLayer = layui.spLayer,
sptable = layui.sptable; spTable = layui.spTable;
// 表格及数据初始化 // 表格及数据初始化
var tableIns = sptable.render({ var tableIns = spTable.render({
url: '${request.contextPath}/admin/sys/user/page', url: '${request.contextPath}/admin/sys/user/page',
cols: [ cols: [
[{ [{
@ -160,13 +161,31 @@
// 添加 // 添加
if (obj.event === 'add') { if (obj.event === 'add') {
var index = splayer.open({ var index = spLayer.open({
title: '添加', title: '添加',
area: ['90%', '90%'], area: ['90%', '90%'],
content: '${request.contextPath}/admin/sys/user/add-or-update-ui' content: '${request.contextPath}/admin/sys/user/add-or-update-ui'
}); });
} }
// 测试搜索弹框
if (obj.event === 'spSearchPanel') {
var index = spLayer.open({
type: 2,
area: ['680px', '500px'],
content: '${request.contextPath}/admin/common/ui/spSearchPanel4SysUser',
// 如果是搜索弹窗,需要添加回调函数来获取选中数据
spCallback: spSearchPanel4SysUserCallback
}); });
}
});
/**
* 回调函数
*/
function spSearchPanel4SysUserCallback(result) {
console.log(result);
}
/** /**
* 监听行工具事件 * 监听行工具事件
@ -176,7 +195,7 @@
// 编辑 // 编辑
if (obj.event === 'edit') { if (obj.event === 'edit') {
splayer.open({ spLayer.open({
title: '编辑', title: '编辑',
area: ['90%', '90%'], area: ['90%', '90%'],
// 请求url参数 // 请求url参数

View File

@ -0,0 +1,103 @@
<!DOCTYPE html>
<html>
<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.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<#include "${request.contextPath}/common/common.ftl">
</head>
<body>
<div class="splayui-container">
<div class="splayui-main">
<!--查询参数-->
<form id="js-search-form" class="layui-form" lay-filter="js-q-form-filter">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">姓名</label>
<div class="layui-input-inline" style="width: 120px;">
<input type="text" name="nameLike" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">用户名</label>
<div class="layui-input-inline" style="width: 120px;">
<input type="text" name="usernameLike" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<a class="layui-btn" lay-submit lay-filter="js-search-filter"><i class="layui-icon layui-icon-search"></i></a>
</div>
</div>
</form>
<!--表格-->
<table class="layui-hide" id="js-record-table" lay-filter="js-record-table-filter"></table>
<form class="layui-form splayui-form">
<div class="layui-row">
<div class="layui-form-item layui-hide">
<div class="layui-input-block">
<input id="js-id" name="id" value=""/>
<button id="js-submit" class="layui-btn" lay-submit lay-filter="js-submit-filter">确定</button>
</div>
</div>
</div>
</form>
</div>
</div>
<script>
var tableChecked;
layui.use(['form', 'util', 'table', 'spTable'], function () {
var form = layui.form,
util = layui.util,
table = layui.table,
spTable = layui.spTable;
// 表格及数据初始化
var tableIns = spTable.render({
toolbar: '',
url: '${request.contextPath}/admin/sys/user/page',
cols: [
[{
type: 'checkbox'
}, {
field: 'name', title: '姓名'
}, {
field: 'username', title: '用户名'
}]
],
done: function (res, curr, count) {
}
});
/**
* 搜索按钮事件
*/
form.on('submit(js-search-filter)', function (data) {
tableIns.reload({
where: data.field,
page: {
// 重新从第 1 页开始
curr: 1
}
});
// 阻止表单跳转。如果需要表单跳转,去掉这段即可。
return false;
});
// 监听提交
form.on('submit(js-submit-filter)', function (data) {
tableChecked = table.checkStatus('js-record-table');
return false;
});
});
function callbackData() {
return tableChecked;
}
</script>
</body>
</html>